BCU function ok --new PCB
This commit is contained in:
parent
83b4133c68
commit
5280b76d65
|
@ -31,7 +31,6 @@ void bmu_adapt_ic_num(void)
|
|||
bmu_data.total_ic_num = bmu_data.total_ic_adapt_num;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
void bmu_adapt_volt_temp(void)
|
||||
{
|
||||
|
@ -83,7 +82,6 @@ void bmu_adapt_volt_temp(void)
|
|||
|
||||
bmu_data.bmu_cell_num = bmu_data.total_cell_num / bmu_data.bmu_ic_num;
|
||||
bmu_data.bmu_temp_num = bmu_data.total_temp_num / bmu_data.bmu_ic_num;
|
||||
|
||||
}
|
||||
|
||||
void bmu_init_isoSpi(void)
|
||||
|
|
|
@ -271,6 +271,7 @@ typedef enum
|
|||
|
||||
const uint16_t uart_parity[kUartParity_End] = {0x0000, 0x0007, 0x0005};
|
||||
const uint32_t uart_baudrate[kR485BaudRateEnd] = {4800, 9600, 19200, 38400, 115200};
|
||||
const uint32_t can_baudrate[kCanBaudRateEnd] = {125, 250, 500, 1000};
|
||||
void bms_init_comm(void)
|
||||
{
|
||||
uint32_t i, tmp, prop;
|
||||
|
@ -292,11 +293,13 @@ void bms_init_comm(void)
|
|||
|
||||
prop = get_eeprom_data(kEep_Inter485Parity_Baudrate + i, kEepromDataType_High);
|
||||
prop = (prop < kUartParity_End) ? uart_parity[prop] : 0;
|
||||
|
||||
uint32_t tmpBaud = uart_baudrate[prop];
|
||||
drv_uart_init((UartDev)modbus_rtu_array[i]->comm_dev, 115200, 0 | UART_CFG_STOP_BIT_1, kGpioType_Rs485_Ch1_Tx + (i << 1), kGpioType_Rs485_Ch1_Rx + (i << 1));
|
||||
drv_uart_set_interrupt((UartDev)modbus_rtu_array[i]->comm_dev, kUartInterrupt_Tx, APP_CFG_INT_PRIO_UART2_RX, uart_tx_it_call);//设置中断回调
|
||||
}
|
||||
|
||||
uint32_t tmpIndex = get_eeprom_data(kEep_InterCanProtocol_Baudrate + i, kEepromDataType_Low);
|
||||
uint32_t tmpCanBaud = can_baudrate[tmpIndex];
|
||||
drv_uart_set_interrupt(INTER_UART_PORT, kUartInterrupt_Rx, APP_CFG_INT_PRIO_UART2_RX, inter_uart_rx_it_call);
|
||||
drv_uart_set_interrupt(EXTER_UART1_PORT, kUartInterrupt_Rx, APP_CFG_INT_PRIO_UART2_RX, exter_uart1_rx_it_call);
|
||||
drv_uart_set_interrupt(EXTER_UART2_PORT, kUartInterrupt_Rx, APP_CFG_INT_PRIO_UART2_RX, exter_uart2_rx_it_call);
|
||||
|
|
|
@ -293,6 +293,10 @@ uint16_t zero_calc(uint16_t value)
|
|||
{
|
||||
return 0;
|
||||
}
|
||||
else if(value > 60000)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
return value;
|
||||
|
|
|
@ -600,7 +600,7 @@ void bms_integral_soc(int32_t current, uint16_t base_time)
|
|||
sox_item.tmp_chg_cap += tmp_32u;
|
||||
//单位 kWms
|
||||
//tmp_32少除了100,这里应该多除个100--2.20
|
||||
sox_item.tmp_chg_energy += tmp_32u * total_volt / 1000000;
|
||||
sox_item.tmp_chg_energy += tmp_32u * total_volt / 10000;
|
||||
|
||||
if(sox_item.calculate_cap < sox_item.rated_cap)
|
||||
{
|
||||
|
@ -646,7 +646,7 @@ void bms_integral_soc(int32_t current, uint16_t base_time)
|
|||
|
||||
sox_item.tmp_dis_cap += tmp_32u;
|
||||
//单位 kWms
|
||||
sox_item.tmp_dis_energy += tmp_32u * total_volt / 1000000;
|
||||
sox_item.tmp_dis_energy += tmp_32u * total_volt / 10000;
|
||||
|
||||
if(sox_item.calculate_cap > 0)
|
||||
{
|
||||
|
|
Binary file not shown.
|
@ -10,14 +10,14 @@
|
|||
<TargetName>stm32f407</TargetName>
|
||||
<ToolsetNumber>0x4</ToolsetNumber>
|
||||
<ToolsetName>ARM-ADS</ToolsetName>
|
||||
<pArmCC>5060960::V5.06 update 7 (build 960)::.\ARM_Compiler_5.06u7</pArmCC>
|
||||
<pCCUsed>5060960::V5.06 update 7 (build 960)::.\ARM_Compiler_5.06u7</pCCUsed>
|
||||
<pArmCC>5050106::V5.05 update 1 (build 106)::ARMCC</pArmCC>
|
||||
<pCCUsed>5050106::V5.05 update 1 (build 106)::ARMCC</pCCUsed>
|
||||
<uAC6>0</uAC6>
|
||||
<TargetOption>
|
||||
<TargetCommonOption>
|
||||
<Device>STM32F407ZGTx</Device>
|
||||
<Vendor>STMicroelectronics</Vendor>
|
||||
<PackID>Keil.STM32F4xx_DFP.2.14.0</PackID>
|
||||
<PackID>Keil.STM32F4xx_DFP.2.16.0</PackID>
|
||||
<PackURL>http://www.keil.com/pack/</PackURL>
|
||||
<Cpu>IRAM(0x20000000,0x00020000) IRAM2(0x10000000,0x00010000) IROM(0x08000000,0x00100000) CPUTYPE("Cortex-M4") FPU2 CLOCK(12000000) ELITTLE</Cpu>
|
||||
<FlashUtilSpec></FlashUtilSpec>
|
||||
|
@ -50,7 +50,7 @@
|
|||
<InvalidFlash>1</InvalidFlash>
|
||||
</TargetStatus>
|
||||
<OutputDirectory>.\Objects\</OutputDirectory>
|
||||
<OutputName>BCU_APP2</OutputName>
|
||||
<OutputName>BCU1</OutputName>
|
||||
<CreateExecutable>1</CreateExecutable>
|
||||
<CreateLib>0</CreateLib>
|
||||
<CreateHexFile>1</CreateHexFile>
|
||||
|
@ -83,7 +83,7 @@
|
|||
<AfterMake>
|
||||
<RunUserProg1>1</RunUserProg1>
|
||||
<RunUserProg2>0</RunUserProg2>
|
||||
<UserProg1Name>D:\Soft\Setup\Keil\ARM\ARM_Compiler_5.06u7\bin\fromelf.exe --bin -o D:\Code\BMS\BCU\app/BCU_APP2.bin D:\Code\BMS\BCU\app/BCU_APP2.axf"</UserProg1Name>
|
||||
<UserProg1Name>D:\CodeCompare\BCU\app\stm32fxxx_app\hex2bin.exe D:\CodeCompare\BCU\app\stm32fxxx_app\prj\Objects\BCU1.hex</UserProg1Name>
|
||||
<UserProg2Name></UserProg2Name>
|
||||
<UserProg1Dos16Mode>0</UserProg1Dos16Mode>
|
||||
<UserProg2Dos16Mode>0</UserProg2Dos16Mode>
|
||||
|
@ -186,6 +186,8 @@
|
|||
<uocXRam>0</uocXRam>
|
||||
<RvdsVP>2</RvdsVP>
|
||||
<RvdsMve>0</RvdsMve>
|
||||
<RvdsCdeCp>0</RvdsCdeCp>
|
||||
<nBranchProt>0</nBranchProt>
|
||||
<hadIRAM2>1</hadIRAM2>
|
||||
<hadIROM2>0</hadIROM2>
|
||||
<StupSel>8</StupSel>
|
||||
|
@ -352,7 +354,7 @@
|
|||
<NoWarn>0</NoWarn>
|
||||
<uSurpInc>0</uSurpInc>
|
||||
<useXO>0</useXO>
|
||||
<uClangAs>0</uClangAs>
|
||||
<ClangAsOpt>4</ClangAsOpt>
|
||||
<VariousControls>
|
||||
<MiscControls></MiscControls>
|
||||
<Define></Define>
|
||||
|
@ -471,7 +473,7 @@
|
|||
<NoWarn>2</NoWarn>
|
||||
<uSurpInc>2</uSurpInc>
|
||||
<useXO>2</useXO>
|
||||
<uClangAs>2</uClangAs>
|
||||
<ClangAsOpt>0</ClangAsOpt>
|
||||
<VariousControls>
|
||||
<MiscControls></MiscControls>
|
||||
<Define></Define>
|
||||
|
@ -774,11 +776,6 @@
|
|||
<FileType>1</FileType>
|
||||
<FilePath>..\app\dido_manager.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>eeprom_manager.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\app\eeprom_manager.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>fault_manager.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
|
@ -794,16 +791,16 @@
|
|||
<FileType>1</FileType>
|
||||
<FilePath>..\app\fault_register.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>gpio_manager.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\app\gpio_manager.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>hv_adc_manager.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\app\hv_adc_manager.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>gpio_manager.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\app\gpio_manager.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>iso_check.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
|
@ -834,6 +831,11 @@
|
|||
<FileType>1</FileType>
|
||||
<FilePath>..\app\logic_same_circuit_ctrl.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>eeprom_manager.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\app\eeprom_manager.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>run_status.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
|
@ -972,7 +974,7 @@
|
|||
<NoWarn>2</NoWarn>
|
||||
<uSurpInc>2</uSurpInc>
|
||||
<useXO>2</useXO>
|
||||
<uClangAs>2</uClangAs>
|
||||
<ClangAsOpt>0</ClangAsOpt>
|
||||
<VariousControls>
|
||||
<MiscControls></MiscControls>
|
||||
<Define></Define>
|
||||
|
@ -1143,8 +1145,8 @@
|
|||
<TargetCommonOption>
|
||||
<Device>STM32F407VGTx</Device>
|
||||
<Vendor>STMicroelectronics</Vendor>
|
||||
<PackID>Keil.STM32F4xx_DFP.3.0.0</PackID>
|
||||
<PackURL>https://www.keil.com/pack/</PackURL>
|
||||
<PackID>Keil.STM32F4xx_DFP.2.16.0</PackID>
|
||||
<PackURL>http://www.keil.com/pack/</PackURL>
|
||||
<Cpu>IRAM(0x20000000,0x00020000) IRAM2(0x10000000,0x00010000) IROM(0x08000000,0x00100000) CPUTYPE("Cortex-M4") FPU2 CLOCK(12000000) ELITTLE</Cpu>
|
||||
<FlashUtilSpec></FlashUtilSpec>
|
||||
<StartupFile></StartupFile>
|
||||
|
@ -1312,6 +1314,8 @@
|
|||
<uocXRam>0</uocXRam>
|
||||
<RvdsVP>2</RvdsVP>
|
||||
<RvdsMve>0</RvdsMve>
|
||||
<RvdsCdeCp>0</RvdsCdeCp>
|
||||
<nBranchProt>0</nBranchProt>
|
||||
<hadIRAM2>1</hadIRAM2>
|
||||
<hadIROM2>0</hadIROM2>
|
||||
<StupSel>8</StupSel>
|
||||
|
@ -1478,7 +1482,7 @@
|
|||
<NoWarn>0</NoWarn>
|
||||
<uSurpInc>0</uSurpInc>
|
||||
<useXO>0</useXO>
|
||||
<uClangAs>0</uClangAs>
|
||||
<ClangAsOpt>4</ClangAsOpt>
|
||||
<VariousControls>
|
||||
<MiscControls></MiscControls>
|
||||
<Define></Define>
|
||||
|
@ -1729,11 +1733,6 @@
|
|||
<FileType>1</FileType>
|
||||
<FilePath>..\app\dido_manager.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>eeprom_manager.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\app\eeprom_manager.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>fault_manager.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
|
@ -1749,16 +1748,16 @@
|
|||
<FileType>1</FileType>
|
||||
<FilePath>..\app\fault_register.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>gpio_manager.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\app\gpio_manager.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>hv_adc_manager.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\app\hv_adc_manager.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>gpio_manager.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\app\gpio_manager.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>iso_check.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
|
@ -1789,6 +1788,11 @@
|
|||
<FileType>1</FileType>
|
||||
<FilePath>..\app\logic_same_circuit_ctrl.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>eeprom_manager.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\app\eeprom_manager.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>run_status.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,39 +1,45 @@
|
|||
[BREAKPOINTS]
|
||||
ForceImpTypeAny = 0
|
||||
FForceImpTypeAny = 0
|
||||
ShowInfoWin = 1
|
||||
EnableFlashBP = 2
|
||||
BPDuringExecution = 0
|
||||
orceImpTypeAny = 0
|
||||
[CFI]
|
||||
CFISize = 0x00
|
||||
CCFISize = 0x00
|
||||
CFIAddr = 0x00
|
||||
FISize = 0x00
|
||||
[CPU]
|
||||
MonModeVTableAddr = 0xFFFFFFFF
|
||||
MOverrideMemMap = 0
|
||||
AllowSimulation = 1
|
||||
ScriptFile=""
|
||||
onModeVTableAddr = 0xFFFFFFFF
|
||||
MonModeDebug = 0
|
||||
MaxNumAPs = 0
|
||||
LowPowerHandlingMode = 0
|
||||
OverrideMemMap = 0
|
||||
AllowSimulation = 1
|
||||
ScriptFile=""
|
||||
[FLASH]
|
||||
CacheExcludeSize = 0x00
|
||||
CCacheExcludeSize = 0x00
|
||||
CacheExcludeAddr = 0x00
|
||||
MinNumBytesFlashDL = 0
|
||||
SkipProgOnCRCMatch = 1
|
||||
VerifyDownload = 1
|
||||
AllowCaching = 1
|
||||
EnableFlashDL = 2
|
||||
Override = 0
|
||||
Device="ARM7"
|
||||
Override = 1
|
||||
Device="Unspecified"
|
||||
acheExcludeSize = 0x00
|
||||
[GENERAL]
|
||||
WorkRAMSize = 0x00
|
||||
WWorkRAMSize = 0x00
|
||||
WorkRAMAddr = 0x00
|
||||
RAMUsageLimit = 0x00
|
||||
orkRAMSize = 0x00
|
||||
[SWO]
|
||||
SWOLogFile=""
|
||||
SSWOLogFile=""
|
||||
WOLogFile=""
|
||||
[MEM]
|
||||
RdOverrideOrMask = 0x00
|
||||
RRdOverrideOrMask = 0x00
|
||||
RdOverrideAndMask = 0xFFFFFFFF
|
||||
RdOverrideAddr = 0xFFFFFFFF
|
||||
WrOverrideOrMask = 0x00
|
||||
WrOverrideAndMask = 0xFFFFFFFF
|
||||
WrOverrideAddr = 0xFFFFFFFF
|
||||
dOverrideOrMask = 0x00
|
||||
|
|
|
@ -270,6 +270,429 @@ void protocol_can_bcu_init(can_dev_e can)
|
|||
protocol_can_set_call(can, bcu_can_receive, bcu_can_send,NULL);
|
||||
}
|
||||
|
||||
|
||||
/*********************pylon can*********************/
|
||||
/*********************pylon can*********************/
|
||||
/*********************pylon can*********************/
|
||||
void bcu_send_0x42100000(can_dev_e can)
|
||||
{
|
||||
uint8_t len = 0, buf[8];
|
||||
uint16_t tmp_16u;
|
||||
uint8_t tmp_8u;
|
||||
|
||||
//电池组总电压
|
||||
tmp_16u = bms_get_statistic_data(kStatisticData_TotalVolt);
|
||||
WRITE_LT_INT16U(buf, len, tmp_16u);
|
||||
//电池组充/放电总电流
|
||||
tmp_16u = bms_get_current();
|
||||
WRITE_LT_INT16U(buf, len, tmp_16u);
|
||||
//主控温度--我们点表中没有,用单体平均温度替代
|
||||
tmp_16u = bms_get_statistic_data(kStatisticData_AvgTemp);
|
||||
WRITE_LT_INT16U(buf, len, tmp_16u);
|
||||
//电池模块SOC
|
||||
tmp_8u = (uint8_t )(bms_get_soc()/100);
|
||||
WRITE_LT_INT8U(buf, len, tmp_8u);
|
||||
//电池模块SOH
|
||||
tmp_8u = (uint8_t)(bms_get_soh()/100);
|
||||
WRITE_LT_INT8U(buf, len, tmp_8u);
|
||||
bsp_can_ext_data_sync_send(can, 0x42100000, buf, len);
|
||||
}
|
||||
|
||||
void bcu_send_0x42200000(can_dev_e can)
|
||||
{
|
||||
uint8_t len = 0, buf[8];
|
||||
uint16_t tmp_16u;
|
||||
|
||||
//充电截止电压
|
||||
tmp_16u = get_eeprom_data(kEep_ChgHTVoltHTAlarm1, kEepromDataType_Full);
|
||||
WRITE_LT_INT16U(buf, len, tmp_16u);
|
||||
//放点截止电压
|
||||
tmp_16u = get_eeprom_data(kEep_DisLTVoltHTAlarm1, kEepromDataType_Full);
|
||||
WRITE_LT_INT16U(buf, len, tmp_16u);
|
||||
//最大充电电流
|
||||
tmp_16u = bms_get_sop_data(kSopData_ChgCur);
|
||||
WRITE_LT_INT16U(buf, len, tmp_16u);
|
||||
//最大放电电流
|
||||
tmp_16u = bms_get_sop_data(kSopData_DisCur);
|
||||
WRITE_LT_INT16U(buf, len, tmp_16u);
|
||||
bsp_can_ext_data_sync_send(can, 0x42200000, buf, len);
|
||||
}
|
||||
|
||||
void bcu_send_0x42300000(can_dev_e can)
|
||||
{
|
||||
uint8_t len = 0, buf[8];
|
||||
uint16_t tmp_16u;
|
||||
|
||||
//最高单体电池电压
|
||||
tmp_16u = bms_get_statistic_data(kStatisticData_MaxVolt);
|
||||
WRITE_LT_INT16U(buf, len, tmp_16u);
|
||||
//最低单体电池电压
|
||||
tmp_16u = bms_get_statistic_data(kStatisticData_MinVolt);
|
||||
WRITE_LT_INT16U(buf, len, tmp_16u);
|
||||
//最高单体电池电压编号
|
||||
tmp_16u = bms_get_statistic_data(kStatisticData_MaxVoltIdx) + 1;
|
||||
WRITE_LT_INT16U(buf, len, tmp_16u);
|
||||
//最低单体电池电压编号
|
||||
tmp_16u = bms_get_statistic_data(kStatisticData_MinVoltIdx) + 1;
|
||||
WRITE_LT_INT16U(buf, len, tmp_16u);
|
||||
bsp_can_ext_data_sync_send(can, 0x42300000, buf, len);
|
||||
}
|
||||
|
||||
void bcu_send_0x42400000(can_dev_e can)
|
||||
{
|
||||
uint8_t len = 0, buf[8];
|
||||
uint16_t tmp_16u;
|
||||
|
||||
//最高单体电池温度
|
||||
tmp_16u = bms_get_statistic_data(kStatisticData_MaxTemp);
|
||||
WRITE_LT_INT16U(buf, len, tmp_16u);
|
||||
//最低单体电池温度
|
||||
tmp_16u = bms_get_statistic_data(kStatisticData_MinTemp);
|
||||
WRITE_LT_INT16U(buf, len, tmp_16u);
|
||||
//最高单体电池温度编号
|
||||
tmp_16u = bms_get_statistic_data(kStatisticData_MaxTempIdx) + 1;
|
||||
WRITE_LT_INT16U(buf, len, tmp_16u);
|
||||
//最低单体电池温度编号
|
||||
tmp_16u = bms_get_statistic_data(kStatisticData_MinTempIdx) + 1;
|
||||
WRITE_LT_INT16U(buf, len, tmp_16u);
|
||||
bsp_can_ext_data_sync_send(can, 0x42400000, buf, len);
|
||||
}
|
||||
|
||||
void bcu_send_0x42500000(can_dev_e can)
|
||||
{
|
||||
uint8_t len = 0, buf[8];
|
||||
uint16_t tmp_16u;
|
||||
uint8_t tmp_8u, status;
|
||||
uint16_t temp_second;
|
||||
uint16_t temp_third;
|
||||
|
||||
/* 基本状态
|
||||
pylon bluesun
|
||||
0 休眠 初始化
|
||||
1 充电 待机
|
||||
2 放电 充电
|
||||
3 搁置 放电
|
||||
*/
|
||||
switch(bms_get_run_status())
|
||||
{
|
||||
case kRunStatus_Standby:
|
||||
status = 0;
|
||||
break;
|
||||
case kRunStatus_Chg:
|
||||
status = 1;
|
||||
break;
|
||||
case kRunStatus_Dis:
|
||||
status = 2;
|
||||
break;
|
||||
case kRunStatus_PwrOff:
|
||||
status = 3;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
//基本状态
|
||||
tmp_8u = status;
|
||||
WRITE_LT_INT8U(buf, len, tmp_8u);
|
||||
//循环周期
|
||||
tmp_16u = bms_get_cycle();
|
||||
WRITE_LT_INT16U(buf, len, tmp_16u);
|
||||
//故障--无
|
||||
tmp_8u = 0;
|
||||
WRITE_LT_INT8U(buf, len, tmp_8u);
|
||||
//告警--二三级放入告警中
|
||||
//每个告警的位的位置需要测一下
|
||||
|
||||
temp_second = set_bit_based_on_source_pylon(status, kFaultLevel_Second);
|
||||
temp_third = set_bit_based_on_source_pylon(status, kFaultLevel_Third);
|
||||
|
||||
tmp_16u = temp_second | temp_third;
|
||||
WRITE_LT_INT16U(buf, len, tmp_16u);
|
||||
//保护--一级放入保护中
|
||||
//每个告警的位的位置需要测一下
|
||||
|
||||
tmp_16u = set_bit_based_on_source_pylon(status, kFaultLevel_First);
|
||||
|
||||
WRITE_LT_INT16U(buf, len, tmp_16u);
|
||||
bsp_can_ext_data_sync_send(can, 0x42500000, buf, len);
|
||||
}
|
||||
|
||||
void bcu_send_0x42600000(can_dev_e can)
|
||||
{
|
||||
uint8_t len = 0, buf[8];
|
||||
uint16_t tmp_16u;
|
||||
|
||||
//最高电池模块电压--无,用单体平均电压×16代替
|
||||
tmp_16u = bms_get_statistic_data(kStatisticData_AvgVolt) * 16;
|
||||
WRITE_LT_INT16U(buf, len, tmp_16u);
|
||||
//最低电池模块电压--无,用单体平均电压×16代替
|
||||
tmp_16u = bms_get_statistic_data(kStatisticData_AvgVolt) * 16;
|
||||
WRITE_LT_INT16U(buf, len, tmp_16u);
|
||||
//最高电池模块电压编号--无,用单体从机号代替
|
||||
tmp_16u = bms_get_statistic_data(kStatisticData_MaxVoltBmuIdx) + 1;
|
||||
WRITE_LT_INT16U(buf, len, tmp_16u);
|
||||
//最低电池模块电压编号--无,用单体从机号代替
|
||||
tmp_16u = bms_get_statistic_data(kStatisticData_MinVoltBmuIdx) + 1;
|
||||
WRITE_LT_INT16U(buf, len, tmp_16u);
|
||||
bsp_can_ext_data_sync_send(can, 0x42600000, buf, len);
|
||||
}
|
||||
|
||||
void bcu_send_0x42700000(can_dev_e can)
|
||||
{
|
||||
uint8_t len = 0, buf[8];
|
||||
uint16_t tmp_16u;
|
||||
|
||||
//最高电池模块温度--无,用最高单体温度代替
|
||||
tmp_16u = bms_get_statistic_data(kStatisticData_MaxTemp);
|
||||
WRITE_LT_INT16U(buf, len, tmp_16u);
|
||||
//最低电池模块温度--无,用最低单体温度代替
|
||||
tmp_16u = bms_get_statistic_data(kStatisticData_MinTemp);
|
||||
WRITE_LT_INT16U(buf, len, tmp_16u);
|
||||
//最高电池模块温度编号--无,用单体从机号代替
|
||||
tmp_16u = bms_get_statistic_data(kStatisticData_MaxTempBmuIdx) + 1;
|
||||
WRITE_LT_INT16U(buf, len, tmp_16u);
|
||||
//最低电池模块温度编号--无,用单体从机号代替
|
||||
tmp_16u = bms_get_statistic_data(kStatisticData_MinTempBmuIdx) + 1;
|
||||
WRITE_LT_INT16U(buf, len, tmp_16u);
|
||||
bsp_can_ext_data_sync_send(can, 0x42700000, buf, len);
|
||||
}
|
||||
|
||||
void bcu_send_0x42800000(can_dev_e can)
|
||||
{
|
||||
uint8_t len = 0, buf[8];
|
||||
uint16_t tmp_16u;
|
||||
uint8_t tmp_8u;
|
||||
uint16_t bms_stu = 0;
|
||||
|
||||
if(bms_get_run_status() == kRunStatus_Init)
|
||||
{
|
||||
bms_stu = 0;
|
||||
}
|
||||
else if(bms_get_run_status() == kRunStatus_Standby)
|
||||
{
|
||||
bms_stu |= 0x1;
|
||||
}
|
||||
else if(bms_get_run_status() == kRunStatus_Chg)
|
||||
{
|
||||
bms_stu |= 0x2;
|
||||
}
|
||||
else if(bms_get_run_status() == kRunStatus_Dis)
|
||||
{
|
||||
bms_stu |= 0x3;
|
||||
}
|
||||
if(bms_get_signal(kSignalIdx_ForbidChg) == kSignalStatus_High)
|
||||
{
|
||||
bms_stu |= 0x10;
|
||||
}
|
||||
if(bms_get_signal(kSignalIdx_ForbidDis) == kSignalStatus_High)
|
||||
{
|
||||
bms_stu |= 0x20;
|
||||
}
|
||||
|
||||
//禁止充电标志
|
||||
|
||||
if ((bms_stu & 0x10) >> 4 == 1)
|
||||
{
|
||||
tmp_8u = 0xAA;
|
||||
}
|
||||
else
|
||||
{
|
||||
tmp_8u = 0;
|
||||
}
|
||||
WRITE_LT_INT8U(buf, len, tmp_8u);
|
||||
//禁止放电标志
|
||||
if ((bms_stu & 0x10) >> 5 == 1)
|
||||
{
|
||||
tmp_8u = 0xAA;
|
||||
}
|
||||
else
|
||||
{
|
||||
tmp_8u = 0;
|
||||
}
|
||||
WRITE_LT_INT8U(buf, len, tmp_8u);
|
||||
//预留
|
||||
tmp_16u = 0;
|
||||
WRITE_LT_INT16U(buf, len, tmp_16u);
|
||||
//预留
|
||||
tmp_16u = 0;
|
||||
WRITE_LT_INT16U(buf, len, tmp_16u);
|
||||
//预留
|
||||
tmp_16u = 0;
|
||||
WRITE_LT_INT16U(buf, len, tmp_16u);
|
||||
|
||||
bsp_can_ext_data_sync_send(can, 0x42800000, buf, len);
|
||||
}
|
||||
|
||||
void bcu_send_0x73100000(can_dev_e can)
|
||||
{
|
||||
uint8_t len = 0, buf[8];
|
||||
uint16_t tmp_16u;
|
||||
uint8_t tmp_8u;
|
||||
|
||||
//Hardware Version
|
||||
tmp_8u = 1;
|
||||
WRITE_LT_INT8U(buf, len, tmp_8u);
|
||||
//预留
|
||||
tmp_8u = 1;
|
||||
WRITE_LT_INT8U(buf, len, tmp_8u);
|
||||
//硬件版本-V
|
||||
tmp_8u = 1;
|
||||
WRITE_LT_INT8U(buf, len, tmp_8u);
|
||||
//硬件版本-R
|
||||
tmp_8u = 1;
|
||||
WRITE_LT_INT8U(buf, len, tmp_8u);
|
||||
//软件版本-V(主版本Major)
|
||||
tmp_8u = 1;
|
||||
WRITE_LT_INT8U(buf, len, tmp_8u);
|
||||
//软件版本-V(子版本Minor)
|
||||
tmp_8u = 1;
|
||||
WRITE_LT_INT8U(buf, len, tmp_8u);
|
||||
//开发主版本
|
||||
tmp_8u = 1;
|
||||
WRITE_LT_INT8U(buf, len, tmp_8u);
|
||||
//开发子版本
|
||||
tmp_8u = 1;
|
||||
WRITE_LT_INT8U(buf, len, tmp_8u);
|
||||
|
||||
bsp_can_ext_data_sync_send(can, 0x73100000, buf, len);
|
||||
}
|
||||
|
||||
void bcu_can_send_pylon(uint32_t base_time,can_dev_e can)
|
||||
{
|
||||
static uint32_t dly = 0;
|
||||
|
||||
dly += base_time;
|
||||
if((dly % 100) == 0)
|
||||
{
|
||||
dly = 0;
|
||||
bcu_send_0x42100000(can);
|
||||
bcu_send_0x42200000(can);
|
||||
bcu_send_0x42300000(can);
|
||||
bcu_send_0x42400000(can);
|
||||
bcu_send_0x42500000(can);
|
||||
bcu_send_0x42600000(can);
|
||||
bcu_send_0x42700000(can);
|
||||
bcu_send_0x42800000(can);
|
||||
bcu_send_0x73100000(can);
|
||||
}
|
||||
}
|
||||
|
||||
uint16_t set_bit_based_on_source_pylon(uint8_t status, FaultLevel alarmLevel)
|
||||
{
|
||||
uint16_t tmp_16u = 0;
|
||||
if (KIT_GET_BIT_32(bms_get_fault_single_bit(0 , alarmLevel), 0)) //一级总压过压--电池组充电高压保护
|
||||
{
|
||||
if (status == 1)
|
||||
{
|
||||
KIT_SET_BIT_MASK_32(tmp_16u, 3);
|
||||
//tmp_16u = set_bit_based_on_source_pylon(bms_get_fault_single_bit(0 , kFaultLevel_First), 0, tmp_16u, 3);
|
||||
}
|
||||
}
|
||||
if (KIT_GET_BIT_32(bms_get_fault_single_bit(0 , alarmLevel), 1)) //一级总压欠压--电池组放电低压保护
|
||||
{
|
||||
if (status == 2)
|
||||
{
|
||||
KIT_SET_BIT_MASK_32(tmp_16u, 2);
|
||||
//tmp_16u = set_bit_based_on_source_pylon(bms_get_fault_single_bit(0 , kFaultLevel_First), 1, tmp_16u, 2);
|
||||
}
|
||||
}
|
||||
|
||||
if (KIT_GET_BIT_32(bms_get_fault_single_bit(0 , alarmLevel), 2)) //一级单体过压--电池单体高压保护
|
||||
{
|
||||
KIT_SET_BIT_MASK_32(tmp_16u, 1);
|
||||
//tmp_16u = set_bit_based_on_source_pylon(bms_get_fault_single_bit(0 , kFaultLevel_First), 2, tmp_16u, 1);
|
||||
}
|
||||
if (KIT_GET_BIT_32(bms_get_fault_single_bit(0 , alarmLevel), 3)) //一级单体欠压--电池单体低压保护
|
||||
{
|
||||
KIT_SET_BIT_MASK_32(tmp_16u, 0);
|
||||
//tmp_16u = set_bit_based_on_source_pylon(bms_get_fault_single_bit(0 , kFaultLevel_First), 3, tmp_16u, 0);
|
||||
}
|
||||
|
||||
if (KIT_GET_BIT_32(bms_get_fault_single_bit(0 , alarmLevel), 4)) //一级单体过温--充电高温保护 && 放电高温保护
|
||||
{
|
||||
if (status == 1)
|
||||
{
|
||||
KIT_SET_BIT_MASK_32(tmp_16u, 5);
|
||||
//tmp_16u = set_bit_based_on_source_pylon(bms_get_fault_single_bit(0 , kFaultLevel_First), 4, tmp_16u, 5);
|
||||
}
|
||||
else if (status == 2)
|
||||
{
|
||||
KIT_SET_BIT_MASK_32(tmp_16u, 7);
|
||||
//tmp_16u = set_bit_based_on_source_pylon(bms_get_fault_single_bit(0 , kFaultLevel_First), 4, tmp_16u, 7);
|
||||
}
|
||||
}
|
||||
if (KIT_GET_BIT_32(bms_get_fault_single_bit(0 , alarmLevel), 5)) //一级单体低温--充电低温保护 && 放电低温保护
|
||||
{
|
||||
if (status == 1)
|
||||
{
|
||||
KIT_SET_BIT_MASK_32(tmp_16u, 4);
|
||||
//tmp_16u = set_bit_based_on_source_pylon(bms_get_fault_single_bit(0 , kFaultLevel_First), 5, tmp_16u, 4);
|
||||
}
|
||||
else if (status == 2)
|
||||
{
|
||||
KIT_SET_BIT_MASK_32(tmp_16u, 6);
|
||||
//tmp_16u = set_bit_based_on_source_pylon(bms_get_fault_single_bit(0 , kFaultLevel_First), 5, tmp_16u, 6);
|
||||
}
|
||||
}
|
||||
|
||||
if (KIT_GET_BIT_32(bms_get_fault_single_bit(0 , alarmLevel), 8)) //一级电流过大--电池组充电过流保护 && 电池组放电过流保护
|
||||
{
|
||||
if (status == 1)
|
||||
{
|
||||
KIT_SET_BIT_MASK_32(tmp_16u, 8);
|
||||
//tmp_16u = set_bit_based_on_source_pylon(bms_get_fault_single_bit(0 , kFaultLevel_First), 8, tmp_16u, 8);
|
||||
}
|
||||
else if (status == 2)
|
||||
{
|
||||
KIT_SET_BIT_MASK_32(tmp_16u, 9);
|
||||
//tmp_16u = set_bit_based_on_source_pylon(bms_get_fault_single_bit(0 , kFaultLevel_First), 8, tmp_16u, 9);
|
||||
}
|
||||
}
|
||||
|
||||
return tmp_16u;
|
||||
}
|
||||
|
||||
//pylon接收函数,休眠和唤醒控制,充电放电命令
|
||||
void bcu_can_receive_pylon(CanMsg *msg, can_dev_e can)
|
||||
{
|
||||
uint8_t code = 0,value = 0, statusChg = 0, statusDischg = 0;
|
||||
if(msg->id.value == 0x620)
|
||||
{
|
||||
code = msg->data.byte[0];
|
||||
if(code == 0x55)
|
||||
{
|
||||
//控制设备进入休眠状态,断开总正总负继电器
|
||||
bms_crtl_do_status(kDoType_Positive, kDoCtrlStatus_Off, 100);
|
||||
bms_crtl_do_status(kDoType_Negative, kDoCtrlStatus_Off, 100);
|
||||
}
|
||||
else if (code == 0xAA)
|
||||
{
|
||||
//控制设备退出休眠状态,闭合总正总负继电器
|
||||
bms_crtl_do_status(kDoType_Positive, kDoCtrlStatus_On, 100);
|
||||
bms_crtl_do_status(kDoType_Negative, kDoCtrlStatus_On, 100);
|
||||
}
|
||||
}
|
||||
|
||||
if(msg->id.value == 0x621)
|
||||
{
|
||||
statusChg = msg->data.byte[0];
|
||||
statusDischg = msg->data.byte[1];
|
||||
if(statusChg == 0xAA)
|
||||
{
|
||||
//充电命令,闭合总正总负继电器
|
||||
bms_crtl_do_status(kDoType_Positive, kDoCtrlStatus_On, 100);
|
||||
bms_crtl_do_status(kDoType_Negative, kDoCtrlStatus_On, 100);
|
||||
}
|
||||
else if (statusDischg == 0xAA)
|
||||
{
|
||||
//放电命令,闭合总正总负继电器
|
||||
bms_crtl_do_status(kDoType_Positive, kDoCtrlStatus_On, 100);
|
||||
bms_crtl_do_status(kDoType_Negative, kDoCtrlStatus_On, 100);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void protocol_pylon_can_init(can_dev_e can)
|
||||
{
|
||||
protocol_can_set_call(can, bcu_can_receive_pylon, bcu_can_send_pylon, NULL);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ typedef enum
|
|||
{
|
||||
kCanProtocal_None, //使用CAN并机的时候需要将外can协议设置为闲置
|
||||
kCanProtocal_Bcu,
|
||||
kCanProtocal_Bcu_invt, //英威腾协议
|
||||
kCanProtocal_Bcu_Pylon, //pylon协议
|
||||
kCanProtocal_End,
|
||||
}CanProtocal;
|
||||
|
||||
|
@ -61,6 +61,7 @@ CanProtocalCall protocol_can_init_array[kCanProtocal_End] =
|
|||
{
|
||||
protocol_can_none_init,
|
||||
protocol_can_bcu_init,
|
||||
protocol_pylon_can_init,
|
||||
};
|
||||
|
||||
/************************************************modbus*****************************************************/
|
||||
|
@ -141,7 +142,7 @@ void protocol_comm_init(void)
|
|||
{
|
||||
protocol = get_eeprom_data(kEep_InterCanProtocol_Baudrate + i, kEepromDataType_High);
|
||||
//测试
|
||||
protocol = 1;
|
||||
//protocol = 1;
|
||||
if((protocol < kCanProtocal_End) && (protocol_can_init_array[protocol] != NULL))
|
||||
{
|
||||
protocol_can_init_array[protocol](i);
|
||||
|
|
|
@ -10,6 +10,7 @@ extern "C" {
|
|||
#include "bsp_modbus.h"
|
||||
|
||||
#include "drv_can.h"
|
||||
#include "fault_manager.h"
|
||||
|
||||
|
||||
typedef void (*CanCommReceive)(CanMsg *msg, can_dev_e can);
|
||||
|
@ -30,8 +31,11 @@ void protocol_can_set_call(can_dev_e can, CanCommReceive rx, CanCommSend tx, Can
|
|||
void protocol_modbus_bcu_init(void * const mb_item,uint16_t addr);
|
||||
void protocol_modbus_demo(void * const mb_item,uint16_t addr);
|
||||
void protocol_can_bcu_init(can_dev_e can);
|
||||
void protocol_pylon_can_init(can_dev_e can);
|
||||
void protocol_can_invt_pcs_init(can_dev_e can);
|
||||
|
||||
//根据位,转换告警的位
|
||||
uint16_t set_bit_based_on_source_pylon(uint8_t status, FaultLevel alarmLevel);
|
||||
|
||||
void bms_analyse_model_data(void);
|
||||
uint16_t bms_read_model_data(uint8_t *buf);
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,40 +1,45 @@
|
|||
[BREAKPOINTS]
|
||||
ForceImpTypeAny = 0
|
||||
FForceImpTypeAny = 0
|
||||
ShowInfoWin = 1
|
||||
EnableFlashBP = 2
|
||||
BPDuringExecution = 0
|
||||
orceImpTypeAny = 0
|
||||
[CFI]
|
||||
CFISize = 0x00
|
||||
CCFISize = 0x00
|
||||
CFIAddr = 0x00
|
||||
FISize = 0x00
|
||||
[CPU]
|
||||
MonModeVTableAddr = 0xFFFFFFFF
|
||||
MOverrideMemMap = 0
|
||||
AllowSimulation = 1
|
||||
ScriptFile=""
|
||||
onModeVTableAddr = 0xFFFFFFFF
|
||||
MonModeDebug = 0
|
||||
MaxNumAPs = 0
|
||||
LowPowerHandlingMode = 0
|
||||
OverrideMemMap = 0
|
||||
AllowSimulation = 1
|
||||
ScriptFile=""
|
||||
[FLASH]
|
||||
EraseType = 0x00
|
||||
CacheExcludeSize = 0x00
|
||||
ECacheExcludeSize = 0x00
|
||||
CacheExcludeAddr = 0x00
|
||||
MinNumBytesFlashDL = 0
|
||||
SkipProgOnCRCMatch = 1
|
||||
VerifyDownload = 1
|
||||
AllowCaching = 1
|
||||
EnableFlashDL = 2
|
||||
Override = 0
|
||||
Device="ARM7"
|
||||
Override = 1
|
||||
Device="Unspecified"
|
||||
raseType = 0x00
|
||||
[GENERAL]
|
||||
WorkRAMSize = 0x00
|
||||
WWorkRAMSize = 0x00
|
||||
WorkRAMAddr = 0x00
|
||||
RAMUsageLimit = 0x00
|
||||
orkRAMSize = 0x00
|
||||
[SWO]
|
||||
SWOLogFile=""
|
||||
SSWOLogFile=""
|
||||
WOLogFile=""
|
||||
[MEM]
|
||||
RdOverrideOrMask = 0x00
|
||||
RRdOverrideOrMask = 0x00
|
||||
RdOverrideAndMask = 0xFFFFFFFF
|
||||
RdOverrideAddr = 0xFFFFFFFF
|
||||
WrOverrideOrMask = 0x00
|
||||
WrOverrideAndMask = 0xFFFFFFFF
|
||||
WrOverrideAddr = 0xFFFFFFFF
|
||||
dOverrideOrMask = 0x00
|
||||
|
|
|
@ -10,15 +10,15 @@
|
|||
<TargetName>stm32f407</TargetName>
|
||||
<ToolsetNumber>0x4</ToolsetNumber>
|
||||
<ToolsetName>ARM-ADS</ToolsetName>
|
||||
<pArmCC>5060960::V5.06 update 7 (build 960)::.\ARM_Compiler_5.06u7</pArmCC>
|
||||
<pCCUsed>5060960::V5.06 update 7 (build 960)::.\ARM_Compiler_5.06u7</pCCUsed>
|
||||
<pArmCC>5050106::V5.05 update 1 (build 106)::ARMCC</pArmCC>
|
||||
<pCCUsed>5050106::V5.05 update 1 (build 106)::ARMCC</pCCUsed>
|
||||
<uAC6>0</uAC6>
|
||||
<TargetOption>
|
||||
<TargetCommonOption>
|
||||
<Device>STM32F407VGTx</Device>
|
||||
<Vendor>STMicroelectronics</Vendor>
|
||||
<PackID>Keil.STM32F4xx_DFP.3.0.0</PackID>
|
||||
<PackURL>https://www.keil.com/pack/</PackURL>
|
||||
<PackID>Keil.STM32F4xx_DFP.2.16.0</PackID>
|
||||
<PackURL>http://www.keil.com/pack/</PackURL>
|
||||
<Cpu>IRAM(0x20000000,0x00020000) IRAM2(0x10000000,0x00010000) IROM(0x08000000,0x00100000) CPUTYPE("Cortex-M4") FPU2 CLOCK(12000000) ELITTLE</Cpu>
|
||||
<FlashUtilSpec></FlashUtilSpec>
|
||||
<StartupFile></StartupFile>
|
||||
|
|
|
@ -518,8 +518,8 @@ void SystemInit(void)
|
|||
|
||||
/* Configure the System clock source, PLL Multiplier and Divider factors,
|
||||
AHB/APBx prescalers and Flash settings ----------------------------------*/
|
||||
//SetSysClock();
|
||||
SystemClock_Config();
|
||||
SetSysClock();
|
||||
//SystemClock_Config();
|
||||
|
||||
/* Configure the Vector Table location add offset address ------------------*/
|
||||
#ifdef VECT_TAB_SRAM
|
||||
|
|
Loading…
Reference in New Issue