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 146 adc_lld_configuration_group_fields;
181 #if (ADC_USE_WAIT == TRUE) || defined(__DOXYGEN__) 187 #if (ADC_USE_MUTUAL_EXCLUSION == TRUE) || defined(__DOXYGEN__) 193 #if defined(ADC_DRIVER_EXT_FIELDS) 194 ADC_DRIVER_EXT_FIELDS
221 #define adcIsBufferComplete(adcp) ((bool)((adcp)->state == ADC_COMPLETE)) 228 #if (ADC_USE_WAIT == TRUE) || defined(__DOXYGEN__) 236 #define _adc_reset_i(adcp) \ 237 osalThreadResumeI(&(adcp)->thread, MSG_RESET) 246 #define _adc_reset_s(adcp) \ 247 osalThreadResumeS(&(adcp)->thread, MSG_RESET) 256 #define _adc_wakeup_isr(adcp) { \ 257 osalSysLockFromISR(); \ 258 osalThreadResumeI(&(adcp)->thread, MSG_OK); \ 259 osalSysUnlockFromISR(); \ 269 #define _adc_timeout_isr(adcp) { \ 270 osalSysLockFromISR(); \ 271 osalThreadResumeI(&(adcp)->thread, MSG_TIMEOUT); \ 272 osalSysUnlockFromISR(); \ 276 #define _adc_reset_i(adcp) 277 #define _adc_reset_s(adcp) 278 #define _adc_wakeup_isr(adcp) 279 #define _adc_timeout_isr(adcp) 294 #define _adc_isr_half_code(adcp) { \ 295 if ((adcp)->grpp->end_cb != NULL) { \ 296 (adcp)->grpp->end_cb(adcp); \ 314 #define _adc_isr_full_code(adcp) { \ 315 if ((adcp)->grpp->circular) { \ 317 if ((adcp)->grpp->end_cb != NULL) { \ 318 (adcp)->state = ADC_COMPLETE; \ 319 (adcp)->grpp->end_cb(adcp); \ 320 if ((adcp)->state == ADC_COMPLETE) { \ 321 (adcp)->state = ADC_ACTIVE; \ 327 adc_lld_stop_conversion(adcp); \ 328 if ((adcp)->grpp->end_cb != NULL) { \ 329 (adcp)->state = ADC_COMPLETE; \ 330 (adcp)->grpp->end_cb(adcp); \ 331 if ((adcp)->state == ADC_COMPLETE) { \ 332 (adcp)->state = ADC_READY; \ 333 (adcp)->grpp = NULL; \ 337 (adcp)->state = ADC_READY; \ 338 (adcp)->grpp = NULL; \ 340 _adc_wakeup_isr(adcp); \ 359 #define _adc_isr_error_code(adcp, err) { \ 360 adc_lld_stop_conversion(adcp); \ 361 if ((adcp)->grpp->error_cb != NULL) { \ 362 (adcp)->state = ADC_ERROR; \ 363 (adcp)->grpp->error_cb(adcp, err); \ 364 if ((adcp)->state == ADC_ERROR) { \ 365 (adcp)->state = ADC_READY; \ 366 (adcp)->grpp = NULL; \ 370 (adcp)->state = ADC_READY; \ 371 (adcp)->grpp = NULL; \ 373 _adc_timeout_isr(adcp); \ 398 #if ADC_USE_WAIT == TRUE 404 #if ADC_USE_MUTUAL_EXCLUSION == TRUE bool circular
Enables the circular buffer mode for the group.
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.
Driver configuration structure.
void adcAcquireBus(ADCDriver *adcp)
Gains exclusive access to the ADC peripheral.
mutex_t mutex
Mutex protecting the peripheral.
adcerror_t
Possible ADC failure causes.
size_t depth
Current samples buffer depth or 0.
PLATFORM ADC subsystem low level driver header.
thread_reference_t thread
Waiting thread.
void adcReleaseBus(ADCDriver *adcp)
Releases exclusive access to the ADC peripheral.
adcsample_t * samples
Current samples buffer pointer or NULL.
uint16_t adc_channels_num_t
Channels number in a conversion group.
#define adc_lld_driver_fields
Low level fields of the ADC driver structure.
void adcStart(ADCDriver *adcp, const ADCConfig *config)
Configures and activates the ADC peripheral.
Conversion group configuration structure.
adccallback_t end_cb
Callback function associated to the group or NULL.
void(* adccallback_t)(ADCDriver *adcp)
Type of an ADC notification callback.
adc_channels_num_t num_channels
Number of the analog channels belonging to the conversion group.
adcerrorcallback_t error_cb
Error callback or NULL.
msg_t adcConvert(ADCDriver *adcp, const ADCConversionGroup *grpp, adcsample_t *samples, size_t depth)
Performs an ADC conversion.
Structure representing an ADC driver.
void(* adcerrorcallback_t)(ADCDriver *adcp, adcerror_t err)
Type of an ADC error callback.
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.
#define adc_lld_config_fields
Low level fields of the ADC configuration structure.
const ADCConversionGroup * grpp
Current conversion group pointer or NULL.
const ADCConfig * config
Current configuration data.
void adcInit(void)
ADC Driver initialization.
adcstate_t state
Driver state.
Structure representing a thread.