V2.13 使用新的can帧回复数据
解决ew自检模式 8导致小板死机的bug,自检返回值除以400,单位0.1ms
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -20,3 +20,4 @@ quest_info.txt
|
|||||||
bootcode.txt
|
bootcode.txt
|
||||||
*.uvoptx
|
*.uvoptx
|
||||||
build/
|
build/
|
||||||
|
doc/*.bin
|
||||||
|
@@ -377,7 +377,24 @@
|
|||||||
<Name></Name>
|
<Name></Name>
|
||||||
</SetRegEntry>
|
</SetRegEntry>
|
||||||
</TargetDriverDllRegistry>
|
</TargetDriverDllRegistry>
|
||||||
<Breakpoint/>
|
<Breakpoint>
|
||||||
|
<Bp>
|
||||||
|
<Number>0</Number>
|
||||||
|
<Type>0</Type>
|
||||||
|
<LineNumber>185</LineNumber>
|
||||||
|
<EnabledFlag>1</EnabledFlag>
|
||||||
|
<Address>134234652</Address>
|
||||||
|
<ByteObject>0</ByteObject>
|
||||||
|
<HtxType>0</HtxType>
|
||||||
|
<ManyObjects>0</ManyObjects>
|
||||||
|
<SizeOfObject>0</SizeOfObject>
|
||||||
|
<BreakByAccess>0</BreakByAccess>
|
||||||
|
<BreakIfRCount>1</BreakIfRCount>
|
||||||
|
<Filename>.\source\rt_thread\libcpu\arm\cortex-m3\context_rvds.S</Filename>
|
||||||
|
<ExecCommand></ExecCommand>
|
||||||
|
<Expression>\\checker_slave_app\source/rt_thread/libcpu/arm/cortex-m3/context_rvds.S\185</Expression>
|
||||||
|
</Bp>
|
||||||
|
</Breakpoint>
|
||||||
<WatchWindow1>
|
<WatchWindow1>
|
||||||
<Ww>
|
<Ww>
|
||||||
<count>0</count>
|
<count>0</count>
|
||||||
@@ -388,16 +405,16 @@
|
|||||||
<MemoryWindow1>
|
<MemoryWindow1>
|
||||||
<Mm>
|
<Mm>
|
||||||
<WinNumber>1</WinNumber>
|
<WinNumber>1</WinNumber>
|
||||||
<SubType>0</SubType>
|
<SubType>1</SubType>
|
||||||
<ItemText>0x0803b800</ItemText>
|
<ItemText>0x20002CE0</ItemText>
|
||||||
<AccSizeX>0</AccSizeX>
|
<AccSizeX>0</AccSizeX>
|
||||||
</Mm>
|
</Mm>
|
||||||
</MemoryWindow1>
|
</MemoryWindow1>
|
||||||
<MemoryWindow2>
|
<MemoryWindow2>
|
||||||
<Mm>
|
<Mm>
|
||||||
<WinNumber>2</WinNumber>
|
<WinNumber>2</WinNumber>
|
||||||
<SubType>1</SubType>
|
<SubType>8</SubType>
|
||||||
<ItemText>0x200028C8</ItemText>
|
<ItemText>0x20007088</ItemText>
|
||||||
<AccSizeX>0</AccSizeX>
|
<AccSizeX>0</AccSizeX>
|
||||||
</Mm>
|
</Mm>
|
||||||
</MemoryWindow2>
|
</MemoryWindow2>
|
||||||
@@ -605,18 +622,18 @@
|
|||||||
<Bp>
|
<Bp>
|
||||||
<Number>0</Number>
|
<Number>0</Number>
|
||||||
<Type>0</Type>
|
<Type>0</Type>
|
||||||
<LineNumber>108</LineNumber>
|
<LineNumber>185</LineNumber>
|
||||||
<EnabledFlag>1</EnabledFlag>
|
<EnabledFlag>1</EnabledFlag>
|
||||||
<Address>134339522</Address>
|
<Address>134234652</Address>
|
||||||
<ByteObject>0</ByteObject>
|
<ByteObject>0</ByteObject>
|
||||||
<HtxType>0</HtxType>
|
<HtxType>0</HtxType>
|
||||||
<ManyObjects>0</ManyObjects>
|
<ManyObjects>0</ManyObjects>
|
||||||
<SizeOfObject>0</SizeOfObject>
|
<SizeOfObject>0</SizeOfObject>
|
||||||
<BreakByAccess>0</BreakByAccess>
|
<BreakByAccess>0</BreakByAccess>
|
||||||
<BreakIfRCount>1</BreakIfRCount>
|
<BreakIfRCount>1</BreakIfRCount>
|
||||||
<Filename>D:\work\SVN\鍐夊窛\mcu_program\checker_slave\source\rt_thread\board.c</Filename>
|
<Filename>.\source\rt_thread\libcpu\arm\cortex-m3\context_rvds.S</Filename>
|
||||||
<ExecCommand></ExecCommand>
|
<ExecCommand></ExecCommand>
|
||||||
<Expression>\\checker_slave_app\source/rt_thread/board.c\108</Expression>
|
<Expression>\\checker_slave_app\source/rt_thread/libcpu/arm/cortex-m3/context_rvds.S\185</Expression>
|
||||||
</Bp>
|
</Bp>
|
||||||
</Breakpoint>
|
</Breakpoint>
|
||||||
<WatchWindow1>
|
<WatchWindow1>
|
||||||
|
Binary file not shown.
@@ -326,3 +326,8 @@
|
|||||||
V2.12 sn为0时如果未写流水号则报错
|
V2.12 sn为0时如果未写流水号则报错
|
||||||
2024.01.05
|
2024.01.05
|
||||||
收到广播命令时重新初始化定时器,can总线添加发送时长超时判断,超时后自动重发
|
收到广播命令时重新初始化定时器,can总线添加发送时长超时判断,超时后自动重发
|
||||||
|
2024.1.8
|
||||||
|
V2.13 使用新的can帧回复数据
|
||||||
|
解决ew自检模式 8导致小板死机的bug,自检返回值除以400,单位0.1ms
|
||||||
|
|
||||||
|
|
||||||
|
@@ -265,8 +265,8 @@ array_def *protm_decode(protu_def *p,array_def *data)
|
|||||||
int dst_addrs=arr_get(r,0)|(arr_get(r,1)<<8)|(arr_get(r,2)<<16);
|
int dst_addrs=arr_get(r,0)|(arr_get(r,1)<<8)|(arr_get(r,2)<<16);
|
||||||
if((dst_addrs&(1<<(self_addr-1)))!=0){
|
if((dst_addrs&(1<<(self_addr-1)))!=0){
|
||||||
p->silent=1;
|
p->silent=1;
|
||||||
// p->timer->write(p->timer,0);
|
p->timer->write(p->timer,0);
|
||||||
p->timer->init(p->timer);
|
// p->timer->init(p->timer);
|
||||||
p->rank=calc_bit_num(dst_addrs,self_addr-1);
|
p->rank=calc_bit_num(dst_addrs,self_addr-1);
|
||||||
p->num=calc_bit_num(dst_addrs,32);
|
p->num=calc_bit_num(dst_addrs,32);
|
||||||
arr_remove(r,0,3);
|
arr_remove(r,0,3);
|
||||||
|
@@ -304,6 +304,8 @@ int flash_write(uint8_t *addr,const uint8_t *data,int len)
|
|||||||
{
|
{
|
||||||
DBG_WARN("addr=%08x write/read data not equate.",addr);
|
DBG_WARN("addr=%08x write/read data not equate.",addr);
|
||||||
ret=3;
|
ret=3;
|
||||||
|
}else{
|
||||||
|
ret=0;
|
||||||
}
|
}
|
||||||
rt_mutex_release(s->mutex);
|
rt_mutex_release(s->mutex);
|
||||||
return ret;
|
return ret;
|
||||||
|
@@ -438,7 +438,7 @@ void EW_Test_VerifyThreedCode(void)
|
|||||||
@brief 自检
|
@brief 自检
|
||||||
@param 自检模式
|
@param 自检模式
|
||||||
@param1 自检时间ms
|
@param1 自检时间ms
|
||||||
@rtv 自检模式0x08的回读数据
|
@rtv 自检模式0x08的回读数据(0.1ms)
|
||||||
*/
|
*/
|
||||||
void EW_Test_CheckSelf()
|
void EW_Test_CheckSelf()
|
||||||
{
|
{
|
||||||
@@ -447,8 +447,10 @@ void EW_Test_CheckSelf()
|
|||||||
uint8_t uc_mode = checker_runcfg.params[0];
|
uint8_t uc_mode = checker_runcfg.params[0];
|
||||||
uc_rtv = EW_ChecSelf(checker_runcfg.netid,uc_mode,(uint8_t*)&ul_temp);
|
uc_rtv = EW_ChecSelf(checker_runcfg.netid,uc_mode,(uint8_t*)&ul_temp);
|
||||||
delay_ms(checker_runcfg.params[1]);
|
delay_ms(checker_runcfg.params[1]);
|
||||||
|
// 250ns 除以400 单位0.1ms
|
||||||
|
ul_temp/=400;
|
||||||
Checker_MaskResult(uc_rtv,checker_runcfg.task_info.runindex);
|
Checker_MaskResult(uc_rtv,checker_runcfg.task_info.runindex);
|
||||||
Checker_SetRtv((uint16_t*)ul_temp,checker_runcfg.rtv_count);
|
Checker_SetRtv((uint16_t*)&ul_temp,checker_runcfg.rtv_count);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@@ -4,6 +4,8 @@
|
|||||||
#include "rthw.h"
|
#include "rthw.h"
|
||||||
#include "elec_det.h"
|
#include "elec_det.h"
|
||||||
#include "board.h"
|
#include "board.h"
|
||||||
|
#include "core_delay.h"
|
||||||
|
|
||||||
CanRxMsg receive_message;
|
CanRxMsg receive_message;
|
||||||
static YeCanRxFrame_st canrx_st;
|
static YeCanRxFrame_st canrx_st;
|
||||||
static uint8_t Can_Device_ID = 0;
|
static uint8_t Can_Device_ID = 0;
|
||||||
@@ -61,18 +63,18 @@ void YeCanInit(void)
|
|||||||
Can_Device_ID = elec_local_addr();
|
Can_Device_ID = elec_local_addr();
|
||||||
|
|
||||||
yeid_un.Exide = 0;
|
yeid_un.Exide = 0;
|
||||||
yeid_un.yecanid.ACK = 0;
|
yeid_un.yecanid_old.ACK = 0;
|
||||||
yeid_un.yecanid.FunClass = 0;
|
yeid_un.yecanid_old.FunClass = 0;
|
||||||
yeid_un.yecanid.Reserve1 = 0;
|
yeid_un.yecanid_old.Reserve1 = 0;
|
||||||
yeid_un.yecanid.Reserve0 = 0;
|
yeid_un.yecanid_old.Reserve0 = 0;
|
||||||
yeid_un.yecanid.SegFlag = 0;
|
yeid_un.yecanid_old.SegFlag = 0;
|
||||||
yeid_un.yecanid.SegNum = 0;
|
yeid_un.yecanid_old.SegNum = 0;
|
||||||
yeid_un.yecanid.srcMACID = 0x00;
|
yeid_un.yecanid_old.srcMACID = 0x00;
|
||||||
|
|
||||||
yeid_un.yecanid.destMACID = 0x1F;
|
yeid_un.yecanid_old.destMACID = 0x1F;
|
||||||
ul_mask = GetCanFilter(yeid_un);
|
ul_mask = GetCanFilter(yeid_un);
|
||||||
ul_can_mask =ul_mask;
|
ul_can_mask =ul_mask;
|
||||||
yeid_un.yecanid.destMACID = Can_Device_ID;
|
yeid_un.yecanid_old.destMACID = Can_Device_ID;
|
||||||
ul_filter = GetCanFilter(yeid_un);
|
ul_filter = GetCanFilter(yeid_un);
|
||||||
|
|
||||||
CAN_FilterInitStructure.CAN_FilterNumber = 0;
|
CAN_FilterInitStructure.CAN_FilterNumber = 0;
|
||||||
@@ -86,14 +88,14 @@ void YeCanInit(void)
|
|||||||
CAN_FilterInitStructure.CAN_FilterActivation = ENABLE;
|
CAN_FilterInitStructure.CAN_FilterActivation = ENABLE;
|
||||||
CAN_FilterInit(&CAN_FilterInitStructure);
|
CAN_FilterInit(&CAN_FilterInitStructure);
|
||||||
|
|
||||||
yeid_un.yecanid.destMACID = 0x1E;
|
// yeid_un.yecanid_old.destMACID = 0x1E;
|
||||||
ul_filter = GetCanFilter(yeid_un);
|
// ul_filter = GetCanFilter(yeid_un);
|
||||||
CAN_FilterInitStructure.CAN_FilterNumber = 1;
|
// CAN_FilterInitStructure.CAN_FilterNumber = 1;
|
||||||
CAN_FilterInitStructure.CAN_FilterIdHigh = (ul_filter >> 16) & 0x0FFFF;;
|
// CAN_FilterInitStructure.CAN_FilterIdHigh = (ul_filter >> 16) & 0x0FFFF;;
|
||||||
CAN_FilterInitStructure.CAN_FilterIdLow = ul_filter & 0x0FFFF;;
|
// CAN_FilterInitStructure.CAN_FilterIdLow = ul_filter & 0x0FFFF;;
|
||||||
CAN_FilterInit(&CAN_FilterInitStructure);
|
// CAN_FilterInit(&CAN_FilterInitStructure);
|
||||||
|
|
||||||
yeid_un.yecanid.destMACID = 0x1F;
|
yeid_un.yecanid_old.destMACID = 0x1F;
|
||||||
ul_filter = GetCanFilter(yeid_un);
|
ul_filter = GetCanFilter(yeid_un);
|
||||||
CAN_FilterInitStructure.CAN_FilterNumber = 2;
|
CAN_FilterInitStructure.CAN_FilterNumber = 2;
|
||||||
CAN_FilterInitStructure.CAN_FilterIdHigh = (ul_filter >> 16) & 0x0FFFF;;
|
CAN_FilterInitStructure.CAN_FilterIdHigh = (ul_filter >> 16) & 0x0FFFF;;
|
||||||
@@ -135,22 +137,18 @@ static uint32_t GetCanFilter(YeCanID_un yeid)
|
|||||||
@param 发送数据长度
|
@param 发送数据长度
|
||||||
@rtv 0 成功 1 失败
|
@rtv 0 成功 1 失败
|
||||||
*/
|
*/
|
||||||
timer_def *timer=0;
|
|
||||||
uint8_t YeCan_SendFrame(uint8_t srcaddr,uint8_t dstaddr,const uint8_t* txdata, uint16_t len,int delay_ms)
|
uint8_t YeCan_SendFrame(uint8_t srcaddr,uint8_t dstaddr,const uint8_t* txdata, uint16_t len,int delay_ms)
|
||||||
{
|
{
|
||||||
CanTxMsg transmit_message;
|
CanTxMsg transmit_message;
|
||||||
uint8_t mailbox_number;
|
uint8_t mailbox_number;
|
||||||
YeCanID_un yeid_un;
|
YeCanID_un yeid_un;
|
||||||
int time_out = delay_ms*1000;
|
uint32_t time_out = delay_ms*1000;
|
||||||
uint8_t uc_rtv = 0;
|
uint8_t uc_rtv = 0;
|
||||||
uint32_t tick_start=0;
|
uint32_t tick_start=0;
|
||||||
if(timer==0){
|
uint8_t pack_len;
|
||||||
timer=dev_get("timer");
|
tick_start=delay_get_us();
|
||||||
}
|
|
||||||
tick_start=timer->read(timer);
|
|
||||||
|
|
||||||
//can_transmission_stop(CAN1,0);
|
|
||||||
/* initialize transmit message */
|
|
||||||
transmit_message.ExtId = 0x00;
|
transmit_message.ExtId = 0x00;
|
||||||
transmit_message.StdId = 0x00;
|
transmit_message.StdId = 0x00;
|
||||||
transmit_message.RTR = CAN_RTR_DATA;
|
transmit_message.RTR = CAN_RTR_DATA;
|
||||||
@@ -162,87 +160,66 @@ uint8_t YeCan_SendFrame(uint8_t srcaddr,uint8_t dstaddr,const uint8_t* txdata, u
|
|||||||
yeid_un.yecanid.FunClass = 1;
|
yeid_un.yecanid.FunClass = 1;
|
||||||
yeid_un.yecanid.SegFlag = 0;
|
yeid_un.yecanid.SegFlag = 0;
|
||||||
yeid_un.yecanid.SegNum = 0;
|
yeid_un.yecanid.SegNum = 0;
|
||||||
if(can_tx_mutex != RT_NULL)
|
yeid_un.yecanid.Reserve0=1;// 使用新协议
|
||||||
{
|
|
||||||
if(RT_EOK != rt_mutex_take (can_tx_mutex,500))
|
|
||||||
{
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(len <= 8)
|
if(len <= 8)
|
||||||
{
|
{
|
||||||
transmit_message.DLC = len;
|
transmit_message.DLC = len;
|
||||||
transmit_message.ExtId = yeid_un.Exide;
|
transmit_message.ExtId = yeid_un.Exide;
|
||||||
memcpy(transmit_message.Data,txdata,8);
|
memcpy(transmit_message.Data,txdata,8);
|
||||||
|
|
||||||
mailbox_number = CAN_Transmit(CAN1, &transmit_message);
|
mailbox_number = CAN_Transmit(CAN1, &transmit_message);
|
||||||
while( CAN_TxStatus_Ok != CAN_TransmitStatus(CAN1,mailbox_number) && time_out > 0)
|
}else{
|
||||||
{
|
while(len > 0)
|
||||||
time_out -=20;
|
{
|
||||||
rt_hw_us_delay(20);
|
pack_len=8;
|
||||||
}
|
if(len<pack_len){
|
||||||
// if(time_out <= 0)
|
pack_len=len;
|
||||||
if((timer->read(timer)-tick_start)>=delay_ms)
|
}
|
||||||
{
|
memcpy(transmit_message.Data,txdata,pack_len);
|
||||||
uc_rtv = 1;
|
if(yeid_un.yecanid.SegNum == 0){
|
||||||
goto can0_tx_end;
|
yeid_un.yecanid.SegFlag = 0x01;
|
||||||
}
|
}else if(len>8){
|
||||||
goto can0_tx_end;
|
yeid_un.yecanid.SegFlag = 0x02;
|
||||||
}
|
}else{
|
||||||
while(len > 8)
|
yeid_un.yecanid.SegFlag = 0x03;
|
||||||
{
|
}
|
||||||
memcpy(transmit_message.Data,txdata,8);
|
len -= pack_len;
|
||||||
len -= 8;
|
txdata += pack_len;
|
||||||
txdata += 8;
|
transmit_message.DLC = pack_len;
|
||||||
|
transmit_message.ExtId = yeid_un.Exide;
|
||||||
if(yeid_un.yecanid.SegNum == 0)
|
while(mailbox_number = CAN_Transmit(CAN1, &transmit_message),mailbox_number==CAN_TxStatus_NoMailBox)
|
||||||
{
|
//while( CAN_TxStatus_Ok != CAN_TransmitStatus(CAN1,mailbox_number))
|
||||||
yeid_un.yecanid.SegFlag = 0x01;
|
{
|
||||||
}else
|
rt_hw_us_delay(20);
|
||||||
{
|
if(delay_check(tick_start,time_out))
|
||||||
yeid_un.yecanid.SegFlag = 0x02;
|
{
|
||||||
}
|
uc_rtv = 1;
|
||||||
transmit_message.ExtId = yeid_un.Exide;
|
goto can0_tx_end;
|
||||||
transmit_message.DLC = 8;
|
}
|
||||||
mailbox_number = CAN_Transmit(CAN1, &transmit_message);
|
}
|
||||||
time_out = 5000;
|
yeid_un.yecanid.SegNum ++;
|
||||||
while( CAN_TxStatus_Ok != CAN_TransmitStatus(CAN1,mailbox_number) && time_out > 0)
|
}
|
||||||
{
|
}
|
||||||
time_out -=20;
|
|
||||||
rt_hw_us_delay(20);
|
|
||||||
}
|
|
||||||
// if(time_out <= 0)
|
|
||||||
if((timer->read(timer)-tick_start)>=delay_ms)
|
|
||||||
{
|
|
||||||
uc_rtv = 1;
|
|
||||||
goto can0_tx_end;
|
|
||||||
}
|
|
||||||
yeid_un.yecanid.SegNum ++;
|
|
||||||
}
|
|
||||||
yeid_un.yecanid.SegFlag = 0x3;
|
|
||||||
memcpy(transmit_message.Data,txdata,len);
|
|
||||||
transmit_message.DLC = len;
|
|
||||||
transmit_message.ExtId = yeid_un.Exide;
|
|
||||||
mailbox_number = CAN_Transmit(CAN1, &transmit_message);
|
|
||||||
while(CAN_TxStatus_Ok != CAN_TransmitStatus(CAN1,mailbox_number) && time_out > 0)
|
|
||||||
{
|
|
||||||
|
|
||||||
time_out -=20;
|
|
||||||
rt_hw_us_delay(20);
|
|
||||||
}
|
|
||||||
// if(time_out <= 0)
|
|
||||||
if((timer->read(timer)-tick_start)>=delay_ms)
|
|
||||||
{
|
|
||||||
uc_rtv = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
can0_tx_end:
|
can0_tx_end:
|
||||||
CAN0_TX_BUSY_Flag = 0;
|
CAN0_TX_BUSY_Flag = 0;
|
||||||
rt_mutex_release(can_tx_mutex);
|
|
||||||
return uc_rtv;
|
return uc_rtv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
typedef struct{
|
typedef struct{
|
||||||
void (*end_irq)(void *t,uint32_t len);
|
void (*end_irq)(void *t,uint32_t len);
|
||||||
void *t;
|
void *t;
|
||||||
@@ -257,25 +234,38 @@ static self_def g_self;
|
|||||||
static void save_data(void)
|
static void save_data(void)
|
||||||
{
|
{
|
||||||
YeCanID_un yeid_un;
|
YeCanID_un yeid_un;
|
||||||
|
uint8_t seg,seg_num,dstaddr;
|
||||||
|
yeid_un.Exide = receive_message.ExtId;
|
||||||
|
ul_exid = yeid_un.Exide << 3;
|
||||||
|
ul_exid &= ul_can_mask;
|
||||||
|
if(yeid_un.yecanid.Reserve0==0){
|
||||||
|
seg=yeid_un.yecanid_old.SegFlag;
|
||||||
|
seg_num=yeid_un.yecanid_old.SegNum;
|
||||||
|
dstaddr=yeid_un.yecanid_old.destMACID;
|
||||||
|
}else{
|
||||||
|
seg=yeid_un.yecanid.SegFlag;
|
||||||
|
seg_num=yeid_un.yecanid.SegNum;
|
||||||
|
dstaddr=yeid_un.yecanid.destMACID;
|
||||||
|
}
|
||||||
|
if((dstaddr!=elec_local_addr())&&(dstaddr!=0x1f)){
|
||||||
|
return;
|
||||||
|
}
|
||||||
if(receive_message.DLC > 0)
|
if(receive_message.DLC > 0)
|
||||||
{
|
{
|
||||||
yeid_un.Exide = receive_message.ExtId;
|
if(seg == 00)
|
||||||
ul_exid = yeid_un.Exide << 3;
|
|
||||||
ul_exid &= ul_can_mask;
|
|
||||||
if(yeid_un.yecanid.SegFlag == 00)
|
|
||||||
{
|
{
|
||||||
memcpy(canrx_st.rx_databuf,receive_message.Data,receive_message.DLC);
|
memcpy(canrx_st.rx_databuf,receive_message.Data,receive_message.DLC);
|
||||||
canrx_st.rx_index = receive_message.DLC;
|
canrx_st.rx_index = receive_message.DLC;
|
||||||
g_self.end_irq(g_self.t,canrx_st.rx_index);
|
g_self.end_irq(g_self.t,canrx_st.rx_index);
|
||||||
}
|
}
|
||||||
else if(yeid_un.yecanid.SegFlag == 0x01)
|
else if(seg == 0x01)
|
||||||
{
|
{
|
||||||
canrx_st.seg_num = 0;
|
canrx_st.seg_num = 0;
|
||||||
memcpy(canrx_st.rx_databuf,receive_message.Data,receive_message.DLC);
|
memcpy(canrx_st.rx_databuf,receive_message.Data,receive_message.DLC);
|
||||||
canrx_st.rx_index = receive_message.DLC;
|
canrx_st.rx_index = receive_message.DLC;
|
||||||
}else if(yeid_un.yecanid.SegFlag == 0x02)
|
}else if(seg == 0x02)
|
||||||
{
|
{
|
||||||
if((canrx_st.seg_num+1) == yeid_un.yecanid.SegNum )
|
if((canrx_st.seg_num+1) == seg_num )
|
||||||
{
|
{
|
||||||
canrx_st.seg_num++;
|
canrx_st.seg_num++;
|
||||||
memcpy(canrx_st.rx_databuf+canrx_st.rx_index,receive_message.Data,receive_message.DLC);
|
memcpy(canrx_st.rx_databuf+canrx_st.rx_index,receive_message.Data,receive_message.DLC);
|
||||||
@@ -284,7 +274,7 @@ static void save_data(void)
|
|||||||
}else{
|
}else{
|
||||||
//error
|
//error
|
||||||
}
|
}
|
||||||
}else if(yeid_un.yecanid.SegFlag == 0x03)
|
}else if(seg == 0x03)
|
||||||
{
|
{
|
||||||
memcpy(canrx_st.rx_databuf+canrx_st.rx_index,receive_message.Data,receive_message.DLC);
|
memcpy(canrx_st.rx_databuf+canrx_st.rx_index,receive_message.Data,receive_message.DLC);
|
||||||
canrx_st.rx_index += receive_message.DLC;
|
canrx_st.rx_index += receive_message.DLC;
|
||||||
|
@@ -4,6 +4,8 @@
|
|||||||
//#include "define.h"
|
//#include "define.h"
|
||||||
#include "stm32f10x_can.h"
|
#include "stm32f10x_can.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
typedef struct{
|
typedef struct{
|
||||||
uint32_t Reserve1 :3;
|
uint32_t Reserve1 :3;
|
||||||
uint32_t srcMACID :5;
|
uint32_t srcMACID :5;
|
||||||
@@ -14,11 +16,26 @@ typedef struct{
|
|||||||
uint32_t SegFlag :2;
|
uint32_t SegFlag :2;
|
||||||
uint32_t SegNum :8;
|
uint32_t SegNum :8;
|
||||||
|
|
||||||
|
}YeCanID_st_old;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct{
|
||||||
|
uint32_t SegNum :8;
|
||||||
|
uint32_t Reserve0 :2;
|
||||||
|
uint32_t ACK :1;
|
||||||
|
uint32_t FunClass :6;
|
||||||
|
uint32_t SegFlag :2;
|
||||||
|
uint32_t destMACID :5;
|
||||||
|
uint32_t srcMACID :5;
|
||||||
|
uint32_t Reserve1 :3;
|
||||||
|
|
||||||
}YeCanID_st;
|
}YeCanID_st;
|
||||||
|
|
||||||
typedef union{
|
typedef union{
|
||||||
uint32_t Exide;
|
uint32_t Exide;
|
||||||
YeCanID_st yecanid;
|
YeCanID_st yecanid;
|
||||||
|
YeCanID_st_old yecanid_old;
|
||||||
}YeCanID_un;
|
}YeCanID_un;
|
||||||
|
|
||||||
|
|
||||||
|
@@ -6,8 +6,8 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
#define BUILD_DATE "2024-01-05 18:59:06"
|
#define BUILD_DATE "2024-01-08 16:28:07"
|
||||||
#define SOFT_VERSION "2.12"
|
#define SOFT_VERSION "2.13"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@@ -7,7 +7,7 @@ import mycopy
|
|||||||
|
|
||||||
|
|
||||||
# 定义软件版本号
|
# 定义软件版本号
|
||||||
SOFT_VERION = "2.12"
|
SOFT_VERION = "2.13"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@@ -46,7 +46,29 @@ static uint32_t delay_get_tick(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 获取当前微妙数
|
||||||
|
uint32_t delay_get_us(void)
|
||||||
|
{
|
||||||
|
return ((uint32_t)DWT_CYCCNT/(get_sys_clocks_freq()/1000000));
|
||||||
|
}
|
||||||
|
|
||||||
|
// 判断延时是否到,返回1已到,0未到
|
||||||
|
int delay_check(uint32_t old,uint32_t wnd)
|
||||||
|
{
|
||||||
|
uint32_t now=delay_get_us();
|
||||||
|
if(now>=old){
|
||||||
|
if((now-old)>=wnd){
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
if((UINT32_MAX - old + now)>=wnd){
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 最长可以延时59s
|
||||||
// 低于1ms的精确延时
|
// 低于1ms的精确延时
|
||||||
void delay_us(uint32_t us)
|
void delay_us(uint32_t us)
|
||||||
{
|
{
|
||||||
|
@@ -12,7 +12,9 @@ int delay_init(void);
|
|||||||
|
|
||||||
void delay_us(uint32_t us);
|
void delay_us(uint32_t us);
|
||||||
|
|
||||||
|
uint32_t delay_get_us(void);
|
||||||
|
|
||||||
|
int delay_check(uint32_t old,uint32_t wnd);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@@ -28,7 +28,7 @@
|
|||||||
#define DBG_DEV_WRITE(d,len)\
|
#define DBG_DEV_WRITE(d,len)\
|
||||||
{\
|
{\
|
||||||
if(g_data.uart){\
|
if(g_data.uart){\
|
||||||
g_data.uart->write(g_data.uart,d,len);\
|
g_data.uart->write(g_data.uart,d,len,1000);\
|
||||||
}\
|
}\
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -13,6 +13,7 @@
|
|||||||
#include "dev_flash.h"
|
#include "dev_flash.h"
|
||||||
#include "mymisc.h"
|
#include "mymisc.h"
|
||||||
#include "elec_det.h"
|
#include "elec_det.h"
|
||||||
|
#include "commend.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -251,7 +252,7 @@ protu_def *protu_creat(uart_def *uart)
|
|||||||
p->cmd=0xff;// 命令字不可能是0xff
|
p->cmd=0xff;// 命令字不可能是0xff
|
||||||
protu_set_endecode_fun(p);
|
protu_set_endecode_fun(p);
|
||||||
sprintf(name,"protu_t#%d",count);
|
sprintf(name,"protu_t#%d",count);
|
||||||
rt_thread_t rt_t=rt_thread_create(name,protu_run,p,1024,5,20);
|
rt_thread_t rt_t=rt_thread_create(name,protu_run,p,1024,6,20);
|
||||||
rt_thread_startup(rt_t);
|
rt_thread_startup(rt_t);
|
||||||
int bsp=sys_param()->uartbsp;
|
int bsp=sys_param()->uartbsp;
|
||||||
if(bsp==9600)
|
if(bsp==9600)
|
||||||
@@ -287,8 +288,8 @@ array_def *t;
|
|||||||
static void protu_send_later(void *ptr)
|
static void protu_send_later(void *ptr)
|
||||||
{
|
{
|
||||||
send_pkt_def *s=ptr;
|
send_pkt_def *s=ptr;
|
||||||
protu_send(s->p,s->t,50);
|
protu_send(s->p,s->t,1000);
|
||||||
arr_delete(s->t);
|
// arr_delete(s->t);
|
||||||
}
|
}
|
||||||
|
|
||||||
static send_pkt_def g_send_pkt;
|
static send_pkt_def g_send_pkt;
|
||||||
@@ -318,7 +319,7 @@ static int protu_send_ontime(protu_def *p,send_pkt_def *s)
|
|||||||
//later_execute(protu_send_later,s,delay);
|
//later_execute(protu_send_later,s,delay);
|
||||||
while(p->timer->read(p->timer)<(tick+delay));
|
while(p->timer->read(p->timer)<(tick+delay));
|
||||||
// protu_send_later(s);
|
// protu_send_later(s);
|
||||||
return protu_send(s->p,s->t,wnd_tick-2);
|
return protu_send(s->p,s->t,wnd_tick-1);
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
// 单播命令直接发送
|
// 单播命令直接发送
|
||||||
@@ -327,12 +328,29 @@ static int protu_send_ontime(protu_def *p,send_pkt_def *s)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int g_send_failed_times;
|
||||||
static int protu_send_ontime_loop(protu_def *p,send_pkt_def *s)
|
static int protu_send_ontime_loop(protu_def *p,send_pkt_def *s,int retry)
|
||||||
{
|
{
|
||||||
while(protu_send_ontime(p,s)==0);
|
// g_send_failed_times=0;
|
||||||
|
for(int i=0;i<retry;i++)
|
||||||
|
{
|
||||||
|
if(protu_send_ontime(p,s)!=0){
|
||||||
|
break;
|
||||||
|
}else{
|
||||||
|
g_send_failed_times++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
arr_delete(s->t);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
static int send_failed(list_def *argv)
|
||||||
|
{
|
||||||
|
cmd_print("send failed times=%d",g_send_failed_times);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
commend_export(send_failed,send_failed,"print send_failed times")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -348,7 +366,7 @@ void protu_reply_call(protu_def *p,array_def *data)
|
|||||||
if(t){
|
if(t){
|
||||||
g_send_pkt.p=p;
|
g_send_pkt.p=p;
|
||||||
g_send_pkt.t=t;
|
g_send_pkt.t=t;
|
||||||
protu_send_ontime_loop(p,&g_send_pkt);
|
protu_send_ontime_loop(p,&g_send_pkt,3);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -371,7 +389,7 @@ void protu_send_call(protu_def *p,uint8_t cmd,array_def *data)
|
|||||||
if(t){
|
if(t){
|
||||||
g_send_pkt.p=p;
|
g_send_pkt.p=p;
|
||||||
g_send_pkt.t=t;
|
g_send_pkt.t=t;
|
||||||
protu_send_ontime_loop(p,&g_send_pkt);
|
protu_send_ontime_loop(p,&g_send_pkt,3);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -392,7 +392,7 @@ static int write_data_dolater(ucport_def *u,uint8_t cmd,array_def *data,char *er
|
|||||||
addr=g_updata.flash_addr+offset;
|
addr=g_updata.flash_addr+offset;
|
||||||
ret=flash_write((uint8_t *)addr,&arr_data(data)[4],len);
|
ret=flash_write((uint8_t *)addr,&arr_data(data)[4],len);
|
||||||
array_def *r=arr_creat();
|
array_def *r=arr_creat();
|
||||||
arr_append(r,(ret!=0));
|
arr_append(r,ret);
|
||||||
emit tran_reply_signal(u->p,arr_temp(r));
|
emit tran_reply_signal(u->p,arr_temp(r));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user