generated from Template/H563ZI-HAL-CMake-Template
加入了消息队列,线程是可以正常运行的,rx接收任务一直运行不成功,暂时放弃
This commit is contained in:
@@ -100,7 +100,7 @@ VOID tx_application_define(VOID *first_unused_memory)
|
||||
/* USER CODE END App_ThreadX_Init_Error */
|
||||
}
|
||||
/* USER CODE BEGIN App_ThreadX_Init_Success */
|
||||
// App_ThreadX_Init(first_unused_memory); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> //app_thread_init()<29>ſ<EFBFBD><C5BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
// App_ThreadX_Init(first_unused_memory); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> //app_thread_init()<29>ſ<EFBFBD><C5BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
/* USER CODE END App_ThreadX_Init_Success */
|
||||
|
||||
}
|
||||
|
||||
@@ -59,11 +59,11 @@ extern "C" {
|
||||
extern TX_QUEUE ble_tx_queue;
|
||||
extern TX_EVENT_FLAGS_GROUP system_events;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t msg_type; // 1=λ<><CEBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,2=<3D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
|
||||
char data[128];
|
||||
}BLE_Message; // <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ <20><><EFBFBD>ݽṹ
|
||||
//typedef struct
|
||||
//{
|
||||
//// uint32_t msg_type; // 应该使用 int --- 4字节
|
||||
// char data[128];
|
||||
//}BLE_Message; //
|
||||
|
||||
/* USER CODE END PD */
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@
|
||||
|
||||
/* Private variables ---------------------------------------------------------*/
|
||||
/* USER CODE BEGIN PV */
|
||||
/* ȫ<EFBFBD>ֱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||
/* ȫ<>ֱ<EFBFBD><D6B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||
|
||||
TX_EVENT_FLAGS_GROUP system_events;
|
||||
MotorCommand current_motor_cmd = {0,0};
|
||||
@@ -66,8 +66,13 @@ UCHAR ble_tx_stack[BLE_TX_THREAD_STACK_SIZE];
|
||||
|
||||
TX_QUEUE ble_tx_queue;
|
||||
#define BLE_TX_QUEUE_LEN 10
|
||||
BLE_Message ble_tx_queue_buffer[BLE_TX_QUEUE_LEN];
|
||||
//ULONG ble_tx_queue_buffer[BLE_TX_QUEUE_LEN]; // 一定要是ULONG类型 之前使用的是BLE_Message
|
||||
|
||||
#define BLE_TX_MSG_LEN 64
|
||||
#define BLE_TX_QUEUE_LEN 10
|
||||
|
||||
__attribute__((aligned(4)))
|
||||
ULONG ble_tx_queue_buffer[BLE_TX_QUEUE_LEN * ((BLE_TX_MSG_LEN + sizeof(ULONG) - 1) / sizeof(ULONG))];
|
||||
|
||||
//
|
||||
|
||||
@@ -90,7 +95,7 @@ BLE_Message ble_tx_queue_buffer[BLE_TX_QUEUE_LEN];
|
||||
UINT App_ThreadX_Init(VOID *memory_ptr)
|
||||
{
|
||||
HCBle_SendData("进入 App_ThreadX_Init\r\n");
|
||||
|
||||
// HCBle_SendData("%d",sizeof(ULONG));
|
||||
UINT status;
|
||||
|
||||
// === 创建 BLE RX 线程 ===
|
||||
@@ -111,20 +116,24 @@ UINT App_ThreadX_Init(VOID *memory_ptr)
|
||||
ble_tx_stack, BLE_TX_THREAD_STACK_SIZE,
|
||||
BLE_TX_THREAD_PRIORITY, BLE_TX_THREAD_PRIORITY,
|
||||
TX_NO_TIME_SLICE, TX_AUTO_START);
|
||||
|
||||
if (status != TX_SUCCESS) {
|
||||
HCBle_SendData("❌ BLE TX 线程创建失败,错误码=%d\r\n", status);
|
||||
return status;
|
||||
}
|
||||
|
||||
// === 创建 BLE TX 消息队列 ===
|
||||
// status = tx_queue_create(&ble_tx_queue, "BLE TX Queue",
|
||||
// sizeof(ULONG),
|
||||
// ble_tx_queue_buffer,
|
||||
// sizeof(ble_tx_queue_buffer));
|
||||
// if (status != TX_SUCCESS) {
|
||||
// HCBle_SendData("❌ BLE TX 消息队列创建失败,错误码=%d\r\n", status);
|
||||
// return status;
|
||||
// }
|
||||
status = tx_queue_create(&ble_tx_queue, "BLE TX Queue",
|
||||
(BLE_TX_MSG_LEN + sizeof(ULONG) - 1) / sizeof(ULONG),
|
||||
ble_tx_queue_buffer,
|
||||
sizeof(ble_tx_queue_buffer));
|
||||
|
||||
|
||||
if (status != TX_SUCCESS) {
|
||||
HCBle_SendData("❌ BLE TX 消息队列创建失败,错误码=%d\r\n", status);
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
HCBle_SendData("✅ BLE RX/TX 线程和队列初始化完成\r\n");
|
||||
|
||||
@@ -140,7 +149,7 @@ UINT App_ThreadX_Init(VOID *memory_ptr)
|
||||
void MX_ThreadX_Init(void)
|
||||
{
|
||||
/* USER CODE BEGIN Before_Kernel_Start */
|
||||
|
||||
HCBle_InitEventFlags(); // 这必须在任何使用前调用一次
|
||||
/* USER CODE END Before_Kernel_Start */
|
||||
|
||||
tx_kernel_enter();
|
||||
@@ -151,7 +160,7 @@ void MX_ThreadX_Init(void)
|
||||
}
|
||||
|
||||
/* USER CODE BEGIN 1 */
|
||||
#ifdef TEST //Ŀǰ<EFBFBD><EFBFBD><EFBFBD>ڲ<EFBFBD><EFBFBD><EFBFBD>
|
||||
#ifdef TEST //Ŀǰ<C4BF><C7B0><EFBFBD>ڲ<EFBFBD><DAB2><EFBFBD>
|
||||
|
||||
|
||||
/* USER CODE BEGIN 1 */
|
||||
@@ -177,11 +186,7 @@ void main_control_thread_entry(ULONG thread_input)
|
||||
Buzzer_Close();
|
||||
Shake_Motor_Close();
|
||||
|
||||
// 发送报警到手机
|
||||
BLE_Message msg;
|
||||
msg.msg_type = 2;
|
||||
snprintf(msg.data, sizeof(msg.data), "#{\"alert\":\"Obstacle detected!\"}\n");
|
||||
tx_queue_send(&ble_tx_queue, &msg, TX_WAIT_FOREVER);
|
||||
|
||||
}
|
||||
|
||||
// 处理蓝牙控制指令
|
||||
|
||||
@@ -103,7 +103,7 @@ int main(void)
|
||||
/* USER CODE BEGIN 2 */
|
||||
// HCBle_InitDMAReception();
|
||||
// HAL_Delay(200);
|
||||
|
||||
// GPS_Init();
|
||||
/* USER CODE END 2 */
|
||||
|
||||
MX_ThreadX_Init();
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -152,18 +152,82 @@
|
||||
<Bp>
|
||||
<Number>0</Number>
|
||||
<Type>0</Type>
|
||||
<LineNumber>110</LineNumber>
|
||||
<LineNumber>97</LineNumber>
|
||||
<EnabledFlag>1</EnabledFlag>
|
||||
<Address>134273076</Address>
|
||||
<Address>134229406</Address>
|
||||
<ByteObject>0</ByteObject>
|
||||
<HtxType>0</HtxType>
|
||||
<ManyObjects>0</ManyObjects>
|
||||
<SizeOfObject>0</SizeOfObject>
|
||||
<BreakByAccess>0</BreakByAccess>
|
||||
<BreakIfRCount>1</BreakIfRCount>
|
||||
<Filename>..\fun\HCBle.c</Filename>
|
||||
<Filename>../Core/Src/app_threadx.c</Filename>
|
||||
<ExecCommand></ExecCommand>
|
||||
<Expression>\\AutoGuideStick\../fun/HCBle.c\110</Expression>
|
||||
<Expression>\\AutoGuideStick\../Core/Src/app_threadx.c\97</Expression>
|
||||
</Bp>
|
||||
<Bp>
|
||||
<Number>1</Number>
|
||||
<Type>0</Type>
|
||||
<LineNumber>0</LineNumber>
|
||||
<EnabledFlag>1</EnabledFlag>
|
||||
<Address>134229670</Address>
|
||||
<ByteObject>0</ByteObject>
|
||||
<HtxType>0</HtxType>
|
||||
<ManyObjects>0</ManyObjects>
|
||||
<SizeOfObject>0</SizeOfObject>
|
||||
<BreakByAccess>0</BreakByAccess>
|
||||
<BreakIfRCount>1</BreakIfRCount>
|
||||
<Filename></Filename>
|
||||
<ExecCommand></ExecCommand>
|
||||
<Expression></Expression>
|
||||
</Bp>
|
||||
<Bp>
|
||||
<Number>2</Number>
|
||||
<Type>0</Type>
|
||||
<LineNumber>93</LineNumber>
|
||||
<EnabledFlag>1</EnabledFlag>
|
||||
<Address>0</Address>
|
||||
<ByteObject>0</ByteObject>
|
||||
<HtxType>0</HtxType>
|
||||
<ManyObjects>0</ManyObjects>
|
||||
<SizeOfObject>0</SizeOfObject>
|
||||
<BreakByAccess>0</BreakByAccess>
|
||||
<BreakIfRCount>0</BreakIfRCount>
|
||||
<Filename>../Core/Src/app_threadx.c</Filename>
|
||||
<ExecCommand></ExecCommand>
|
||||
<Expression></Expression>
|
||||
</Bp>
|
||||
<Bp>
|
||||
<Number>3</Number>
|
||||
<Type>0</Type>
|
||||
<LineNumber>95</LineNumber>
|
||||
<EnabledFlag>1</EnabledFlag>
|
||||
<Address>0</Address>
|
||||
<ByteObject>0</ByteObject>
|
||||
<HtxType>0</HtxType>
|
||||
<ManyObjects>0</ManyObjects>
|
||||
<SizeOfObject>0</SizeOfObject>
|
||||
<BreakByAccess>0</BreakByAccess>
|
||||
<BreakIfRCount>0</BreakIfRCount>
|
||||
<Filename>../Core/Src/app_threadx.c</Filename>
|
||||
<ExecCommand></ExecCommand>
|
||||
<Expression></Expression>
|
||||
</Bp>
|
||||
<Bp>
|
||||
<Number>4</Number>
|
||||
<Type>0</Type>
|
||||
<LineNumber>95</LineNumber>
|
||||
<EnabledFlag>1</EnabledFlag>
|
||||
<Address>0</Address>
|
||||
<ByteObject>0</ByteObject>
|
||||
<HtxType>0</HtxType>
|
||||
<ManyObjects>0</ManyObjects>
|
||||
<SizeOfObject>0</SizeOfObject>
|
||||
<BreakByAccess>0</BreakByAccess>
|
||||
<BreakIfRCount>0</BreakIfRCount>
|
||||
<Filename>startup_stm32h563xx.s</Filename>
|
||||
<ExecCommand></ExecCommand>
|
||||
<Expression></Expression>
|
||||
</Bp>
|
||||
</Breakpoint>
|
||||
<WatchWindow1>
|
||||
@@ -217,6 +281,16 @@
|
||||
<WinNumber>1</WinNumber>
|
||||
<ItemText>tx_event_flags_get</ItemText>
|
||||
</Ww>
|
||||
<Ww>
|
||||
<count>10</count>
|
||||
<WinNumber>1</WinNumber>
|
||||
<ItemText>GPS</ItemText>
|
||||
</Ww>
|
||||
<Ww>
|
||||
<count>11</count>
|
||||
<WinNumber>1</WinNumber>
|
||||
<ItemText>status</ItemText>
|
||||
</Ww>
|
||||
</WatchWindow1>
|
||||
<WatchWindow2>
|
||||
<Ww>
|
||||
|
||||
Binary file not shown.
@@ -27,6 +27,10 @@ Project File Date: 06/26/2025
|
||||
<h2>Output:</h2>
|
||||
*** Using Compiler 'V6.21', folder: 'D:\keil5\ARM\ARMCLANG\Bin'
|
||||
Build target 'AutoGuideStick'
|
||||
compiling app_threadx.c...
|
||||
linking...
|
||||
Program Size: Code=83340 RO-data=1604 RW-data=16 ZI-data=11520
|
||||
FromELF: creating hex file...
|
||||
"AutoGuideStick\AutoGuideStick.axf" - 0 Error(s), 0 Warning(s).
|
||||
|
||||
<h2>Software Packages used:</h2>
|
||||
@@ -51,7 +55,7 @@ Package Vendor: Keil
|
||||
|
||||
* Component: ARM::CMSIS:CORE@5.6.0
|
||||
Include file: CMSIS/Core/Include/tz_context.h
|
||||
Build Time Elapsed: 00:00:01
|
||||
Build Time Elapsed: 00:00:08
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,7 +1,7 @@
|
||||
Dependencies for Project 'AutoGuideStick', Target 'AutoGuideStick': (DO NOT MODIFY !)
|
||||
CompilerVersion: 6210000::V6.21::ARMCLANG
|
||||
F (startup_stm32h563xx.s)(0x685C2A9A)(--target=arm-arm-none-eabi -mcpu=cortex-m33 -mfpu=fpv5-sp-d16 -mfloat-abi=hard -masm=auto -Wa,armasm,--diag_suppress=A1950W -c
|
||||
|
||||
F (startup_stm32h563xx.s)(0x685D3117)(--target=arm-arm-none-eabi -mcpu=cortex-m33 -mfpu=fpv5-sp-d16 -mfloat-abi=hard -masm=auto -Wa,armasm,--diag_suppress=A1950W -c
|
||||
|
||||
-gdwarf-4 -I ../Core/Inc -I ../AZURE_RTOS/App -I ../Drivers/STM32H5xx_HAL_Driver/Inc -I ../Drivers/STM32H5xx_HAL_Driver/Inc/Legacy -I ../Middlewares/ST/threadx/common/inc -I ../Drivers/CMSIS/Device/ST/STM32H5xx/Include -I ../Middlewares/ST/threadx/ports/cortex_m33/ac6/inc -I ../Drivers/CMSIS/Include
|
||||
|
||||
-I./RTE/_AutoGuideStick
|
||||
@@ -140,8 +140,8 @@ I (..\Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_hal_tim_ex.h)(0x683FA4DD)
|
||||
-ID:/keil5/ARM/PACK/Keil/STM32H5xx_DFP/1.3.0/Drivers/CMSIS/Device/ST/STM32H5xx/Include
|
||||
|
||||
-D__UVISION_VERSION="539" -D_RTE_ -DSTM32H563xx -D_RTE_ -DTX_INCLUDE_USER_DEFINE_FILE -DTX_SINGLE_MODE_NON_SECURE="1" -DUSE_HAL_DRIVER -DSTM32H563xx
|
||||
|
||||
-o autoguidestick/gpdma.o -MD)
|
||||
|
||||
-o autoguidestick/gpdma.o -MD)
|
||||
I (..\Core\Inc\main.hc.\Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_hal.h)(0x00000000)
|
||||
I (..\Core\Inc\stm32h5xx_hal_conf.h)(0x685C2A98)
|
||||
I (..\Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_hal_rcc.h)(0x683FA4DD)
|
||||
@@ -352,7 +352,7 @@ I (..\Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_hal_tim_ex.h)(0x683FA4DD)
|
||||
I (D:\advance_stick\AutoGuideStick\Drivers\CMSIS\Include\mpu_armv8.h)(0x683FA4DE)
|
||||
I (..\Drivers\CMSIS\Device\ST\STM32H5xx\Include\system_stm32h5xx.h)(0x683FA4DE)
|
||||
I (..\Drivers\STM32H5xx_HAL_Driver\Inc\Legacy\stm32_hal_legacy.h)(0x683FA4DD)
|
||||
I (D:\keil5\ARM\ARMCLANG\include\stddef.h)(0x6569B012)
|
||||
I (D:\keil5\ARM\ARMCLANG\include\stddef.h)(0x6569B012)
|
||||
I (..\Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_hal_rcc_ex.h)(0x683FA4DD)
|
||||
I (..\Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_hal_gpio.h)(0x683FA4DD)
|
||||
I (..\Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_hal_gpio_ex.h)(0x683FA4DD)
|
||||
@@ -2070,7 +2070,7 @@ I (..\Middlewares\ST\threadx\ports\cortex_m33\ac6\inc\tx_port.h)(0x683FA4D9)
|
||||
|
||||
-o autoguidestick/tx_event_flags_info_get.o -MD)
|
||||
I (..\Middlewares\ST\threadx\common\inc\tx_api.h)(0x683FA4DA)
|
||||
I (..\Middlewares\ST\threadx\ports\cortex_m33\ac6\inc\tx_port.h)(0x683FA4D9)
|
||||
I (..\Middlewares\ST\threadx\ports\cortex_m33\ac6\inc\tx_port.h)(0x683FA4D9)
|
||||
I (..\Core\Inc\tx_user.he:\keil5\ARM\ARMCLANG\include\stdlib.h)(0x00000000)
|
||||
I (D:\keil5\ARM\ARMCLANG\include\string.h)(0x6569B012)
|
||||
I (..\Middlewares\ST\threadx\common\inc\tx_trace.h)(0x683FA4DA)
|
||||
@@ -2111,9 +2111,9 @@ I (D:\keil5\ARM\ARMCLANG\include\string.h)(0x6569B012)
|
||||
|
||||
-o autoguidestick/tx_event_flags_set.o -MD)
|
||||
I (..\Middlewares\ST\threadx\common\inc\tx_api.h)(0x683FA4DA)
|
||||
I (..\Middlewares\ST\threadx\ports\cortex_m33\ac6\inc\tx_port.h)(0x683FA4D9)
|
||||
I (..\Middlewares\ST\threadx\ports\cortex_m33\ac6\inc\tx_port.h)(0x683FA4D9)
|
||||
I (..\Core\Inc\tx_user.he:\keil5\ARM\ARMCLANG\include\stdlib.h)(0x00000000)
|
||||
I (D:\keil5\ARM\ARMCLANG\include\string.h)(0x6569B012)
|
||||
I (D:\keil5\ARM\ARMCLANG\include\string.h)(0x6569B012)
|
||||
I (..\Middlewares\ST\threadx\common\inc\tx_trace.h)(0x683FA4DA)
|
||||
I (..\Middlewares\ST\threadx\common\inc\tx_thread.h)(0x683FA4DA)
|
||||
I (..\Middlewares\ST\threadx\common\inc\tx_event_flags.h)(0x683FA4DA)
|
||||
@@ -2154,7 +2154,7 @@ I (D:\keil5\ARM\ARMCLANG\include\string.h)(0x6569B012)
|
||||
|
||||
-o autoguidestick/tx_mutex_cleanup.o -MD)
|
||||
I (..\Middlewares\ST\threadx\common\inc\tx_api.h)(0x683FA4DA)
|
||||
I (..\Middlewares\ST\threadx\ports\cortex_m33\ac6\inc\tx_port.h)(0x683FA4D9)
|
||||
I (..\Middlewares\ST\threadx\ports\cortex_m33\ac6\inc\tx_port.h)(0x683FA4D9)
|
||||
I (..\Core\Inc\tx_user.he:\keil5\ARM\ARMCLANG\include\stdlib.h)(0x00000000)
|
||||
I (D:\keil5\ARM\ARMCLANG\include\string.h)(0x6569B012)
|
||||
I (..\Middlewares\ST\threadx\common\inc\tx_thread.h)(0x683FA4DA)
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
16
fun/HCBle.c
16
fun/HCBle.c
@@ -38,6 +38,8 @@ float imu_angle = 0.0f;
|
||||
|
||||
TX_EVENT_FLAGS_GROUP ble_event_flags;
|
||||
#define BLE_EVENT_DATA_READY 0x01
|
||||
|
||||
|
||||
void HCBle_InitEventFlags(void)
|
||||
{ tx_event_flags_create(&ble_event_flags, "BLE Events");}
|
||||
|
||||
@@ -144,6 +146,8 @@ void HCBle_ExtractAndParseFrame(void) {
|
||||
}
|
||||
}
|
||||
|
||||
//Ϊɶһֱʹ<D6B1>ò<EFBFBD><C3B2>ˣ<EFBFBD><CBA3><EFBFBD><EFBFBD><EFBFBD>һֱ<D2BB>ٵȴ<D9B5>TX<54><58><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
// <20>ں<EFBFBD>̨<EFBFBD><CCA8><EFBFBD>е<EFBFBD>һ<EFBFBD><D2BB><EFBFBD>̣߳<DFB3><CCA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȴ<EFBFBD>UART<52>յ<EFBFBD>BLE<4C><45><EFBFBD>ݺ<DDBA><F3B4A5B7><EFBFBD><EFBFBD>¼<EFBFBD><C2BC><EFBFBD>Ȼ<EFBFBD><C8BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Щ<EFBFBD><D0A9><EFBFBD><EFBFBD>
|
||||
void ble_rx_task_entry(ULONG thread_input)
|
||||
{
|
||||
HCBle_InitDMAReception();
|
||||
@@ -166,11 +170,15 @@ void ble_rx_task_entry(ULONG thread_input)
|
||||
// HCBle_SendData("#{\"lat\":%.6f,\"lon\":%.6f,\"angle\":%.2f}\n",
|
||||
// current_location.lat, current_location.lon, current_location.angle);
|
||||
void ble_tx_task_entry(ULONG thread_input) {
|
||||
BLE_Message msg;
|
||||
char recv_msg[128];
|
||||
while(1) {
|
||||
// HCBle_SendData("fuck");
|
||||
HCBle_SendData("#{\"lat\":%.6f,\"lon\":%.6f,\"angle\":%.2f}\n",23.123456, 113.654321, 95.0);
|
||||
tx_thread_sleep(500);
|
||||
|
||||
// HCBle_SendData("#{\"lat\":%.6f,\"lon\":%.6f,\"angle\":%.2f}\n",23.123456, 113.654321, 95.0);
|
||||
// tx_thread_sleep(500);
|
||||
if(tx_queue_receive(&ble_tx_queue,&recv_msg,TX_WAIT_FOREVER) == TX_SUCCESS)
|
||||
{
|
||||
HCBle_SendData("%s",recv_msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
31
fun/gps.c
31
fun/gps.c
@@ -25,8 +25,8 @@ _GPSData GPS;
|
||||
|
||||
void GPS_Init(void)
|
||||
{
|
||||
HAL_UARTEx_ReceiveToIdle_DMA(&huart2, GPS_DMA_RX_BUF, GPS_DMA_RX_BUF_LEN);
|
||||
__HAL_DMA_DISABLE_IT(&handle_GPDMA1_Channel3, DMA_IT_HT); // <20><><EFBFBD>ð봫<C3B0><EBB4AB>
|
||||
HAL_UARTEx_ReceiveToIdle_IT(&huart2, GPS_DMA_RX_BUF, GPS_DMA_RX_BUF_LEN);
|
||||
// __HAL_DMA_DISABLE_IT(&handle_GPDMA1_Channel3, DMA_IT_HT); // <20><><EFBFBD>ð봫<C3B0><EBB4AB>
|
||||
}
|
||||
|
||||
#ifdef parse
|
||||
@@ -162,12 +162,12 @@ void GPS_Data_CLR(void)
|
||||
|
||||
|
||||
|
||||
//void GPS_DMA_Start(void)
|
||||
//{
|
||||
// HAL_UART_Receive_DMA(&huart2,GPS_DMA_RX_BUF,GPS_DMA_RX_BUF_LEN);
|
||||
// __HAL_DMA_ENABLE_IT(huart2.hdmarx,DMA_IT_HT); //<2F>봫<EFBFBD><EBB4AB><EFBFBD>ж<EFBFBD>
|
||||
// __HAL_DMA_ENABLE_IT(huart2.hdmarx,DMA_IT_TC); //ȫ<><C8AB><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>
|
||||
//}
|
||||
void GPS_DMA_Start(void)
|
||||
{
|
||||
HAL_UART_Receive_DMA(&huart2,GPS_DMA_RX_BUF,GPS_DMA_RX_BUF_LEN);
|
||||
__HAL_DMA_ENABLE_IT(huart2.hdmarx,DMA_IT_HT); //<2F>봫<EFBFBD><EBB4AB><EFBFBD>ж<EFBFBD>
|
||||
__HAL_DMA_ENABLE_IT(huart2.hdmarx,DMA_IT_TC); //ȫ<><C8AB><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>
|
||||
}
|
||||
|
||||
//void HAL_UARTEx_RxEventCallback(UART_HandleTypeDef *huart, uint16_t Size)
|
||||
//{
|
||||
@@ -178,6 +178,7 @@ void GPS_Data_CLR(void)
|
||||
// GPS.GPS_Buffer[Size] = '\0';
|
||||
// GPS.isGetData = 1; //<2F><><EFBFBD>ݽ<EFBFBD><DDBD>ձ<EFBFBD>־λ<D6BE><CEBB>Ϊ1
|
||||
//
|
||||
// tx_event_flags_set(&system_events, EVENT_GPS_DATA_READY, TX_OR);
|
||||
// //<2F><><EFBFBD>¿<EFBFBD><C2BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
// HAL_UARTEx_ReceiveToIdle_DMA(&huart2,GPS_DMA_RX_BUF,GPS_DMA_RX_BUF_LEN);
|
||||
// __HAL_DMA_DISABLE_IT(&handle_GPDMA1_Channel3,DMA_IT_HT);
|
||||
@@ -208,22 +209,14 @@ void gps_thread_entry(ULONG thread_input)
|
||||
current_location.lon = Convert_to_degrees(GPS.longitude);
|
||||
tx_event_flags_set(&system_events, EVENT_LOCATION_UPDATED, TX_OR);
|
||||
|
||||
BLE_Message msg;
|
||||
msg.msg_type = 1;
|
||||
snprintf(msg.data, sizeof(msg.data), "#{\"lat\":%.6f,\"lon\":%.6f,\"angle\":%.2f}\n",
|
||||
char msg[128];
|
||||
snprintf(msg, sizeof(msg), "#{\"lat\":%.6f,\"lon\":%.6f,\"angle\":%.2f}\n",
|
||||
current_location.lat,
|
||||
current_location.lon,
|
||||
current_location.angle);
|
||||
tx_queue_send(&ble_tx_queue, &msg, TX_WAIT_FOREVER);
|
||||
|
||||
if (!gps_first_fix_sent)
|
||||
{
|
||||
gps_first_fix_sent = 1;
|
||||
BLE_Message fix_msg;
|
||||
fix_msg.msg_type = 2;
|
||||
snprintf(fix_msg.data, sizeof(fix_msg.data), "#{\"info\":\"GPS fixed and ready\"}\n");
|
||||
tx_queue_send(&ble_tx_queue, &fix_msg, TX_WAIT_FOREVER);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user