Test GPS;it can achieve function what i wannna

This commit is contained in:
2025-06-29 19:29:35 +08:00
parent 32d4821e6f
commit 1dd27dce37
12 changed files with 8649 additions and 8218 deletions

View File

@@ -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 */