analog inputs library for multi-channel DMA running in interrupt mode, averaging and custom linearization functions
More...
Go to the source code of this file.
|
uint32_t | ADC_data_buffer [(AI_NONE *2)+1] |
|
analog inputs library for multi-channel DMA running in interrupt mode, averaging and custom linearization functions
- Author
- panvicka
- Date
- 8.1.2022
To use this library define flag LIB_AI in the lib_config.h file and create an enum in init.h file with the outputs you would like to use. You then have to initialize each input with input_init function.
MY_ANALOG_INPUT_1,
MY_ANALOG_INPUT_2,
MY_ANALOG_INPUT_3,
AI_NONE
anaInputs
Definition: ai.h:34
- Note
- Do not forget to include the AI_NONE at the end of the enum listing.
◆ anaInputs
If the library is not used (LIB_AI is not defined as symbol) this dummy enum will be created to prevent compilation errors
◆ anaInputs
If the library is not used (LIB_AI is not defined as symbol) this dummy enum will be created to prevent compilation errors
Enumerator |
---|
AI_1 | AI_1 (PA1)
|
AI_2 | AI_2 (PA2)
|
◆ analog_input_get()
retStatus analog_input_get |
( |
uint16_t |
analog_input, |
|
|
uint16_t |
data, |
|
|
int32_t * |
value |
|
) |
| |
Standardized getter function for digital input library.
- Parameters
-
[in] | analog_input | analog input identification, defined by anaInputs |
[in] | data | data for /p analog_input that can be read out of the module, available data aioData |
[out] | value | getter output |
- Note
- /p input and /p data types are changed to
uint32_t
and uint16_t
to keep the standard function prototype
- Returns
- EOK is the /p value is valid ENODEV if the /p an_input_name is out of range defined by anaInputs or not initialized EINVAL if invalid /p data is read
◆ analog_input_handle()
void analog_input_handle |
( |
void |
| ) |
|
Handler for analog inputs.
- Note
- call inside
HAL_ADC_ConvCpltCallback()
(from the HAL library)
◆ analog_input_init()
retStatus analog_input_init |
( |
anaInputs |
an_input_name, |
|
|
int32_t |
sample_from, |
|
|
liner_fce |
linearization_function |
|
) |
| |
Analog input initialization function.
- Parameters
-
[in] | an_input_name | analog input identification, defined by anaInputs |
[in] | sample_from | how many samples should be averaged (0-0x7fff) |
[in] | linearization_function | in case there is an voltage divider or any other input that needs to be converted |
- Note
- if a simple 0-3.3V input without non-linearities is expected, you can use lin_adc_no_scaling_no_corrections()
- Returns
- EOK is the initialization completed OK ENODEV if the /p an_input_name is out of range defined by anaInputs EFAULT null pointer passed to /p linearization_function
◆ analog_input_start()
__weak HAL_StatusTypeDef analog_input_start |
( |
ADC_HandleTypeDef |
adc | ) |
|
Starts the ADC with DMA in interrupt mode using STM32 HAL.
- Parameters
-
- Returns
- HAL status