Commit ff4d7d95 authored by 李俭双's avatar 李俭双

🐞 fix:蓝牙功能调试

parent f64ae345
......@@ -11,7 +11,7 @@ void BlueTooth_KL30_KL15_Wakeup_Init(void)
}
void Send_UUID_To_Esp32(void)
{
Protocol_Send(MCU_ESP32_0x03, Protocol_NULL, 0);
Protocol_Send(MCU_ESP32_0x03, UUIDData, 32);
}
uint8_t Get_Navigation_St_Dis(void)
{
......
......@@ -17,7 +17,7 @@ enum
BLUE_STATE_ON, //蓝牙模组启动完成
BLUE_STATE_OFF,
};
typedef struct
typedef struct __attribute__((aligned(4)))
{
uint8_t BlueTooth_St; /*蓝牙模组启动状态 0启动中 1启动完成*/
uint8_t Navigation_St;/*导航状态 0x35 未导航或导航结束 0x33 正在导航*/
......@@ -26,17 +26,20 @@ typedef struct
uint8_t BLE_St;
} BlueTooth_t;
typedef enum {
typedef enum __attribute__((aligned(4)))
{
EM_ESP32_BT_STARTUP_ST_STANDBY = 0,
EM_ESP32_BT_STARTUP_ST_SUCCESS,
} EM_ESP32_BT_STARTUP_ST_T;
typedef enum {
typedef enum __attribute__((aligned(4)))
{
EM_ESP32_NAVI_ST_STANDBY = 0,
EM_ESP32_NAVI_ST_NAVIGATING,
} EM_ESP32_NAVI_ST_T;
typedef struct {
typedef struct __attribute__((aligned(4)))
{
EM_ESP32_BT_STARTUP_ST_T Startup;
EM_ESP32_NAVI_ST_T NaviSt;
uint8_t NaviCode;
......
......@@ -30,7 +30,7 @@ Platform_16Bit
/**@struct Protocol_Data_t
* @brief 解析后的协议数据
*/
typedef struct
typedef struct __attribute__((aligned(4)))
{
Protocol_uint8_t FrameNo; /**< 帧序号 */
Protocol_uint8_t PowerSts; /**< 电源状态 */
......@@ -49,7 +49,7 @@ typedef void (*UARTClose)(void);
/**@struct Protocol_Func_t
* @brief 协议解析回调函数
*/
typedef struct
typedef struct __attribute__((aligned(4)))
{
UARTOpen UARTOpen_Cbk; /**< 串口打开回调 */
UARTSend UARTSend_Cbk; /**< 串口发送回调 */
......
......@@ -7,14 +7,14 @@
#define UART_RX_MAX_DEPTH (2 * 1024UL) // 4K
#define UART_DATA_BUF_LEN (2 * 1024UL) // 4K
typedef struct
typedef struct __attribute__((aligned(4)))
{
Protocol_uint32_t read_pos;
Protocol_uint32_t write_pos;
Protocol_uint8_t Rx_Buffer [ UART_RX_MAX_DEPTH ];
} UARTRxBuf_t;
typedef struct
typedef struct __attribute__((aligned(4)))
{
Protocol_uint32_t read_pos;
Protocol_uint32_t write_pos;
......@@ -54,41 +54,36 @@ void Protocol_Send_Service(void)
Protocol_uint32_t i = 0u;
Protocol_uint32_t DataLen = 0u;
Protocol_uint32_t SendLen = 0u;
//if ( UART_Ch1_Get_TX_Busy_Flag( ) == 0u )
if ( UARTTxBuf.write_pos == UARTTxBuf.read_pos )
{
if ( UARTTxBuf.write_pos == UARTTxBuf.read_pos )
{
return;
}
if ( UARTTxBuf.write_pos > UARTTxBuf.read_pos )
{
DataLen = UARTTxBuf.write_pos - UARTTxBuf.read_pos;
}
else
{
DataLen = UART_TX_MAX_DEPTH - (UARTTxBuf.read_pos - UARTTxBuf.write_pos);
}
if ( DataLen > 255 )
{
SendLen = 255;
}
else
{
SendLen = DataLen;
}
for ( i = 0u; i < SendLen; i++ )
{
UsartDataBuf [ i ] = UARTTxBuf.Tx_Buffer [ UARTTxBuf.read_pos ];
UARTTxBuf.read_pos = (UARTTxBuf.read_pos + 1) % UART_TX_MAX_DEPTH;
}
Uart0_IntSend(UsartDataBuf, SendLen);
//UART_Ch1_Send_Multiple_Byte(UsartDataBuf, SendLen);
return;
}
if ( UARTTxBuf.write_pos > UARTTxBuf.read_pos )
{
DataLen = UARTTxBuf.write_pos - UARTTxBuf.read_pos;
}
else
{
DataLen = UART_TX_MAX_DEPTH - (UARTTxBuf.read_pos - UARTTxBuf.write_pos);
}
if ( DataLen > 255 )
{
SendLen = 255;
}
else
{
SendLen = DataLen;
}
for ( i = 0u; i < SendLen; i++ )
{
UsartDataBuf [ i ] = UARTTxBuf.Tx_Buffer [ UARTTxBuf.read_pos ];
UARTTxBuf.read_pos = (UARTTxBuf.read_pos + 1) % UART_TX_MAX_DEPTH;
}
Uart0_IntSend(UsartDataBuf, SendLen);
}
static Protocol_uint8_t Protocol_OpenUart(void)
......
......@@ -11,7 +11,7 @@
/*** 控制结构 ***/
typedef struct
typedef struct __attribute__((aligned(4)))
{
uint8_t Dis_Valid;
uint8_t u8_DestSeg;
......@@ -29,7 +29,7 @@ typedef struct
extern DataCoolantTempDisStruct DataCoolantTemp_Dis;
typedef struct
typedef struct __attribute__((aligned(4)))
{
uint16_t Value;
uint8_t Valid;
......
......@@ -18,20 +18,20 @@
#define DATA_ESPEED_HYSTERESIS 80 //回差
/*** 控制结构 ***/
typedef struct
typedef struct __attribute__((aligned(4)))
{
uint16_t Buffer[5];
uint8_t Cnt;
} DataESpeedSamplerStruct; //转速采样结构
typedef struct
typedef struct __attribute__((aligned(4)))
{
uint16_t Speed;
uint16_t Delta;
uint8_t Dir;
} DataESPeedDampingStruct; //转速阻尼结构
typedef struct
typedef struct __attribute__((aligned(4)))
{
uint16_t ESpeedBackup;
uint16_t Timer;
......
......@@ -2,7 +2,7 @@
#define _DATA_TPMS_H_
#include "common.h"
typedef struct
typedef struct __attribute__((aligned(4)))
{
uint32_t Front_Press_Value;
uint32_t Rear_Press_Value;
......
......@@ -14,7 +14,7 @@
#define DATA_VSPEED_HYSTERESIS 15 //回差
/*** 控制结构 ***/
typedef struct
typedef struct __attribute__((aligned(4)))
{
uint16_t Timer;
uint16_t Timer1;
......@@ -23,7 +23,7 @@ typedef struct
uint8_t Cnt;
} DataVSpeedSamplerStruct; //车速采样结构
typedef struct
typedef struct __attribute__((aligned(4)))
{
uint16_t Speed;
uint16_t Delta;
......
......@@ -4,7 +4,8 @@
#include "Components.h"
typedef enum{
typedef enum __attribute__((aligned(4)))
{
FuelSensorNormal = 0,
FuelSensorShortCircuit,
FuelSensorOpenCircuit,
......
......@@ -22,7 +22,7 @@ extern {
#endif
/* Exported types ------------------------------------------------------------*/
typedef struct
typedef struct __attribute__((aligned(4)))
{
uint32_t u32Res1;
uint32_t u32Res2;
......
......@@ -54,6 +54,7 @@ static void Power_KL30_Init(void)
BU98R10_Init();
Uart0_Init(115200);
Protocol_KL30_Wakeup_Init();
BlueTooth_KL30_KL15_Wakeup_Init();
Sys_KL30_Init();
Checkself_Init();
Data_Vehicle_Speed_KL30_Init();
......@@ -112,6 +113,8 @@ static void Power_Wakeup_Init(void)
//Light_Sensor_Init_Example();//注意顺序1
LED_Driver_Init_Example();//注意顺序2
Protocol_KL30_Wakeup_Init();
Uart0_Init(115200);
BlueTooth_KL30_KL15_Wakeup_Init();
Fuel_KL30_Init();
Data_Voltage_Init();
TimerM_PWM_counter_Output_Init(TIMERM_COUNTER0, 400, 64000000);
......@@ -153,6 +156,7 @@ static void Power_IG_ON_Init(void)
Data_Voltage_Init();
MenuData_TCS_Init();
Data_Coolant_Temp_KL15_Init();
BlueTooth_KL30_KL15_Wakeup_Init();
CAN_TX_SetEnable(&CAN_CH0_CanMsgTxOp, CAN_N_TX_Enable);
}
......
This diff is collapsed.
......@@ -49,11 +49,11 @@
*/
static uint32_t UART_GetSysClock(void)
{
if (USE_HSE_SYSTYEM_CLOCK == SYSTYEM_CLOCK_OPEN)
{
return 64000000;
}
else
//if (USE_HSE_SYSTYEM_CLOCK == SYSTYEM_CLOCK_OPEN)
//{
// return 32000000;
//}
//else
{
return SystemCoreClock;
}
......
......@@ -159,7 +159,7 @@ void uart0_interrupt_receive(void)
uart_callback_error(err_type);
}
UART_Put((uint8_t)UART0_RX);
UART_Put((uint16_t)UART0_RX);
......
......@@ -35,12 +35,14 @@ void Sys_2ms_Tasks(void)
void Sys_5ms_Tasks(void)
{
Flash_Sync_Signal_Generation_Service();
}
}
uint8_t ljs_buf[200] = {0};
void Sys_10ms_Tasks(void)
{
Line_In_Debounce_Service(10u);
memset(ljs_buf, 0x55, 200);
Line_In_Debounce_Service(10u);
Key_Service();
Data_Mileage_Write_EEPROM();
Can_BusOff_Recover(10u);
......@@ -48,7 +50,9 @@ void Sys_10ms_Tasks(void)
Fuel_R_Cal(10u);
TYW_Check_Count();
Data_TPMS_Processing_Service();
Protocol_Send_Service();
Protocol_Service();
Protocol_Send_Service();
//Uart0_IntSend(ljs_buf, 200) ;
}
void Sys_20ms_Tasks(void)
......@@ -58,7 +62,7 @@ void Sys_20ms_Tasks(void)
Data_Vehicle_Speed_Processing_Service();
Data_Engine_Speed_Processing_Service();
Data_Coolant_Temp_Processing_Service();
Protocol_Service();
}
......@@ -118,4 +122,5 @@ void Sys_Exact_50us_Tasks(void)
task_1ms =0U;
eeprom_1ms_timeCount( );
}
}
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