Commit 9eb3266c authored by 何锐's avatar 何锐

feat:完成串口与按键

parent c903ee28
...@@ -4,6 +4,8 @@ ...@@ -4,6 +4,8 @@
#include "init.h" #include "init.h"
#include "Display_Info.h" #include "Display_Info.h"
#include "R485_Communication_Matrix.h" #include "R485_Communication_Matrix.h"
#include "app_lsdn.h"
#define UART_RX_MAX_DEPTH (1024) // 4K #define UART_RX_MAX_DEPTH (1024) // 4K
typedef struct typedef struct
...@@ -15,17 +17,23 @@ typedef struct ...@@ -15,17 +17,23 @@ typedef struct
static UARTRxBuf_t UARTRxBuf; static UARTRxBuf_t UARTRxBuf;
static UARTRxBuf_t UARTRxBuf1; static UARTRxBuf_t UARTRxBuf1;
static UARTRxBuf_t UARTRxBuf2;
static uint8_t mDataBufPtr[1024] = {0}; static uint8_t mDataBufPtr[1024] = {0};
static uint32_t mDataBufLen = 0; static uint32_t mDataBufLen = 0;
static uint8_t mDataBufPtr1[1024] = {0}; static uint8_t mDataBufPtr1[1024] = {0};
static uint8_t mDataBufPtr2[1024] = {0};
static uint32_t mDataBufLen1 = 0; static uint32_t mDataBufLen1 = 0;
static uint32_t mDataBufLen2 = 0;
uint8_t BarCode[256] = {0}; uint8_t BarCode[256] = {0};
uint8_t BarCode1[256] = {0}; uint8_t BarCode1[256] = {0};
uint8_t BarCode2[256] = {0};
uint32_t readNum = 0; uint32_t readNum = 0;
uint32_t readNum1 = 0; uint32_t readNum1 = 0;
uint32_t readNum2 = 0;
static uint32_t Protocol_UartRead(uint8_t *pData, uint32_t len); static uint32_t Protocol_UartRead(uint8_t *pData, uint32_t len);
static uint32_t Protocol_UartRead1(uint8_t *pData, uint32_t len); static uint32_t Protocol_UartRead1(uint8_t *pData, uint32_t len);
static uint32_t Protocol_UartRead2(uint8_t *pData, uint32_t len);
uint8_t nowdata[4]; uint8_t nowdata[4];
uint8_t lastdata[4]; uint8_t lastdata[4];
uint8_t checkresult; uint8_t checkresult;
...@@ -345,6 +353,22 @@ void BarCodeDataGet(void) ...@@ -345,6 +353,22 @@ void BarCodeDataGet(void)
memset(barcode_Msg,0,34); memset(barcode_Msg,0,34);
} }
} }
uint8_t AIMAtext;
void BarCodeDataGet2(void)
{
uint8_t Frame_Header = 0; //帧头
if((mDataBufPtr2[Frame_Header] == 0x5A) && (mDataBufPtr2[Frame_Header + 1] == 0xA5) \
&& (mDataBufPtr2[Frame_Header + 2] == 0x01) && (mDataBufPtr2[Frame_Header + 3] == 0x01))
{
UART_Ch2_Send_Multiple_Byte(AimaDateUart, sizeof(AimaDateUart));
}
else
{
;
}
}
uint8_t GetDataCompare(void) uint8_t GetDataCompare(void)
{ {
...@@ -412,6 +436,27 @@ void UART_Put1(uint32_t Value) ...@@ -412,6 +436,27 @@ void UART_Put1(uint32_t Value)
// RS485_TX_finish = 0; // RS485_TX_finish = 0;
return; return;
} }
void UART_Put2(uint32_t Value)
{
uint32_t nextPos = 0u;
nextPos = (UARTRxBuf2.write_pos + 1) % UART_RX_MAX_DEPTH;
if ( nextPos == UARTRxBuf2.read_pos )
{
//队列已满,无法插入队列
// UARTRxBuf.write_pos = 0;
// RS485_TX_finish = 0;
}
else
{
UARTRxBuf2.Rx_Buffer [ UARTRxBuf2.write_pos ] = Value;
UARTRxBuf2.write_pos = (UARTRxBuf2.write_pos + 1) % UART_RX_MAX_DEPTH;
}
// RS485_send_time = 0;
return;
}
void Recv_Byte(void) void Recv_Byte(void)
{ {
int i = 0; int i = 0;
...@@ -602,3 +647,101 @@ static uint32_t Protocol_UartRead1(uint8_t *pData, uint32_t len) ...@@ -602,3 +647,101 @@ static uint32_t Protocol_UartRead1(uint8_t *pData, uint32_t len)
return i; return i;
} }
void Recv_Byte2(void)
{
int i = 0;
int j = 0;
uint32_t len;
readNum2 = Protocol_UartRead2(mDataBufPtr2 + mDataBufLen2, 1024 - mDataBufLen2);
// if (readNum1 > 0)
// {
// BarCodeDataGet();
// }
if (readNum2 > 0)
{
mDataBufLen2 += readNum2;
while(mDataBufLen2)
{
memset(BarCode2, 0, sizeof(BarCode2));
for(i = 0; i < mDataBufLen2; i++)
{
// if((mDataBufPtr1[i] == 0x0 ) && (mDataBufPtr1[i - 1] == 0x0))
// {
// if( i < 1)
// {
// break;
// }
// memset(BarCode1, 0, sizeof(BarCode1));
for(j = 0; j < mDataBufLen2; j++)
{
BarCode2[j] = mDataBufPtr2[j];
}
// }
}
// 解析协议
len = mDataBufLen2;
if ( (len > 0) && (len < mDataBufLen2) )
{
// 将未解析的数据移到头部
// Move unparsed data to the head
memcpy(mDataBufPtr2, mDataBufPtr2 + len, mDataBufLen2 - len);
// memcpy(nowdata,mDataBufPtr + len,len);
// datacheck();
}
mDataBufLen2 -= len;
}
BarCodeDataGet2();
}
}
static uint32_t Protocol_UartRead2(uint8_t *pData, uint32_t len)
{
uint32_t i = 0;
uint32_t DataLen = 0u;
uint32_t ReadLen = 0u;
if ( UARTRxBuf2.write_pos == UARTRxBuf2.read_pos )
{
return 0; //队列空
}
if ( UARTRxBuf2.write_pos > UARTRxBuf2.read_pos )
{
DataLen = UARTRxBuf2.write_pos - UARTRxBuf2.read_pos;
}
else
{
DataLen = UART_RX_MAX_DEPTH - (UARTRxBuf2.read_pos - UARTRxBuf2.write_pos);
}
if ( len > DataLen )
{
ReadLen = DataLen;
}
else
{
ReadLen = len;
}
for ( i = 0u; i < ReadLen; i++ )
{
pData [ i ] = UARTRxBuf2.Rx_Buffer [ UARTRxBuf2.read_pos ];
UARTRxBuf2.read_pos = (UARTRxBuf2.read_pos + 1) % UART_RX_MAX_DEPTH;
}
return i;
}
...@@ -8,6 +8,8 @@ void UART_Put(uint32_t Value); ...@@ -8,6 +8,8 @@ void UART_Put(uint32_t Value);
void UART_Put1(uint32_t Value); void UART_Put1(uint32_t Value);
void Recv_Byte(void); void Recv_Byte(void);
void Recv_Byte1(void); void Recv_Byte1(void);
extern void UART_Put2(uint32_t Value);
extern void Recv_Byte2(void);
extern uint8_t GetDataCompare(void); extern uint8_t GetDataCompare(void);
extern uint32_t readNum; extern uint32_t readNum;
extern uint8_t BarCode[256]; extern uint8_t BarCode[256];
......
...@@ -4573,11 +4573,11 @@ void ONE_KEY_Display(void) ...@@ -4573,11 +4573,11 @@ void ONE_KEY_Display(void)
if(ONEKEYLongTime <= 24) if(ONEKEYLongTime <= 24)
{ {
ONEKEYLongTime++; ONEKEYLongTime++;
ONE_KEY = 0; // ONE_KEY = 0;
} }
else else
{ {
ONE_KEY = 1; // ONE_KEY = 1;
ONEKEYFlag = 0; ONEKEYFlag = 0;
ONEKEYLongTime = 0; ONEKEYLongTime = 0;
} }
...@@ -4587,26 +4587,26 @@ void ONE_KEY_Display(void) ...@@ -4587,26 +4587,26 @@ void ONE_KEY_Display(void)
ONEKEYDoubleclickTime++; ONEKEYDoubleclickTime++;
if(ONEKEYDoubleclickTime <= 4) if(ONEKEYDoubleclickTime <= 4)
{ {
ONE_KEY = 0; // ONE_KEY = 0;
} }
else if(ONEKEYDoubleclickTime <= 6) else if(ONEKEYDoubleclickTime <= 6)
{ {
ONE_KEY = 1; // ONE_KEY = 1;
} }
else if(ONEKEYDoubleclickTime <= 10) else if(ONEKEYDoubleclickTime <= 10)
{ {
ONE_KEY = 0; // ONE_KEY = 0;
} }
else else
{ {
ONE_KEY = 1; // ONE_KEY = 1;
ONEKEYFlag = 0; ONEKEYFlag = 0;
ONEKEYDoubleclickTime = 0; ONEKEYDoubleclickTime = 0;
} }
} }
else else
{ {
ONE_KEY = 1; // ONE_KEY = 1;
ONEKEYLongTime = 0; ONEKEYLongTime = 0;
ONEKEYDoubleclickTime = 0; ONEKEYDoubleclickTime = 0;
} }
......
...@@ -73,6 +73,8 @@ extern Key_Real_Status_en_t enKeyLeftRealStatus; ...@@ -73,6 +73,8 @@ extern Key_Real_Status_en_t enKeyLeftRealStatus;
extern Key_Real_Status_en_t enKeyRightRealStatus; extern Key_Real_Status_en_t enKeyRightRealStatus;
/*------------------------------------------------------------------------------------*/ /*------------------------------------------------------------------------------------*/
extern uint8_t Key_Mode;
extern void Key_Init(void); extern void Key_Init(void);
extern void Key_Service(void); /*10ms*/ extern void Key_Service(void); /*10ms*/
......
...@@ -5,7 +5,9 @@ ...@@ -5,7 +5,9 @@
#include "Barcode_Scanner.h" #include "Barcode_Scanner.h"
#include "Task.h" #include "Task.h"
#include "string.h" #include "string.h"
#include "app_lsdn.h"
uint8_t Key_Mode = 0;
//ABC输出 //ABC输出
void Key_Operation_SW5(Key_Event_en_t enKeyEvent) void Key_Operation_SW5(Key_Event_en_t enKeyEvent)
{ {
...@@ -49,13 +51,22 @@ void Key_Operation_SW7(Key_Event_en_t enKeyEvent) //上下ACC电 ...@@ -49,13 +51,22 @@ void Key_Operation_SW7(Key_Event_en_t enKeyEvent) //上下ACC电
{ {
if ( enKeyEvent == KEY_EVENT_SHORT_PRESS ) if ( enKeyEvent == KEY_EVENT_SHORT_PRESS )
{ {
if(RELAY_KEY_MCU == 1) // if(RELAY_KEY_MCU == 1)
// {
// RELAY_KEY_MCU = 0;
// }
// else
// {
// RELAY_KEY_MCU = 1;
// }
if(Scroll_Wheel < 100)
{ {
RELAY_KEY_MCU = 0; Scroll_Wheel++;
} }
else else
{ {
RELAY_KEY_MCU = 1; Scroll_Wheel = 0;
} }
} }
else if ( enKeyEvent == KEY_EVENT_LONG_PRESS ) else if ( enKeyEvent == KEY_EVENT_LONG_PRESS )
...@@ -73,7 +84,15 @@ void Key_Operation_SW8(Key_Event_en_t enKeyEvent) ...@@ -73,7 +84,15 @@ void Key_Operation_SW8(Key_Event_en_t enKeyEvent)
{ {
if ( enKeyEvent == KEY_EVENT_SHORT_PRESS ) //长按一键启动 if ( enKeyEvent == KEY_EVENT_SHORT_PRESS ) //长按一键启动
{ {
ONEKEYFlag = 1; // ONEKEYFlag = 1;
if(Scroll_Wheel > 0)
{
Scroll_Wheel--;
}
else
{
Scroll_Wheel = 100;
}
} }
else if ( enKeyEvent == KEY_EVENT_LONG_PRESS ) //长按2秒 else if ( enKeyEvent == KEY_EVENT_LONG_PRESS ) //长按2秒
{ {
......
...@@ -109,9 +109,9 @@ void RTE_GPIO_Init(void) ...@@ -109,9 +109,9 @@ void RTE_GPIO_Init(void)
GPIO_Config(&gpio_temp); GPIO_Config(&gpio_temp);
gpio_temp.enGPIOPort = GPIO_PORT_GROUP_10; gpio_temp.enGPIOPort = GPIO_PORT_GROUP_10;
gpio_temp.enGPIOPIN = GPIO_PIN_14; gpio_temp.enGPIOPIN = GPIO_PIN_14;
gpio_temp.enGPIOMode = GPIO_MODE_PORT; gpio_temp.enGPIOMode = GPIO_MODE_ALTER_SOFTWARE;
gpio_temp.enGPIODir = GPIO_DIR_OUT; gpio_temp.enGPIODir = GPIO_DIR_OUT;
gpio_temp.enGPIOAltFun = GPIO_ALTER_FUN_1; gpio_temp.enGPIOAltFun = GPIO_ALTER_FUN_2;
GPIO_Config(&gpio_temp); GPIO_Config(&gpio_temp);
gpio_temp.enGPIOPort = GPIO_PORT_GROUP_10; gpio_temp.enGPIOPort = GPIO_PORT_GROUP_10;
gpio_temp.enGPIOPIN = GPIO_PIN_6; gpio_temp.enGPIOPIN = GPIO_PIN_6;
...@@ -121,9 +121,9 @@ void RTE_GPIO_Init(void) ...@@ -121,9 +121,9 @@ void RTE_GPIO_Init(void)
GPIO_Config(&gpio_temp); GPIO_Config(&gpio_temp);
gpio_temp.enGPIOPort = GPIO_PORT_GROUP_10; gpio_temp.enGPIOPort = GPIO_PORT_GROUP_10;
gpio_temp.enGPIOPIN = GPIO_PIN_13; gpio_temp.enGPIOPIN = GPIO_PIN_13;
gpio_temp.enGPIOMode = GPIO_MODE_PORT; gpio_temp.enGPIOMode = GPIO_MODE_ALTER_SOFTWARE;
gpio_temp.enGPIODir = GPIO_DIR_OUT; gpio_temp.enGPIODir = GPIO_DIR_IN;
gpio_temp.enGPIOAltFun = GPIO_ALTER_FUN_1; gpio_temp.enGPIOAltFun = GPIO_ALTER_FUN_2;
GPIO_Config(&gpio_temp); GPIO_Config(&gpio_temp);
gpio_temp.enGPIOPort = GPIO_PORT_GROUP_AP0; gpio_temp.enGPIOPort = GPIO_PORT_GROUP_AP0;
gpio_temp.enGPIOPIN = GPIO_PIN_11; gpio_temp.enGPIOPIN = GPIO_PIN_11;
......
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
#define LINE_OUT_NEG_09 GPIO_OUT_PORT10_PIN04 //485_RE #define LINE_OUT_NEG_09 GPIO_OUT_PORT10_PIN04 //485_RE
#define ONE_START GPIO_OUT_PORT10_PIN14 //一键启动
#define ABC_OUT GPIO_OUT_PORT00_PIN04 //ABC轮动报警输出 #define ABC_OUT GPIO_OUT_PORT00_PIN04 //ABC轮动报警输出
#define BCDD_MCU GPIO_OUT_PORT10_PIN00 //脚撑 #define BCDD_MCU GPIO_OUT_PORT10_PIN00 //脚撑
...@@ -42,7 +41,6 @@ ...@@ -42,7 +41,6 @@
#define ZTS_A GPIO_IN_APORT00_PIN14 //坐桶锁 #define ZTS_A GPIO_IN_APORT00_PIN14 //坐桶锁
#define ZTS_B GPIO_IN_APORT00_PIN15 //坐桶锁 #define ZTS_B GPIO_IN_APORT00_PIN15 //坐桶锁
#define ONE_KEY GPIO_OUT_PORT10_PIN13 //一键启动输出
/* ---------------------旧的-------------------------- */ /* ---------------------旧的-------------------------- */
#define POWER_CTRL_KL15 GPIO_OUT_PORT10_PIN12 #define POWER_CTRL_KL15 GPIO_OUT_PORT10_PIN12
...@@ -65,7 +63,6 @@ ...@@ -65,7 +63,6 @@
#define LED4 GPIO_OUT_APORT00_PIN11 //左转 #define LED4 GPIO_OUT_APORT00_PIN11 //左转
#define LINE_OUT_NEG_06 GPIO_OUT_PORT09_PIN01 //位置灯 #define LINE_OUT_NEG_06 GPIO_OUT_PORT09_PIN01 //位置灯
#define LINE_jinguang GPIO_OUT_PORT10_PIN10 //近光 #define LINE_jinguang GPIO_OUT_PORT10_PIN10 //近光
#define POWER_CTRL_KL30_Current GPIO_OUT_PORT10_PIN14 //蓝牙
//zh: //zh:
/****************************************************************************** /******************************************************************************
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#include "string.h" #include "string.h"
#include "api_RS485.h" #include "api_RS485.h"
#include "R485_Communication_Matrix.h" #include "R485_Communication_Matrix.h"
#include "app_lsdn.h"
/******************************************************************************* /*******************************************************************************
* * * *
* ϵͳ��������ģʽ(SYS_MODE_OFF / SYS_MODE_ON / SYS_MODE_STANDBY )�����б� * * ϵͳ��������ģʽ(SYS_MODE_OFF / SYS_MODE_ON / SYS_MODE_STANDBY )�����б� *
...@@ -81,6 +82,8 @@ uint8_t sartigon = 0; ...@@ -81,6 +82,8 @@ uint8_t sartigon = 0;
void Sys_Run_Mode_10ms_Tasks_Group(void) void Sys_Run_Mode_10ms_Tasks_Group(void)
{ {
// BusOff_Service( ); // BusOff_Service( );
Key_Judgment_Service();
Recv_Byte2();
Key_Service( ); Key_Service( );
if(devicename<0xFFFF) if(devicename<0xFFFF)
{ {
...@@ -231,7 +234,7 @@ void Sys_Run_Mode_10ms_Tasks_Group(void) ...@@ -231,7 +234,7 @@ void Sys_Run_Mode_10ms_Tasks_Group(void)
uint8_t time100mssend = 0; uint8_t time100mssend = 0;
void Sys_Run_Mode_20ms_Tasks_Group0(void) void Sys_Run_Mode_20ms_Tasks_Group0(void)
{ {
AIMA_Uart_Send();
// uint8_t data[8] = {0}; // uint8_t data[8] = {0};
// uint32_t SpdN = 0; // uint32_t SpdN = 0;
// _CAN_Msg canMag; // _CAN_Msg canMag;
...@@ -325,21 +328,14 @@ uint8_t showtime = 0; ...@@ -325,21 +328,14 @@ uint8_t showtime = 0;
uint8_t ACCONOFF_delay_3s; uint8_t ACCONOFF_delay_3s;
uint16_t ONE_KEY_ONOFF; uint16_t ONE_KEY_ONOFF;
uint16_t CHECK_Ctrl_delay = 0; uint16_t CHECK_Ctrl_delay = 0;
uint8_t ttext[5] = {4,5,6,7,8};
void Sys_Run_Mode_100ms_Tasks_Group(void) void Sys_Run_Mode_100ms_Tasks_Group(void)
{ {
// static uint32_t loc_timer = 0; // Aima_SLF(1,1,1,1);
// loc_timer++;
// if ( loc_timer >= 3 )
// {
// loc_timer = 0;
// // HW_CHECK_IPK_EXIST( );
// Recv_Byte1();
// }
Display_PageNum(); Display_PageNum();
ONE_KEY_Display(); ONE_KEY_Display();
RotationAlarm(); RotationAlarm();
BCDD_MCU_Service(); BCDD_MCU_Service();
if(CHECK_Ctrl_delay < 200) if(CHECK_Ctrl_delay < 200)
{ {
CHECK_Ctrl_delay++; CHECK_Ctrl_delay++;
......
#include "app_lsdn.h" #include "app_lsdn.h"
#include "RTE_GPIO.h" #include "RTE_GPIO.h"
#include "GenDelay.h" #include "GenDelay.h"
#include "../UART/UART.h"
#include "Key.h"
#include <string.h>
_AimaDataText Aimadata;
// 假设的GPIO操作函数 // 假设的GPIO操作函数
void set_pin_high(uint8_t mode) void set_pin_high(uint8_t mode)
...@@ -14,7 +19,6 @@ void set_pin_high(uint8_t mode) ...@@ -14,7 +19,6 @@ void set_pin_high(uint8_t mode)
} }
else else
{ {
ONE_START = 1;
} }
} }
void set_pin_low(uint8_t mode) void set_pin_low(uint8_t mode)
...@@ -28,7 +32,6 @@ void set_pin_low(uint8_t mode) ...@@ -28,7 +32,6 @@ void set_pin_low(uint8_t mode)
} }
else else
{ {
ONE_START = 0;
} }
} }
void lsdn_delay_us(uint32_t us) void lsdn_delay_us(uint32_t us)
...@@ -99,27 +102,115 @@ uint8_t c_YXT_sum(uint8_t *buf,uint8_t len) ...@@ -99,27 +102,115 @@ uint8_t c_YXT_sum(uint8_t *buf,uint8_t len)
return ret; return ret;
} }
uint8_t crc8_calculate(const uint8_t *data, uint8_t length)
{
uint8_t crc = 0x00; // 初始值
const uint8_t polynomial = 0x07; // CRC-8标准多项式
for (uint32_t i = 0; i < length; i++)
{
crc ^= data[i];
for(uint8_t j = 0; j < 8; j++)
{
if(crc & 0x80)
{
crc = (crc << 1) ^ polynomial;
}
else
{
crc <<= 1;
}
}
}
return crc;
}
uint8_t Aima_SLF_DataBuf[50]; uint8_t Aima_SLF_DataBuf[50];
uint8_t flag1 = 0; uint8_t flag1 = 0;
// mode = 0,485接口;mode=1,一键启动接口 // mode = 0,485接口;mode=1,一键启动接口
void Aima_SLF(uint8_t mode, uint8_t cmd, uint8_t data, uint8_t data_len) void Aima_SLF(uint8_t mode, uint8_t cmd, uint8_t data, uint8_t data_len)
{ {
Aima_SLF_DataBuf[0] = 0x5A;
Aima_SLF_DataBuf[1] = 0xA5; //帧头
Aima_SLF_DataBuf[2] = 0x02; //从机指令
Aima_SLF_DataBuf[3] = 0x11;
Aima_SLF_DataBuf[4] = 0x01; //设备类型
Aima_SLF_DataBuf[5] = 0x01; //功能码
Aima_SLF_DataBuf[6] = 0x03; //数据长度
Aima_SLF_DataBuf[7] = 0xFF; //数据内容
Aima_SLF_DataBuf[8] = 0xFF; //数据内容
Aima_SLF_DataBuf[9] = 0x00; //数据内容
Aima_SLF_DataBuf[10] = 0xC6; //校验
Aima_SLF_DataBuf[11] = 0xFF; //帧尾
lsdn_send_data(mode, Aima_SLF_DataBuf, 12);
// 5C 2f
// 0101 1100 0010 1111
}
// if(flag1 == onoff) uint8_t AimaDateUart[Aima_Data_Length];
// { void AIMA_Uart_Send(void)
// return; {
// } AimaDateUart[0] = 0x5A;
Aima_SLF_DataBuf[0] = 0x55; AimaDateUart[1] = 0xA5; //帧头
Aima_SLF_DataBuf[1] = 0xaa; AimaDateUart[2] = 0x02;
Aima_SLF_DataBuf[2] = cmd; AimaDateUart[3] = 0x11;
Aima_SLF_DataBuf[3] = data; AimaDateUart[4] = 0x01; //设备地址
Aima_SLF_DataBuf[4] = c_YXT_sum(Aima_SLF_DataBuf, data_len + 3); AimaDateUart[5] = 0x01; //功能码
lsdn_send_data(mode, Aima_SLF_DataBuf, data_len + 4); AimaDateUart[6] = 0x03; //数据长度
AimaDateUart[7] = Aimadata.Msg[0];
// flag1 = onoff; AimaDateUart[8] = Aimadata.Msg[1];
AimaDateUart[9] = Aimadata.Msg[2]; //数据
AimaDateUart[10] = crc8_calculate(&AimaDateUart[6], (AimaDateUart[6] + 1)); //校验
AimaDateUart[11] = 0xFF; //帧尾
// UART_Ch2_Send_Multiple_Byte(AimaDateUart, sizeof(AimaDateUart));
} }
uint8_t Scroll_Wheel;
void Key_Judgment_Service(void)
{
// memset(Aimadata.Msg, 0x00, Aima_Data_Length);
if(Key_Mode == 1) //左键
{
Aimadata.Sig.media_left_key = 0x01;
}
else if(Key_Mode == 2) //右键
{
Aimadata.Sig.media_right_key = 0x01;
}
else if(Key_Mode == 3) //中键
{
Aimadata.Sig.media_middle_key = 0x01;
}
else if(Key_Mode == 4) //向上
{
if(Scroll_Wheel < 100)
{
Scroll_Wheel++;
}
else
{
Scroll_Wheel = 0;
}
}
else if(Key_Mode == 5)
{
if(Scroll_Wheel > 0)
{
Scroll_Wheel--;
}
else
{
Scroll_Wheel = 100;
}
}
else
{
;
}
Aimadata.Sig.media_key_pos = Scroll_Wheel;
}
......
...@@ -3,9 +3,39 @@ ...@@ -3,9 +3,39 @@
#include "TYW_stdint.h" #include "TYW_stdint.h"
#define Aima_Data_Length 12
typedef union
{
uint8_t Msg[3];
struct
{
// ---------------- 转向/灯光类信号(1位/项) ----------------
uint8_t left_turn_signal : 1; // 左转信号
uint8_t right_turn_signal : 1; // 右转信号
uint8_t turn_reset : 1; // 转向复位(关)
uint8_t overtake_light_switch : 1; // 超车灯开关
uint8_t high_beam_switch : 1; // 远光灯开关
uint8_t low_beam_switch : 1; // 近光灯开关
uint8_t custom_func : 1; // 自定义
uint8_t list_ui_return_switch : 1; // --LIST开关(返回当前UI一级界面)
// ---------------- 多媒体类信号 ----------------
uint8_t media_left_key : 1; // 多媒体左键(1位)
uint8_t media_right_key : 1; // 多媒体右键(1位)
uint8_t media_middle_key : 1; // 多媒体中间(1位)
uint8_t reserved : 5; //预留
void Aima_SLF(uint8_t mode, uint8_t cmd, uint8_t data, uint8_t data_len); uint8_t media_key_pos : 8; // 多媒体按键位置
}Sig;
} _AimaDataText;
extern uint8_t Scroll_Wheel;
extern uint8_t AimaDateUart[Aima_Data_Length];
extern _AimaDataText Aimadata;
extern void Aima_SLF(uint8_t mode, uint8_t cmd, uint8_t data, uint8_t data_len);
extern void AIMA_Uart_Send(void);
extern void Key_Judgment_Service(void);
#endif #endif
\ No newline at end of file
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
/**根据实际应用调整buf大小**/ /**根据实际应用调整buf大小**/
#define UART_30_SEND_MAX 512UL #define UART_30_SEND_MAX 512UL
#define UART_31_SEND_MAX 512UL #define UART_31_SEND_MAX 512UL
#define UART_32_SEND_MAX 1UL #define UART_32_SEND_MAX 512UL
#define UART_33_SEND_MAX 1UL #define UART_33_SEND_MAX 1UL
/***************************************************************/ /***************************************************************/
......
...@@ -77,7 +77,6 @@ void Sys_Startup_Init(void) ...@@ -77,7 +77,6 @@ void Sys_Startup_Init(void)
// GPIO_DIR_PORT00_PIN08 = 1; // GPIO_DIR_PORT00_PIN08 = 1;
// TX_OUT = 0; // TX_OUT = 0;
ONE_START = 1;
ABC_OUT = 0; ABC_OUT = 0;
GPIO_SET_KEPP( ); GPIO_SET_KEPP( );
...@@ -104,19 +103,17 @@ void Sys_Startup_Init(void) ...@@ -104,19 +103,17 @@ void Sys_Startup_Init(void)
firstIGON = 1; firstIGON = 1;
UART_Init(UART_RLIN30, &loc_config); UART_Init(UART_RLIN30, &loc_config);
loc_config.enUARTLINMode = MODE_UART; loc_config.enUARTLINMode = MODE_UART;
loc_config.u32UARTbps = 9600; loc_config.u32UARTbps = 19200;
loc_config.enUARTOrder = UART_LSB; loc_config.enUARTOrder = UART_LSB;
loc_config.en2UARTParity = UART_PARITY_DISABLE; loc_config.en2UARTParity = UART_PARITY_DISABLE;
loc_config.en2UARTPolarity = UART_POLARITY_NORMAL; loc_config.en2UARTPolarity = UART_POLARITY_NORMAL;
loc_config.pfnUARTConfirmCallBack = 0; loc_config.pfnUARTConfirmCallBack = 0;
loc_config.pfnUARTErrHandleCallBack = 0; loc_config.pfnUARTErrHandleCallBack = 0;
loc_config.pfnUARTReadMsgCallBack = UART_Put1; loc_config.pfnUARTReadMsgCallBack = UART_Put2;
// UART_Init(UART_RLIN31, &loc_config); UART_Init(UART_RLIN32, &loc_config);
// Auto_ONOFF = 1;
// AutoFlag = 1;
RELAY_VBAT_MCU = 1; RELAY_VBAT_MCU = 1;
RELAY_KEY_MCU = 0; RELAY_KEY_MCU = 1;
ONE_KEY = 1; // ONE_KEY = 1;
} }
/*********************************************************************** /***********************************************************************
......
...@@ -939,17 +939,17 @@ ...@@ -939,17 +939,17 @@
#define INTRLIN32_ENABLE 0x00000000u #define INTRLIN32_ENABLE 0x00000000u
#endif #endif
// #define INTRLIN32UR0_ENABLE (IRQ_TABLE_START + 0x00000294u) #define INTRLIN32UR0_ENABLE (IRQ_TABLE_START + 0x00000294u)
#ifndef INTRLIN32UR0_ENABLE #ifndef INTRLIN32UR0_ENABLE
#define INTRLIN32UR0_ENABLE 0x00000000u #define INTRLIN32UR0_ENABLE 0x00000000u
#endif #endif
// #define INTRLIN32UR1_ENABLE (IRQ_TABLE_START + 0x00000298u) #define INTRLIN32UR1_ENABLE (IRQ_TABLE_START + 0x00000298u)
#ifndef INTRLIN32UR1_ENABLE #ifndef INTRLIN32UR1_ENABLE
#define INTRLIN32UR1_ENABLE 0x00000000u #define INTRLIN32UR1_ENABLE 0x00000000u
#endif #endif
// #define INTRLIN32UR2_ENABLE (IRQ_TABLE_START + 0x0000029Cu) #define INTRLIN32UR2_ENABLE (IRQ_TABLE_START + 0x0000029Cu)
#ifndef INTRLIN32UR2_ENABLE #ifndef INTRLIN32UR2_ENABLE
#define INTRLIN32UR2_ENABLE 0x00000000u #define INTRLIN32UR2_ENABLE 0x00000000u
#endif #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