generated from Template/H563ZI-HAL-CMake-Template
Test GPS;it can achieve function what i wannna
This commit is contained in:
@@ -41,9 +41,13 @@
|
||||
#define BLE_TX_THREAD_PRIORITY 10
|
||||
//IMU define
|
||||
#define IMU_ANGLE_THREAD_STACK_SIZE 1024
|
||||
#define IMU_ANGLE_THREAD_PRIORITY 9
|
||||
|
||||
|
||||
#define IMU_ANGLE_THREAD_PRIORITY 11
|
||||
// GPS define
|
||||
#define GPS_THREAD_STACK_SIZE 1024
|
||||
#define GPS_THREAD_PRIORITY 11
|
||||
//线程控制块和栈
|
||||
#define SENSOR_AGG_STACK_SIZE 512
|
||||
#define SENSOR_AGG_PRIORITY 12
|
||||
|
||||
/* USER CODE END PD */
|
||||
|
||||
@@ -56,7 +60,7 @@
|
||||
/* USER CODE BEGIN PV */
|
||||
/* ȫ<>ֱ<EFBFBD><D6B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||
|
||||
TX_EVENT_FLAGS_GROUP system_events;
|
||||
TX_EVENT_FLAGS_GROUP system_events; // 传感器事件组
|
||||
MotorCommand current_motor_cmd = {0,0};
|
||||
_GPSData gps_data;
|
||||
|
||||
@@ -85,6 +89,11 @@ ULONG ble_tx_queue_buff[BLE_TX_QUEUE_LEN * ((sizeof(BleMessage) + sizeof(ULONG)
|
||||
//imu thread
|
||||
TX_THREAD imu_angle_thread;
|
||||
UCHAR imu_angle_stack[IMU_ANGLE_THREAD_STACK_SIZE];
|
||||
|
||||
//GPS thread
|
||||
TX_THREAD gps_thread;
|
||||
UCHAR gps_stack[GPS_THREAD_STACK_SIZE];
|
||||
|
||||
/* USER CODE END PV */
|
||||
|
||||
/* Private function prototypes -----------------------------------------------*/
|
||||
@@ -131,6 +140,7 @@ UINT App_ThreadX_Init(VOID *memory_ptr)
|
||||
return status;
|
||||
}
|
||||
|
||||
// ============IMU 角度线程 ==================
|
||||
status = tx_thread_create(&imu_angle_thread,"IMU Angle Thread",
|
||||
imu_angle_ble_task_entry,0,
|
||||
imu_angle_stack,IMU_ANGLE_THREAD_STACK_SIZE,
|
||||
@@ -142,17 +152,19 @@ UINT App_ThreadX_Init(VOID *memory_ptr)
|
||||
return status;
|
||||
}
|
||||
|
||||
// ============= GPS 定位线程 ================
|
||||
status = tx_thread_create(&gps_thread, "GPS Thread",
|
||||
gps_thread_entry, 0,
|
||||
gps_stack, GPS_THREAD_STACK_SIZE,
|
||||
GPS_THREAD_PRIORITY, GPS_THREAD_PRIORITY,
|
||||
TX_NO_TIME_SLICE, TX_AUTO_START);
|
||||
if (status != TX_SUCCESS) {
|
||||
HCBle_SendData("❌ GPS 线程创建失败,错误码=%d\r\n", status);
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
// === 创建 BLE TX 消息队列 ===
|
||||
// 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;
|
||||
// }
|
||||
|
||||
status = tx_queue_create(&ble_tx_queue,"Ble lat Imu",
|
||||
(sizeof(BleMessage) + sizeof(ULONG) - 1) / sizeof(ULONG),
|
||||
@@ -190,45 +202,5 @@ void MX_ThreadX_Init(void)
|
||||
}
|
||||
|
||||
/* USER CODE BEGIN 1 */
|
||||
#ifdef TEST //Ŀǰ<C4BF><C7B0><EFBFBD>ڲ<EFBFBD><DAB2><EFBFBD>
|
||||
|
||||
|
||||
/* USER CODE BEGIN 1 */
|
||||
void main_control_thread_entry(ULONG thread_input)
|
||||
{
|
||||
ULONG events;
|
||||
MotorCommand motor_cmd = {0, 0};
|
||||
|
||||
while(1)
|
||||
{
|
||||
// 等待事件发生
|
||||
tx_event_flags_get(&system_events,
|
||||
EVENT_OBSTACLE_DETECTED | EVENT_BLE_COMMAND_RECEIVED,
|
||||
TX_OR_CLEAR, &events, TX_WAIT_FOREVER);
|
||||
|
||||
// 处理障碍物事件
|
||||
if(events & EVENT_OBSTACLE_DETECTED)
|
||||
{
|
||||
// 触发蜂鸣器和振动提示
|
||||
Buzzer_Open();
|
||||
Shake_Motor_Open();
|
||||
tx_thread_sleep(100); // 振动100ms
|
||||
Buzzer_Close();
|
||||
Shake_Motor_Close();
|
||||
|
||||
|
||||
}
|
||||
|
||||
// 处理蓝牙控制指令
|
||||
if(events & EVENT_BLE_COMMAND_RECEIVED)
|
||||
{
|
||||
// 从队列获取电机命令
|
||||
// tx_queue_receive(&ble_rx_queue, &motor_cmd, TX_WAIT_FOREVER);
|
||||
|
||||
// 实际控制电机 (伪代码)
|
||||
// set_motor_speed(motor_cmd.leftSpeed, motor_cmd.rightSpeed);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
/* USER CODE END 1 */
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -148,40 +148,7 @@
|
||||
<Name>-U004200403132511238363431 -O2254 -SF10000 -C0 -A1 -I0 -HNlocalhost -HP7184 -P1 -N00("ARM CoreSight SW-DP (ARM Core") -D00(6BA02477) -L00(0) -TO131090 -TC10000000 -TT10000000 -TP21 -TDS8007 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -FO15 -FD20000000 -FC1000 -FN1 -FF0STM32H5xx_2M_0800.FLM -FS08000000 -FL0200000 -FP0($$Device:STM32H563ZITx$CMSIS\Flash\STM32H5xx_2M_0800.FLM) -WA0 -WE0 -WVCE4 -WS2710 -WM0 -WP2 -WK0</Name>
|
||||
</SetRegEntry>
|
||||
</TargetDriverDllRegistry>
|
||||
<Breakpoint>
|
||||
<Bp>
|
||||
<Number>0</Number>
|
||||
<Type>0</Type>
|
||||
<LineNumber>141</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>1</Number>
|
||||
<Type>0</Type>
|
||||
<LineNumber>143</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>
|
||||
</Breakpoint>
|
||||
<Breakpoint/>
|
||||
<WatchWindow1>
|
||||
<Ww>
|
||||
<count>0</count>
|
||||
|
||||
Binary file not shown.
@@ -27,10 +27,6 @@ Project File Date: 06/29/2025
|
||||
<h2>Output:</h2>
|
||||
*** Using Compiler 'V6.21', folder: 'D:\keil5\ARM\ARMCLANG\Bin'
|
||||
Build target 'AutoGuideStick'
|
||||
compiling imu948.c...
|
||||
linking...
|
||||
Program Size: Code=84772 RO-data=1628 RW-data=16 ZI-data=12160
|
||||
FromELF: creating hex file...
|
||||
"AutoGuideStick\AutoGuideStick.axf" - 0 Error(s), 0 Warning(s).
|
||||
|
||||
<h2>Software Packages used:</h2>
|
||||
@@ -55,7 +51,7 @@ Package Vendor: Keil
|
||||
|
||||
* Component: ARM::CMSIS:CORE@5.6.0
|
||||
Include file: CMSIS/Core/Include/tz_context.h
|
||||
Build Time Elapsed: 00:00:02
|
||||
Build Time Elapsed: 00:00:01
|
||||
</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
@@ -141,7 +141,7 @@ 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)
|
||||
I (..\Core\Inc\main.hc.\Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_hal.h)(0x00000000)
|
||||
I (..\Core\Inc\stm32h5xx_hal_conf.h)(0x685C2A98)
|
||||
@@ -2074,7 +2074,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)
|
||||
@@ -2117,7 +2117,7 @@ I (D:\keil5\ARM\ARMCLANG\include\stdarg.h)(0x6569B012)
|
||||
I (..\Middlewares\ST\threadx\common\inc\tx_api.h)(0x683FA4DA)
|
||||
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)
|
||||
@@ -2293,7 +2293,7 @@ I (D:\keil5\ARM\ARMCLANG\include\stdarg.h)(0x6569B012)
|
||||
I (..\Middlewares\ST\threadx\common\inc\tx_thread.h)(0x683FA4DA)
|
||||
I (..\Middlewares\ST\threadx\common\inc\tx_mutex.h)(0x683FA4DA)
|
||||
F (../Middlewares/ST/threadx/common/src/tx_mutex_priority_change.c)(0x683FA4DA)(-xc -std=c11 --target=arm-arm-none-eabi -mcpu=cortex-m33 -mfpu=fpv5-sp-d16 -mfloat-abi=hard -c
|
||||
|
||||
|
||||
-fno-rtti -funsigned-char -fshort-enums -fshort-wchar
|
||||
|
||||
-gdwarf-4 -O0 -ffunction-sections -Wno-packed -Wno-missing-variable-declarations -Wno-missing-prototypes -Wno-missing-noreturn -Wno-sign-conversion -Wno-nonportable-include-path -Wno-reserved-id-macro -Wno-unused-macros -Wno-documentation-unknown-command -Wno-documentation -Wno-license-management -Wno-parentheses-equality -Wno-reserved-identifier -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 ../fun
|
||||
@@ -2335,7 +2335,7 @@ I (D:\keil5\ARM\ARMCLANG\include\stdio.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_mutex.h)(0x683FA4DA)
|
||||
F (../Middlewares/ST/threadx/common/src/tx_queue_cleanup.c)(0x683FA4DA)(-xc -std=c11 --target=arm-arm-none-eabi -mcpu=cortex-m33 -mfpu=fpv5-sp-d16 -mfloat-abi=hard -c
|
||||
F (../Middlewares/ST/threadx/common/src/tx_queue_cleanup.c)(0x683FA4DA)(-xc -std=c11 --target=arm-arm-none-eabi -mcpu=cortex-m33 -mfpu=fpv5-sp-d16 -mfloat-abi=hard -c
|
||||
|
||||
-fno-rtti -funsigned-char -fshort-enums -fshort-wchar
|
||||
|
||||
@@ -2379,7 +2379,7 @@ I (D:\keil5\ARM\ARMCLANG\include\stdarg.h)(0x6569B012)
|
||||
I (..\Middlewares\ST\threadx\common\inc\tx_queue.h)(0x683FA4DA)
|
||||
F (../Middlewares/ST/threadx/common/src/tx_queue_delete.c)(0x683FA4DA)(-xc -std=c11 --target=arm-arm-none-eabi -mcpu=cortex-m33 -mfpu=fpv5-sp-d16 -mfloat-abi=hard -c
|
||||
|
||||
-fno-rtti -funsigned-char -fshort-enums -fshort-wchar
|
||||
-fno-rtti -funsigned-char -fshort-enums -fshort-wchar
|
||||
|
||||
-gdwarf-4 -O0 -ffunction-sections -Wno-packed -Wno-missing-variable-declarations -Wno-missing-prototypes -Wno-missing-noreturn -Wno-sign-conversion -Wno-nonportable-include-path -Wno-reserved-id-macro -Wno-unused-macros -Wno-documentation-unknown-command -Wno-documentation -Wno-license-management -Wno-parentheses-equality -Wno-reserved-identifier -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 ../fun
|
||||
|
||||
@@ -2422,5 +2422,5 @@ I (D:\keil5\ARM\ARMCLANG\include\stdio.h)(0x6569B012)
|
||||
I (..\Middlewares\ST\threadx\common\inc\tx_thread.h)(0x683FA4DA)
|
||||
I (..\Middlewares\ST\threadx\common\inc\tx_queue.h)(0x683FA4DA)
|
||||
F (../Middlewares/ST/threadx/common/src/tx_queue_front_send.c)(0x683FA4DA)(-xc -std=c11 --target=arm-arm-none-eabi -mcpu=cortex-m33 -mfpu=fpv5-sp-d16 -mfloat-abi=hard -c
|
||||
|
||||
-fno-rtti -funsigned-char -fshort-enums -fshort-wchar
|
||||
|
||||
-fno-rtti -funsigned-char -fshort-enums -fshort-wchar
|
||||
|
||||
Binary file not shown.
Binary file not shown.
12
fun/HCBle.c
12
fun/HCBle.c
@@ -97,6 +97,18 @@ void HAL_UARTEx_RxEventCallback(UART_HandleTypeDef *huart, uint16_t Size)
|
||||
tx_event_flags_set(&ble_event_flags, BLE_EVENT_DATA_READY, TX_OR);
|
||||
HAL_UARTEx_ReceiveToIdle_IT(&huart4, uart_dma_rx_buf, UART_DMA_RX_BUF_SIZE);
|
||||
}
|
||||
else if(huart->Instance == USART2) // gps<70>Ľ<EFBFBD><C4BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
{
|
||||
// // <20><><EFBFBD><EFBFBD> Size <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>յ<EFBFBD><D5B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
memcpy(GPS.GPS_Buffer,GPS_DMA_RX_BUF,Size);
|
||||
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_IT(&huart2,GPS_DMA_RX_BUF,GPS_DMA_RX_BUF_LEN);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user