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 145 adc_lld_configuration_group_fields;
180 #if (ADC_USE_WAIT == TRUE) || defined(__DOXYGEN__) 186 #if (ADC_USE_MUTUAL_EXCLUSION == TRUE) || defined(__DOXYGEN__) 192 #if defined(ADC_DRIVER_EXT_FIELDS) 193 ADC_DRIVER_EXT_FIELDS
220 #define adcIsBufferComplete(adcp) ((bool)((adcp)->state == ADC_COMPLETE)) 227 #if (ADC_USE_WAIT == TRUE) || defined(__DOXYGEN__) 235 #define _adc_reset_i(adcp) \ 236 osalThreadResumeI(&(adcp)->thread, MSG_RESET) 245 #define _adc_reset_s(adcp) \ 246 osalThreadResumeS(&(adcp)->thread, MSG_RESET) 255 #define _adc_wakeup_isr(adcp) { \ 256 osalSysLockFromISR(); \ 257 osalThreadResumeI(&(adcp)->thread, MSG_OK); \ 258 osalSysUnlockFromISR(); \ 268 #define _adc_timeout_isr(adcp) { \ 269 osalSysLockFromISR(); \ 270 osalThreadResumeI(&(adcp)->thread, MSG_TIMEOUT); \ 271 osalSysUnlockFromISR(); \ 275 #define _adc_reset_i(adcp) 276 #define _adc_reset_s(adcp) 277 #define _adc_wakeup_isr(adcp) 278 #define _adc_timeout_isr(adcp) 293 #define _adc_isr_half_code(adcp) { \ 294 if ((adcp)->grpp->end_cb != NULL) { \ 295 (adcp)->grpp->end_cb(adcp); \ 313 #define _adc_isr_full_code(adcp) { \ 314 if ((adcp)->grpp->circular) { \ 316 if ((adcp)->grpp->end_cb != NULL) { \ 317 (adcp)->state = ADC_COMPLETE; \ 318 (adcp)->grpp->end_cb(adcp); \ 319 if ((adcp)->state == ADC_COMPLETE) { \ 320 (adcp)->state = ADC_ACTIVE; \ 326 adc_lld_stop_conversion(adcp); \ 327 if ((adcp)->grpp->end_cb != NULL) { \ 328 (adcp)->state = ADC_COMPLETE; \ 329 (adcp)->grpp->end_cb(adcp); \ 330 if ((adcp)->state == ADC_COMPLETE) { \ 331 (adcp)->state = ADC_READY; \ 332 (adcp)->grpp = NULL; \ 336 (adcp)->state = ADC_READY; \ 337 (adcp)->grpp = NULL; \ 339 _adc_wakeup_isr(adcp); \ 358 #define _adc_isr_error_code(adcp, err) { \ 359 adc_lld_stop_conversion(adcp); \ 360 if ((adcp)->grpp->error_cb != NULL) { \ 361 (adcp)->state = ADC_ERROR; \ 362 (adcp)->grpp->error_cb(adcp, err); \ 363 if ((adcp)->state == ADC_ERROR) \ 364 (adcp)->state = ADC_READY; \ 365 (adcp)->grpp = NULL; \ 368 (adcp)->state = ADC_READY; \ 369 (adcp)->grpp = NULL; \ 371 _adc_timeout_isr(adcp); \ 396 #if ADC_USE_WAIT == TRUE 402 #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.
int32_t msg_t
Type of a message.
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 * thread_reference_t
Type of a thread reference.
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.
uint32_t mutex_t
Type of a mutex.
const ADCConfig * config
Current configuration data.
void adcInit(void)
ADC Driver initialization.
adcstate_t state
Driver state.