microHAL
An abstraction layer for your future F4xx projects
|
Function prototypes for the ADC driver. More...
Go to the source code of this file.
Data Structures | |
struct | ADCRegs |
Contains ADC registers. More... | |
struct | ADCCommonRegs |
Contains ADC common registers. More... | |
struct | ADCModes |
Contains ADC conversion modes. More... | |
Macros | |
#define | ADC_(NUM) |
#define | ADC_COMMON (struct ADCCommonRegs *)(ADC123_COMMON_BASE) |
Typedefs | |
typedef enum adc_peripheral | adc_peripheral_t |
Available ADC peripherals. | |
typedef enum adc_res | adc_res_t |
Available ADC resolutions. | |
typedef enum adc_trigger | adc_trigger_t |
Available ADC trigger modes. | |
typedef enum adc_samplerate | adc_samplerate_t |
Available ADC samplerates (in cycles) | |
typedef enum adc_prescaler | adc_prescaler_t |
Available ADC prescaler dividers. | |
Enumerations | |
enum | adc_peripheral { ADC_PERIPH_LEN } |
Available ADC peripherals. | |
enum | adc_res { ADC_RES_B12 = 0x00 , ADC_RES_B10 = 0x01 , ADC_RES_B08 = 0x02 , ADC_RES_B06 = 0x03 } |
Available ADC resolutions. | |
enum | adc_trigger { ADC_TRIGGER_NONE = 0x00 , ADC_TRIGGER_RISE = 0x01 , ADC_TRIGGER_FALL = 0x02 , ADC_TRIGGER_BOTH = 0x03 } |
Available ADC trigger modes. | |
enum | adc_samplerate { ADC_SAMPLERATE_C003 = 0x00 , ADC_SAMPLERATE_C015 = 0x01 , ADC_SAMPLERATE_C028 = 0x02 , ADC_SAMPLERATE_C056 = 0x03 , ADC_SAMPLERATE_C084 = 0x04 , ADC_SAMPLERATE_C112 = 0x05 , ADC_SAMPLERATE_C144 = 0x06 , ADC_SAMPLERATE_C480 = 0x07 } |
Available ADC samplerates (in cycles) | |
enum | adc_prescaler { ADC_PRESCALER_DIV2 = 0x00 , ADC_PRESCALER_DIV4 = 0x01 , ADC_PRESCALER_DIV6 = 0x02 , ADC_PRESCALER_DIV8 = 0x03 } |
Available ADC prescaler dividers. | |
Functions | |
void | adc_set_prescaler (const adc_prescaler_t value) |
Sets the ADC Prescaler divider to the specified value. | |
void | adc_set_resolution (const adc_peripheral_t adc, const adc_res_t value) |
Sets the ADC resolution to the specified value. | |
void | adc_set_samplerate (const adc_peripheral_t adc, const uint8_t channel, const adc_samplerate_t value) |
Sets the ADC sampling rate to the specified value. | |
void | adc_set_modes (const adc_peripheral_t adc, const struct ADCModes config) |
Sets the ADC modes according to the configuration. | |
void | adc_set_seq (const adc_peripheral_t adc, const uint8_t *seq, const uint8_t count) |
Sets the ADC conversion sequence to the specified order. | |
void | adc_on (const adc_peripheral_t adc) |
Starts the ADC conversion. | |
void | adc_off (const adc_peripheral_t adc) |
Stops the ADC conversion. | |
uint16_t | adc_read (const adc_peripheral_t adc) |
Reads the last ADC conversion result. | |
Function prototypes for the ADC driver.
This file contains all of the enums, macros, and function prototypes required for a functional ADC driver.
DISCLAIMER: Only for regular channels in single / continuous / discontinuous modes. Injected channels may be implemented later.
#define ADC_ | ( | NUM | ) |
void adc_off | ( | const adc_peripheral_t | adc | ) |
Stops the ADC conversion.
The ADC will be powered off upon calling this command and instantly stop the conversion procedure.
adc | The selected ADC |
void adc_on | ( | const adc_peripheral_t | adc | ) |
Starts the ADC conversion.
The ADC will be powered on upon calling this command and start the conversion procedure as configured. Dummy reads are included.
adc | The selected ADC |
uint16_t adc_read | ( | const adc_peripheral_t | adc | ) |
Reads the last ADC conversion result.
adc | The selected ADC |
void adc_set_modes | ( | const adc_peripheral_t | adc, |
const struct ADCModes | config ) |
Sets the ADC modes according to the configuration.
The configuration values are specified within the adc_config struct. Some modes may not work as expected yet.
adc | The selected ADC |
config | The ADC configuration |
void adc_set_prescaler | ( | const adc_prescaler_t | value | ) |
Sets the ADC Prescaler divider to the specified value.
The available dividers for the ADC Prescaler are specified in the adc_prescaler_t enum. Any other value will be ignored.
value | The prescaler divider value |
void adc_set_resolution | ( | const adc_peripheral_t | adc, |
const adc_res_t | value ) |
Sets the ADC resolution to the specified value.
The available resolutions for the ADC channel reads are specified in the adc_res_t enum. Any other value will be ignored.
adc | The selected ADC |
value | The resolution of the ADC conversions |
void adc_set_samplerate | ( | const adc_peripheral_t | adc, |
const uint8_t | channel, | ||
const adc_samplerate_t | value ) |
Sets the ADC sampling rate to the specified value.
The available sampling rates for the ADC channel reads are specified in the adc_res_t enum (in clock cycles). Any other value will be ignored.
adc | The selected ADC |
channel | The selected channel (0..19) |
value | The clock cycles of the ADC conversions |
void adc_set_seq | ( | const adc_peripheral_t | adc, |
const uint8_t * | seq, | ||
const uint8_t | count ) |
Sets the ADC conversion sequence to the specified order.
The sequence consists of 16 5-bit elements. Bits 6..8 will be ignored.
adc | The selected ADC |
seq | Pointer to channel conversion sequence array |
count | The total amount of conversions |