libopencm3
A free/libre/open-source firmware library for various ARM Cortex-M3 microcontrollers.
adc_common_v1.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define ADC1   ADC1_BASE
 
#define ADC_SR(block)   MMIO32((block) + 0x00)
 
#define ADC_CR1(block)   MMIO32((block) + 0x04)
 
#define ADC_CR2(block)   MMIO32((block) + 0x08)
 
#define ADC_SMPR1(block)   MMIO32((block) + 0x0c)
 
#define ADC_SMPR2(block)   MMIO32((block) + 0x10)
 
#define ADC1_SR   ADC_SR(ADC1)
 
#define ADC1_CR1   ADC_CR1(ADC1)
 
#define ADC1_CR2   ADC_CR2(ADC1)
 
#define ADC1_SMPR1   ADC_SMPR1(ADC1)
 
#define ADC1_SMPR2   ADC_SMPR2(ADC1)
 
#define ADC1_JOFR1   ADC_JOFR1(ADC1)
 
#define ADC1_JOFR2   ADC_JOFR2(ADC1)
 
#define ADC1_JOFR3   ADC_JOFR3(ADC1)
 
#define ADC1_JOFR4   ADC_JOFR4(ADC1)
 
#define ADC1_HTR   ADC_HTR(ADC1)
 
#define ADC1_LTR   ADC_LTR(ADC1)
 
#define ADC1_SQR1   ADC_SQR1(ADC1)
 
#define ADC1_SQR2   ADC_SQR2(ADC1)
 
#define ADC1_SQR3   ADC_SQR3(ADC1)
 
#define ADC1_JSQR   ADC_JSQR(ADC1)
 
#define ADC1_JDR1   ADC_JDR1(ADC1)
 
#define ADC1_JDR2   ADC_JDR2(ADC1)
 
#define ADC1_JDR3   ADC_JDR3(ADC1)
 
#define ADC1_JDR4   ADC_JDR4(ADC1)
 
#define ADC1_DR   ADC_DR(ADC1)
 
#define ADC_CHANNEL0   0x00
 
#define ADC_CHANNEL1   0x01
 
#define ADC_CHANNEL2   0x02
 
#define ADC_CHANNEL3   0x03
 
#define ADC_CHANNEL4   0x04
 
#define ADC_CHANNEL5   0x05
 
#define ADC_CHANNEL6   0x06
 
#define ADC_CHANNEL7   0x07
 
#define ADC_CHANNEL8   0x08
 
#define ADC_CHANNEL9   0x09
 
#define ADC_CHANNEL10   0x0A
 
#define ADC_CHANNEL11   0x0B
 
#define ADC_CHANNEL12   0x0C
 
#define ADC_CHANNEL13   0x0D
 
#define ADC_CHANNEL14   0x0E
 
#define ADC_CHANNEL15   0x0F
 
#define ADC_CHANNEL16   0x10
 
#define ADC_CHANNEL17   0x11
 
#define ADC_CHANNEL18   0x12
 
#define ADC_CHANNEL_MASK   0x1F
 
#define ADC_SR_STRT   (1 << 4)
 Regular channel Start flag. More...
 
#define ADC_SR_JSTRT   (1 << 3)
 Injected channel Start flag. More...
 
#define ADC_SR_JEOC   (1 << 2)
 Injected channel end of conversion. More...
 
#define ADC_SR_EOC   (1 << 1)
 End of conversion. More...
 
#define ADC_SR_AWD   (1 << 0)
 Analog watchdog flag. More...
 
#define ADC_CR1_AWDEN   (1 << 23)
 
#define ADC_CR1_JAWDEN   (1 << 22)
 
#define ADC_CR1_DISCNUM_1CHANNELS   (0x0 << 13)
 
#define ADC_CR1_DISCNUM_2CHANNELS   (0x1 << 13)
 
#define ADC_CR1_DISCNUM_3CHANNELS   (0x2 << 13)
 
#define ADC_CR1_DISCNUM_4CHANNELS   (0x3 << 13)
 
#define ADC_CR1_DISCNUM_5CHANNELS   (0x4 << 13)
 
#define ADC_CR1_DISCNUM_6CHANNELS   (0x5 << 13)
 
#define ADC_CR1_DISCNUM_7CHANNELS   (0x6 << 13)
 
#define ADC_CR1_DISCNUM_8CHANNELS   (0x7 << 13)
 
#define ADC_CR1_DISCNUM_MASK   (0x7 << 13)
 
#define ADC_CR1_DISCNUM_SHIFT   13
 
#define ADC_CR1_JDISCEN   (1 << 12)
 Discontinuous mode on injected channels. More...
 
#define ADC_CR1_DISCEN   (1 << 11)
 Discontinuous mode on regular channels. More...
 
#define ADC_CR1_JAUTO   (1 << 10)
 Automatic Injection Group conversion. More...
 
#define ADC_CR1_AWDSGL   (1 << 9)
 Enable the watchdog on a single channel in scan mode. More...
 
#define ADC_CR1_SCAN   (1 << 8)
 Scan mode. More...
 
#define ADC_CR1_JEOCIE   (1 << 7)
 Interrupt enable for injected channels. More...
 
#define ADC_CR1_AWDIE   (1 << 6)
 Analog watchdog interrupt enable. More...
 
#define ADC_CR1_EOCIE   (1 << 5)
 Interrupt enable EOC. More...
 
#define ADC_CR1_AWDCH_CHANNEL0   (0x00 << 0)
 
#define ADC_CR1_AWDCH_CHANNEL1   (0x01 << 0)
 
#define ADC_CR1_AWDCH_CHANNEL2   (0x02 << 0)
 
#define ADC_CR1_AWDCH_CHANNEL3   (0x03 << 0)
 
#define ADC_CR1_AWDCH_CHANNEL4   (0x04 << 0)
 
#define ADC_CR1_AWDCH_CHANNEL5   (0x05 << 0)
 
#define ADC_CR1_AWDCH_CHANNEL6   (0x06 << 0)
 
#define ADC_CR1_AWDCH_CHANNEL7   (0x07 << 0)
 
#define ADC_CR1_AWDCH_CHANNEL8   (0x08 << 0)
 
#define ADC_CR1_AWDCH_CHANNEL9   (0x09 << 0)
 
#define ADC_CR1_AWDCH_CHANNEL10   (0x0A << 0)
 
#define ADC_CR1_AWDCH_CHANNEL11   (0x0B << 0)
 
#define ADC_CR1_AWDCH_CHANNEL12   (0x0C << 0)
 
#define ADC_CR1_AWDCH_CHANNEL13   (0x0D << 0)
 
#define ADC_CR1_AWDCH_CHANNEL14   (0x0E << 0)
 
#define ADC_CR1_AWDCH_CHANNEL15   (0x0F << 0)
 
#define ADC_CR1_AWDCH_CHANNEL16   (0x10 << 0)
 
#define ADC_CR1_AWDCH_CHANNEL17   (0x11 << 0)
 
#define ADC_CR1_AWDCH_MASK   (0x1F << 0)
 
#define ADC_CR1_AWDCH_SHIFT   0
 
#define ADC_CR2_ALIGN_RIGHT   (0 << 11)
 
#define ADC_CR2_ALIGN_LEFT   (1 << 11)
 
#define ADC_CR2_ALIGN   (1 << 11)
 
#define ADC_CR2_DMA   (1 << 8)
 
#define ADC_CR2_CONT   (1 << 1)
 
#define ADC_CR2_ADON   (1 << 0)
 
#define ADC_JOFFSET_LSB   0
 
#define ADC_JOFFSET_MSK   0xfff
 
#define ADC_HT_LSB   0
 
#define ADC_HT_MSK   0xfff
 
#define ADC_LT_LSB   0
 
#define ADC_LT_MSK   0xfff
 
#define ADC_SQR1_L_LSB   20
 
#define ADC_JSQR_JL_LSB   20
 
#define ADC_JSQR_JSQ4_LSB   15
 
#define ADC_JSQR_JSQ3_LSB   10
 
#define ADC_JSQR_JSQ2_LSB   5
 
#define ADC_JSQR_JSQ1_LSB   0
 
#define ADC_JSQR_JL_1CHANNELS   (0x0 << ADC_JSQR_JL_LSB)
 
#define ADC_JSQR_JL_2CHANNELS   (0x1 << ADC_JSQR_JL_LSB)
 
#define ADC_JSQR_JL_3CHANNELS   (0x2 << ADC_JSQR_JL_LSB)
 
#define ADC_JSQR_JL_4CHANNELS   (0x3 << ADC_JSQR_JL_LSB)
 
#define ADC_JSQR_JL_MSK   (0x2 << ADC_JSQR_JL_LSB)
 
#define ADC_JSQR_JSQ4_MSK   (0x1f << ADC_JSQR_JSQ4_LSB)
 
#define ADC_JSQR_JSQ3_MSK   (0x1f << ADC_JSQR_JSQ3_LSB)
 
#define ADC_JSQR_JSQ2_MSK   (0x1f << ADC_JSQR_JSQ2_LSB)
 
#define ADC_JSQR_JSQ1_MSK   (0x1f << ADC_JSQR_JSQ1_LSB)
 
#define ADC_JSQR_JSQ_VAL(n, val)   ((val) << (((n) - 1) * 5))
 
#define ADC_JSQR_JL_VAL(val)   (((val) - 1) << ADC_JSQR_JL_LSB)
 

Functions

void adc_power_on (uint32_t adc)
 ADC Power On. More...
 
void adc_power_off (uint32_t adc)
 ADC Off. More...
 
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 Disable 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_scan_mode (uint32_t adc)
 ADC Set Scan Mode. More...
 
void adc_disable_scan_mode (uint32_t adc)
 ADC Disable Scan Mode. 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_awd_interrupt (uint32_t adc)
 ADC Enable Analog Watchdog Interrupt. More...
 
void adc_disable_awd_interrupt (uint32_t adc)
 ADC Disable Analog Watchdog Interrupt. 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...
 
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...
 
bool adc_eoc (uint32_t adc)
 ADC Read the End-of-Conversion Flag. More...
 
bool adc_eoc_injected (uint32_t adc)
 ADC Read the End-of-Conversion Flag for Injected Conversion. More...
 
uint32_t adc_read_regular (uint32_t adc)
 ADC Read from the Regular Conversion Result Register. More...
 
uint32_t adc_read_injected (uint32_t adc, uint8_t reg)
 ADC Read from an Injected Conversion Result Register. More...
 
void adc_set_continuous_conversion_mode (uint32_t adc)
 ADC Enable Continuous Conversion Mode. More...
 
void adc_set_single_conversion_mode (uint32_t adc)
 ADC Enable Single Conversion Mode. More...
 
void adc_set_regular_sequence (uint32_t adc, uint8_t length, uint8_t channel[])
 ADC Set a Regular Channel Conversion Sequence. More...
 
void adc_set_injected_sequence (uint32_t adc, uint8_t length, uint8_t channel[])
 ADC Set an Injected Channel Conversion Sequence. 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_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_start_conversion_regular (uint32_t adc)
 ADC Software Triggered Conversion on Regular Channels. More...
 
void adc_start_conversion_injected (uint32_t adc)
 ADC Software Triggered Conversion on Injected Channels. 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...
 
bool adc_get_flag (uint32_t adc, uint32_t flag)
 Read a Status Flag. More...
 
void adc_clear_flag (uint32_t adc, uint32_t flag)
 Clear a Status Flag. 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_disable_external_trigger_regular (uint32_t adc)
 ADC Disable an External Trigger for Regular Channels. More...
 
void adc_disable_external_trigger_injected (uint32_t adc)
 ADC Disable an External Trigger for Injected Channels. More...