28 #if (HAL_USE_ADC == TRUE) || defined(__DOXYGEN__) 46 #if !defined(ADC_USE_WAIT) || defined(__DOXYGEN__) 47 #define ADC_USE_WAIT TRUE 54 #if !defined(ADC_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__) 55 #define ADC_USE_MUTUAL_EXCLUSION TRUE 89 #if (ADC_USE_WAIT == TRUE) || defined(__DOXYGEN__) 97 #define _adc_reset_i(adcp) \ 98 osalThreadResumeI(&(adcp)->thread, MSG_RESET) 107 #define _adc_reset_s(adcp) \ 108 osalThreadResumeS(&(adcp)->thread, MSG_RESET) 117 #define _adc_wakeup_isr(adcp) { \ 118 osalSysLockFromISR(); \ 119 osalThreadResumeI(&(adcp)->thread, MSG_OK); \ 120 osalSysUnlockFromISR(); \ 130 #define _adc_timeout_isr(adcp) { \ 131 osalSysLockFromISR(); \ 132 osalThreadResumeI(&(adcp)->thread, MSG_TIMEOUT); \ 133 osalSysUnlockFromISR(); \ 137 #define _adc_reset_i(adcp) 138 #define _adc_reset_s(adcp) 139 #define _adc_wakeup_isr(adcp) 140 #define _adc_timeout_isr(adcp) 155 #define _adc_isr_half_code(adcp) { \ 156 if ((adcp)->grpp->end_cb != NULL) { \ 157 (adcp)->grpp->end_cb(adcp, (adcp)->samples, (adcp)->depth / 2); \ 175 #define _adc_isr_full_code(adcp) { \ 176 if ((adcp)->grpp->circular) { \ 178 if ((adcp)->grpp->end_cb != NULL) { \ 179 if ((adcp)->depth > 1) { \ 181 size_t half = (adcp)->depth / 2; \ 182 size_t half_index = half * (adcp)->grpp->num_channels; \ 183 (adcp)->grpp->end_cb(adcp, (adcp)->samples + half_index, half); \ 187 (adcp)->grpp->end_cb(adcp, (adcp)->samples, (adcp)->depth); \ 193 adc_lld_stop_conversion(adcp); \ 194 if ((adcp)->grpp->end_cb != NULL) { \ 195 (adcp)->state = ADC_COMPLETE; \ 197 (adcp)->grpp->end_cb(adcp, (adcp)->samples, (adcp)->depth); \ 198 if ((adcp)->state == ADC_COMPLETE) { \ 199 (adcp)->state = ADC_READY; \ 200 (adcp)->grpp = NULL; \ 204 (adcp)->state = ADC_READY; \ 205 (adcp)->grpp = NULL; \ 207 _adc_wakeup_isr(adcp); \ 226 #define _adc_isr_error_code(adcp, err) { \ 227 adc_lld_stop_conversion(adcp); \ 228 if ((adcp)->grpp->error_cb != NULL) { \ 229 (adcp)->state = ADC_ERROR; \ 230 (adcp)->grpp->error_cb(adcp, err); \ 231 if ((adcp)->state == ADC_ERROR) \ 232 (adcp)->state = ADC_READY; \ 233 (adcp)->grpp = NULL; \ 236 (adcp)->state = ADC_READY; \ 237 (adcp)->grpp = NULL; \ 239 _adc_timeout_isr(adcp); \ 264 #if ADC_USE_WAIT == TRUE 270 #if ADC_USE_MUTUAL_EXCLUSION == TRUE adcstate_t
Driver state machine possible states.
void adcObjectInit(ADCDriver *adcp)
Initializes the standard part of a ADCDriver structure.
void adcStartConversion(ADCDriver *adcp, const ADCConversionGroup *grpp, adcsample_t *samples, size_t depth)
Starts an ADC conversion.
void adcStop(ADCDriver *adcp)
Deactivates the ADC peripheral.
void adcAcquireBus(ADCDriver *adcp)
Gains exclusive access to the ADC peripheral.
PLATFORM ADC subsystem low level driver header.
void adcReleaseBus(ADCDriver *adcp)
Releases exclusive access to the ADC peripheral.
Conversion group configuration structure.
int32_t msg_t
Type of a message.
void adcStart(ADCDriver *adcp, const ADCConfig *config)
Configures and activates the ADC peripheral.
Structure representing an ADC driver.
msg_t adcConvert(ADCDriver *adcp, const ADCConversionGroup *grpp, adcsample_t *samples, size_t depth)
Performs an ADC conversion.
void adcStopConversion(ADCDriver *adcp)
Stops an ongoing conversion.
void adcStartConversionI(ADCDriver *adcp, const ADCConversionGroup *grpp, adcsample_t *samples, size_t depth)
Starts an ADC conversion.
uint16_t adcsample_t
ADC sample data type.
void adcStopConversionI(ADCDriver *adcp)
Stops an ongoing conversion.
Driver configuration structure.
void adcInit(void)
ADC Driver initialization.