| 12345678910111213141516171819202122232425262728293031323334353637 |
- #include "battery.h"
- Battery batteries[NUM_SLOTS];
- // Permissible charge temperature for LiIon battery is 0.0 degree Celsius to 45.0 degree Celsius
- // Correct temp_threshold yet to be analyzed
- #define TEMP_THRESHOLD (460)
- //#define VOLTAGE_THRESHOLD ()
- uint16_t charge_change_threshold;
- /*Initialize battery array and default parameters*/
- void Battery_Init(){
- for(uint8_t i=0; i< NUM_SLOTS; i++){
- batteries[i].slot_id= i;
- batteries[i].state= STATE_EMPTY;
- batteries[i].voltage= 0;
- batteries[i].current= 0;
- batteries[i].temperature= 0;
- batteries[i].min_voltage= 0;
- batteries[i].max_voltage= 0;
- batteries[i].cut_off_current= 0;
- batteries[i].capacitance= 0;
- }
- }
- void Battery_SafetyCheck(uint8_t slot){
- if(slot>= NUM_SLOTS){
- return;
- }
- if (batteries[slot].temperature > TEMP_THRESHOLD){
- batteries[slot].state= STATE_OVERCHARGING;
- //How to exit? Disable the DAC channel?
- }
- }
|