libopencm3
A free/libre/open-source firmware library for various ARM Cortex-M3 microcontrollers.
|
Functions | |
void | adc_enable_analog_watchdog_regular (uint32_t adc) |
ADC Enable Analog Watchdog for Regular Conversions. More... | |
void | adc_disable_analog_watchdog_regular (uint32_t adc) |
ADC Enable Analog Watchdog for Regular Conversions. More... | |
void | adc_enable_analog_watchdog_injected (uint32_t adc) |
ADC Enable Analog Watchdog for Injected Conversions. More... | |
void | adc_disable_analog_watchdog_injected (uint32_t adc) |
ADC Disable Analog Watchdog for Injected Conversions. More... | |
void | adc_enable_discontinuous_mode_regular (uint32_t adc, uint8_t length) |
ADC Enable Discontinuous Mode for Regular Conversions. More... | |
void | adc_disable_discontinuous_mode_regular (uint32_t adc) |
ADC Disable Discontinuous Mode for Regular Conversions. More... | |
void | adc_enable_discontinuous_mode_injected (uint32_t adc) |
ADC Enable Discontinuous Mode for Injected Conversions. More... | |
void | adc_disable_discontinuous_mode_injected (uint32_t adc) |
ADC Disable Discontinuous Mode for Injected Conversions. More... | |
void | adc_enable_automatic_injected_group_conversion (uint32_t adc) |
ADC Enable Automatic Injected Conversions. More... | |
void | adc_disable_automatic_injected_group_conversion (uint32_t adc) |
ADC Disable Automatic Injected Conversions. More... | |
void | adc_enable_analog_watchdog_on_all_channels (uint32_t adc) |
ADC Enable Analog Watchdog for All Regular and/or Injected Channels. More... | |
void | adc_enable_analog_watchdog_on_selected_channel (uint32_t adc, uint8_t channel) |
ADC Enable Analog Watchdog for a Selected Channel. More... | |
void | adc_enable_eoc_interrupt_injected (uint32_t adc) |
ADC Enable Injected End-Of-Conversion Interrupt. More... | |
void | adc_disable_eoc_interrupt_injected (uint32_t adc) |
ADC Disable Injected End-Of-Conversion Interrupt. More... | |
void | adc_enable_eos_interrupt_injected (uint32_t adc) |
ADC Enable Injected End-Of-Sequence Interrupt. More... | |
void | adc_disable_eos_interrupt_injected (uint32_t adc) |
ADC Disable Injected End-Of-Sequence Interrupt. More... | |
void | adc_enable_all_awd_interrupt (uint32_t adc) |
ADC Enable Analog Watchdog Interrupt. More... | |
void | adc_disable_all_awd_interrupt (uint32_t adc) |
ADC Disable Analog Watchdog Interrupt. More... | |
void | adc_enable_eos_interrupt (uint32_t adc) |
ADC Enable Regular End-Of-Sequence Interrupt. More... | |
void | adc_disable_eos_interrupt (uint32_t adc) |
ADC Disable Regular End-Of-Sequence Interrupt. More... | |
void | adc_start_conversion_injected (uint32_t adc) |
ADC Software Triggered Conversion on Injected Channels. More... | |
void | adc_set_watchdog_high_threshold (uint32_t adc, uint16_t threshold) |
ADC Set Analog Watchdog Upper Threshold. More... | |
void | adc_set_watchdog_low_threshold (uint32_t adc, uint16_t threshold) |
ADC Set Analog Watchdog Lower Threshold. More... | |
void | adc_set_injected_sequence (uint32_t adc, uint8_t length, uint8_t channel[]) |
ADC Set an Injected Channel Conversion Sequence. More... | |
bool | adc_eoc_injected (uint32_t adc) |
ADC Read the End-of-Conversion Flag for Injected Conversion. More... | |
bool | adc_eos_injected (uint32_t adc) |
ADC Read the End-of-Sequence Flag for Injected Conversions. More... | |
uint32_t | adc_read_injected (uint32_t adc, uint8_t reg) |
ADC Read from an Injected Conversion Result Register. More... | |
void | adc_set_injected_offset (uint32_t adc, uint8_t reg, uint32_t offset) |
ADC Set the Injected Channel Data Offset. More... | |
void | adc_set_clk_prescale (uint32_t adc, uint32_t prescale) |
ADC Set Clock Prescale. More... | |
void | adc_set_multi_mode (uint32_t adc, uint32_t mode) |
ADC set multi mode. More... | |
void | adc_enable_external_trigger_regular (uint32_t adc, uint32_t trigger, uint32_t polarity) |
ADC Enable an External Trigger for Regular Channels. More... | |
void | adc_disable_external_trigger_regular (uint32_t adc) |
ADC Disable an External Trigger for Regular Channels. More... | |
void | adc_enable_external_trigger_injected (uint32_t adc, uint32_t trigger, uint32_t polarity) |
ADC Enable an External Trigger for Injected Channels. More... | |
void | adc_disable_external_trigger_injected (uint32_t adc) |
ADC Disable an External Trigger for Injected Channels. More... | |
bool | adc_awd (uint32_t adc) |
ADC Read the Analog Watchdog Flag. More... | |
void | adc_enable_regulator (uint32_t adc) |
Enable the ADC Voltage regulator Before any use of the ADC, the ADC Voltage regulator must be enabled. More... | |
void | adc_disable_regulator (uint32_t adc) |
Disable the ADC Voltage regulator You can disable the adc vreg when not in use to save power. More... | |
bool | adc_eoc (uint32_t adc) |
ADC Read the End-of-Conversion Flag. More... | |
bool | adc_eos (uint32_t adc) |
ADC Read the End-of-Sequence Flag for Regular Conversions. More... | |
void | adc_power_on_async (uint32_t adc) |
Turn on the ADC (async) More... | |
bool | adc_is_power_on (uint32_t adc) |
Is the ADC powered up and ready? More... | |
void | adc_power_on (uint32_t adc) |
Turn on the ADC. More... | |
void | adc_power_off_async (uint32_t adc) |
Turn off the ADC (async) This will actually block if it needs to turn off a currently running conversion, as per ref man. More... | |
bool | adc_is_power_off (uint32_t adc) |
Is the ADC powered down? More... | |
void | adc_power_off (uint32_t adc) |
Turn off the ADC This will actually block if it needs to turn off a currently running conversion, as per ref man. More... | |
void | adc_calibrate_async (uint32_t adc) |
Start the ADC calibration and immediately return. More... | |
bool | adc_is_calibrating (uint32_t adc) |
Is the ADC Calibrating? More... | |
void | adc_calibrate (uint32_t adc) |
Start ADC calibration and wait for it to finish. More... | |
void | adc_set_continuous_conversion_mode (uint32_t adc) |
Enable Continuous Conversion Mode In this mode the ADC starts a new conversion of a single channel or a channel group immediately following completion of the previous channel group conversion. More... | |
void | adc_set_single_conversion_mode (uint32_t adc) |
Enable Single Conversion Mode In this mode the ADC performs a conversion of one channel or a channel group and stops. More... | |
void | adc_set_resolution (uint32_t adc, uint16_t resolution) |
ADC Set Resolution. More... | |
void | adc_set_left_aligned (uint32_t adc) |
ADC Set the Data as Left Aligned. More... | |
void | adc_set_right_aligned (uint32_t adc) |
ADC Set the Data as Right Aligned. More... | |
void | adc_enable_dma (uint32_t adc) |
ADC Enable DMA Transfers. More... | |
void | adc_disable_dma (uint32_t adc) |
ADC Disable DMA Transfers. More... | |
void | adc_enable_overrun_interrupt (uint32_t adc) |
ADC Enable the Overrun Interrupt. More... | |
void | adc_disable_overrun_interrupt (uint32_t adc) |
ADC Disable the Overrun Interrupt. More... | |
bool | adc_get_overrun_flag (uint32_t adc) |
ADC Read the Overrun Flag. More... | |
void | adc_clear_overrun_flag (uint32_t adc) |
ADC Clear Overrun Flags. More... | |
void | adc_enable_eoc_interrupt (uint32_t adc) |
ADC Enable Regular End-Of-Conversion Interrupt. More... | |
void | adc_disable_eoc_interrupt (uint32_t adc) |
ADC Disable Regular End-Of-Conversion Interrupt. More... | |
uint32_t | adc_read_regular (uint32_t adc) |
ADC Read from the Regular Conversion Result Register. More... | |
void | adc_enable_temperature_sensor (void) |
Enable the temperature sensor (only) The channel this is available on is unfortunately not consistent, even though the bit used to enable it is. More... | |
void | adc_disable_temperature_sensor (void) |
Disable the temperature sensor (only) More... | |
void | adc_enable_vrefint (void) |
Enable the internal voltage reference (only) The channel this is available on is unfortunately not consistent, even though the bit used to enable it is. More... | |
void | adc_disable_vrefint (void) |
Disable the internal voltage reference (only) More... | |
void | adc_start_conversion_regular (uint32_t adc) |
ADC Software Triggered Conversion on Regular Channels. More... | |
void | adc_enable_dma_circular_mode (uint32_t adc) |
Enable circular mode for DMA transfers. More... | |
void | adc_disable_dma_circular_mode (uint32_t adc) |
Disable circular mode for DMA transfers. More... | |
void | adc_enable_delayed_conversion_mode (uint32_t adc) |
Enable Delayed Conversion Mode. More... | |
void | adc_disable_delayed_conversion_mode (uint32_t adc) |
Enable Delayed Conversion Mode. More... | |
void | adc_set_sample_time (uint32_t adc, uint8_t channel, uint8_t time) |
ADC Set the Sample Time for a Single Channel. More... | |
void | adc_set_sample_time_on_all_channels (uint32_t adc, uint8_t time) |
ADC Set the Sample Time for All Channels. More... | |
void | adc_set_regular_sequence (uint32_t adc, uint8_t length, uint8_t channel[]) |
ADC Set a Regular Channel Conversion Sequence. More... | |
This library supports the A/D Converter Control System in the STM32 series of ARM Cortex Microcontrollers by ST Microelectronics.
Devices can have up to three A/D converters each with their own set of registers. However all the A/D converters share a common clock which is prescaled from the APB2 clock by default by a minimum factor of 2 to a maximum of 8. The ADC resolution can be set to 12, 10, 8 or 6 bits.
Each A/D converter has up to 19 channels:
The conversions can occur as a one-off conversion whereby the process stops once conversion is complete. The conversions can also be continuous wherein a new conversion starts immediately the previous conversion has ended.
Conversion can occur as a single channel conversion or a scan of a group of channels in either continuous or one-off mode. If more than one channel is converted in a scan group, DMA must be used to transfer the data as there is only one result register available. An interrupt can be set to occur at the end* of conversion, which occurs after all channels have been scanned.
A discontinuous mode allows a subgroup of group of a channels to be converted in bursts of a given length.
Injected conversions allow a second group of channels to be converted separately from the regular group. An interrupt can be set to occur at the end of conversion, which occurs after all channels have been scanned.
Example 1: Simple single channel conversion polled. Enable the peripheral clock and ADC, reset ADC and set the prescaler divider. Set multiple mode to independent.
LGPL License Terms libopencm3 License
This library supports one style of the Analog to Digital Conversion System in the STM32 series of ARM Cortex Microcontrollers by ST Microelectronics.
The style of ADC Peripheral supported by this code is found in the F0, L0 and F30x series devices (at the time of writing)
LGPL License Terms libopencm3 License
This provides the "multi" extensions to the "v2" ADC peripheral. This is those devices that support injected channels and per channel sampling times. At the time of writing, this is the STM32F30x and the STM32L4x
LGPL License Terms libopencm3 License
bool adc_awd | ( | uint32_t | adc | ) |
ADC Read the Analog Watchdog Flag.
This flag is set when the converted voltage crosses the high or low thresholds.
[in] | adc | Unsigned int32. ADC block register address base ADC register base addresses |
Definition at line 696 of file adc.c.
References ADC_ISR, ADC_ISR_AWD1, ADC_ISR_AWD2, and ADC_ISR_AWD3.
void adc_calibrate | ( | uint32_t | adc | ) |
Start ADC calibration and wait for it to finish.
adc | ADC Block register address base ADC register base addresses |
Definition at line 175 of file adc_common_v2.c.
References adc_calibrate_async(), and adc_is_calibrating().
void adc_calibrate_async | ( | uint32_t | adc | ) |
Start the ADC calibration and immediately return.
adc | ADC Block register address base ADC register base addresses |
Definition at line 156 of file adc_common_v2.c.
References ADC_CR, and ADC_CR_ADCAL.
Referenced by adc_calibrate().
void adc_clear_overrun_flag | ( | uint32_t | adc | ) |
ADC Clear Overrun Flags.
The overrun flag is cleared. Note that if an overrun occurs, DMA is terminated. The flag must be cleared and the DMA stream and ADC reinitialised to resume conversions (see the reference manual).
[in] | adc | Unsigned int32. ADC base address (ADC register base addresses) |
Definition at line 299 of file adc_common_v2.c.
References ADC_ISR, and ADC_ISR_OVR.
void adc_disable_all_awd_interrupt | ( | uint32_t | adc | ) |
ADC Disable Analog Watchdog Interrupt.
[in] | adc | Unsigned int32. ADC block register address base ADC register base addresses |
Definition at line 360 of file adc.c.
References ADC_IER.
void adc_disable_analog_watchdog_injected | ( | uint32_t | adc | ) |
ADC Disable Analog Watchdog for Injected Conversions.
[in] | adc | Unsigned int32. ADC block register address base ADC register base addresses |
Definition at line 142 of file adc.c.
References ADC_CFGR1.
void adc_disable_analog_watchdog_regular | ( | uint32_t | adc | ) |
ADC Enable Analog Watchdog for Regular Conversions.
The analog watchdog allows the monitoring of an analog signal between two threshold levels. The thresholds must be preset. Comparison is done before data alignment takes place, so the thresholds are left-aligned.
[in] | adc | Unsigned int32. ADC block register address base ADC register base addresses |
Definition at line 114 of file adc.c.
References ADC_CFGR1.
void adc_disable_automatic_injected_group_conversion | ( | uint32_t | adc | ) |
ADC Disable Automatic Injected Conversions.
[in] | adc | Unsigned int32. ADC block register address base ADC register base addresses |
Definition at line 234 of file adc.c.
References ADC_CFGR1.
void adc_disable_delayed_conversion_mode | ( | uint32_t | adc | ) |
Enable Delayed Conversion Mode.
[in] | adc | ADC block register address base ADC register base addresses |
Definition at line 425 of file adc_common_v2.c.
References ADC_CFGR1.
void adc_disable_discontinuous_mode_injected | ( | uint32_t | adc | ) |
ADC Disable Discontinuous Mode for Injected Conversions.
[in] | adc | Unsigned int32. ADC block register address base ADC register base addresses |
Definition at line 205 of file adc.c.
References ADC_CFGR1.
void adc_disable_discontinuous_mode_regular | ( | uint32_t | adc | ) |
ADC Disable Discontinuous Mode for Regular Conversions.
[in] | adc | Unsigned int32. ADC block register address base ADC register base addresses |
Definition at line 177 of file adc.c.
References ADC_CFGR1.
void adc_disable_dma | ( | uint32_t | adc | ) |
ADC Disable DMA Transfers.
[in] | adc | Unsigned int32. ADC base address (ADC register base addresses) |
Definition at line 250 of file adc_common_v2.c.
References ADC_CFGR1.
void adc_disable_dma_circular_mode | ( | uint32_t | adc | ) |
Disable circular mode for DMA transfers.
[in] | adc | Unsigned int32. ADC base address (ADC register base addresses) |
Definition at line 407 of file adc_common_v2.c.
References ADC_CFGR1.
void adc_disable_eoc_interrupt | ( | uint32_t | adc | ) |
ADC Disable Regular End-Of-Conversion Interrupt.
[in] | adc | Unsigned int32. ADC base address (ADC register base addresses) |
Definition at line 317 of file adc_common_v2.c.
References ADC_IER.
void adc_disable_eoc_interrupt_injected | ( | uint32_t | adc | ) |
ADC Disable Injected End-Of-Conversion Interrupt.
[in] | adc | Unsigned int32. ADC block register address base ADC register base addresses |
Definition at line 309 of file adc.c.
References ADC_IER.
void adc_disable_eos_interrupt | ( | uint32_t | adc | ) |
ADC Disable Regular End-Of-Sequence Interrupt.
[in] | adc | Unsigned int32. ADC block register address base ADC register base addresses |
Definition at line 386 of file adc.c.
References ADC_IER.
void adc_disable_eos_interrupt_injected | ( | uint32_t | adc | ) |
ADC Disable Injected End-Of-Sequence Interrupt.
[in] | adc | Unsigned int32. ADC block register address base ADC register base addresses |
Definition at line 333 of file adc.c.
References ADC_IER.
void adc_disable_external_trigger_injected | ( | uint32_t | adc | ) |
ADC Disable an External Trigger for Injected Channels.
[in] | adc | Unsigned int32. ADC block register address base ADC register base addresses |
Definition at line 679 of file adc.c.
References ADC_JSQR.
Referenced by adc_enable_automatic_injected_group_conversion().
void adc_disable_external_trigger_regular | ( | uint32_t | adc | ) |
ADC Disable an External Trigger for Regular Channels.
[in] | adc | Unsigned int32. ADC block register address base ADC register base addresses |
Definition at line 643 of file adc.c.
References ADC_CFGR1.
void adc_disable_overrun_interrupt | ( | uint32_t | adc | ) |
ADC Disable the Overrun Interrupt.
[in] | adc | Unsigned int32. ADC base address (ADC register base addresses) |
Definition at line 272 of file adc_common_v2.c.
References ADC_IER.
void adc_disable_regulator | ( | uint32_t | adc | ) |
Disable the ADC Voltage regulator You can disable the adc vreg when not in use to save power.
[in] | adc | ADC block register address base |
Definition at line 723 of file adc.c.
References ADC_CR, and ADC_CR_ADVREGEN_DISABLE.
void adc_disable_temperature_sensor | ( | void | ) |
Disable the temperature sensor (only)
Definition at line 351 of file adc_common_v2.c.
void adc_disable_vrefint | ( | void | ) |
Disable the internal voltage reference (only)
Definition at line 372 of file adc_common_v2.c.
void adc_enable_all_awd_interrupt | ( | uint32_t | adc | ) |
ADC Enable Analog Watchdog Interrupt.
[in] | adc | Unsigned int32. ADC block register address base ADC register base addresses |
Definition at line 346 of file adc.c.
References ADC_IER, ADC_IER_AWD1IE, ADC_IER_AWD2IE, and ADC_IER_AWD3IE.
void adc_enable_analog_watchdog_injected | ( | uint32_t | adc | ) |
ADC Enable Analog Watchdog for Injected Conversions.
The analog watchdog allows the monitoring of an analog signal between two threshold levels. The thresholds must be preset. Comparison is done before data alignment takes place, so the thresholds are left-aligned.
[in] | adc | Unsigned int32. ADC block register address base ADC register base addresses |
Definition at line 130 of file adc.c.
References ADC_CFGR1, and ADC_CFGR1_JAWD1EN.
void adc_enable_analog_watchdog_on_all_channels | ( | uint32_t | adc | ) |
ADC Enable Analog Watchdog for All Regular and/or Injected Channels.
The analog watchdog allows the monitoring of an analog signal between two threshold levels. The thresholds must be preset. Comparison is done before data alignment takes place, so the thresholds are left-aligned.
adc_enable_analog_watchdog_injected, adc_enable_analog_watchdog_regular.
[in] | adc | Unsigned int32. ADC block register address base ADC register base addresses |
Definition at line 256 of file adc.c.
References ADC_CFGR1.
void adc_enable_analog_watchdog_on_selected_channel | ( | uint32_t | adc, |
uint8_t | channel | ||
) |
ADC Enable Analog Watchdog for a Selected Channel.
The analog watchdog allows the monitoring of an analog signal between two threshold levels. The thresholds must be preset. Comparison is done before data alignment takes place, so the thresholds are left-aligned.
[in] | adc | Unsigned int32. ADC block register address base ADC register base addresses |
[in] | channel | Unsigned int8. ADC channel numbe adc_watchdog_channel |
Definition at line 280 of file adc.c.
References ADC_CFGR1, ADC_CFGR1_AWD1CH_VAL, ADC_CFGR1_AWD1EN, and ADC_CFGR1_AWD1SGL.
void adc_enable_analog_watchdog_regular | ( | uint32_t | adc | ) |
ADC Enable Analog Watchdog for Regular Conversions.
The analog watchdog allows the monitoring of an analog signal between two threshold levels. The thresholds must be preset. Comparison is done before data alignment takes place, so the thresholds are left-aligned.
[in] | adc | Unsigned int32. ADC block register address base ADC register base addresses |
Definition at line 99 of file adc.c.
References ADC_CFGR1, and ADC_CFGR1_AWD1EN.
void adc_enable_automatic_injected_group_conversion | ( | uint32_t | adc | ) |
ADC Enable Automatic Injected Conversions.
The ADC converts a defined injected group of channels immediately after the regular channels have been converted. The external trigger on the injected channels is disabled as required.
[in] | adc | Unsigned int32. ADC block register address base ADC register base addresses |
Definition at line 221 of file adc.c.
References ADC_CFGR1, ADC_CFGR1_JAUTO, and adc_disable_external_trigger_injected().
void adc_enable_delayed_conversion_mode | ( | uint32_t | adc | ) |
Enable Delayed Conversion Mode.
[in] | adc | ADC block register address base ADC register base addresses |
Definition at line 416 of file adc_common_v2.c.
References ADC_CFGR1, and ADC_CFGR1_AUTDLY.
void adc_enable_discontinuous_mode_injected | ( | uint32_t | adc | ) |
ADC Enable Discontinuous Mode for Injected Conversions.
In this mode the ADC converts sequentially one channel of the defined group of injected channels, cycling back to the first channel in the group once the entire group has been converted.
[in] | adc | Unsigned int32. ADC block register address base ADC register base addresses |
Definition at line 193 of file adc.c.
References ADC_CFGR1, and ADC_CFGR1_JDISCEN.
void adc_enable_discontinuous_mode_regular | ( | uint32_t | adc, |
uint8_t | length | ||
) |
ADC Enable Discontinuous Mode for Regular Conversions.
In this mode the ADC converts, on each trigger, a subgroup of up to 8 of the defined regular channel group. The subgroup is defined by the number of consecutive channels to be converted. After a subgroup has been converted the next trigger will start conversion of the immediately following subgroup of the same length or until the whole group has all been converted. When the whole group has been converted, the next trigger will restart conversion of the subgroup at the beginning of the whole group.
[in] | adc | ADC block register address base ADC register base addresses |
[in] | length | Number of channels in the group adc_cr1_discnum |
Definition at line 161 of file adc.c.
References ADC_CFGR1, ADC_CFGR1_DISCEN, and ADC_CFGR1_DISCNUM_SHIFT.
void adc_enable_dma | ( | uint32_t | adc | ) |
ADC Enable DMA Transfers.
[in] | adc | Unsigned int32. ADC base address (ADC register base addresses) |
Definition at line 241 of file adc_common_v2.c.
References ADC_CFGR1, and ADC_CFGR1_DMAEN.
void adc_enable_dma_circular_mode | ( | uint32_t | adc | ) |
Enable circular mode for DMA transfers.
For this to work it needs to be ebabled on the DMA side as well.
[in] | adc | Unsigned int32. ADC base address (ADC register base addresses) |
Definition at line 398 of file adc_common_v2.c.
References ADC_CFGR1, and ADC_CFGR1_DMACFG.
void adc_enable_eoc_interrupt | ( | uint32_t | adc | ) |
ADC Enable Regular End-Of-Conversion Interrupt.
[in] | adc | Unsigned int32. ADC base address (ADC register base addresses) |
Definition at line 308 of file adc_common_v2.c.
References ADC_IER, and ADC_IER_EOCIE.
void adc_enable_eoc_interrupt_injected | ( | uint32_t | adc | ) |
ADC Enable Injected End-Of-Conversion Interrupt.
[in] | adc | Unsigned int32. ADC block register address base ADC register base addresses |
Definition at line 297 of file adc.c.
References ADC_IER, and ADC_IER_JEOCIE.
void adc_enable_eos_interrupt | ( | uint32_t | adc | ) |
ADC Enable Regular End-Of-Sequence Interrupt.
[in] | adc | Unsigned int32. ADC block register address base ADC register base addresses |
Definition at line 374 of file adc.c.
References ADC_IER, and ADC_IER_EOSIE.
void adc_enable_eos_interrupt_injected | ( | uint32_t | adc | ) |
ADC Enable Injected End-Of-Sequence Interrupt.
[in] | adc | Unsigned int32. ADC block register address base ADC register base addresses |
Definition at line 321 of file adc.c.
References ADC_IER, and ADC_IER_JEOSIE.
void adc_enable_external_trigger_injected | ( | uint32_t | adc, |
uint32_t | trigger, | ||
uint32_t | polarity | ||
) |
ADC Enable an External Trigger for Injected Channels.
This enables an external trigger for set of defined injected channels, and sets the polarity of the trigger event: rising or falling edge or both.
[in] | adc | Unsigned int32. ADC block register address base ADC register base addresses |
[in] | trigger | Unsigned int8. Trigger identifier adc_trigger_injected |
[in] | polarity | Unsigned int32. Trigger polarity adc_trigger_polarity_injected |
Definition at line 662 of file adc.c.
References ADC_JSQR, ADC_JSQR_JEXTEN_MASK, and ADC_JSQR_JEXTSEL_MASK.
void adc_enable_external_trigger_regular | ( | uint32_t | adc, |
uint32_t | trigger, | ||
uint32_t | polarity | ||
) |
ADC Enable an External Trigger for Regular Channels.
This enables an external trigger for set of defined regular channels, and sets the polarity of the trigger event: rising or falling edge or both. Note that if the trigger polarity is zero, triggering is disabled.
[in] | adc | Unsigned int32. ADC block register address base ADC register base addresses |
[in] | trigger | Unsigned int32. Trigger identifier adc_trigger_regular |
[in] | polarity | Unsigned int32. Trigger polarity adc_trigger_polarity_regular |
Definition at line 626 of file adc.c.
References ADC_CFGR1, ADC_CFGR1_EXTEN_MASK, and ADC_CFGR1_EXTSEL_MASK.
void adc_enable_overrun_interrupt | ( | uint32_t | adc | ) |
ADC Enable the Overrun Interrupt.
The overrun interrupt is generated when data is not read from a result register before the next conversion is written. If DMA is enabled, all transfers are terminated and any conversion sequence is aborted.
[in] | adc | Unsigned int32. ADC base address (ADC register base addresses) |
Definition at line 263 of file adc_common_v2.c.
References ADC_IER, and ADC_IER_OVRIE.
void adc_enable_regulator | ( | uint32_t | adc | ) |
Enable the ADC Voltage regulator Before any use of the ADC, the ADC Voltage regulator must be enabled.
You must wait up to 10uSecs afterwards before trying anything else.
[in] | adc | ADC block register address base |
Definition at line 711 of file adc.c.
References ADC_CR, and ADC_CR_ADVREGEN_ENABLE.
void adc_enable_temperature_sensor | ( | void | ) |
Enable the temperature sensor (only) The channel this is available on is unfortunately not consistent, even though the bit used to enable it is.
Definition at line 342 of file adc_common_v2.c.
References ADC1, ADC_CCR, and ADC_CCR_TSEN.
void adc_enable_vrefint | ( | void | ) |
Enable the internal voltage reference (only) The channel this is available on is unfortunately not consistent, even though the bit used to enable it is.
FIXME - on f3, you can actually have it on ADC34 as well!
Definition at line 363 of file adc_common_v2.c.
References ADC1, ADC_CCR, and ADC_CCR_VREFEN.
bool adc_eoc | ( | uint32_t | adc | ) |
ADC Read the End-of-Conversion Flag.
This flag is set by hardware at the end of each regular conversion of a channel when a new data is available in the ADCx_DR register.
[in] | adc | Unsigned int32. ADC block register address base ADC register base addresses |
Definition at line 49 of file adc_common_v2.c.
References ADC_ISR, and ADC_ISR_EOC.
bool adc_eoc_injected | ( | uint32_t | adc | ) |
ADC Read the End-of-Conversion Flag for Injected Conversion.
This flag is set by hardware at the end of each injected conversion of a channel when a new data is available in the corresponding ADCx_JDRy register.
[in] | adc | Unsigned int32. ADC block register address base ADC register base addresses |
Definition at line 491 of file adc.c.
References ADC_ISR, and ADC_ISR_JEOC.
bool adc_eos | ( | uint32_t | adc | ) |
ADC Read the End-of-Sequence Flag for Regular Conversions.
This flag is set after all channels of an regular group have been converted.
[in] | adc | Unsigned int32. ADC block register address base ADC register base addresses |
Definition at line 63 of file adc_common_v2.c.
References ADC_ISR, and ADC_ISR_EOS.
bool adc_eos_injected | ( | uint32_t | adc | ) |
ADC Read the End-of-Sequence Flag for Injected Conversions.
This flag is set after all channels of an injected group have been converted.
[in] | adc | Unsigned int32. ADC block register address base ADC register base addresses |
Definition at line 506 of file adc.c.
References ADC_ISR, and ADC_ISR_JEOS.
bool adc_get_overrun_flag | ( | uint32_t | adc | ) |
ADC Read the Overrun Flag.
The overrun flag is set when data is not read from a result register before the next conversion is written. If DMA is enabled, all transfers are terminated and any conversion sequence is aborted.
[in] | adc | Unsigned int32. ADC base address (ADC register base addresses) |
Definition at line 285 of file adc_common_v2.c.
References ADC_ISR, and ADC_ISR_OVR.
bool adc_is_calibrating | ( | uint32_t | adc | ) |
Is the ADC Calibrating?
adc | ADC Block register address base ADC register base addresses |
Definition at line 166 of file adc_common_v2.c.
References ADC_CR, and ADC_CR_ADCAL.
Referenced by adc_calibrate().
bool adc_is_power_off | ( | uint32_t | adc | ) |
Is the ADC powered down?
adc | ADC Block register address base ADC register base addresses |
Definition at line 132 of file adc_common_v2.c.
References ADC_CR, and ADC_CR_ADEN.
Referenced by adc_power_off(), and adc_power_off_async().
bool adc_is_power_on | ( | uint32_t | adc | ) |
Is the ADC powered up and ready?
adc | ADC Block register address base ADC register base addresses |
Definition at line 84 of file adc_common_v2.c.
References ADC_ISR, and ADC_ISR_ADRDY.
Referenced by adc_power_on().
void adc_power_off | ( | uint32_t | adc | ) |
Turn off the ADC This will actually block if it needs to turn off a currently running conversion, as per ref man.
adc | ADC Block register address base ADC register base addresses |
Definition at line 144 of file adc_common_v2.c.
References adc_is_power_off(), and adc_power_off_async().
void adc_power_off_async | ( | uint32_t | adc | ) |
Turn off the ADC (async) This will actually block if it needs to turn off a currently running conversion, as per ref man.
(Handles injected on hardware that supports injected conversions.
adc | ADC Block register address base ADC register base addresses |
Definition at line 108 of file adc_common_v2.c.
References ADC_CR, ADC_CR_ADDIS, ADC_CR_ADSTART, ADC_CR_ADSTP, ADC_CR_JADSTART, ADC_CR_JADSTP, and adc_is_power_off().
Referenced by adc_power_off().
void adc_power_on | ( | uint32_t | adc | ) |
Turn on the ADC.
adc | ADC Block register address base ADC register base addresses |
Definition at line 94 of file adc_common_v2.c.
References adc_is_power_on(), and adc_power_on_async().
void adc_power_on_async | ( | uint32_t | adc | ) |
Turn on the ADC (async)
adc | ADC Block register address base ADC register base addresses |
Definition at line 73 of file adc_common_v2.c.
References ADC_CR, and ADC_CR_ADEN.
Referenced by adc_power_on().
uint32_t adc_read_injected | ( | uint32_t | adc, |
uint8_t | reg | ||
) |
ADC Read from an Injected Conversion Result Register.
The result read back from the selected injected result register (one of four) is 12 bits, right or left aligned within the first 16 bits. The result can have a negative value if the injected channel offset has been set
[in] | adc | Unsigned int32. ADC block register address base ADC register base addresses |
[in] | reg | Unsigned int8. Register number (1 ... 4). |
uint32_t adc_read_regular | ( | uint32_t | adc | ) |
ADC Read from the Regular Conversion Result Register.
The result read back is 12 bits, right or left aligned within the first 16 bits.
[in] | adc | Unsigned int32. ADC block register address base ADC register base addresses |
Definition at line 331 of file adc_common_v2.c.
References ADC_DR.
void adc_set_clk_prescale | ( | uint32_t | adc, |
uint32_t | prescale | ||
) |
ADC Set Clock Prescale.
The ADC clock taken from the APB2 clock can be scaled down by 2, 4, 6 or 8.
adc | peripheral of choice ADC register base addresses | |
[in] | prescale | Unsigned int32. Prescale value for ADC Clock adc_ccr_adcpre |
Definition at line 585 of file adc.c.
References ADC_CCR.
void adc_set_continuous_conversion_mode | ( | uint32_t | adc | ) |
Enable Continuous Conversion Mode In this mode the ADC starts a new conversion of a single channel or a channel group immediately following completion of the previous channel group conversion.
[in] | adc | ADC block register address base ADC register base addresses |
Definition at line 189 of file adc_common_v2.c.
References ADC_CFGR1, and ADC_CFGR1_CONT.
void adc_set_injected_offset | ( | uint32_t | adc, |
uint8_t | reg, | ||
uint32_t | offset | ||
) |
ADC Set the Injected Channel Data Offset.
This value is subtracted from the injected channel results after conversion is complete, and can result in negative results. A separate value can be specified for each injected data register.
[in] | adc | Unsigned int32. ADC block register address base ADC register base addresses |
[in] | reg | Unsigned int8. Register number (1 ... 4). |
[in] | offset | Unsigned int32. |
Definition at line 554 of file adc.c.
References ADC_OFR1, ADC_OFR1_OFFSET1_EN, ADC_OFR2, ADC_OFR2_OFFSET2_EN, ADC_OFR3, ADC_OFR3_OFFSET3_EN, ADC_OFR4, and ADC_OFR4_OFFSET4_EN.
void adc_set_injected_sequence | ( | uint32_t | adc, |
uint8_t | length, | ||
uint8_t | channel[] | ||
) |
ADC Set an Injected Channel Conversion Sequence.
Defines a sequence of channels to be converted as an injected group with a length from 1 to 4 channels. If this is called during conversion, the current conversion is reset and conversion begins again with the newly defined group.
[in] | adc | Unsigned int32. ADC block register address base ADC register base addresses |
[in] | length | Unsigned int8. Number of channels in the group. |
[in] | channel | Unsigned int8[]. Set of channels in sequence, integers 0..18 |
Definition at line 461 of file adc.c.
References ADC_JSQR, ADC_JSQR_JL_VAL, and ADC_JSQR_JSQ_VAL.
void adc_set_left_aligned | ( | uint32_t | adc | ) |
ADC Set the Data as Left Aligned.
[in] | adc | Unsigned int32. ADC base address (ADC register base addresses) |
Definition at line 223 of file adc_common_v2.c.
References ADC_CFGR1, and ADC_CFGR1_ALIGN.
void adc_set_multi_mode | ( | uint32_t | adc, |
uint32_t | mode | ||
) |
ADC set multi mode.
The multiple mode can uses these arrangement:
This setting is applied to ADC master only (ADC1 or ADC3).
The various modes possible are described in the reference manual.
adc | peripheral of choice ADC register base addresses | |
[in] | mode | Multiple mode selection from ADC Multi mode selection |
Definition at line 605 of file adc.c.
References ADC_CCR, ADC_CCR_DUAL_MASK, and ADC_CCR_DUAL_SHIFT.
void adc_set_regular_sequence | ( | uint32_t | adc, |
uint8_t | length, | ||
uint8_t | channel[] | ||
) |
ADC Set a Regular Channel Conversion Sequence.
Define a sequence of channels to be converted as a regular group with a length from 1 to 16 channels. If this is called during conversion, the current conversion is reset and conversion begins again with the newly defined group.
[in] | adc | ADC block register address base ADC register base addresses |
[in] | length | Number of channels in the group, range 0..16 |
[in] | channel | Set of channels in sequence, range ADC Channel Numbers |
Definition at line 100 of file adc_common_v2_multi.c.
References ADC_SQR1, ADC_SQR1_L_SHIFT, ADC_SQR2, ADC_SQR3, and ADC_SQR4.
void adc_set_resolution | ( | uint32_t | adc, |
uint16_t | resolution | ||
) |
ADC Set Resolution.
ADC Resolution can be reduced from 12 bits to 10, 8 or 6 bits for a corresponding reduction in conversion time.
[in] | adc | Unsigned int32. ADC base address (ADC register base addresses) |
[in] | resolution | Unsigned int16. Resolution value (adc_api_res) |
Definition at line 214 of file adc_common_v2.c.
References ADC_CFGR1.
void adc_set_right_aligned | ( | uint32_t | adc | ) |
ADC Set the Data as Right Aligned.
[in] | adc | Unsigned int32. ADC base address (ADC register base addresses) |
Definition at line 232 of file adc_common_v2.c.
References ADC_CFGR1.
void adc_set_sample_time | ( | uint32_t | adc, |
uint8_t | channel, | ||
uint8_t | time | ||
) |
ADC Set the Sample Time for a Single Channel.
The sampling time can be selected in ADC clock cycles, exact values depend on the device.
[in] | adc | ADC block register address base ADC register base addresses |
[in] | channel | ADC Channel integer ADC Channel Numbers |
[in] | time | Sampling time selection from ADC Sample Time Selection values |
Definition at line 47 of file adc_common_v2_multi.c.
void adc_set_sample_time_on_all_channels | ( | uint32_t | adc, |
uint8_t | time | ||
) |
ADC Set the Sample Time for All Channels.
The sampling time can be selected in ADC clock cycles, exact values depend on the device.
[in] | adc | ADC block register address base ADC register base addresses |
[in] | time | Sampling time selection from ADC Sample Time Selection values |
Definition at line 72 of file adc_common_v2_multi.c.
void adc_set_single_conversion_mode | ( | uint32_t | adc | ) |
Enable Single Conversion Mode In this mode the ADC performs a conversion of one channel or a channel group and stops.
[in] | adc | ADC block register address base ADC register base addresses |
Definition at line 201 of file adc_common_v2.c.
References ADC_CFGR1.
void adc_set_watchdog_high_threshold | ( | uint32_t | adc, |
uint16_t | threshold | ||
) |
void adc_set_watchdog_low_threshold | ( | uint32_t | adc, |
uint16_t | threshold | ||
) |
void adc_start_conversion_injected | ( | uint32_t | adc | ) |
ADC Software Triggered Conversion on Injected Channels.
This starts conversion on a set of defined injected channels. Depending on the configuration bits JEXTEN, a conversion will start immediately (software trigger configuration) or once an injected hardware trigger event occurs (hardware trigger configuration).
[in] | adc | Unsigned int32. ADC block register address base ADC register base addresses |
Definition at line 404 of file adc.c.
References ADC_CR, and ADC_CR_JADSTART.
void adc_start_conversion_regular | ( | uint32_t | adc | ) |
ADC Software Triggered Conversion on Regular Channels.
This starts conversion on a set of defined regular channels. Depending on the configuration bits EXTEN, a conversion will start immediately (software trigger configuration) or once a regular hardware trigger event occurs (hardware trigger configuration)
[in] | adc | ADC block register address base ADC register base addresses |
Definition at line 386 of file adc_common_v2.c.
References ADC_CR, and ADC_CR_ADSTART.