engine_control/source/firmware/kernel/driver/battery_monitor.h

35 lines
1.1 KiB
C
Raw Normal View History

2016-07-23 05:59:54 +00:00
/*
* battery_monitor.h
*
* Created on: Dec 23, 2012
* Author: tkl
*/
#ifndef BATTERY_MONITOR_H_
#define BATTERY_MONITOR_H_
#include "stdbool.h"
//------------------------------------------------------------------------------
//! \brief battery monitor device.
struct battery_monitor {
const struct adc *adc; //!< Adc device for the battery monitor.
const unsigned short timeout; //!< Adc measurement timeout.
const int factor; //!< Factor to calculate voltage from adc result.
const int divider; //!< Divider to calculate voltage from adc result.
const int offset; //!< Offset to calculate voltage from adc result.
};
//------------------------------------------------------------------------------
//! \brief Value container for the battery monitor.
struct battery_monitor_voltage {
unsigned short voltage; //!< Calculated voltage.
unsigned short raw; //!< Raw value of the adc.
bool valid; //!< Indicates if result is valid.
};
//------------------------------------------------------------------------------
struct battery_monitor_voltage get_voltage(const struct battery_monitor * device);
#endif /* BATTERY_MONITOR_H_ */