/** * @file include/di_fw/battery.h * @brief battery header file * @date August 24, 2016 * @author A.A.W.M. Ruijs * @copyright 2016 Dual Inventive Technology Centre B.V. */ #ifndef INCLUDE_DI_FW_BATTERY_H_ #define INCLUDE_DI_FW_BATTERY_H_ #include #include /** * Enum of batteries that can be selected * Note: entries are used as index in an array, do not change values */ enum di_fw_batteries { DI_FW_BATTERY_1 = 0, #ifdef DI_FW_BATTERY_ADC_CHANNEL2 DI_FW_BATTERY_2, #endif DI_FW_BATTERY_COUNT, }; #define DI_FW_BATTERY_DELTA 0.1f /* threshold for sending data */ struct di_fw_battery_data { uint32_t periodic_id; float current_voltage; float previous_voltage; const enum di_fw_batteries battery_num; enum di_device_battery_state current_state; enum di_device_battery_state previous_state; }; /** * convert raw ADC value to voltage * @param val the adc sample that need to be converted to voltage */ float di_fw_battery_calculate_voltage(adcsample_t val); /** * configure ADC for measurement and start the thread for measuring */ void di_fw_battery_init(void); #endif /* INCLUDE_DI_FW_BATTERY_H_ */