embedded-software
reusable software modules for embedded systems
|
Macros | |
#define | ADC_MAX_CHANNELS 8 |
Typedefs | |
typedef void(* | callback_input_t )(uint16_t, void *) |
helpful typedef for adc callback with input More... | |
Functions | |
void | ADC_Init (void) |
Initialize the ADC module. More... | |
void | ADC_AddChannel (uint8_t channel, uint16_t period, void(*callback)(uint16_t, void *), void *ptr) |
add a channel to the list of channels to measure, a period at which to measure it, and a callback More... | |
void | ADC_ProcessMeasurementFromISR (uint16_t value) |
void | hal_ADC_Init (void) |
hardware abstaction layer ADC initialization More... | |
void | hal_ADC_StartChannel (uint8_t channel) |
hardware abstaction layer start ADC measurement for a channel More... | |
Here is my description of what this module does and how to use it.
#define ADC_MAX_CHANNELS 8 |
Maximum number of concurrent channels
typedef void(* callback_input_t)(uint16_t, void *) |
helpful typedef for adc callback with input
To be used with the function ADC_AddChannel for callbacks that do not match the form void(*callback)(uint16_t, void *) to avoid compiler error/warning.
For example an ADC channel with the following callback: void callback (uint16_t value);
Would added as: ADC_AddChannel(channel, period, (callback_input_t)callback, 0);
void ADC_AddChannel | ( | uint8_t | channel, |
uint16_t | period, | ||
void(*)(uint16_t, void *) | callback, | ||
void * | ptr | ||
) |
add a channel to the list of channels to measure, a period at which to measure it, and a callback
channel | ADC channel index base 0 |
period | Period between measurements in milliseconds |
callback | Callback when measurements are complete. Can be void Function(uint16_t value) or void Function(uint16_t value, void * ptr) |
ptr | Optional pointer to be passed to the callback function |
void ADC_Init | ( | void | ) |
Initialize the ADC module.
This is the longer description which uses more words to say initializes the ADC module.
void ADC_ProcessMeasurementFromISR | ( | uint16_t | value | ) |
Function to be called from the ADC interrupt in hal_adc.c with the measurement
value | the ADC measurement |
void hal_ADC_Init | ( | void | ) |
hardware abstaction layer ADC initialization
Must be implemented for each MCU in hal_adc.c and configure the ADC for single measurements with interrupts enabled after completion of measurements.
void hal_ADC_StartChannel | ( | uint8_t | channel | ) |
hardware abstaction layer start ADC measurement for a channel
Must be implemented for each MCU in hal_adc.c and setup the ADC to sample the given channel, automatically start the conversion, and interrupt when the conversion is complete. A interrupt service routine also needs to be added to hal_adc.c which calls ADC_ProcessMeasurementFromISR() with the measured value.