Changeset 27 for trunk/fw_g473rct/SES/src/eeprom.c
- Timestamp:
- Sep 10, 2025, 8:48:05 AM (7 weeks ago)
- File:
-
- 1 edited
-
trunk/fw_g473rct/SES/src/eeprom.c (modified) (14 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/fw_g473rct/SES/src/eeprom.c
r26 r27 3 3 #include "eeprom.h" 4 4 #include "stdio.h" 5 #include "math.h"6 5 #include "modbus.h" 7 6 … … 20 19 #define PAGE_SIZE 64 // in Bytes 21 20 #define PAGE_NUM 4096 // number of pages 21 22 23 #define PADDRPOSITION 6 //MUST BE calculated for every eeprom type --//int paddrposition = log(PAGE_SIZE)/log(2); 22 24 23 25 /********************************************************/ … … 76 78 uint16_t uBatFull; 77 79 uint16_t uBatEmpty; 78 uint 8_t socCalcMode;80 uint16_t socCalcMode; 79 81 uint16_t cellRatedDischargeTime; 80 82 … … 100 102 int16_t extraDischargeStrom_mA; // For example, current that consumes LiPro itself 101 103 uint16_t cefW; 104 int16_t batteryEmptyDetectionMode; 102 105 103 106 } eeprom_data_t; … … 221 224 /* tBatFull */ 2, // t-batt full 2 Sekunden 222 225 /* uBatFull */ 0, // 14V olt Ubatt full, Neu: Bei 0: Erkung von Lipro LVP als 0% 223 /* uBatEmpty */ -1, // 11,312V Ubatt Empty226 /* uBatEmpty */ 11312, // 11,312V Ubatt Empty 224 227 /* socCalcMode */ 1, // SoC calculation mode: 0(default) 225 228 /* cellRatedDischargeTime */ 2, // cell rated current discharge time [C/x]. For example, if 40Ah cell is rated as 0.5c, then rated discharge time is 2 … … 257 260 /* extraDischargeStrom_mA */ 7, // mA, current that LiPro consumes itself 258 261 /* cefW */ 90, // 90% cef for Wh calculations 262 /* Battery Empty Detection Mode*/ 1, // Auto, from BMS 259 263 260 264 … … 371 375 dataToStore->changedData.extraDischargeStrom_mA = defaultEepromData.extraDischargeStrom_mA; 372 376 dataToStore->changedData.cefW = defaultEepromData.cefW; 377 dataToStore->changedData.batteryEmptyDetectionMode = defaultEepromData.batteryEmptyDetectionMode; 373 378 374 379 … … 475 480 dataToStore->changedData.extraDischargeStrom_mA = defaultEepromData.extraDischargeStrom_mA; 476 481 dataToStore->changedData.cefW = defaultEepromData.cefW; 482 dataToStore->changedData.batteryEmptyDetectionMode = defaultEepromData.batteryEmptyDetectionMode; 477 483 478 484 … … 570 576 dataToStore->changedData.extraDischargeStrom_mA = data->s.parameter.extraDischargeStrom_mA; 571 577 dataToStore->changedData.cefW = data->s.parameter.cefW; 572 578 dataToStore->changedData.batteryEmptyDetectionMode = data->s.parameter.batteryEmptyDetectionMode; 579 573 580 // Eeprom Status Infos 574 581 dataToStore->eepromState.writeCounter++; … … 672 679 data->s.parameter.extraDischargeStrom_mA = dataToStore->changedData.extraDischargeStrom_mA; 673 680 data->s.parameter.cefW = dataToStore->changedData.cefW; 681 data->s.parameter.batteryEmptyDetectionMode = dataToStore->changedData.batteryEmptyDetectionMode; 682 674 683 675 684 … … 713 722 void EEPROM_Read (uint16_t page, uint16_t offset, uint8_t *data, uint16_t size) 714 723 { 715 int paddrposition = log(PAGE_SIZE)/log(2); 724 //int paddrposition = log(PAGE_SIZE)/log(2); 725 int paddrposition = PADDRPOSITION; 716 726 717 727 uint16_t startPage = page; … … 731 741 pos += bytesremaining; 732 742 } 743 733 744 } 734 745 … … 738 749 739 750 // Find out the number of bit, where the page addressing starts 740 int paddrposition = log(PAGE_SIZE)/log(2);751 int paddrposition = PADDRPOSITION; 741 752 742 753 // calculate the start page and the end page … … 758 769 759 770 HAL_I2C_Mem_Write(EEPROM_I2C, EEPROM_ADDR, MemAddress, 2, &data[pos], bytesremaining, 1000); // write the data to the EEPROM 760 761 771 startPage += 1; // increment the page, so that a new page address can be selected for further write 762 772 offset=0; // since we will be writing to a new page, so offset will be 0
Note: See TracChangeset
for help on using the changeset viewer.
