Analog-to-Digital Converter (ADC) interface for hardware platforms. More...
|
Data Structures | |
| struct | hw_adc_t |
| ADC channel. More... | |
Typedefs | |
| typedef struct hw_adc_t | hw_adc_t |
| ADC channel. | |
Functions | |
| uint8_t | hw_adc_count (void) |
| Get the total number of available ADC channels. More... | |
| hw_adc_t | hw_adc_init_pin (uint8_t pin) |
| Initialize an ADC interface for a specific pin. More... | |
| hw_adc_t | hw_adc_init_temperature () |
| Initialize an ADC interface on which the temperature sensor is connected. More... | |
| void | hw_adc_finalize (hw_adc_t *adc) |
| Finalize and release an ADC interface. More... | |
| uint8_t | hw_adc_gpio_channel (uint8_t gpio) |
| Get the ADC channel number for a specific GPIO pin. More... | |
| static bool | hw_adc_valid (hw_adc_t *adc) |
| Check if an ADC handle is valid and usable. More... | |
| uint16_t | hw_adc_read (hw_adc_t *adc) |
| Read the current value from an ADC channel. More... | |
| float | hw_adc_read_voltage (hw_adc_t *adc) |
| Read the current value from an ADC channel as a voltage. More... | |
| float | hw_adc_read_temperature (hw_adc_t *adc) |
| Read the current value from an ADC channel as a temperature. More... | |
Analog-to-Digital Converter (ADC) interface for hardware platforms.
This module provides functions to initialize and read from ADC peripherals.
| uint8_t hw_adc_count | ( | void | ) |
Get the total number of available ADC channels.
Returns the number of logical ADC channels that can be used in the system. These are usually numbered from 0 to hw_adc_count() - 1. If zero is returned, it indicates that ADC functionality is not available.
| void hw_adc_finalize | ( | hw_adc_t * | adc | ) |
Finalize and release an ADC interface.
| adc | Pointer to the ADC structure to finalize. |
This function releases the ADC interface and frees any associated resources. After calling this function, the ADC interface should not be used for further operations.
| uint8_t hw_adc_gpio_channel | ( | uint8_t | gpio | ) |
| hw_adc_t hw_adc_init_pin | ( | uint8_t | pin | ) |
Initialize an ADC interface for a specific pin.
This function initializes the ADC interface for a specific channel and pin, allowing for flexible configuration of the ADC hardware.
| hw_adc_t hw_adc_init_temperature | ( | ) |
Initialize an ADC interface on which the temperature sensor is connected.
This function initializes the ADC interface which is used for measuring the temperature sensor.
| uint16_t hw_adc_read | ( | hw_adc_t * | adc | ) |
Read the current value from an ADC channel.
| adc | Pointer to the ADC structure. |
This function reads the current value from the specified ADC channel and returns the raw digital value corresponding to the analog input voltage.
| float hw_adc_read_temperature | ( | hw_adc_t * | adc | ) |
Read the current value from an ADC channel as a temperature.
| adc | Pointer to the ADC structure configured for temperature sensing. |
This function reads the current value from an ADC channel that is connected to a temperature sensor and converts the reading to a temperature value. This function is typically used with the ADC channel initialized by hw_adc_init_temperature().
| float hw_adc_read_voltage | ( | hw_adc_t * | adc | ) |
Read the current value from an ADC channel as a voltage.
| adc | Pointer to the ADC structure. |
This function reads the current value from the specified ADC channel and converts the raw digital value to a voltage measurement.
The conversion is based on the reference voltage of the ADC (typically 3.3V for most microcontrollers), except for the battery voltage pin which uses a voltage divider to scale the input.