提交 aa721fa9 作者: wysheng

获取模块输入交流电压

上级 7c6a81bb
......@@ -60,6 +60,7 @@ extern osMessageQId DcModeMsg;
void SendCmdToDcModule(u8 addr, u8 cmd);
void SendDataToDcModule(u8 addr, u8 cmd, u32 volt, u32 current);
extern void GetNXRAcVoltMsg(u32 addr);
void DcModuleManageProcess_SmartAllocation(void)
{
......@@ -146,6 +147,16 @@ void DcModuleManageProcess_SmartAllocation(void)
Flag = Flag << 1;
}
if(0x0002 & DcModuleManage_All.OnlineFlag)
{
static u32 GetAcVoltTick = 0;
if(GetSystemTick() - GetAcVoltTick > 1000)
{
GetAcVoltTick = GetSystemTick();
GetNXRAcVoltMsg(1);
}
}
for (i = 0; i < DcModuleGroupSize; i++)
{
......
......@@ -35,7 +35,8 @@ StructDcModuleCtrl DcModuleCtrl_B;
StructDcModuleCtrl DcModuleCtrl_ALL;
void DcModeleRelayInit(void);
extern void GetNXRAcVolt(CanRxMsg* RxMsg);
extern void GetNXRAcVoltMsg(u32 addr);
void DcModuleRxIrqHandle(void)
{
......@@ -43,14 +44,6 @@ void DcModuleRxIrqHandle(void)
u8 IrSta = 0;
StructDcModuleStatus Data;
u8 RecvFlag;
Union1939Id Id1939 =
{
.Mult = 0,
};
UnionYouExtId CommId =
{
.Mult = 0,
};
IrSta = MCP2515_ReadStatus();
......@@ -58,8 +51,7 @@ void DcModuleRxIrqHandle(void)
{
RecvFlag = MCP2515_Receive(0, &RxMsg);
MCP2515_BitModify(CANINTF, 0x01, 0x00);
Id1939.Mult = RxMsg.ExtId;
CommId.Mult = RxMsg.ExtId;
if (TRUE == RecvFlag)
{
......@@ -76,7 +68,7 @@ void DcModuleRxIrqHandle(void)
Data.RecvTime = GetSystemTick();
DcModuleStatus_ALL[Data.Id] = Data;
}
GetNXRAcVolt(&RxMsg);
}
}
}
......@@ -84,8 +76,6 @@ void DcModuleRxIrqHandle(void)
{
RecvFlag = MCP2515_Receive(1, &RxMsg);
MCP2515_BitModify(CANINTF, 0x02, 0x00);
Id1939.Mult = RxMsg.ExtId;
CommId.Mult = RxMsg.ExtId;
if (TRUE == RecvFlag)
{
......@@ -102,7 +92,7 @@ void DcModuleRxIrqHandle(void)
Data.RecvTime = GetSystemTick();
DcModuleStatus_ALL[Data.Id] = Data;
}
GetNXRAcVolt(&RxMsg);
}
}
}
......@@ -567,3 +557,66 @@ void DcModeleRelayInit()
GPIO_ResetBits(RELAY_K9K10_Port,RELAY_K9K10_Pin);
}
void GetNXRAcVoltMsg(u32 addr)
{
StructDcModuleSend DataSend = {0};
u16 reg = 0;
DataSend.Id = 0x680780 + (addr<<11);
DataSend.Len = 8;
DataSend.Data[0] = 0x10;
DataSend.Data[1] = 0x00;
DataSend.Data[2] = 0x00;
DataSend.Data[3] = 0x00;
DataSend.Data[4] = 0x00;
DataSend.Data[5] = 0x00;
DataSend.Data[6] = 0x00;
DataSend.Data[7] = 0x00;
reg = 0x000C; //A相
DataSend.Data[2] = reg>>8;
DataSend.Data[3] = reg;
if (pdTRUE != xQueueSend(DcModeMsg, &DataSend, 0))
{
//osDelay(10);
}
reg = 0x000D; //B相
DataSend.Data[2] = reg>>8;
DataSend.Data[3] = reg;
if (pdTRUE != xQueueSend(DcModeMsg, &DataSend, 0))
{
//osDelay(10);
}
reg = 0x000E; //C相
DataSend.Data[2] = reg>>8;
DataSend.Data[3] = reg;
if (pdTRUE != xQueueSend(DcModeMsg, &DataSend, 0))
{
//osDelay(10);
}
}
void GetNXRAcVolt(CanRxMsg* RxMsg)
{
if ((0x6f8000 == (RxMsg->ExtId & 0x1FFFF807)) \
/*&& (0x41 == RxMsg->Data[0] || 0x42 == RxMsg->Data[0]) \*/
&& (0xf0 == RxMsg->Data[1]))
{
if(0x0C == RxMsg->Data[3])
{
//A
}
else if(0x0D == RxMsg->Data[3])
{
//B
}
else if(0x0E == RxMsg->Data[3])
{
//C
}
}
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论