This commit is contained in:
hamza
2024-07-07 18:52:54 +03:00
parent e7b5054e02
commit a4a856eb31
14 changed files with 126 additions and 260 deletions

16
Core/Src/ADBMS_Abstraction.c Normal file → Executable file
View File

@ -28,7 +28,7 @@ uint8 amsReset() {
amsStopBalancing();
amsConfigOverUnderVoltage(DEFAULT_OV, DEFAULT_UV);
uint8 buffer[6] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
const uint8 buffer[6] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
CHECK_RETURN(writeCMD(CLRFLAG, buffer, 6)); //clear flags,
CHECK_RETURN(writeCMD(CLOVUV, buffer, 6)); //OVUV flags
@ -131,8 +131,8 @@ uint8 amsAuxAndStatusMeasurement(Cell_Module* module) {
uint8 amsConfigBalancing(uint32 channels, uint8 dutyCycle) {
uint8 buffer_a[PWM_GROUP_A_SIZE] = {};
uint8 buffer_b[PWM_GROUP_B_SIZE] = {};
CHECK_RETURN(readCMD(RDPWMA, buffer_a, CFG_GROUP_A_SIZE));
CHECK_RETURN(readCMD(RDPWMB, buffer_b, CFG_GROUP_B_SIZE));
CHECK_RETURN(readCMD(RDPWMA, buffer_a, PWM_GROUP_A_SIZE));
CHECK_RETURN(readCMD(RDPWMB, buffer_b, PWM_GROUP_B_SIZE));
if (dutyCycle > 0x0F) { // there are only 4 bits for duty cycle
return 1;
@ -150,8 +150,8 @@ uint8 amsConfigBalancing(uint32 channels, uint8 dutyCycle) {
}
}
CHECK_RETURN(writeCMD(WRPWMA, buffer_a, CFG_GROUP_A_SIZE));
CHECK_RETURN(writeCMD(WRPWMB, buffer_b, CFG_GROUP_B_SIZE));
CHECK_RETURN(writeCMD(WRPWMA, buffer_a, PWM_GROUP_A_SIZE));
CHECK_RETURN(writeCMD(WRPWMB, buffer_b, PWM_GROUP_B_SIZE));
return 0;
}
@ -203,13 +203,11 @@ uint8 amsCheckUnderOverVoltage(Cell_Module* module) {
}
uint8 amsClearAux() {
uint8 buffer[6];
return writeCMD(CLRAUX, buffer, 0);
return writeCMD(CLRAUX, NULL, 0);
}
uint8 amsClearCells() {
uint8 buffer[6];
return writeCMD(CLRCELL, buffer, 0);
return writeCMD(CLRCELL, NULL, 0);
}
uint8 amsReadCellVoltages(Cell_Module* module) {