Go to the documentation of this file.
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;
154 adc_lld_config_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
197 adc_lld_driver_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
uint32_t adcerror_t
Type of an ADC error mask.
thread_reference_t thread
Waiting thread.
uint16_t adcsample_t
ADC sample data type.
msg_t adcConvert(ADCDriver *adcp, const ADCConversionGroup *grpp, adcsample_t *samples, size_t depth)
Performs an ADC conversion.
adccallback_t end_cb
Callback function associated to the group or NULL.
void adcObjectInit(ADCDriver *adcp)
Initializes the standard part of a ADCDriver structure.
mutex_t mutex
Mutex protecting the peripheral.
Conversion group configuration structure.
void adcStopConversion(ADCDriver *adcp)
Stops an ongoing conversion.
bool circular
Enables the circular buffer mode for the group.
void adcStartConversion(ADCDriver *adcp, const ADCConversionGroup *grpp, adcsample_t *samples, size_t depth)
Starts an ADC conversion.
void adcInit(void)
ADC Driver initialization.
size_t depth
Current samples buffer depth or 0.
Structure representing an ADC driver.
Structure representing a thread.
PLATFORM ADC subsystem low level driver header.
uint16_t adc_channels_num_t
Channels number in a conversion group.
void(* adccallback_t)(ADCDriver *adcp)
Type of an ADC notification callback.
adcsample_t * samples
Current samples buffer pointer or NULL.
void(* adcerrorcallback_t)(ADCDriver *adcp, adcerror_t err)
Type of an ADC error callback.
void adcStartConversionI(ADCDriver *adcp, const ADCConversionGroup *grpp, adcsample_t *samples, size_t depth)
Starts an ADC conversion.
void adcAcquireBus(ADCDriver *adcp)
Gains exclusive access to the ADC peripheral.
void adcStopConversionI(ADCDriver *adcp)
Stops an ongoing conversion.
void adcReleaseBus(ADCDriver *adcp)
Releases exclusive access to the ADC peripheral.
adcstate_t
Driver state machine possible states.
void adcStop(ADCDriver *adcp)
Deactivates the ADC peripheral.
Driver configuration structure.
adcstate_t state
Driver state.
adcerrorcallback_t error_cb
Error callback or NULL.
const ADCConversionGroup * grpp
Current conversion group pointer or NULL.
void adcStart(ADCDriver *adcp, const ADCConfig *config)
Configures and activates the ADC peripheral.
const ADCConfig * config
Current configuration data.
adc_channels_num_t num_channels
Number of the analog channels belonging to the conversion group.