Functions to meassure battery and reference voltage. More...
#include <avr/io.h>
#include "xtypes.h"
#include "global.h"
#include "adc.h"
#include "safety.h"
#include "voltage.h"
Go to the source code of this file.
Defines | |
#define | EXPORT |
#define | AVG_COUNT 40U |
Defines the number of voltage readings used for calculating the average voltage. | |
Functions | |
void | voltage_Init (void) |
Init function of module <voltage.c>. | |
void | voltage_Update (void) |
Read and update ADC values for battery voltage and reference voltage. | |
void | voltage_UpdateAvg (void) |
Reads the battery voltage and recalculates the average value. | |
UINT16 | voltage_GetValue (void) |
Returns the battery voltage. | |
UINT16 | voltage_GetAvg (void) |
Returns average battery voltage. | |
UINT16 | voltage_GetRef (void) |
Returns reference voltage. | |
Variables | |
static UINT16 | mg_u16Ref = 0U |
UINT16 variable to store the ADC value of reference voltage. | |
static UINT16 | mg_u16Value = 0U |
UINT16 variable to store the ADC value of battery voltage. | |
static UINT16 | mg_au16Data [AVG_COUNT] |
UINT16 variable to store the ADC values of battery voltage for averaging. | |
static UINT16 | mg_u16Avg = 0U |
UINT16 variable to store averaged value of battery voltage. | |
static UINT8 | mg_u8Idx = 0U |
UINT8 variable to keep the ring array index position. |
This module provides service-level functions to get the momentary and averaged battery voltage and the reference voltage.
Definition in file voltage.c.