src.dualinventive.com/fw/dncm/libdi_fw/include/di_fw/charger.h

70 lines
2.0 KiB
C
Executable File

/**
* @file include/di_fw/charger.h
* @brief charger header file
* @date September 12, 2016
* @author R.H. van Lieshout (PragmaLab)
* @copyright 2016 Dual Inventive Technology Centre B.V.
*/
#ifndef INCLUDE_DI_FW_CHARGER_H_
#define INCLUDE_DI_FW_CHARGER_H_
#include <di/time.h>
#include <di/constants/device/charger.h>
/**
* Enum of chargers that can be selected
* Note: for now the charger ID is only used for publishing charger data
* to the server
*/
enum di_fw_charger {
DI_FW_CHARGER_1 = 0,
DI_FW_CHARGER_2,
};
/**
* Charger data
* store charger related data in one structure
*/
struct di_fw_charger_data {
di_time_t last_update;
float current_voltage;
float previous_voltage;
enum di_fw_charger charger_num;
enum di_device_charger_state current_state;
enum di_device_charger_state previous_state;
};
#define DI_FW_CHARGER_DELTA 0.1f /* threshold for sending data */
/**
* return current charger state
* @return boolean that indicates if the charger is charging (TRUE) or not (FALSE)
*/
bool di_fw_charger_is_active(void);
/**
* Set charger module to work
* @param battery_voltage the battery voltage of the battery that needs to be charged
*/
void di_fw_charger_kick_charger(float battery_voltage);
/**
* enable/disable charger Hardware pins
* For testing purposes, we need a charge mode that does not control the charger
* HW pins. The charger statemachine is fully operating without outputting a charger voltage
*
* @param enable enable charger HW pins (TRUE) or disable charger HW pins (FALSE)
*/
void di_fw_charger_enable_pins(bool enable);
/**
* init the charger module
* @param powersafe_mode: boolean that indicates the powersafe mode. When TRUE the powersafe mode
* is active and no periodic thread will be spawned and no charger data will be published
* When FALSE the charger will function in normal operation and charger data will be
* published
*/
void di_fw_charger_init(bool powersafe_mode);
#endif /* INCLUDE_DI_FW_CHARGER_H_ */