|
ChibiOS/RT
2.5.1 |
|
Generic ADC Driver.
This module implements a generic ADC (Analog to Digital Converter) driver supporting a variety of buffer and conversion modes.
HAL_USE_ADC option must be enabled in halconf.h.The driver implements a state machine internally, not all the driver functionalities can be used in any moment, any transition not explicitly shown in the following diagram has to be considered an error and shall be captured by an assertion (if enabled).
The ADC driver is quite complex, an explanation of the terminology and of the operational details follows.
The ADCConversionGroup is the objects that specifies a physical conversion operation. This structure contains some standard fields and several implementation-dependent fields.
The standard fields define the CG mode, the number of channels belonging to the CG and the optional callbacks.
The implementation-dependent fields specify the physical ADC operation mode, the analog channels belonging to the group and any other implementation-specific setting. Usually the extra fields just mirror the physical ADC registers, please refer to the vendor's MCU Reference Manual for details about the available settings. Details are also available into the documentation of the ADC low level drivers and in the various sample applications.
The driver supports several conversion modes:
The driver is able to invoke callbacks during the conversion process. A callback is invoked when the operation has been completed or, in circular mode, when the buffer has been filled and the operation is restarted. In linear and circular modes a callback is also invoked when the buffer is half filled.
The "half filled" and "filled" callbacks in circular mode allow to implement "streaming processing" of the sampled data, while the driver is busy filling one half of the buffer the application can process the other half, this allows for continuous interleaved operations.
The driver is not thread safe for performance reasons, if you need to access the ADC bus from multiple threads then use the adcAcquireBus() and adcReleaseBus() APIs in order to gain exclusive access.
Data Structures | |
| struct | ADCConversionGroup |
| Conversion group configuration structure. More... | |
| struct | ADCConfig |
| Driver configuration structure. More... | |
| struct | ADCDriver |
| Structure representing an ADC driver. 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. | |
| void | adcStartConversion (ADCDriver *adcp, const ADCConversionGroup *grpp, adcsample_t *samples, size_t depth) |
| Starts an ADC conversion. | |
| void | adcStartConversionI (ADCDriver *adcp, const ADCConversionGroup *grpp, adcsample_t *samples, size_t depth) |
| Starts an ADC conversion. | |
| void | adcStopConversion (ADCDriver *adcp) |
| Stops an ongoing conversion. | |
| void | adcStopConversionI (ADCDriver *adcp) |
| Stops an ongoing conversion. | |
| void | adcAcquireBus (ADCDriver *adcp) |
| Gains exclusive access to the ADC peripheral. | |
| void | adcReleaseBus (ADCDriver *adcp) |
| Releases exclusive access to the ADC peripheral. | |
| msg_t | adcConvert (ADCDriver *adcp, const ADCConversionGroup *grpp, adcsample_t *samples, size_t depth) |
| Performs an ADC conversion. | |
| CH_IRQ_HANDLER (ADC1_IRQHandler) | |
| ADC interrupt handler. | |
| void | adc_lld_init (void) |
| Low level ADC driver initialization. | |
| void | adc_lld_start (ADCDriver *adcp) |
| Configures and activates the ADC peripheral. | |
| void | adc_lld_stop (ADCDriver *adcp) |
| Deactivates the ADC peripheral. | |
| void | adc_lld_start_conversion (ADCDriver *adcp) |
| Starts an ADC conversion. | |
| void | adc_lld_stop_conversion (ADCDriver *adcp) |
| Stops an ongoing conversion. | |
| void | adcSTM32EnableTSVREFE (void) |
| Enables the TSVREFE bit. | |
| void | adcSTM32DisableTSVREFE (void) |
| Disables the TSVREFE bit. | |
Variables | |
| ADCDriver | ADCD1 |
| ADC1 driver identifier. | |
ADC configuration options | |
| #define | ADC_USE_WAIT TRUE |
| Enables synchronous APIs. | |
| #define | ADC_USE_MUTUAL_EXCLUSION TRUE |
Enables the adcAcquireBus() and adcReleaseBus() APIs. | |
Low Level driver helper macros | |
| #define | _adc_reset_i(adcp) |
| Resumes a thread waiting for a conversion completion. | |
| #define | _adc_reset_s(adcp) |
| Resumes a thread waiting for a conversion completion. | |
| #define | _adc_wakeup_isr(adcp) |
| Wakes up the waiting thread. | |
| #define | _adc_timeout_isr(adcp) |
| Wakes up the waiting thread with a timeout message. | |
| #define | _adc_isr_half_code(adcp) |
| Common ISR code, half buffer event. | |
| #define | _adc_isr_full_code(adcp) |
| Common ISR code, full buffer event. | |
| #define | _adc_isr_error_code(adcp, err) |
| Common ISR code, error event. | |
Triggers selection | |
| #define | ADC_CR2_EXTSEL_SRC(n) ((n) << 24) |
| Trigger source. | |
ADC clock divider settings | |
| #define | ADC_CCR_ADCPRE_DIV1 0 |
| #define | ADC_CCR_ADCPRE_DIV2 1 |
| #define | ADC_CCR_ADCPRE_DIV4 2 |
Available analog channels | |
| #define | ADC_CHANNEL_IN0 0 |
| External analog input 0. | |
| #define | ADC_CHANNEL_IN1 1 |
| External analog input 1. | |
| #define | ADC_CHANNEL_IN2 2 |
| External analog input 2. | |
| #define | ADC_CHANNEL_IN3 3 |
| External analog input 3. | |
| #define | ADC_CHANNEL_IN4 4 |
| External analog input 4. | |
| #define | ADC_CHANNEL_IN5 5 |
| External analog input 5. | |
| #define | ADC_CHANNEL_IN6 6 |
| External analog input 6. | |
| #define | ADC_CHANNEL_IN7 7 |
| External analog input 7. | |
| #define | ADC_CHANNEL_IN8 8 |
| External analog input 8. | |
| #define | ADC_CHANNEL_IN9 9 |
| External analog input 9. | |
| #define | ADC_CHANNEL_IN10 10 |
| External analog input 10. | |
| #define | ADC_CHANNEL_IN11 11 |
| External analog input 11. | |
| #define | ADC_CHANNEL_IN12 12 |
| External analog input 12. | |
| #define | ADC_CHANNEL_IN13 13 |
| External analog input 13. | |
| #define | ADC_CHANNEL_IN14 14 |
| External analog input 14. | |
| #define | ADC_CHANNEL_IN15 15 |
| External analog input 15. | |
| #define | ADC_CHANNEL_SENSOR 16 |
| Internal temperature sensor. | |
| #define | ADC_CHANNEL_VREFINT 17 |
| Internal reference. | |
| #define | ADC_CHANNEL_IN18 18 |
| External analog input 18. | |
| #define | ADC_CHANNEL_IN19 19 |
| External analog input 19. | |
| #define | ADC_CHANNEL_IN20 20 |
| External analog input 20. | |
| #define | ADC_CHANNEL_IN21 21 |
| External analog input 21. | |
| #define | ADC_CHANNEL_IN22 22 |
| External analog input 22. | |
| #define | ADC_CHANNEL_IN23 23 |
| External analog input 23. | |
| #define | ADC_CHANNEL_IN24 24 |
| External analog input 24. | |
| #define | ADC_CHANNEL_IN25 25 |
| External analog input 25. | |
Sampling rates | |
| #define | ADC_SAMPLE_4 0 |
| 4 cycles sampling time. | |
| #define | ADC_SAMPLE_9 1 |
| 9 cycles sampling time. | |
| #define | ADC_SAMPLE_16 2 |
| 16 cycles sampling time. | |
| #define | ADC_SAMPLE_24 3 |
| 24 cycles sampling time. | |
| #define | ADC_SAMPLE_48 4 |
| 48 cycles sampling time. | |
| #define | ADC_SAMPLE_96 5 |
| 96 cycles sampling time. | |
| #define | ADC_SAMPLE_192 6 |
| 192 cycles sampling time. | |
| #define | ADC_SAMPLE_384 7 |
| 384 cycles sampling time. | |
Configuration options | |
| #define | STM32_ADC_USE_ADC1 FALSE |
| ADC1 driver enable switch. | |
| #define | STM32_ADC_ADCPRE ADC_CCR_ADCPRE_DIV1 |
| ADC common clock divider. | |
| #define | STM32_ADC_ADC1_DMA_PRIORITY 2 |
| ADC1 DMA priority (0..3|lowest..highest). | |
| #define | STM32_ADC_IRQ_PRIORITY 5 |
| ADC interrupt priority level setting. | |
| #define | STM32_ADC_ADC1_DMA_IRQ_PRIORITY 5 |
| ADC1 DMA interrupt priority level setting. | |
Sequences building helper macros | |
| #define | ADC_SQR1_NUM_CH(n) (((n) - 1) << 20) |
| Number of channels in a conversion sequence. | |
| #define | ADC_SQR5_SQ1_N(n) ((n) << 0) |
| 1st channel in seq. | |
| #define | ADC_SQR5_SQ2_N(n) ((n) << 5) |
| 2nd channel in seq. | |
| #define | ADC_SQR5_SQ3_N(n) ((n) << 10) |
| 3rd channel in seq. | |
| #define | ADC_SQR5_SQ4_N(n) ((n) << 15) |
| 4th channel in seq. | |
| #define | ADC_SQR5_SQ5_N(n) ((n) << 20) |
| 5th channel in seq. | |
| #define | ADC_SQR5_SQ6_N(n) ((n) << 25) |
| 6th channel in seq. | |
| #define | ADC_SQR4_SQ7_N(n) ((n) << 0) |
| 7th channel in seq. | |
| #define | ADC_SQR4_SQ8_N(n) ((n) << 5) |
| 8th channel in seq. | |
| #define | ADC_SQR4_SQ9_N(n) ((n) << 10) |
| 9th channel in seq. | |
| #define | ADC_SQR4_SQ10_N(n) ((n) << 15) |
| 10th channel in seq. | |
| #define | ADC_SQR4_SQ11_N(n) ((n) << 20) |
| 11th channel in seq. | |
| #define | ADC_SQR4_SQ12_N(n) ((n) << 25) |
| 12th channel in seq. | |
| #define | ADC_SQR3_SQ13_N(n) ((n) << 0) |
| 13th channel in seq. | |
| #define | ADC_SQR3_SQ14_N(n) ((n) << 5) |
| 14th channel in seq. | |
| #define | ADC_SQR3_SQ15_N(n) ((n) << 10) |
| 15th channel in seq. | |
| #define | ADC_SQR3_SQ16_N(n) ((n) << 15) |
| 16th channel in seq. | |
| #define | ADC_SQR3_SQ17_N(n) ((n) << 20) |
| 17th channel in seq. | |
| #define | ADC_SQR3_SQ18_N(n) ((n) << 25) |
| 18th channel in seq. | |
| #define | ADC_SQR2_SQ19_N(n) ((n) << 0) |
| 19th channel in seq. | |
| #define | ADC_SQR2_SQ20_N(n) ((n) << 5) |
| 20th channel in seq. | |
| #define | ADC_SQR2_SQ21_N(n) ((n) << 10) |
| 21th channel in seq. | |
| #define | ADC_SQR2_SQ22_N(n) ((n) << 15) |
| 22th channel in seq. | |
| #define | ADC_SQR2_SQ23_N(n) ((n) << 20) |
| 23th channel in seq. | |
| #define | ADC_SQR2_SQ24_N(n) ((n) << 25) |
| 24th channel in seq. | |
| #define | ADC_SQR1_SQ25_N(n) ((n) << 0) |
| 25th channel in seq. | |
| #define | ADC_SQR1_SQ26_N(n) ((n) << 5) |
| 26th channel in seq. | |
| #define | ADC_SQR1_SQ27_N(n) ((n) << 10) |
| 27th channel in seq. | |
Sampling rate settings helper macros | |
| #define | ADC_SMPR3_SMP_AN0(n) ((n) << 0) |
| AN0 sampling time. | |
| #define | ADC_SMPR3_SMP_AN1(n) ((n) << 3) |
| AN1 sampling time. | |
| #define | ADC_SMPR3_SMP_AN2(n) ((n) << 6) |
| AN2 sampling time. | |
| #define | ADC_SMPR3_SMP_AN3(n) ((n) << 9) |
| AN3 sampling time. | |
| #define | ADC_SMPR3_SMP_AN4(n) ((n) << 12) |
| AN4 sampling time. | |
| #define | ADC_SMPR3_SMP_AN5(n) ((n) << 15) |
| AN5 sampling time. | |
| #define | ADC_SMPR3_SMP_AN6(n) ((n) << 18) |
| AN6 sampling time. | |
| #define | ADC_SMPR3_SMP_AN7(n) ((n) << 21) |
| AN7 sampling time. | |
| #define | ADC_SMPR3_SMP_AN8(n) ((n) << 24) |
| AN8 sampling time. | |
| #define | ADC_SMPR3_SMP_AN9(n) ((n) << 27) |
| AN9 sampling time. | |
| #define | ADC_SMPR2_SMP_AN10(n) ((n) << 0) |
| AN10 sampling time. | |
| #define | ADC_SMPR2_SMP_AN11(n) ((n) << 3) |
| AN11 sampling time. | |
| #define | ADC_SMPR2_SMP_AN12(n) ((n) << 6) |
| AN12 sampling time. | |
| #define | ADC_SMPR2_SMP_AN13(n) ((n) << 9) |
| AN13 sampling time. | |
| #define | ADC_SMPR2_SMP_AN14(n) ((n) << 12) |
| AN14 sampling time. | |
| #define | ADC_SMPR2_SMP_AN15(n) ((n) << 15) |
| AN15 sampling time. | |
| #define | ADC_SMPR2_SMP_SENSOR(n) ((n) << 18) |
| Temperature Sensor sampling time. | |
| #define | ADC_SMPR2_SMP_VREF(n) ((n) << 21) |
| Voltage Reference sampling time. | |
| #define | ADC_SMPR2_SMP_AN18(n) ((n) << 24) |
| AN18 sampling time. | |
| #define | ADC_SMPR2_SMP_AN19(n) ((n) << 27) |
| AN19 sampling time. | |
| #define | ADC_SMPR1_SMP_AN20(n) ((n) << 0) |
| AN20 sampling time. | |
| #define | ADC_SMPR1_SMP_AN21(n) ((n) << 3) |
| AN21 sampling time. | |
| #define | ADC_SMPR1_SMP_AN22(n) ((n) << 6) |
| AN22 sampling time. | |
| #define | ADC_SMPR1_SMP_AN23(n) ((n) << 9) |
| AN23 sampling time. | |
| #define | ADC_SMPR1_SMP_AN24(n) ((n) << 12) |
| AN24 sampling time. | |
| #define | ADC_SMPR1_SMP_AN25(n) ((n) << 15) |
| AN25 sampling time. | |
Typedefs | |
| typedef uint16_t | adcsample_t |
| ADC sample data type. | |
| typedef uint16_t | adc_channels_num_t |
| Channels number in a conversion group. | |
| typedef struct ADCDriver | ADCDriver |
| Type of a structure representing an ADC driver. | |
| typedef void(* | adccallback_t )(ADCDriver *adcp, adcsample_t *buffer, size_t n) |
| ADC notification callback type. | |
| typedef void(* | adcerrorcallback_t )(ADCDriver *adcp, adcerror_t err) |
| ADC error callback type. | |
Enumerations | |
| enum | adcstate_t { ADC_UNINIT = 0, ADC_STOP = 1, ADC_READY = 2, ADC_ACTIVE = 3, ADC_COMPLETE = 4, ADC_ERROR = 5 } |
| Driver state machine possible states. More... | |
| enum | adcerror_t { ADC_ERR_DMAFAILURE = 0, ADC_ERR_OVERFLOW = 1 } |
| Possible ADC failure causes. More... | |
| void adcInit | ( | void | ) |
ADC Driver initialization.
halInit(), there is no need to explicitly initialize the driver.Definition at line 61 of file adc.c.
References adc_lld_init().
Referenced by halInit().

| void adcObjectInit | ( | ADCDriver * | adcp | ) |
Initializes the standard part of a ADCDriver structure.
| [out] | adcp | pointer to the ADCDriver object |
Definition at line 73 of file adc.c.
References ADC_STOP, ADCDriver::config, ADCDriver::depth, ADCDriver::grpp, ADCDriver::mutex, ADCDriver::samples, ADCDriver::state, and ADCDriver::thread.
Referenced by adc_lld_init().
Configures and activates the ADC peripheral.
| [in] | adcp | pointer to the ADCDriver object |
| [in] | config | pointer to the ADCConfig object. Depending on the implementation the value can be NULL. |
Definition at line 104 of file adc.c.
References adc_lld_start(), ADC_READY, ADC_STOP, ADCDriver::config, and ADCDriver::state.

| void adcStop | ( | ADCDriver * | adcp | ) |
Deactivates the ADC peripheral.
| [in] | adcp | pointer to the ADCDriver object |
Definition at line 124 of file adc.c.
References adc_lld_stop(), ADC_READY, ADC_STOP, and ADCDriver::state.

| void adcStartConversion | ( | ADCDriver * | adcp, |
| const ADCConversionGroup * | grpp, | ||
| adcsample_t * | samples, | ||
| size_t | depth | ||
| ) |
Starts an ADC conversion.
Starts an asynchronous conversion operation.
| [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. |
Definition at line 152 of file adc.c.
References adcStartConversionI().

| void adcStartConversionI | ( | ADCDriver * | adcp, |
| const ADCConversionGroup * | grpp, | ||
| adcsample_t * | samples, | ||
| size_t | depth | ||
| ) |
Starts an ADC conversion.
Starts an asynchronous conversion operation.
| [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. |
Definition at line 180 of file adc.c.
References ADC_ACTIVE, ADC_COMPLETE, ADC_ERROR, adc_lld_start_conversion(), ADC_READY, ADCDriver::depth, ADCDriver::grpp, ADCDriver::samples, and ADCDriver::state.
Referenced by adcConvert(), and adcStartConversion().

| void adcStopConversion | ( | ADCDriver * | adcp | ) |
Stops an ongoing conversion.
This function stops the currently ongoing conversion and returns the driver in the ADC_READY state. If there was no conversion being processed then the function does nothing.
| [in] | adcp | pointer to the ADCDriver object |
Definition at line 211 of file adc.c.
References _adc_reset_s, ADC_ACTIVE, adc_lld_stop_conversion(), ADC_READY, ADCDriver::grpp, and ADCDriver::state.

| void adcStopConversionI | ( | ADCDriver * | adcp | ) |
Stops an ongoing conversion.
This function stops the currently ongoing conversion and returns the driver in the ADC_READY state. If there was no conversion being processed then the function does nothing.
| [in] | adcp | pointer to the ADCDriver object |
Definition at line 238 of file adc.c.
References _adc_reset_i, ADC_ACTIVE, ADC_COMPLETE, adc_lld_stop_conversion(), ADC_READY, ADCDriver::grpp, and ADCDriver::state.

| void adcAcquireBus | ( | ADCDriver * | adcp | ) |
Gains exclusive access to the ADC peripheral.
This function tries to gain ownership to the ADC bus, if the bus is already being used then the invoking thread is queued.
ADC_USE_MUTUAL_EXCLUSION must be enabled.| [in] | adcp | pointer to the ADCDriver object |
Definition at line 308 of file adc.c.
References ADCDriver::mutex.
| void adcReleaseBus | ( | ADCDriver * | adcp | ) |
Releases exclusive access to the ADC peripheral.
ADC_USE_MUTUAL_EXCLUSION must be enabled.| [in] | adcp | pointer to the ADCDriver object |
| msg_t adcConvert | ( | ADCDriver * | adcp, |
| const ADCConversionGroup * | grpp, | ||
| adcsample_t * | samples, | ||
| size_t | depth | ||
| ) |
Performs an ADC conversion.
Performs a synchronous conversion operation.
| [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. |
| RDY_OK | Conversion finished. |
| RDY_RESET | The conversion has been stopped using acdStopConversion() or acdStopConversionI(), the result buffer may contain incorrect data. |
| RDY_TIMEOUT | The conversion has been stopped because an hardware error. |
Definition at line 279 of file adc.c.
References adcStartConversionI(), and ADCDriver::thread.

| CH_IRQ_HANDLER | ( | ADC1_IRQHandler | ) |
ADC interrupt handler.
Definition at line 91 of file adc_lld.c.
References _adc_isr_error_code, ADC_ERR_OVERFLOW, ADCDriver::dmastp, dmaStreamGetTransactionSize, and ADCDriver::grpp.
| void adc_lld_init | ( | void | ) |
Low level ADC driver initialization.
Definition at line 121 of file adc_lld.c.
References ADCDriver::adc, adcObjectInit(), ADCDriver::dmamode, ADCDriver::dmastp, STM32_ADC_ADC1_DMA_PRIORITY, STM32_ADC_IRQ_PRIORITY, and STM32_DMA_CR_DMEIE.
Referenced by adcInit().

| void adc_lld_start | ( | ADCDriver * | adcp | ) |
Configures and activates the ADC peripheral.
| [in] | adcp | pointer to the ADCDriver object |
Definition at line 147 of file adc_lld.c.
References ADCDriver::adc, ADC_STOP, ADCDriver::dmastp, dmaStreamAllocate(), dmaStreamSetPeripheral, rccEnableADC1, ADCDriver::state, and STM32_ADC_ADC1_DMA_IRQ_PRIORITY.
Referenced by adcStart().

| void adc_lld_stop | ( | ADCDriver * | adcp | ) |
Deactivates the ADC peripheral.
| [in] | adcp | pointer to the ADCDriver object |
Definition at line 179 of file adc_lld.c.
References ADCDriver::adc, ADC_READY, ADCDriver::dmastp, dmaStreamRelease(), rccDisableADC1, and ADCDriver::state.
Referenced by adcStop().

| void adc_lld_start_conversion | ( | ADCDriver * | adcp | ) |
Starts an ADC conversion.
| [in] | adcp | pointer to the ADCDriver object |
Definition at line 201 of file adc_lld.c.
References ADCDriver::adc, ADCConversionGroup::circular, ADCConversionGroup::cr1, ADCConversionGroup::cr2, ADCDriver::depth, ADCDriver::dmamode, ADCDriver::dmastp, dmaStreamEnable, dmaStreamSetMemory0, dmaStreamSetMode, dmaStreamSetTransactionSize, ADCDriver::grpp, ADCConversionGroup::num_channels, ADCDriver::samples, ADCConversionGroup::smpr1, ADCConversionGroup::smpr2, ADCConversionGroup::smpr3, ADCConversionGroup::sqr1, ADCConversionGroup::sqr2, ADCConversionGroup::sqr3, ADCConversionGroup::sqr4, and ADCConversionGroup::sqr5.
Referenced by adcStartConversionI().
| void adc_lld_stop_conversion | ( | ADCDriver * | adcp | ) |
Stops an ongoing conversion.
| [in] | adcp | pointer to the ADCDriver object |
Definition at line 250 of file adc_lld.c.
References ADCDriver::adc, ADCDriver::dmastp, and dmaStreamDisable.
Referenced by adcStopConversion(), and adcStopConversionI().
| void adcSTM32EnableTSVREFE | ( | void | ) |
| void adcSTM32DisableTSVREFE | ( | void | ) |
| #define ADC_USE_WAIT TRUE |
| #define ADC_USE_MUTUAL_EXCLUSION TRUE |
Enables the adcAcquireBus() and adcReleaseBus() APIs.
| #define _adc_reset_i | ( | adcp | ) |
{ \
if ((adcp)->thread != NULL) { \
Thread *tp = (adcp)->thread; \
(adcp)->thread = NULL; \
tp->p_u.rdymsg = RDY_RESET; \
chSchReadyI(tp); \
} \
}
Resumes a thread waiting for a conversion completion.
| [in] | adcp | pointer to the ADCDriver object |
Definition at line 105 of file adc.h.
Referenced by adcStopConversionI().
| #define _adc_reset_s | ( | adcp | ) |
{ \
if ((adcp)->thread != NULL) { \
Thread *tp = (adcp)->thread; \
(adcp)->thread = NULL; \
chSchWakeupS(tp, RDY_RESET); \
} \
}
Resumes a thread waiting for a conversion completion.
| [in] | adcp | pointer to the ADCDriver object |
Definition at line 121 of file adc.h.
Referenced by adcStopConversion().
| #define _adc_wakeup_isr | ( | adcp | ) |
{ \
chSysLockFromIsr(); \
if ((adcp)->thread != NULL) { \
Thread *tp; \
tp = (adcp)->thread; \
(adcp)->thread = NULL; \
tp->p_u.rdymsg = RDY_OK; \
chSchReadyI(tp); \
} \
chSysUnlockFromIsr(); \
}
Wakes up the waiting thread.
| [in] | adcp | pointer to the ADCDriver object |
| #define _adc_timeout_isr | ( | adcp | ) |
{ \
chSysLockFromIsr(); \
if ((adcp)->thread != NULL) { \
Thread *tp; \
tp = (adcp)->thread; \
(adcp)->thread = NULL; \
tp->p_u.rdymsg = RDY_TIMEOUT; \
chSchReadyI(tp); \
} \
chSysUnlockFromIsr(); \
}
Wakes up the waiting thread with a timeout message.
| [in] | adcp | pointer to the ADCDriver object |
| #define _adc_isr_half_code | ( | adcp | ) |
{ \
if ((adcp)->grpp->end_cb != NULL) { \
(adcp)->grpp->end_cb(adcp, (adcp)->samples, (adcp)->depth / 2); \
} \
}
Common ISR code, half buffer event.
This code handles the portable part of the ISR code:
| [in] | adcp | pointer to the ADCDriver object |
| #define _adc_isr_full_code | ( | adcp | ) |
Common ISR code, full buffer event.
This code handles the portable part of the ISR code:
| [in] | adcp | pointer to the ADCDriver object |
| #define _adc_isr_error_code | ( | adcp, | |
| err | |||
| ) |
{ \
adc_lld_stop_conversion(adcp); \
if ((adcp)->grpp->error_cb != NULL) { \
(adcp)->state = ADC_ERROR; \
(adcp)->grpp->error_cb(adcp, err); \
if ((adcp)->state == ADC_ERROR) \
(adcp)->state = ADC_READY; \
} \
(adcp)->grpp = NULL; \
_adc_timeout_isr(adcp); \
}
Common ISR code, error event.
This code handles the portable part of the ISR code:
| [in] | adcp | pointer to the ADCDriver object |
| [in] | err | platform dependent error code |
Definition at line 262 of file adc.h.
Referenced by CH_IRQ_HANDLER().
| #define ADC_CR2_EXTSEL_SRC | ( | n | ) | ((n) << 24) |
| #define STM32_ADC_USE_ADC1 FALSE |
| #define STM32_ADC_ADCPRE ADC_CCR_ADCPRE_DIV1 |
| #define STM32_ADC_ADC1_DMA_PRIORITY 2 |
ADC1 DMA priority (0..3|lowest..highest).
Definition at line 132 of file adc_lld.h.
Referenced by adc_lld_init().
| #define STM32_ADC_IRQ_PRIORITY 5 |
ADC interrupt priority level setting.
Definition at line 139 of file adc_lld.h.
Referenced by adc_lld_init().
| #define STM32_ADC_ADC1_DMA_IRQ_PRIORITY 5 |
ADC1 DMA interrupt priority level setting.
Definition at line 146 of file adc_lld.h.
Referenced by adc_lld_start().
| #define ADC_SQR1_NUM_CH | ( | n | ) | (((n) - 1) << 20) |
| #define ADC_SQR5_SQ1_N | ( | n | ) | ((n) << 0) |
| #define ADC_SQR5_SQ2_N | ( | n | ) | ((n) << 5) |
| #define ADC_SQR5_SQ3_N | ( | n | ) | ((n) << 10) |
| #define ADC_SQR5_SQ4_N | ( | n | ) | ((n) << 15) |
| #define ADC_SQR5_SQ5_N | ( | n | ) | ((n) << 20) |
| #define ADC_SQR5_SQ6_N | ( | n | ) | ((n) << 25) |
| #define ADC_SQR4_SQ7_N | ( | n | ) | ((n) << 0) |
| #define ADC_SQR4_SQ8_N | ( | n | ) | ((n) << 5) |
| #define ADC_SQR4_SQ9_N | ( | n | ) | ((n) << 10) |
| #define ADC_SQR4_SQ10_N | ( | n | ) | ((n) << 15) |
| #define ADC_SQR4_SQ11_N | ( | n | ) | ((n) << 20) |
| #define ADC_SQR4_SQ12_N | ( | n | ) | ((n) << 25) |
| #define ADC_SQR3_SQ13_N | ( | n | ) | ((n) << 0) |
| #define ADC_SQR3_SQ14_N | ( | n | ) | ((n) << 5) |
| #define ADC_SQR3_SQ15_N | ( | n | ) | ((n) << 10) |
| #define ADC_SQR3_SQ16_N | ( | n | ) | ((n) << 15) |
| #define ADC_SQR3_SQ17_N | ( | n | ) | ((n) << 20) |
| #define ADC_SQR3_SQ18_N | ( | n | ) | ((n) << 25) |
| #define ADC_SQR2_SQ19_N | ( | n | ) | ((n) << 0) |
| #define ADC_SQR2_SQ20_N | ( | n | ) | ((n) << 5) |
| #define ADC_SQR2_SQ21_N | ( | n | ) | ((n) << 10) |
| #define ADC_SQR2_SQ22_N | ( | n | ) | ((n) << 15) |
| #define ADC_SQR2_SQ23_N | ( | n | ) | ((n) << 20) |
| #define ADC_SQR2_SQ24_N | ( | n | ) | ((n) << 25) |
| #define ADC_SQR1_SQ25_N | ( | n | ) | ((n) << 0) |
| #define ADC_SQR1_SQ26_N | ( | n | ) | ((n) << 5) |
| #define ADC_SQR1_SQ27_N | ( | n | ) | ((n) << 10) |
| #define ADC_SMPR3_SMP_AN0 | ( | n | ) | ((n) << 0) |
| #define ADC_SMPR3_SMP_AN1 | ( | n | ) | ((n) << 3) |
| #define ADC_SMPR3_SMP_AN2 | ( | n | ) | ((n) << 6) |
| #define ADC_SMPR3_SMP_AN3 | ( | n | ) | ((n) << 9) |
| #define ADC_SMPR3_SMP_AN4 | ( | n | ) | ((n) << 12) |
| #define ADC_SMPR3_SMP_AN5 | ( | n | ) | ((n) << 15) |
| #define ADC_SMPR3_SMP_AN6 | ( | n | ) | ((n) << 18) |
| #define ADC_SMPR3_SMP_AN7 | ( | n | ) | ((n) << 21) |
| #define ADC_SMPR3_SMP_AN8 | ( | n | ) | ((n) << 24) |
| #define ADC_SMPR3_SMP_AN9 | ( | n | ) | ((n) << 27) |
| #define ADC_SMPR2_SMP_AN10 | ( | n | ) | ((n) << 0) |
| #define ADC_SMPR2_SMP_AN11 | ( | n | ) | ((n) << 3) |
| #define ADC_SMPR2_SMP_AN12 | ( | n | ) | ((n) << 6) |
| #define ADC_SMPR2_SMP_AN13 | ( | n | ) | ((n) << 9) |
| #define ADC_SMPR2_SMP_AN14 | ( | n | ) | ((n) << 12) |
| #define ADC_SMPR2_SMP_AN15 | ( | n | ) | ((n) << 15) |
| #define ADC_SMPR2_SMP_SENSOR | ( | n | ) | ((n) << 18) |
| #define ADC_SMPR2_SMP_VREF | ( | n | ) | ((n) << 21) |
| #define ADC_SMPR2_SMP_AN18 | ( | n | ) | ((n) << 24) |
| #define ADC_SMPR2_SMP_AN19 | ( | n | ) | ((n) << 27) |
| #define ADC_SMPR1_SMP_AN20 | ( | n | ) | ((n) << 0) |
| #define ADC_SMPR1_SMP_AN21 | ( | n | ) | ((n) << 3) |
| #define ADC_SMPR1_SMP_AN22 | ( | n | ) | ((n) << 6) |
| #define ADC_SMPR1_SMP_AN23 | ( | n | ) | ((n) << 9) |
| #define ADC_SMPR1_SMP_AN24 | ( | n | ) | ((n) << 12) |
| #define ADC_SMPR1_SMP_AN25 | ( | n | ) | ((n) << 15) |
| typedef uint16_t adcsample_t |
| typedef uint16_t adc_channels_num_t |
| typedef void(* adccallback_t)(ADCDriver *adcp, adcsample_t *buffer, size_t n) |
| typedef void(* adcerrorcallback_t)(ADCDriver *adcp, adcerror_t err) |
| enum adcstate_t |
| enum adcerror_t |