![]() |
ChibiOS/RT Architecture - Reference Manual - Guides |
Generic ADC Driver. More...
|
Generic ADC Driver.
This module implements a generic ADC driver. The driver implements a state machine internally:
The driver supports a continuous conversion mode with circular buffer, callback functions allow to process the converted data in real time. Please refer to the documentation of the function adcStartConversion().
Modules | |
| ADC Low Level Driver | |
ADC Driver low level driver template. | |
Enumerations | |
| enum | adcstate_t { ADC_UNINIT = 0, ADC_STOP = 1, ADC_READY = 2, ADC_RUNNING = 3, ADC_COMPLETE = 4 } |
Driver state machine possible states. More... | |
Functions | |
| void | adcInit (void) |
| ADC Driver initialization. | |
| void | adcObjectInit (ADCDriver *adcp) |
Initializes the standard part of a ADCDriver structure. | |
| void | adcStart (ADCDriver *adcp, const ADCConfig *config) |
| Configures and activates the ADC peripheral. | |
| void | adcStop (ADCDriver *adcp) |
| Deactivates the ADC peripheral. | |
| bool_t | adcStartConversion (ADCDriver *adcp, const ADCConversionGroup *grpp, adcsample_t *samples, size_t depth, adccallback_t callback) |
| Starts an ADC conversion. | |
| void | adcStopConversion (ADCDriver *adcp) |
| Stops an ongoing conversion. | |
| msg_t | adcWaitConversion (ADCDriver *adcp, systime_t timeout) |
| Waits for completion. | |
| enum adcstate_t |
| void adcInit | ( | void | ) |
ADC Driver initialization.
Definition at line 59 of file adc.c.
References adc_lld_init().
Referenced by halInit().

| void adcObjectInit | ( | ADCDriver * | adcp | ) |
Initializes the standard part of a ADCDriver structure.
| [in] | adcp | pointer to the ADCDriver object |
Definition at line 69 of file adc.c.
References ADCDriver::ad_callback, ADCDriver::ad_config, ADCDriver::ad_depth, ADCDriver::ad_grpp, ADCDriver::ad_samples, ADCDriver::ad_sem, ADCDriver::ad_state, and chSemInit().

Configures and activates the ADC peripheral.
Definition at line 86 of file adc.c.
References ADCDriver::ad_config, ADCDriver::ad_state, adc_lld_start(), ADC_READY, ADC_STOP, chDbgAssert, chDbgCheck, chSysLock, and chSysUnlock.

| void adcStop | ( | ADCDriver * | adcp | ) |
Deactivates the ADC peripheral.
| [in] | adcp | pointer to the ADCDriver object |
Definition at line 105 of file adc.c.
References ADCDriver::ad_state, ADC_COMPLETE, adc_lld_stop(), ADC_READY, ADC_STOP, chDbgAssert, chDbgCheck, chSysLock, and chSysUnlock.

| bool_t adcStartConversion | ( | ADCDriver * | adcp, | |
| const ADCConversionGroup * | grpp, | |||
| adcsample_t * | samples, | |||
| size_t | depth, | |||
| adccallback_t | callback | |||
| ) |
Starts an ADC conversion.
Starts a conversion operation, there are two kind of conversion modes:
adcStopConversion().| [in] | adcp | pointer to the ADCDriver object |
| [in] | grpp | pointer to a ADCConversionGroup object |
| [out] | samples | pointer to the samples buffer |
| [in] | depth | buffer depth (matrix rows number). The buffer depth must be one or an even number. |
| [in] | callback | pointer to the conversion callback function, this parameter can be NULL if a callback is not required |
| FALSE | the conversion has been started. | |
| TRUE | the driver is busy, conversion not started. |
Definition at line 150 of file adc.c.
References ADCDriver::ad_callback, ADCDriver::ad_depth, ADCDriver::ad_grpp, ADCDriver::ad_samples, ADCDriver::ad_state, ADC_COMPLETE, adc_lld_start_conversion(), ADC_READY, ADC_RUNNING, chDbgAssert, chDbgCheck, chSysLock, and chSysUnlock.

| void adcStopConversion | ( | ADCDriver * | adcp | ) |
Stops an ongoing conversion.
| [in] | adcp | pointer to the ADCDriver object |
Definition at line 185 of file adc.c.
References ADCDriver::ad_grpp, ADCDriver::ad_sem, ADCDriver::ad_state, ADC_COMPLETE, adc_lld_stop_conversion(), ADC_READY, ADC_RUNNING, chDbgAssert, chDbgCheck, chSchRescheduleS(), chSemResetI(), chSysLock, and chSysUnlock.

Waits for completion.
If the conversion is not completed or not yet started then the invoking thread waits for a conversion completion event.
| [in] | adcp | pointer to the ADCDriver object |
| [in] | timeout | the number of ticks before the operation timeouts, the following special values are allowed:
|
| RDY_OK | conversion finished. | |
| RDY_TIMEOUT | conversion not finished within the specified time. |
Definition at line 222 of file adc.c.
References ADCDriver::ad_sem, ADCDriver::ad_state, ADC_COMPLETE, ADC_READY, ADC_RUNNING, chDbgAssert, chSemWaitTimeoutS(), chSysLock, chSysUnlock, and RDY_TIMEOUT.

1.7.1