embedded-software
reusable software modules for embedded systems
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
ADC Module

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...
 

Detailed Description

Here is my description of what this module does and how to use it.

Macro Definition Documentation

#define ADC_MAX_CHANNELS   8

Maximum number of concurrent channels

Typedef Documentation

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);

Author
Page

Function Documentation

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

Parameters
channelADC channel index base 0
periodPeriod between measurements in milliseconds
callbackCallback when measurements are complete. Can be void Function(uint16_t value) or void Function(uint16_t value, void * ptr)
ptrOptional pointer to be passed to the callback function

Here is the call graph for this function:

void ADC_Init ( void  )

Initialize the ADC module.

This is the longer description which uses more words to say initializes the ADC module.

Author
Muhlbaier
Version
0.0

Here is the call graph for this function:

void ADC_ProcessMeasurementFromISR ( uint16_t  value)

Function to be called from the ADC interrupt in hal_adc.c with the measurement

Parameters
valuethe ADC measurement

Here is the call graph for this function:

Here is the caller graph for this function:

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.

Here is the caller graph for this function:

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.

Here is the caller graph for this function: