rcc 1.0
RCC - RGB LED Color Cube Documentation
Loading...
Searching...
No Matches
battery.c File Reference

Battery monitoring functions for AVR microcontrollers. More...

#include "battery.h"
Include dependency graph for battery.c:

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.

Detailed Description

Battery monitoring functions for AVR microcontrollers.

This source file implements the battery monitoring interface using ADC measurements. It provides functions to initialize the ADC for battery voltage measurement and to check the battery status against a predefined empty voltage threshold.

Author
g.raf
Date
2025-09-18
Version
1.0 Release
Note
This file is part of a larger embedded systems project and subject to the license specified in the repository. For updates and the complete revision history, see the GitHub repository.
See also
https://github.com/0x007e/rcc "AVR ATmega GitHub Repository"

Function Documentation

◆ battery_disable()

void battery_disable ( void )
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.

Note
Ensure that no battery measurement is required before calling this function, as it will disable all ADC functionality until reinitialized.
See also
adc_disable() for generic ADC disable function.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ battery_init()

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.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ battery_status()

BATTERY_Status battery_status ( void )

Check the current battery status.

Returns
Returns BATTERY_Ok if the battery voltage is above the configured minimum threshold, otherwise returns BATTERY_Fault.

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.

Here is the call graph for this function:
Here is the caller graph for this function: