/************************************************************************** * * Copyright (c) 2026 Diality Inc. - All Rights Reserved. * * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. * * @file Battery.h * * @author (last) Suresh Dharnala * @date (last) 15-May-2026 * * @author (original) Suresh Dharnala * @date (original) 13-May-2026 * ***************************************************************************/ #ifndef APP_MONITORS_BATTERY_H_ #define APP_MONITORS_BATTERY_H_ #include "Utilities.h" #include "Messaging.h" /** * @defgroup Battery * @brief The battery monitor module reads and publishes battery charger * and battery pack data over I2C and SMBus. * * @addtogroup Battery * @{ */ // ********** public definitions ********** /// Payload record structure for battery status data broadcast message typedef struct { U32 RemainingCapacity; ///< Remaining capacity (mAh). U32 BatteryStatus; ///< Battery status. U32 BatteryChargerStatus; ///< Battery charge status. U32 BatteryI2CStatus; } BATTERY_STATUS_PAYLOAD_T; /// Payload record structure for battery module data broadcast message typedef struct { U32 FaultStatus; ///< Charger fault status. U32 TS; ///< Temperature. U32 VBAT; ///< Voltage. U32 VSYS; ///< System voltage in mV. U32 IBAT; ///< Current. U32 RelativeStateOfCharge; ///< Relative state of charge. U32 FullChargeCapacity; ///< Full charge capacity. } BATTERY_MANAGER_PAYLOAD_T; /// Enumeration of battery data to be read from the battery pack or battery charger in a round-robin fashion. typedef enum BatteryManagementEnum { BEGINNING_OF_LIST = 0, ///< Start of battery data list BATTERY_PACK_REMAINING_CAPACITY, ///< Remaining battery capacity (in mAh) BATTERY_PACK_BATTERY_STATUS, ///< Battery pack status BATTERY_CHARGER_STATUS, ///< Battery charger status register 1 (0x21) BATTERY_PACK_RELATIVE_STATE_OF_CHARGE, ///< Battery pack relative state of charge (%) BATTERY_PACK_FULL_CHARGE_CAPACITY, ///< Battery pack full charge capacity in mAh BATTERY_CHARGER_TS, ///< Battery charger temperature (in deg K) BATTERY_CHARGER_VBAT, ///< Battery charger terminal voltage (in mV) BATTERY_CHARGER_VSYS, ///< Battery charger system voltage (in mV) BATTERY_CHARGER_FAULT, ///< Battery charger fault status BATTERY_CHARGER_CURRENT, ///< Battery charger current (in mA) END_OF_LIST, ///< End of battery data list NUM_OF_BATTERY_PACK_LIST, ///< Number of battery pack list } BATTERY_MANAGEMENT_ENUM_T; typedef enum BatteryDevicesEnum { BATTERY_CHARGER_ADDRESS = 0, ///< Battery charger at I2C address BATTERY_PACK_ADDRESS, ///< Battery pack at SMBus address NUM_OF_BATTERY_DEVICES, ///< Number of battery devices } BATTERY_DEVICE_ADDRESS_ENUM_T; //********** public function prototypes ********** void initBattery( void ); void execBatteryMonitor( void ); BOOL isBatteryCharged( void ); BOOL testBatteryRemainingCapacityOverride( MESSAGE_T *message ); BOOL testBatteryStatusOverride( MESSAGE_T *message ); BOOL testBatteryChargerStatusOverride( MESSAGE_T *message ); /**@}*/ #endif /* APP_MONITORS_BATTERY_H_ */