V2.05
重写延时等待函数,解决与模块之间通信间隔有可能过短的问题 修改硬件版本号时自动修改can波特率
This commit is contained in:
@@ -299,7 +299,7 @@
|
|||||||
<OPTFL>
|
<OPTFL>
|
||||||
<tvExp>1</tvExp>
|
<tvExp>1</tvExp>
|
||||||
<tvExpOptDlg>0</tvExpOptDlg>
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
<IsCurrentTarget>0</IsCurrentTarget>
|
<IsCurrentTarget>1</IsCurrentTarget>
|
||||||
</OPTFL>
|
</OPTFL>
|
||||||
<CpuCode>18</CpuCode>
|
<CpuCode>18</CpuCode>
|
||||||
<DebugOpt>
|
<DebugOpt>
|
||||||
@@ -327,7 +327,7 @@
|
|||||||
<bEvRecOn>1</bEvRecOn>
|
<bEvRecOn>1</bEvRecOn>
|
||||||
<bSchkAxf>0</bSchkAxf>
|
<bSchkAxf>0</bSchkAxf>
|
||||||
<bTchkAxf>0</bTchkAxf>
|
<bTchkAxf>0</bTchkAxf>
|
||||||
<nTsel>4</nTsel>
|
<nTsel>6</nTsel>
|
||||||
<sDll></sDll>
|
<sDll></sDll>
|
||||||
<sDllPa></sDllPa>
|
<sDllPa></sDllPa>
|
||||||
<sDlgDll></sDlgDll>
|
<sDlgDll></sDlgDll>
|
||||||
@@ -338,7 +338,7 @@
|
|||||||
<tDlgDll></tDlgDll>
|
<tDlgDll></tDlgDll>
|
||||||
<tDlgPa></tDlgPa>
|
<tDlgPa></tDlgPa>
|
||||||
<tIfile></tIfile>
|
<tIfile></tIfile>
|
||||||
<pMon>Segger\JL2CM3.dll</pMon>
|
<pMon>STLink\ST-LINKIII-KEIL_SWO.dll</pMon>
|
||||||
</DebugOpt>
|
</DebugOpt>
|
||||||
<TargetDriverDllRegistry>
|
<TargetDriverDllRegistry>
|
||||||
<SetRegEntry>
|
<SetRegEntry>
|
||||||
@@ -359,7 +359,7 @@
|
|||||||
<SetRegEntry>
|
<SetRegEntry>
|
||||||
<Number>0</Number>
|
<Number>0</Number>
|
||||||
<Key>DLGUARM</Key>
|
<Key>DLGUARM</Key>
|
||||||
<Name>d</Name>
|
<Name>(105=-1,-1,-1,-1,0)</Name>
|
||||||
</SetRegEntry>
|
</SetRegEntry>
|
||||||
<SetRegEntry>
|
<SetRegEntry>
|
||||||
<Number>0</Number>
|
<Number>0</Number>
|
||||||
@@ -523,7 +523,7 @@
|
|||||||
<OPTFL>
|
<OPTFL>
|
||||||
<tvExp>1</tvExp>
|
<tvExp>1</tvExp>
|
||||||
<tvExpOptDlg>0</tvExpOptDlg>
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
<IsCurrentTarget>1</IsCurrentTarget>
|
<IsCurrentTarget>0</IsCurrentTarget>
|
||||||
</OPTFL>
|
</OPTFL>
|
||||||
<CpuCode>18</CpuCode>
|
<CpuCode>18</CpuCode>
|
||||||
<DebugOpt>
|
<DebugOpt>
|
||||||
@@ -1507,7 +1507,7 @@
|
|||||||
|
|
||||||
<Group>
|
<Group>
|
||||||
<GroupName>rt_thread</GroupName>
|
<GroupName>rt_thread</GroupName>
|
||||||
<tvExp>0</tvExp>
|
<tvExp>1</tvExp>
|
||||||
<tvExpOptDlg>0</tvExpOptDlg>
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
<cbSel>0</cbSel>
|
<cbSel>0</cbSel>
|
||||||
<RteFlg>0</RteFlg>
|
<RteFlg>0</RteFlg>
|
||||||
|
@@ -247,5 +247,8 @@
|
|||||||
2023.11.6
|
2023.11.6
|
||||||
解决本地异常判定任务数量与实际不符的bug
|
解决本地异常判定任务数量与实际不符的bug
|
||||||
V2.04
|
V2.04
|
||||||
|
2023.11.13
|
||||||
|
V2.05
|
||||||
|
重写延时等待函数,解决与模块之间通信间隔有可能过短的问题
|
||||||
|
修改硬件版本号时自动修改can波特率
|
||||||
|
|
||||||
|
@@ -4,6 +4,41 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct{
|
||||||
|
rt_tick_t tick_start;
|
||||||
|
}self_def;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static self_def g_self;
|
||||||
|
|
||||||
|
void delay_wait_start(void)
|
||||||
|
{
|
||||||
|
g_self.tick_start=rt_tick_get();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void delay_wait_untill_ms(uint32_t nms)
|
||||||
|
{
|
||||||
|
rt_tick_t tick_end;
|
||||||
|
rt_tick_t diff;
|
||||||
|
if(g_self.tick_start==0){
|
||||||
|
delay_wait_start();
|
||||||
|
}
|
||||||
|
while(1){
|
||||||
|
tick_end=rt_tick_get();
|
||||||
|
diff=tick_end-g_self.tick_start;
|
||||||
|
if(diff>=nms){
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
rt_thread_mdelay(1);
|
||||||
|
}
|
||||||
|
g_self.tick_start=0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//此函数已在别处实现
|
//此函数已在别处实现
|
||||||
//void delay_us(uint32_t nus)
|
//void delay_us(uint32_t nus)
|
||||||
//{
|
//{
|
||||||
@@ -59,5 +94,6 @@ void delay_nop(uint32_t nop)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@@ -9,6 +9,9 @@ void delay_ms(uint32_t nms);
|
|||||||
void delay_us(uint32_t nus);
|
void delay_us(uint32_t nus);
|
||||||
void delay_nop(uint32_t nop);
|
void delay_nop(uint32_t nop);
|
||||||
#define delay_os_ms(ms) rt_thread_delay(ms)
|
#define delay_os_ms(ms) rt_thread_delay(ms)
|
||||||
|
void delay_wait_start(void);
|
||||||
|
void delay_wait_untill_ms(uint32_t nms);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
@@ -31,12 +31,16 @@ volatile uint16_t JQ_EnFreeBack_Test = 0;
|
|||||||
static void JQ_CommBegin()
|
static void JQ_CommBegin()
|
||||||
{
|
{
|
||||||
CurrentSampleR_Def;
|
CurrentSampleR_Def;
|
||||||
WaitDelayEnd(200);//20ms
|
//WaitDelayEnd(200);//20ms
|
||||||
|
//delay_ms(20);
|
||||||
|
delay_wait_untill_ms(20);
|
||||||
}
|
}
|
||||||
static void JQ_CommEnd()
|
static void JQ_CommEnd()
|
||||||
{
|
{
|
||||||
uint16_t us_temp;
|
uint16_t us_temp;
|
||||||
StartDelayTime();
|
//StartDelayTime();
|
||||||
|
TimerCount_Off();
|
||||||
|
delay_wait_start();
|
||||||
if(JQ_CommEnd_CurEn > 0)
|
if(JQ_CommEnd_CurEn > 0)
|
||||||
{
|
{
|
||||||
delay_os_ms(10);
|
delay_os_ms(10);
|
||||||
|
@@ -45,12 +45,16 @@ void XT_FreeBack_Prapare(uint8_t enable_flag)
|
|||||||
static void XT_CommBegin()
|
static void XT_CommBegin()
|
||||||
{
|
{
|
||||||
CurrentSampleR_Def;
|
CurrentSampleR_Def;
|
||||||
WaitDelayEnd(50);//5ms
|
//WaitDelayEnd(50);//5ms
|
||||||
|
//delay_ms(5);
|
||||||
|
delay_wait_untill_ms(5);
|
||||||
}
|
}
|
||||||
static void XT_CommEnd()
|
static void XT_CommEnd()
|
||||||
{
|
{
|
||||||
uint16_t us_temp;
|
uint16_t us_temp;
|
||||||
StartDelayTime();
|
//StartDelayTime();
|
||||||
|
TimerCount_Off();
|
||||||
|
delay_wait_start();
|
||||||
if(XT_CommEnd_CurEn > 0)
|
if(XT_CommEnd_CurEn > 0)
|
||||||
{
|
{
|
||||||
delay_os_ms(10);
|
delay_os_ms(10);
|
||||||
@@ -157,7 +161,7 @@ static uint8_t XT_Get_Ack(uint32_t timeoutcnt, uint8_t ConfirmAckCount,uint32_t
|
|||||||
// }
|
// }
|
||||||
// XT_ADC_BaseValue = (XT_ADC_BaseValue>>6) + XT_FreeBack_Noise;
|
// XT_ADC_BaseValue = (XT_ADC_BaseValue>>6) + XT_FreeBack_Noise;
|
||||||
XT_ADC_BaseValue = XT_FreeBack_Noise;
|
XT_ADC_BaseValue = XT_FreeBack_Noise;
|
||||||
while(ul_runtime < timeoutcnt)
|
while(1)
|
||||||
{
|
{
|
||||||
FeekValue = ADC_GetCurADCFast();
|
FeekValue = ADC_GetCurADCFast();
|
||||||
if(FeekValue >= XT_ADC_BaseValue)
|
if(FeekValue >= XT_ADC_BaseValue)
|
||||||
@@ -181,12 +185,19 @@ static uint8_t XT_Get_Ack(uint32_t timeoutcnt, uint8_t ConfirmAckCount,uint32_t
|
|||||||
ul_runtime = 0;
|
ul_runtime = 0;
|
||||||
}
|
}
|
||||||
ul_runtime = ul_readtime+ul_runtime;
|
ul_runtime = ul_readtime+ul_runtime;
|
||||||
|
if(ul_runtime >= timeoutcnt){
|
||||||
|
// time out
|
||||||
|
rtv = 2;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
LED1_Out_Off;
|
LED1_Out_Off;
|
||||||
XTBUS_IDLE;
|
XTBUS_IDLE;
|
||||||
Power_SetSampleCurrentRange(Current_Max);
|
Power_SetSampleCurrentRange(Current_Max);
|
||||||
XT_CommEnd();
|
XT_CommEnd();
|
||||||
|
if(rtv){
|
||||||
|
rtv=!0;
|
||||||
|
}
|
||||||
return rtv;
|
return rtv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -85,6 +85,10 @@ int elec_scheme_deinit(void)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// 找到第一个指定taskid的任务
|
// 找到第一个指定taskid的任务
|
||||||
static CheckerTask_Info_st *elec_find_task_by_taskid(int id)
|
static CheckerTask_Info_st *elec_find_task_by_taskid(int id)
|
||||||
{
|
{
|
||||||
@@ -157,6 +161,15 @@ void elec_led2_power(int power)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 获取小板硬件版本号
|
||||||
|
int elec_hard_version(void)
|
||||||
|
{
|
||||||
|
return HARD_VERSION;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// 获取自检参数
|
// 获取自检参数
|
||||||
|
@@ -14,6 +14,8 @@ int elec_scheme_deinit(void);
|
|||||||
|
|
||||||
uint8_t elec_local_addr(void);
|
uint8_t elec_local_addr(void);
|
||||||
|
|
||||||
|
int elec_hard_version(void);
|
||||||
|
|
||||||
void elec_led1_power(int power);
|
void elec_led1_power(int power);
|
||||||
|
|
||||||
void elec_led2_power(int power);
|
void elec_led2_power(int power);
|
||||||
|
@@ -24,7 +24,7 @@ void CtrlGpio_DefInit(void)
|
|||||||
GPIO_ResetBits(GPIOA,GPIO_InitStructure.GPIO_Pin);
|
GPIO_ResetBits(GPIOA,GPIO_InitStructure.GPIO_Pin);
|
||||||
|
|
||||||
GPIO_InitStructure.GPIO_Pin = SEG0_Pin;
|
GPIO_InitStructure.GPIO_Pin = SEG0_Pin;
|
||||||
GPIO_InitStructure.GPIO_Mode=GPIO_Mode_IPU;
|
GPIO_InitStructure.GPIO_Mode=GPIO_Mode_IN_FLOATING;
|
||||||
GPIO_Init(GPIOA,&GPIO_InitStructure);
|
GPIO_Init(GPIOA,&GPIO_InitStructure);
|
||||||
|
|
||||||
|
|
||||||
@@ -69,7 +69,7 @@ void CtrlGpio_DefInit(void)
|
|||||||
|
|
||||||
//GPIO 配置
|
//GPIO 配置
|
||||||
GPIO_InitStructure.GPIO_Pin=SEG4_Pin|SEG3_Pin|SEG1_Pin|SEG2_Pin;
|
GPIO_InitStructure.GPIO_Pin=SEG4_Pin|SEG3_Pin|SEG1_Pin|SEG2_Pin;
|
||||||
GPIO_InitStructure.GPIO_Mode=GPIO_Mode_IPU;
|
GPIO_InitStructure.GPIO_Mode=GPIO_Mode_IN_FLOATING;
|
||||||
GPIO_InitStructure.GPIO_Speed=GPIO_Speed_50MHz;
|
GPIO_InitStructure.GPIO_Speed=GPIO_Speed_50MHz;
|
||||||
GPIO_Init(GPIOC,&GPIO_InitStructure);
|
GPIO_Init(GPIOC,&GPIO_InitStructure);
|
||||||
|
|
||||||
|
@@ -363,3 +363,15 @@ uint16_t GetCountTimerCnt()
|
|||||||
return TIM2->CNT;
|
return TIM2->CNT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void TimerCount_Off(void)
|
||||||
|
{
|
||||||
|
TIM_Cmd(TIM2,DISABLE);
|
||||||
|
TIM2->CNT = 0;
|
||||||
|
TIM2->PSC = (uint32_t)7200-1;//10K 0.1ms
|
||||||
|
TIM2->EGR |= TIM_EventSource_Update;
|
||||||
|
TIM2->SR = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -65,4 +65,9 @@ uint16_t GetCountTimerCnt(void);
|
|||||||
使用轮询的方式检测校准结束
|
使用轮询的方式检测校准结束
|
||||||
*/
|
*/
|
||||||
void FireBus_ClkAmendCycle(void);
|
void FireBus_ClkAmendCycle(void);
|
||||||
|
|
||||||
|
// 复位并关闭定时器
|
||||||
|
void TimerCount_Off(void);
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -50,7 +50,11 @@ void YeCanInit(void)
|
|||||||
CAN_InitStructure.CAN_SJW = CAN_SJW_1tq;
|
CAN_InitStructure.CAN_SJW = CAN_SJW_1tq;
|
||||||
CAN_InitStructure.CAN_BS1 = CAN_BS1_3tq;
|
CAN_InitStructure.CAN_BS1 = CAN_BS1_3tq;
|
||||||
CAN_InitStructure.CAN_BS2 = CAN_BS2_2tq;
|
CAN_InitStructure.CAN_BS2 = CAN_BS2_2tq;
|
||||||
|
if(elec_hard_version()==1){
|
||||||
|
CAN_InitStructure.CAN_Prescaler = 60;
|
||||||
|
}else{
|
||||||
CAN_InitStructure.CAN_Prescaler = 30;
|
CAN_InitStructure.CAN_Prescaler = 30;
|
||||||
|
}
|
||||||
|
|
||||||
CAN_Init(CAN1, &CAN_InitStructure);
|
CAN_Init(CAN1, &CAN_InitStructure);
|
||||||
|
|
||||||
|
@@ -6,8 +6,8 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
#define BUILD_DATE "2023-11-06 16:44:51"
|
#define BUILD_DATE "2023-11-13 17:12:52"
|
||||||
#define SOFT_VERSION "2.04"
|
#define SOFT_VERSION "2.05"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@@ -7,7 +7,7 @@ import mycopy
|
|||||||
|
|
||||||
|
|
||||||
# 定义软件版本号
|
# 定义软件版本号
|
||||||
SOFT_VERION = "2.04"
|
SOFT_VERION = "2.05"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user