适配Ew开头的协议
注释iic相关命令,添加命令jwtcrc用于验证jwt程序是否正常 EW_Updata 添加错误12表示小板中无jwt程序
This commit is contained in:
@@ -1,14 +1,12 @@
|
||||
#include "driver/ewdriver.h"
|
||||
#include "base/define.h"
|
||||
#include "base/delay.h"
|
||||
//#include "console_usart.h"
|
||||
#include "base/utility.h"
|
||||
//#include "usartapp.h"
|
||||
//#include "arrayfifo.h"
|
||||
//#include "YeCommProtocol.h"
|
||||
#include "hardware/power.h"
|
||||
#include "elec_io.h"
|
||||
|
||||
#include "mymisc.h"
|
||||
|
||||
#pragma pack(1)
|
||||
typedef struct{
|
||||
uint8_t head[2];//<2F>̶<EFBFBD>ͷ<EFBFBD><CDB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>豸
|
||||
@@ -100,7 +98,6 @@ static void EW_AckCmd(EWCmd_un* cmd_un)
|
||||
uc_crc = CheckCRC_8(cmd_un->buf,cmd_un->head.frame_len-1);
|
||||
cmd_un->buf[cmd_un->head.frame_len-1] = uc_crc;
|
||||
ConsoleUsart_send_bytes(cmd_un->buf,cmd_un->head.frame_len);
|
||||
//ConsoleUsart0DMA_send_bytes(cmd_un->yecmdbuf,cmd_un->head.frame_len,10);
|
||||
}
|
||||
|
||||
static void EW_BusCmd01(EWCmd_un* cmd_un)
|
||||
@@ -119,6 +116,16 @@ static void EW_BusCmd01(EWCmd_un* cmd_un)
|
||||
cmd_un->head.frame_len++;
|
||||
EW_AckCmd(cmd_un);
|
||||
}
|
||||
|
||||
|
||||
static void DoHeartBeat(void);
|
||||
static void heart_beat_fun(void *t)
|
||||
{
|
||||
if(heard_beat_flag){
|
||||
DoHeartBeat();
|
||||
later_execute(heart_beat_fun,0,1000);
|
||||
}
|
||||
}
|
||||
static void EW_HeartBeatCmd02(EWCmd_un* cmd_un)
|
||||
{
|
||||
heard_beat_flag = cmd_un->heartbeat02.oper_cmd;
|
||||
@@ -127,6 +134,9 @@ static void EW_HeartBeatCmd02(EWCmd_un* cmd_un)
|
||||
cmd_un->buf[cmd_un->head.frame_len] = 0;
|
||||
cmd_un->head.frame_len++;
|
||||
EW_AckCmd(cmd_un);
|
||||
if(heard_beat_flag){
|
||||
later_execute(heart_beat_fun,0,1000);
|
||||
}
|
||||
}
|
||||
extern uint16_t EW_DMOD_READ_Timeout;
|
||||
static void EW_RWCmd03(EWCmd_un* cmd_un)
|
||||
@@ -212,7 +222,7 @@ void EW_DoCmd(EWCmd_un* cmd_un)
|
||||
}
|
||||
|
||||
|
||||
static void DoHeartBeat()
|
||||
static void DoHeartBeat(void)
|
||||
{
|
||||
uint8_t uc_crc;
|
||||
ew_beat_ack.oper_cmd = 1;
|
||||
@@ -227,52 +237,6 @@ static void DoHeartBeat()
|
||||
|
||||
}
|
||||
|
||||
void EWUsartApp_Task(void* param)
|
||||
{
|
||||
rt_uint32_t event;
|
||||
uint32_t idle_count = 0;
|
||||
UNUSED(param);
|
||||
rt_event_init(&ew_usart0_rx_event, "ew_usart_rx_e", RT_IPC_FLAG_PRIO);
|
||||
ew_app_rec_flag = 0;
|
||||
|
||||
while(1)
|
||||
{
|
||||
if(idle_count > 9)
|
||||
{
|
||||
idle_count = 0;
|
||||
if(heard_beat_flag > 0)
|
||||
{
|
||||
DoHeartBeat();
|
||||
}
|
||||
}
|
||||
|
||||
if(rt_event_recv(&ew_usart0_rx_event, UART_MC_FRAME_EVENT,RT_EVENT_FLAG_OR | RT_EVENT_FLAG_CLEAR,100, &event) != RT_EOK)
|
||||
{
|
||||
idle_count++;
|
||||
continue;
|
||||
}
|
||||
|
||||
if((event & UART_MC_FRAME_EVENT) > 0)
|
||||
{
|
||||
ConsoleRxDisable();
|
||||
if(ewcmd_nu.buf[0]=='E' && ewcmd_nu.buf[1] == 'w')
|
||||
{
|
||||
|
||||
if(ewcmd_nu.buf[ewcmd_nu.head.frame_len-1] == CheckCRC_8(ewcmd_nu.buf,ewcmd_nu.head.frame_len-1))
|
||||
{
|
||||
|
||||
EW_DoCmd(&ewcmd_nu);
|
||||
}
|
||||
|
||||
}
|
||||
ConsoleRxEnable();
|
||||
ew_app_rec_flag = 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
@@ -293,8 +257,13 @@ void EW_UsartApp_Push_Cmd(uint8_t* buf, uint16_t len)
|
||||
len = sizeof(EWCmd_un);
|
||||
}
|
||||
rt_memcpy((void*)&ewcmd_nu,buf,len);
|
||||
rt_event_send(&ew_usart0_rx_event,UART_MC_FRAME_EVENT);//<2F><><EFBFBD>ʹ<EFBFBD><CDB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݽ<EFBFBD><DDBD><EFBFBD><EFBFBD>¼<EFBFBD>
|
||||
ew_app_rec_flag = 1;
|
||||
if(ewcmd_nu.buf[0]=='E' && ewcmd_nu.buf[1] == 'w')
|
||||
{
|
||||
if(ewcmd_nu.buf[ewcmd_nu.head.frame_len-1] == CheckCRC_8(ewcmd_nu.buf,ewcmd_nu.head.frame_len-1))
|
||||
{
|
||||
EW_DoCmd(&ewcmd_nu);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user