#if defined(__18CXX)
typedef struct celltype { // C18 uses byte alignment
#else
typedef struct __attribute__((aligned(1))) celltype { // force C32 to byte alignment, 32bit alignment is still critical
#endif
uint16_t id, model; // battery cell type S,M,L
int32_t voltage, current, charge, cycles, noload, date;
uint8_t cconline, online, discharged, dead, critical, valid, fresh, misc;
float weight;
}
volatile celltype;
/* hist[x].h[x]
* h0 Peukert Factor adjusted Ah usage this cycle, MUST BE INTERGER variable type!
* h1 Lowest discharge ever,
* h2 current lowest discharge,
* h3 avg discharge
* h4 Number of full charge cycles, h5 Number of full discharge cycles
* h6 Real Ah usage this cycle, MUST BE INTERGER variable type!
* h7 Min Batt Voltage
* h8 Max Batt Voltage
* h9 Lowest ESR Pre
* h10 Lowest ESR Post
*/
#if defined(__18CXX)
typedef struct histtype { // C18 uses byte alignment
#else
typedef struct __attribute__((aligned(1))) histtype { // force C32 to byte alignment, 32bit alignment is still critical
#endif
uint16_t rate, udod, bsoc, bound_rate, bound_factor, samplei, sampleo, ah, drate, esr, rest_rate, rest_factor, esrp;
int16_t h[HPARAM_SIZE]; // h[6]=cumulative battery Ah cc and inv (real),h[0]=cumulative battery Ah cc and inv (p_adj)
int32_t kwi, kwo, ttg, btest;
int32_t ahi, aho, ahir, ahop, thermo; // A stored in battery, A taken from battery, A from raw pv, peukert adjusted A
int32_t pv_eff, tot_eff; // pv generation eff factor, total system eff factor
float peukert, cef, peukert_adj, cef_calc, cef_save;
}
volatile histtype;
typedef struct R_data { // set only in adc_read
int32_t current, currentin, currentcharger, thermo_batt;
uint32_t systemvoltage, ccvoltage, inputvoltage, primarypower[POWER_SLOTS];
} R_data;
typedef struct V_data { // OS Counters
uint32_t highint_count, lowint_count, eeprom_count, timerint_count, adc_count, mbmcdata_count, c1rx_int, c1tx_int, c2_int, buttonint_count,
clock50, pwm4int_count;
} V_data;
typedef struct C_data { // set only in adc_read
int32_t currentload;
int temp_drate;
float t_comp;
} C_data;
typedef struct B_data {
int16_t start_ahu, cef_raw; // must be int TYPE
uint32_t start_ahi, start_aho, absorp_ahi, absorp_time, charge_time_left; // uint32_t TYPE
uint8_t yesterday, today, r_soc[DATA_SLOTS]; // Harvest quality for the whole day, 0..100, uses time of harvest (seconds) -> input power (watts) -> max power (watts).
int32_t diversion;
} volatile B_data; // of each measurement during that period.