rcc 1.0
RCC - RGB LED Color Cube Documentation
|
Battery monitoring interface for AVR microcontrollers. More...
Go to the source code of this file.
Macros | |
#define | BATTERY_CHANNEL ADC_CH6 |
Specifies the ADC channel used for battery voltage measurement. | |
#define | BATTERY_EMPTY_VALUE 990UL |
ADC threshold value indicating an empty or critically low battery. |
Typedefs | |
typedef enum BATTERY_Status_t | BATTERY_Status |
Alias for enum BATTERY_Status_t to represent battery status codes. |
Enumerations | |
enum | BATTERY_Status_t { BATTERY_Ok =0 , BATTERY_Fault } |
Represents the status of the battery voltage measurement. More... |
Functions | |
void | battery_init (void) |
Initialize the battery measurement interface. | |
void | battery_disable (void) |
Disable battery voltage measurement. | |
BATTERY_Status | battery_status (void) |
Check the current battery status. |
Battery monitoring interface for AVR microcontrollers.
This header file defines the interface for battery status monitoring using an ADC channel. It provides macros to configure ADC channel and battery empty threshold, a status enumeration, and function prototypes to initialize battery measurement and retrieve battery status.
#define BATTERY_CHANNEL ADC_CH6 |
Specifies the ADC channel used for battery voltage measurement.
This macro defines the ADC channel number used to measure the battery voltage. By default, it is set to ADC_CH6. Override this macro before including the battery module to use a different ADC channel if your hardware configuration requires it.
#define BATTERY_EMPTY_VALUE 990UL |
ADC threshold value indicating an empty or critically low battery.
This macro defines the ADC reading value below which the battery is considered empty or in fault condition. Override this macro before including the battery module to adjust the threshold value if your hardware or battery specifications differ.
typedef enum BATTERY_Status_t BATTERY_Status |
Alias for enum BATTERY_Status_t to represent battery status codes.
enum BATTERY_Status_t |
Represents the status of the battery voltage measurement.
This enumeration defines possible statuses indicating the state of the battery based on the analog-to-digital converter (ADC) measurement.
Values include:
Enumerator | |
---|---|
BATTERY_Ok | |
BATTERY_Fault |
|
inline |
Disable battery voltage measurement.
This inline function disables the ADC hardware module used for battery voltage measurement. Calling this function reduces power consumption by shutting down the ADC when battery monitoring is not needed.
void battery_init | ( | void | ) |
Initialize the battery measurement interface.
This function initializes the ADC module and configures the ADC channel used for battery voltage measurement as defined by the BATTERY_CHANNEL macro. Must be called before reading battery status to ensure proper ADC setup.
BATTERY_Status battery_status | ( | void | ) |
Check the current battery status.
This function reads the battery voltage using the ADC and compares the value against the BATTERY_EMPTY_VALUE threshold to determine if the battery is considered empty or faulty.