Commit 265d3c6e authored by 梁百峰's avatar 梁百峰

feat:发送以及扫码枪

parent 16eacd83
......@@ -3,12 +3,24 @@
#include "TYW_stdint.h"
#include "api_RS485.h"
#include "R485_Communication_Matrix.h"
void UART_Put(uint32_t Value);
void UART_Put1(uint32_t Value);
void Recv_Byte(void);
void Recv_Byte1(void);
extern uint32_t readNum;
extern uint8_t BarCode[50];
extern uint8_t BarCode[256];
extern uint32_t readNum1;
extern uint8_t BarCode1[256];
extern uint8_t sendmsg[8];
extern uint8_t nowdata[4];
extern uint8_t lastdata[4];
extern uint8_t checkresult;
extern uint8_t firstflag;
extern uint8_t zhenduanflag;
extern uint32_t key_value;
extern uint8_t key_array[4];
extern uint8_t seed_value[4];
extern uint8_t zhenduansendStep;
extern uint8_t clearOdoFlag;
#endif
\ No newline at end of file
......@@ -70,11 +70,17 @@ void Function_Check_Ctrl(uint32_t cmd);
void MENU_CHECK_STEP_ADD(void)
{
MENU_CHECK_STEP++;
if(MENU_CHECK_STEP > 12)
{
MENU_CHECK_STEP = 0;
}
}
void MENU_CHECK_STEP_SUB(void)
{
if ( MENU_CHECK_STEP != 0 )
if ( MENU_CHECK_STEP != 0 );
MENU_CHECK_STEP--;
}
void MENU_CHECK_Init(void)
......@@ -157,7 +163,7 @@ void CHECK_IPK_COUNT(void)
Display_Menu_Type = 0;
Display_TFT_Clear( );
Send_Init();
MENU_CHECK_Init( );
// MENU_CHECK_Init( );
Global_Session = 0;//掉线时,认为会话模式归零,重连CAN线后,重新将会话模式切到03扩展会话。
}
else
......@@ -508,153 +514,105 @@ uint8_t LED_Waring = 0;
void Function_Check_Ctrl(uint32_t cmd)
{
uint8_t p [ 20 ];
// uint8_t DIAG_BUFER [ 40 ];
// uint32_t i;
// uint32_t j;
// static uint32_t status = 0;
// static uint32_t MENU_BACK = 0xff;
// static uint8_t UDS_EunD = 0;
// if ( cmd == 0 )
// {
// ;
// }
// else if(cmd == 1)
// {
// //Voltage_UDS__Display();
// //FUEL_UDS__Display(1);
// if ( MENU_CHECK_STEP >= Get_Total_CheckStep( ) )
// {
// MENU_CHECK_STEP = 0;
// }
// if ( MENU_BACK != MENU_CHECK_STEP )
// {
// MENU_BACK = MENU_CHECK_STEP;
// Execute_Specify_Step(MENU_CHECK_STEP);//Excel表格发报文。
uint8_t DIAG_BUFER [ 40 ];
uint32_t i;
uint32_t j;
static uint32_t status = 0;
static uint32_t MENU_BACK = 0xff;
static uint8_t UDS_EunD = 0;
if ( cmd == 0 )
{
;
}
else if(cmd == 1)
{
//Voltage_UDS__Display();
//FUEL_UDS__Display(1);
// if (0)//数字需要3位还是2位
// {
// p [ 0 ] = (MENU_CHECK_STEP + 1) / 100; // 65535
// p [ 1 ] = ((MENU_CHECK_STEP + 1) % 100) / 10;
// p [ 2 ] = (MENU_CHECK_STEP + 1) % 10; // 65535
// p [ 3 ] = 0xff;
// }
// else
// {
// }
if ( MENU_CHECK_STEP >= Get_Total_CheckStep( ) )
{
// MENU_CHECK_STEP = 0;
}
if ( MENU_BACK != MENU_CHECK_STEP )
{
MENU_BACK = MENU_CHECK_STEP;
// }
p [ 0 ] = ((MENU_CHECK_STEP ) % 100) / 10;
p [ 1 ] = (MENU_CHECK_STEP ) % 10; // 65535
p [ 2 ] = 0xff;
General_Number_Disp(p, 190, 10);//刷图:报文检测步数
Display_Send_Vspead(MENU_CHECK_STEP);
// switch (MENU_CHECK_STEP)
// {
// case 0:
// {
// Display_Send_Vspead(0);
// break;
// }
Execute_Specify_Step(MENU_CHECK_STEP);//Excel表格发报文。
if (0)//数字需要3位还是2位
{
p [ 0 ] = (MENU_CHECK_STEP + 1) / 100; // 65535
p [ 1 ] = ((MENU_CHECK_STEP + 1) % 100) / 10;
p [ 2 ] = (MENU_CHECK_STEP + 1) % 10; // 65535
p [ 3 ] = 0xff;
}
else
{
p [ 0 ] = ((MENU_CHECK_STEP ) % 100) / 10;
p [ 1 ] = (MENU_CHECK_STEP ) % 10; // 65535
p [ 2 ] = 0xff;
}
General_Number_Disp(p, 190, 10);//刷图:报文检测步数
}
switch (MENU_CHECK_STEP)
{
case 0:
{
LED3 = 1;
LED4 = 1;
LINE_OUT_NEG_05 = 1;
LINE_OUT_NEG_06 = 1;
LINE_jinguang = 1;
POWER_CTRL_KL30_Current = 1;
break;
}
// case 1:
// {
// break;
// }
// case 3:
// {
// if(Get_CAN_CH0_ID_10FF1017_Sig_LowBeamSts() != 1)
// {
// LED_Waring = 1;
// Display_Menu_Type = 3;
// }
// else
// {
// LED_Waring = 0;
// Display_Menu_Type = 2;
// }
// break;
// }
// case 4:
// {
// if(Get_ID_HandBrakeSts() != 1)
// {
// LED_Waring = 1;
// Display_Menu_Type = 3;
// }
// else
// {
// LED_Waring = 0;
// Display_Menu_Type = 2;
// }
// break;
// }
// case 6:
// {
// Display_Menu_Type = 2;
// break;
// }
case 1:
{
LINE_jinguang = 1;
break;
}
case 3:
{
break;
}
case 4:
{
break;
}
case 6:
{
break;
}
// case 7:
// {
// LINE_OUT_NEG_01 = 0;
// Display_Menu_Type = 2;
// break;
// }
// case 8:
// {
// LINE_OUT_NEG_01 = 1;
// if(Get_CAN_CH0_ID_10FF4117_Sig_Seatbeltsts() != 1)
// {
// LED_Waring = 1;
// Display_Menu_Type = 3;
// }
// else
// {
// LED_Waring = 0;
// Display_Menu_Type = 2;
// }
// break;
// }
// case 9:
// {
// LINE_OUT_NEG_01 = 0;
// LINE_OUT_NEG_02 = 0;
// if(Get_CAN_CH0_ID_10FF1017_Sig_HighBeamSts() != 1)
// {
// LED_Waring = 1;
// Display_Menu_Type = 3;
// }
// else
// {
// LED_Waring = 0;
// Display_Menu_Type = 2;
// }
// break;
// }
// case 10:
// {
// LINE_OUT_NEG_02 = 1;
// break;
// }
// case 11:
// {
// LINE_OUT_NEG_02 = 0;
case 7:
{
break;
}
case 8:
{
break;
}
case 9:
{
break;
}
case 10:
{
// break;
// }
// case 20:
// {
// LINE_OUT_POS_01 = 0;
break;
}
case 11:
{
break;
}
case 20:
{
LINE_OUT_POS_01 = 0;
// break;
// }
......@@ -703,6 +661,9 @@ void Function_Check_Ctrl(uint32_t cmd)
// }
}
}
}
}
void Get_ODO_Call(void)
......
......@@ -2,7 +2,8 @@
#include "Key.h"
#include "Display_Info.h"
#include "Check_Ctrl.h"
#include "Barcode_Scanner.h"
#include "Task.h"
void Key_Operation_SW5(Key_Event_en_t enKeyEvent)
{
if ( enKeyEvent == KEY_EVENT_SHORT_PRESS )
......@@ -17,26 +18,35 @@ void Key_Operation_SW5(Key_Event_en_t enKeyEvent)
Display_TFT_Clear( );
}
MENU_CHECK_STEP_ADD( );
}
else if ( enKeyEvent == KEY_EVENT_LONG_PRESS )
{
}
else if ( enKeyEvent == KEY_EVENT_SUPER_LONG_PRESS )
{
if ( (LED_Waring == 1) || (UDS_Warning_Voltage ==1))
if(AutoFlag == 1)
{
;
AutoFlag = 0;
}
else
{
Display_Add( );
Display_TFT_Clear( );
}
AutoFlag = 1;
}
}
// else if ( enKeyEvent == KEY_EVENT_SUPER_LONG_PRESS )
// {
// if ( (LED_Waring == 1) || (UDS_Warning_Voltage ==1))
// {
// ;
// }
// else
// {
// Display_Add( );
// Display_TFT_Clear( );
// }
}
// }
else
{
}
......@@ -45,19 +55,20 @@ void Key_Operation_SW4(Key_Event_en_t enKeyEvent)
{
if ( enKeyEvent == KEY_EVENT_SHORT_PRESS )
{
if ( (LED_Waring == 1) || (UDS_Warning_Voltage ==1))
{
;
}
else
{
Display_Sub( );
Display_TFT_Clear( );
}
// if ( (LED_Waring == 1) || (UDS_Warning_Voltage ==1))
// {
// ;
// }
// else
// {
// Display_Sub( );
// Display_TFT_Clear( );
// }
MENU_CHECK_STEP_SUB();
}
else if ( enKeyEvent == KEY_EVENT_LONG_PRESS )
{
}
else if ( enKeyEvent == KEY_EVENT_SUPER_LONG_PRESS )
{
......@@ -97,7 +108,19 @@ void Key_Operation_SW8(Key_Event_en_t enKeyEvent)
{
if ( enKeyEvent == KEY_EVENT_SHORT_PRESS )
{
if(zhenduanflag == 0)
{
zhenduanflag = 1;
}
else
{
zhenduanflag = 0;
LINE_OUT_NEG_01 = 0;
LINE_OUT_NEG_02 = 0;
LINE_OUT_NEG_03 = 0;
LINE_OUT_NEG_04 = 0;
}
RS485_TX_finish = 0;
}
else if ( enKeyEvent == KEY_EVENT_LONG_PRESS )
......
#include "R485_Communication_Matrix.h"
#include "string.h"
uint8_t zhenduansendStep = 0;;
uint8_t barcode_Msg[64];
uint32_t R485_Send_0x40(void)
{
memset(R485_ID40h.Msg, 0xFF, 64);
uint32_t u32sendendflag = 0;
// R485_ID40h.Sig.AlarmStatus = 0; // 报警器报警状态
switch (1)
switch (MENU_CHECK_STEP)
{
case 0:
break;
......@@ -56,7 +56,7 @@ uint32_t R485_Send_0x41(void)
R485_ID41h.Sig.IOTRealTime_Year = 0x1; //时间:年
R485_ID41h.Sig.IOTRealTime_Month = 0x1; //时间:月
R485_ID41h.Sig.IOTRealTime_Day = 0x1; //时间:日
switch (1)
switch (MENU_CHECK_STEP)
{
case 0:
R485_ID41h.Sig.EleHeadlightFunctionSettings = 0x0; // 自动大灯
......@@ -670,7 +670,7 @@ uint32_t R485_Send_0x42(void)
R485_ID42h.Sig.TPower = 0; //T动力状态
R485_ID42h.Sig.TotalBatteryCurrent = 0;
uint8_t num = 0;
switch (num)
switch (MENU_CHECK_STEP)
{
case 0:
break;
......@@ -718,94 +718,82 @@ uint32_t R485_Send_0x42(void)
uint8_t R485_zhenduan_Msg[64];
uint32_t R485_Send_0x47(void)
{
// uint8_t length;
// uint32_t u32sendendflag = 0;
// if(RS485_TX_finish == 0)
// {
// if(RS485_send_time > 3000)
// {
// Port_SetPortPinLevel(1, 4, PortGpioHigh);
// Delay(10);
// switch (zhenduansendStep)
// {
// case 0:
// length = 2;
// break;
// case 1:
// length = 2;
// break;
// case 2:
// length = 6;
// break;
// case 3:
// length = 37;
// break;
// case 5:
// break;
// case 6:
// length = 3;
// break;
// default:
// break;
// }
uint8_t length;
uint32_t u32sendendflag = 0;
if(RS485_TX_finish == 0)
{
switch (zhenduansendStep)
{
case 0:
length = 2;
break;
case 1:
length = 2;
break;
case 2:
length = 6;
break;
case 3:
length = 37;
break;
case 5:
break;
case 6:
length = 3;
break;
default:
break;
}
// switch (zhenduansendStep)
// {
// case 0:
// // R485_zhenduan_Msg[0] = 0x2;
// R485_zhenduan_Msg[0] = 0x10;
// R485_zhenduan_Msg[1] = 0x03;
// break;
// case 1:
// // R485_zhenduan_Msg[0] = 0x2;
// R485_zhenduan_Msg[0] = 0x27;
// R485_zhenduan_Msg[1] = 0x1;
// break;
// case 2:
// // R485_zhenduan_Msg[0] = 0x6;
// R485_zhenduan_Msg[0] = 0x27;
// R485_zhenduan_Msg[1] = 0x2;
// R485_zhenduan_Msg[2] = key_array[0];
// R485_zhenduan_Msg[3] = key_array[1];
// R485_zhenduan_Msg[4] = key_array[2];
// R485_zhenduan_Msg[5] = key_array[3];
// break;
// case 3:
// R485_zhenduan_Msg[0] = 0x2E;
// R485_zhenduan_Msg[1] = 0x50;
// R485_zhenduan_Msg[2] = 0x0;
// memcpy(R485_zhenduan_Msg+3,barcode_Msg,34);
// break;
// case 4:
// // zhenduanflag = 0;
// Port_SetPortPinLevel(1, 19, PortGpioLow);
// Port_SetPortPinLevel(1, 20, PortGpioLow);
// Port_SetPortPinLevel(1, 21, PortGpioLow);
// Port_SetPortPinLevel(1, 15, PortGpioLow);
// // zhenduansendStep = 0;
// // zhenduanflag = 0;
// break;
// default:
// break;
// }
// RS485_TX_finish = 1;
// if(zhenduansendStep != 4)
// {
// u32sendendflag = R485_Send(0x47, R485_zhenduan_Msg, length);
// }
switch (zhenduansendStep)
{
case 0:
// R485_zhenduan_Msg[0] = 0x2;
R485_zhenduan_Msg[0] = 0x10;
R485_zhenduan_Msg[1] = 0x03;
break;
case 1:
// R485_zhenduan_Msg[0] = 0x2;
R485_zhenduan_Msg[0] = 0x27;
R485_zhenduan_Msg[1] = 0x1;
break;
case 2:
// R485_zhenduan_Msg[0] = 0x6;
R485_zhenduan_Msg[0] = 0x27;
R485_zhenduan_Msg[1] = 0x2;
R485_zhenduan_Msg[2] = key_array[0];
R485_zhenduan_Msg[3] = key_array[1];
R485_zhenduan_Msg[4] = key_array[2];
R485_zhenduan_Msg[5] = key_array[3];
break;
case 3:
R485_zhenduan_Msg[0] = 0x2E;
R485_zhenduan_Msg[1] = 0x50;
R485_zhenduan_Msg[2] = 0x0;
memcpy(R485_zhenduan_Msg+3,barcode_Msg,34);
break;
case 4:
LINE_OUT_NEG_01 = 0;
LINE_OUT_NEG_02 = 0;
LINE_OUT_NEG_03 = 0;
LINE_OUT_NEG_04 = 0;
// RS485_send_time = 0;
// Delay(10);
// Port_SetPortPinLevel(1, 4, PortGpioLow);
// Delay(10);
// RS485_TX_finish = 1;
// }
// }
// RS485_TX_finish = 1;
// Port_SetPortPinLevel(1, 4, PortGpioLow);
// return u32sendendflag;
break;
default:
break;
}
RS485_TX_finish = 1;
if(zhenduansendStep != 4)
{
u32sendendflag = R485_Send(0x47, R485_zhenduan_Msg, length);
}
RS485_send_time = 0;
RS485_TX_finish = 1;
}
RS485_TX_finish = 1;
return u32sendendflag;
}
uint32_t R485_Send_Line_0x47(uint8_t n)
......
......@@ -2,6 +2,8 @@
#define R485_COMMUNICATION_MATRIX_H__
#include "TYW_stdint.h"
#include "api_RS485.h"
#include "Barcode_Scanner.h"
#include "Check_Ctrl.h"
typedef union
{
uint8_t Msg[64];
......@@ -1132,4 +1134,5 @@ extern uint32_t R485_Send_0x47(void);
extern uint32_t R485_Send_Line_0x47(uint8_t n);
extern uint32_t R485_Send_clear(void);
extern uint8_t barcode_Msg[64];
#endif
......@@ -13,8 +13,7 @@
#define LED1 GPIO_OUT_APORT00_PIN07
#define LED2 GPIO_OUT_APORT00_PIN08
#define LED3 GPIO_OUT_APORT00_PIN10
#define LED4 GPIO_OUT_APORT00_PIN11
#define LED5 GPIO_OUT_APORT00_PIN12
#define LED6 GPIO_OUT_PORT10_PIN06
#define LED7 GPIO_OUT_PORT10_PIN06
......@@ -25,12 +24,12 @@
#define SW1 GPIO_IN_APORT00_PIN00
#define SW2 GPIO_IN_PORT10_PIN05
#define SW3 GPIO_IN_APORT00_PIN01
#define SW4 GPIO_IN_APORT00_PIN02
#define SW5 GPIO_IN_APORT00_PIN03
#define SW4 GPIO_IN_APORT00_PIN02 //按键-
#define SW5 GPIO_IN_APORT00_PIN03 //按键+
#define SW6 GPIO_IN_APORT00_PIN04
#define SW7 GPIO_IN_APORT00_PIN05
#define SW8 GPIO_IN_APORT00_PIN06
#define SW8 GPIO_IN_APORT00_PIN06 //右转
#define SW9 GPIO_IN_PORT09_PIN00
#define SW10 GPIO_IN_PORT10_PIN06
......@@ -48,7 +47,7 @@
#define POWER_CTRL_KL30 GPIO_OUT_PORT10_PIN13
#define POWER_CTRL_KL15 GPIO_OUT_PORT10_PIN12
#define POWER_CTRL_KL30_Current GPIO_OUT_PORT10_PIN14
#define LINE_OUT_FANGDAO GPIO_OUT_PORT10_PIN06
......@@ -95,8 +94,7 @@
#define LINE_OUT_NEG_02 GPIO_OUT_PORT09_PIN05
#define LINE_OUT_NEG_03 GPIO_OUT_PORT09_PIN04
#define LINE_OUT_NEG_04 GPIO_OUT_PORT09_PIN03
#define LINE_OUT_NEG_05 GPIO_OUT_PORT09_PIN02
#define LINE_OUT_NEG_06 GPIO_OUT_PORT09_PIN01
#define LINE_OUT_NEG_07 GPIO_OUT_PORT10_PIN07
#define LINE_OUT_NEG_08 GPIO_OUT_PORT10_PIN03
#define LINE_OUT_NEG_09 GPIO_OUT_PORT10_PIN04
......@@ -108,6 +106,13 @@
#define LINE_FUEL_RES04 GPIO_OUT_PORT08_PIN11
#define GPIO_VSpeed_PWM_IN GPIO_IN_PORT10_PIN15
#define LED3 GPIO_OUT_APORT00_PIN10 //右转
#define LED4 GPIO_OUT_APORT00_PIN11 //左转
#define LINE_OUT_NEG_05 GPIO_OUT_PORT09_PIN02 //ABS
#define LINE_OUT_NEG_06 GPIO_OUT_PORT09_PIN01 //位置灯
#define LINE_jinguang GPIO_OUT_PORT10_PIN10 //近光
#define POWER_CTRL_KL30_Current GPIO_OUT_PORT10_PIN14 //蓝牙
//zh:
/******************************************************************************
......
......@@ -31,6 +31,7 @@
------------------------------------------------------------------------------*/
uint8_t time100ms = 0;
uint8_t finish = 0;
uint8_t AutoFlag = 0;
void Sys_Run_Mode_Pseudo_Real_Time_Tasks(void)
{
SD_FMQ = 1;
......@@ -51,8 +52,8 @@ void Sys_Run_Mode_Pseudo_Real_Time_Tasks(void)
------------------------------------------------------------------------------*/
void Sys_Run_Mode_2ms_Tasks_Group(void)
{
Can_Write_Fun(2); //报文外发
COM_RX_Process( );
// Can_Write_Fun(2); //报文外发
// COM_RX_Process( );
RTE_ADC_Services( );
}
......@@ -70,10 +71,11 @@ void Sys_Run_Mode_5ms_Tasks_Group(void)
uint8_t testdata[3] = {0,1,2};
void Sys_Run_Mode_10ms_Tasks_Group(void)
{
BusOff_Service( );
// BusOff_Service( );
Key_Service( );
Fre_In_Time_Out_Handle(10);
// Fre_In_Time_Out_Handle(10);
//刷数字、刷英文拼写。
//GUI_General_Digit_Display(123456789, Num_09, 10, 0, BackLightDigitNum09PosX, 79);
//GUI_General_Digit_Display(123456789, Num_10_03, 10, 0, BackLightDigitNum09PosX, 79+24*1);
......@@ -90,7 +92,7 @@ void Sys_Run_Mode_10ms_Tasks_Group(void)
// RS485_User_Tx_Data();
Recv_Byte();
}
/*==============================================================================
......@@ -118,16 +120,18 @@ void Sys_Run_Mode_20ms_Tasks_Group0(void)
}
else
{
firstIGON = 0;
// firstIGON = 0;
time100mssend = 0;
}
}
/*==============================================================================
50ms����ִ������ ��0��
------------------------------------------------------------------------------*/
uint8_t powerstu = 0;
uint32_t timerms = 0;
void Sys_Run_Mode_50ms_Tasks_Group(void)
{
static uint32_t timer_100ms = 0;
......@@ -135,31 +139,64 @@ void Sys_Run_Mode_50ms_Tasks_Group(void)
{
timer_100ms++;
}
if(timerms <=1000)
{
timerms++;
}
if ( timer_100ms == 1 )
{
Read_IPK_Session_Type( );//请求仪表发送 软硬件版本号 等数据。
// if ( timer_100ms >= 500 )
// {
// if(powerstu == 0)
// {
// LINE_OUT_NEG_01 = 1;
// LINE_OUT_NEG_02 = 1;
// LINE_OUT_NEG_03 = 1;
// LINE_OUT_NEG_04 = 1;
// powerstu = 1;
// timer_100ms = 0;
// firstIGON = 1;
// timerms = 0;
// }
// else
// {
// LINE_OUT_NEG_01 = 0;
// LINE_OUT_NEG_02 = 0;
// LINE_OUT_NEG_03 = 0;
// LINE_OUT_NEG_04 = 0;
// powerstu = 0;
// timer_100ms = 400;
// firstIGON = 1;
// timerms = 0;
// }
// // Read_IPK_Session_Type( );//请求仪表发送 软硬件版本号 等数据。
}
else if ( timer_100ms == 2 )
{
// timer_100ms = 0;
}
if(timer_100ms >=500)
// }
if(timerms >=60)
{
firstIGON = 0;
}
if(firstIGON == 0)
firstIGON = 0;
if(firstIGON == 0 || firstIGON == 2)
{
backsend();
// RS485_TX_finish = 0;
if(RS485_TX_finish == 0)
{
LINE_OUT_NEG_09 = 1;
if(LINE_OUT_NEG_09 == 1)
{
RS485_User_Tx_Data();
if(zhenduanflag == 0)
{
RS485_User_Tx_Data();
}
else if(zhenduanflag == 1)
{
R485_Send_0x47();
}
}
// else
// {
......@@ -170,8 +207,19 @@ void Sys_Run_Mode_50ms_Tasks_Group(void)
else
{
LINE_OUT_NEG_09 = 0;
Recv_Byte();
if(firstflag == 0)
{
firstflag = 1;
}
}
}
}
else
{
RS485_send_time = 0;
}
}
......@@ -179,23 +227,39 @@ void Sys_Run_Mode_50ms_Tasks_Group(void)
100ms����ִ������ ��0��
------------------------------------------------------------------------------*/
uint16_t u16LJSText;
uint32_t AutoTime;
void Sys_Run_Mode_100ms_Tasks_Group(void)
{
static uint32_t loc_timer = 0;
loc_timer++;
if ( loc_timer >= 15 )
if ( loc_timer >= 3 )
{
loc_timer = 0;
HW_CHECK_IPK_EXIST( );
// HW_CHECK_IPK_EXIST( );
Recv_Byte1();
}
Display_PageNum();
Total_Check( );
Freln_Duty_HZ_Service();
// Freln_Duty_HZ_Service();
if(RS485_send_time<0xFFFFFFFF)
{
RS485_send_time++;
}
if(AutoFlag == 1)
{
if(AutoTime <= 10)
{
AutoTime++;
}
else
{
MENU_CHECK_STEP_ADD( );
AutoTime = 0;
}
}
//u16LJSText = TFT_LCD_REQ_FIFO_MAX_DEPTH;
......
......@@ -3,7 +3,7 @@
#include "TYW_stdint.h"
extern uint8_t AutoFlag;
void Sys_Run_Mode_Pseudo_Real_Time_Tasks(void);
void Sys_Run_Mode_2ms_Tasks_Group(void);
void Sys_Run_Mode_5ms_Tasks_Group(void);
......
#include "api_RS485.h"
#include "R485_Communication_Matrix.h"
#include "string.h"
#define R485_BUF_SIZE (1024 * 4 )
#define R485_UART_PORT (1)
#define R485_TX_OUT_MCU R485_TX
......@@ -267,7 +267,7 @@ static void RS485_Receive_Data_Analysis(void)
uint32_t R485_Send(const uint16_t cmdID, const uint8_t* pData, uint8_t len)
{
uint8_t dataBuf[64];
uint8_t dataBuf[128];
int i = 0;
uint16_t checksum = 0;
uint32_t frameLen;
......@@ -295,8 +295,8 @@ uint32_t R485_Send(const uint16_t cmdID, const uint8_t* pData, uint8_t len)
}
// checksum = Yadi_CAL_Data_Sum(&dataBuf[2], R485_DATA_LEN + 2);
// checksum = Yadi_CAL_Data_Sum(&dataBuf[2], len + 2);
checksum = 0;
checksum = Yadi_CAL_Data_Sum(&dataBuf[2], len + 2);
// checksum = 0;
dataBuf[frameLen] = checksum;
frameLen++;
dataBuf[frameLen] = 0X4B;
......@@ -321,6 +321,7 @@ uint32_t R485_Send(const uint16_t cmdID, const uint8_t* pData, uint8_t len)
{
sendresult = UART_Ch0_Send_Multiple_Byte(dataBuf,frameLen);
}
return sendresult;
// }
}
......@@ -333,9 +334,14 @@ void RS485_User_Tx_Data(void)
{
#if (0)
uint8_t flag = 0;
uint32_t sendfinishflag = 0;
// if(firstflag = 0)
// {
memcpy(lastdata,nowdata,4);
// }
// m
sendmsgAll[0] = (uint8_t)sendnum & 0xFF;
sendmsgAll[1] = ((uint8_t)(sendnum >>8)) & 0xFF;
sendmsgAll[2] = ((uint8_t)(sendnum >>16)) & 0xFF;
......@@ -345,6 +351,7 @@ void RS485_User_Tx_Data(void)
sendmsgAll[5] = ((uint8_t)(sendnum >>8)) & 0xFF;
sendmsgAll[6] = ((uint8_t)(sendnum >>16)) & 0xFF;
sendmsgAll[7] = ((uint8_t)(sendnum >>24)) & 0xFF;
if(RS485_TX_finish == 0)
{
// LINE_OUT_NEG_09 = 1;
......@@ -360,7 +367,16 @@ void RS485_User_Tx_Data(void)
if(RS485_TX_finish == 1)
{
// RS485_send_num++;
// sendnum++;
// lastdata[0] = (uint8_t)sendnum & 0xFF;
// lastdata[1] = ((uint8_t)(sendnum >>8)) & 0xFF;
// lastdata[2] = ((uint8_t)(sendnum >>16)) & 0xFF;
// lastdata[3] = ((uint8_t)(sendnum >>24)) & 0xFF;
nowdata[0] = (uint8_t)sendnum & 0xFF;
nowdata[1] = ((uint8_t)(sendnum >>8)) & 0xFF;
nowdata[2] = ((uint8_t)(sendnum >>16)) & 0xFF;
nowdata[3] = ((uint8_t)(sendnum >>24)) & 0xFF;
sendnum++;
}
}
......@@ -368,13 +384,14 @@ void RS485_User_Tx_Data(void)
case RS485_Tx_ID49_Idx:
sendfinishflag = R485_Send(0x71, sendmsgAll, 8);
RS485_TX_finish = 1;
if(sendfinishflag == 0)
{
RS485_TX_finish = 1;
if(RS485_TX_finish == 1)
{
sendnum++;
RS485_send_num = 0;
// sendnum++;
RS485_send_num ++;
}
}
......@@ -382,6 +399,7 @@ void RS485_User_Tx_Data(void)
break;
case RS485_Tx_ID4A_Idx:
sendfinishflag = R485_Send(0x72, sendmsgAll, sizeof(sendmsgAll));
RS485_TX_finish = 1;
if(sendfinishflag == 0)
{
RS485_TX_finish = 1;
......@@ -393,28 +411,30 @@ void RS485_User_Tx_Data(void)
break;
case 3:
sendfinishflag = R485_Send(0x73, sendmsgAll, sizeof(sendmsgAll));
RS485_TX_finish = 1;
if(sendfinishflag == 0)
{
RS485_TX_finish = 1;
if(RS485_TX_finish == 1)
{
// RS485_send_num++;
RS485_send_num++;
}
}
break;
case 4:
sendfinishflag = R485_Send(0x74, sendmsgAll, sizeof(sendmsgAll));
RS485_TX_finish = 1;
if(sendfinishflag == 0)
{
RS485_TX_finish = 1;
if(RS485_TX_finish == 1)
{
// RS485_send_num++;
RS485_send_num++;
}
}
break;
default:
sendnum++;
// sendnum++;
RS485_send_num = 0;
break;
RS485_TX_finish = 1;
......@@ -422,16 +442,77 @@ void RS485_User_Tx_Data(void)
}
// Port_SetPortPinLevel(1, 4, PortGpioLow);
//
// }
#endif
#if(1)
uint8_t flag = 0;
uint32_t sendfinishflag = 0;
// if(RS485_send_time > 3000)
// {
switch (RS485_send_num)
{
case RS485_Tx_ID48_Idx:
sendfinishflag = R485_Send_0x40();
RS485_TX_finish = 1;
if(sendfinishflag == 0)
{
if(RS485_TX_finish == 1)
{
// sendnum++;
RS485_send_time = 0;
RS485_send_num ++;
}
}
break;
case RS485_Tx_ID49_Idx:
sendfinishflag = R485_Send_0x41();
if(sendfinishflag == 0)
{
RS485_send_time = 0;
RS485_TX_finish = 1;
if(RS485_TX_finish == 1)
{
RS485_send_num++;
}
}
break;
case RS485_Tx_ID4A_Idx:
sendfinishflag = R485_Send_0x42();
if(sendfinishflag == 0)
{
RS485_send_time = 0;
RS485_TX_finish = 1;
if(RS485_TX_finish == 1)
{
RS485_send_num++;
}
}
break;
default:
flag = 1;
RS485_send_time = 0;
RS485_send_num = 0;
break;
}
// }
// }
}
#endif
}
void backsend(void)
{
if(RS485_send_time>=20)
{
RS485_send_time = 0;
RS485_TX_finish = 0;
sendnum--;
RS485_send_num--;
}
}
/**
* @brief R485状态计时函数
*/
......
......@@ -66,4 +66,5 @@ extern uint8_t sendmsgAll[8];
extern uint32_t R485_Send(const uint16_t cmdID, const uint8_t* pData, uint8_t len);
extern uint8_t Yadi_CAL_Data_Sum(uint8_t* pu8LinData, uint16_t u8LinLen);
extern void RS485_User_Tx_Data(void);
void backsend(void);
#endif /* API_ADC_H_ */
......@@ -389,10 +389,6 @@ uint32_t UART_Ch0_Send_Multiple_Byte(uint8_t *Data, uint32_t Len)
RLN30LUTDR = stUARTCtr0.pu8UARTDataBuf[0U];
u32UARTResult = 0UL;
}
else
{
UART_Ch0_Send_Multiple_Byte(Data,Len);
}
return u32UARTResult;
}
......
......@@ -8,7 +8,7 @@
/***************************************************************/
/***************************************************************/
/**根据实际应用调整buf大小**/
#define UART_30_SEND_MAX 1024*10UL
#define UART_30_SEND_MAX 1024UL
#define UART_31_SEND_MAX 512UL
#define UART_32_SEND_MAX 1UL
#define UART_33_SEND_MAX 1UL
......
......@@ -64,7 +64,7 @@ void Sys_Startup_Pre_Init(void)
* \attention
* \retval None
******************************************************************************/
uint8_t firstIGON = 2;
uint8_t firstIGON = 0xFF;
void Sys_Startup_Init(void)
{
RTC_Pre_Init( ); //首次上电
......@@ -95,6 +95,15 @@ void Sys_Startup_Init(void)
loc_config.pfnUARTReadMsgCallBack = UART_Put;
firstIGON = 1;
UART_Init(UART_RLIN30, &loc_config);
loc_config.enUARTLINMode = MODE_UART;
loc_config.u32UARTbps = 9600;
loc_config.enUARTOrder = UART_LSB;
loc_config.en2UARTParity = UART_PARITY_DISABLE;
loc_config.en2UARTPolarity = UART_POLARITY_NORMAL;
loc_config.pfnUARTConfirmCallBack = 0;
loc_config.pfnUARTErrHandleCallBack = 0;
loc_config.pfnUARTReadMsgCallBack = UART_Put1;
UART_Init(UART_RLIN31, &loc_config);
}
/***********************************************************************
......
......@@ -171,7 +171,7 @@ void INTRLIN31UR1(void)
#pragma ghs interrupt
void INTRLIN31UR2(void)
{
UART_CH1_Err_ISR();
// UART_CH1_Err_ISR();
}
#endif
......
......@@ -742,17 +742,17 @@
#define INTRLIN31_ENABLE 0x00000000u
#endif
//#define INTRLIN31UR0_ENABLE (IRQ_TABLE_START + 0x000001E4u)
#define INTRLIN31UR0_ENABLE (IRQ_TABLE_START + 0x000001E4u)
#ifndef INTRLIN31UR0_ENABLE
#define INTRLIN31UR0_ENABLE 0x00000000u
#endif
//#define INTRLIN31UR1_ENABLE (IRQ_TABLE_START + 0x000001E8u)
#define INTRLIN31UR1_ENABLE (IRQ_TABLE_START + 0x000001E8u)
#ifndef INTRLIN31UR1_ENABLE
#define INTRLIN31UR1_ENABLE 0x00000000u
#endif
//#define INTRLIN31UR2_ENABLE (IRQ_TABLE_START + 0x000001ECu)
#define INTRLIN31UR2_ENABLE (IRQ_TABLE_START + 0x000001ECu)
#ifndef INTRLIN31UR2_ENABLE
#define INTRLIN31UR2_ENABLE 0x00000000u
#endif
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment