22 #define ADC_HALL_PIN GPIO_Pin_1 23 #define ADC_HALL_PORT GPIOB 24 #define ADC_HALL_CHANNEL ADC_Channel_9 26 #define ADC_ANIN1_PIN GPIO_Pin_6 27 #define ADC_ANIN1_PORT GPIOA 28 #define ADC_ANIN1_CHANNEL ADC_Channel_6 30 #define ADC_ANIN2_PIN GPIO_Pin_7 31 #define ADC_ANIN2_PORT GPIOA 32 #define ADC_ANIN2_CHANNEL ADC_Channel_7 34 #define ADC_ANIN3_PIN GPIO_Pin_4 35 #define ADC_ANIN3_PORT GPIOC 36 #define ADC_ANIN3_CHANNEL ADC_Channel_14 38 #define ADC_ANIN4_PIN GPIO_Pin_5 39 #define ADC_ANIN4_PORT GPIOC 40 #define ADC_ANIN4_CHANNEL ADC_Channel_15 42 #define ADC_CURRENT_SENSE_PIN GPIO_Pin_3 43 #define ADC_CURRENT_SENSE_PORT GPIOA 44 #define ADC_CURRENT_SENSE_CHANNEL ADC_Channel_3 46 #define ADC_MAX 4095.0f // Maximum value of the ADC register (2^12 - 1). 47 #define ADC_MAX_CONVERSION_TIME 100 // To avoid locking if the conversion was not started properly. 48 #define ADC_BUFFER_SIZE 33 // Fadc =~300kHz -> TE_ADC = 3.33us -> Average over 32 sample => usable bandwidth <10kHz 49 #define ADC_CURRENT_SCALE (ADC_REF_VOLTAGE / (CURRENT_SHUNT_RESISTANCE * CURRENT_SHUNT_AMPLIFIER_GAIN * ADC_MAX)) // Scale between ADC increment and current [A/incr]. 50 #define ADC_CALIB_N_SAMPLES 1000 void adc_CalibrateCurrentSens(void)
Compute the current sense offset.
Definition: adc.c:133
AdcChannel
Enum that corresponds to the two ADC input channels of the board.
Definition: adc.h:78
Pin AN_IN3 (37 & 38) of the connector J12 (analog extension).
Definition: adc.h:83
Pin HALL_INPUT (5) of the connector J9 (Hall position sensor).
Definition: adc.h:80
Pin AN_IN4 (41 & 42) of the connector J12 (analog extension).
Definition: adc.h:84
float32_t adc_GetCurrent(void)
Compute the current sense offset.
Definition: adc.c:152
float32_t adc_GetChannelVoltage(AdcChannel channel)
Gets the voltage measured by the selected ADC channel.
Definition: adc.c:223
Pin AN_IN1 (29 & 30) of the connector J12 (analog extension).
Definition: adc.h:81
void adc_Init(void)
Initialize the ADC converter (2 analog inputs + current sense).
Definition: adc.c:30
Pin AN_IN2 (33 & 34) of the connector J12 (analog extension).
Definition: adc.h:82