LibreSolar / bms-firmware

Firmware for LibreSolar BMS boards based on bq769x0, bq769x2 or ISL94202
https://libre.solar/bms-firmware/
Apache License 2.0
146 stars 67 forks source link

API source code #60

Closed Ananyaaynana closed 6 months ago

Ananyaaynana commented 6 months ago

We want to add the following recovery features to the firmware: Short circuit recovery, discharge overcurrent recovery and charge overcurrent recovery. `

uint8_t dis_sc_recovery_s; ///< Discharge short circuit recovery time (s)

uint8_t dis_sc_scdl_dec_delay_s; ///< Discharge short circuit latch delay (s)

uint8_t dis_sc_scdl_latch_limit;    ///< Discharge short ciruit latch limit (s)

int16_t dis_sc_scdl_recover_time_s; ///< Discharge short circuit recover time(s)

int16_t dis_sc_scdl_recovery_threshold_mA; ///< Discharge short circuit latch recovery limit (mA)`

int16_t dis_oc_recovery_current_mA;     //< Recovery current of discharge overcurrent(mA)

uint8_t recovery_time_s;                //< Recovery time of discharge overcurrent(s)

uint8_t dis_oc_counter_dec_delay_s;     //< Delay for detection of discharge overcurrent.(s)

uint8_t dis_oc_latch_limit;             //< Latch limit for discharge overcurrent.

int16_t dis_oc_latch_recovery_mA;       //< Latch limit recovery current for discharge overcurrent.(mA)

uint8_t dis_oc_latch_recovery_time_s;   //< Latch limit revcovery time for discharge overcurrent.(s)`

In the firmware to set these values the API static inline int bms_ic_configure(const struct device *dev, struct bms_ic_conf *ic_conf, uint32_t flags) is called.

After adding these recovery modifications to the struct bms_ic_conf structure the configure(dev, ic_conf, flags) will apply the changes to the appropriate register address indicated by the BMS_IC_CONF_CURRENT_LIMITS flag. Is my understanding correct?

The source code for the configure(dev, ic_conf, flags), I am not able to find it.

I can share the code for the recovery modifications added to this commit: https://github.com/LibreSolar/bms-firmware/tree/cb89c75b74e85a036b7c6243424e31c68b3b3018 written for the 0.3v BMS code.

Please let me know where to access the configure(dev, ic_conf, flags) source code to add the recovery modifications to the firmware.

martinjaeger commented 6 months ago

The bq76952 driver source code can be found in this folder: https://github.com/LibreSolar/bms-firmware/tree/main/drivers%2Fbms_ic%2Fbq769x2

See the Zephyr driver model for further information regarding driver development.

Ananyaaynana commented 6 months ago

Thank you.