IMU Angle Z get Successful

This commit is contained in:
2025-07-01 13:16:48 +08:00
parent 1dd27dce37
commit 4d36d07b2c
30 changed files with 8747 additions and 11498 deletions

View File

@@ -39,15 +39,12 @@
#define BLE_RX_THREAD_PRIORITY 10
#define BLE_TX_THREAD_STACK_SIZE 2048
#define BLE_TX_THREAD_PRIORITY 10
//IMU define
#define IMU_ANGLE_THREAD_STACK_SIZE 1024
#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
// IMU thread config
// IMU thread config
#define IMU_ANGLE_THREAD_STACK_SIZE 1024
#define IMU_ANGLE_THREAD_PRIORITY 11
/* USER CODE END PD */
@@ -60,7 +57,8 @@
/* USER CODE BEGIN PV */
/* ȫ<>ֱ<EFBFBD><D6B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
TX_EVENT_FLAGS_GROUP system_events; // 传感器事件组
TX_EVENT_FLAGS_GROUP system_events;
TX_EVENT_FLAGS_GROUP sensor_events;
MotorCommand current_motor_cmd = {0,0};
_GPSData gps_data;
@@ -80,20 +78,13 @@ TX_QUEUE ble_tx_queue;
__attribute__((aligned(4)))
ULONG ble_tx_queue_buffer[BLE_TX_QUEUE_LEN * ((BLE_TX_MSG_LEN + sizeof(ULONG) - 1) / sizeof(ULONG))];
// 定义Ble 传输数据的队列 也就是经纬度融合数据
__attribute__((aligned(4)))
ULONG ble_tx_queue_buff[BLE_TX_QUEUE_LEN * ((sizeof(BleMessage) + sizeof(ULONG) - 1) / sizeof(ULONG))];
//imu thread
// imu
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];
#define IM948_RX_QUEUE_SIZE 64
ULONG im948_rx_queue_buffer[IM948_RX_QUEUE_SIZE];
TX_QUEUE im948_uart_rx_queue;
/* USER CODE END PV */
/* Private function prototypes -----------------------------------------------*/
@@ -140,45 +131,37 @@ 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,
IMU_ANGLE_THREAD_PRIORITY,IMU_ANGLE_THREAD_PRIORITY,
TX_NO_TIME_SLICE,TX_AUTO_START);
if(status != TX_SUCCESS)
{
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));
status = tx_queue_create(&ble_tx_queue,"Ble lat Imu",
(sizeof(BleMessage) + sizeof(ULONG) - 1) / sizeof(ULONG),
ble_tx_queue_buff,
sizeof(ble_tx_queue_buff));
if (status != TX_SUCCESS) {
if (status != TX_SUCCESS) {
HCBle_SendData("❌ BLE TX 消息队列创建失败,错误码=%d\r\n", status);
return status;
}
status = tx_thread_create(&imu_angle_thread, "IMU Angle Thread",
imu_angle_ble_task_entry, 0,
imu_angle_stack, IMU_ANGLE_THREAD_STACK_SIZE,
IMU_ANGLE_THREAD_PRIORITY, IMU_ANGLE_THREAD_PRIORITY,
TX_NO_TIME_SLICE, TX_AUTO_START);
if (status != TX_SUCCESS) {
return status;
}
status = tx_queue_create(&im948_uart_rx_queue, "IM948_RX_QUEUE",
TX_1_ULONG, // sizeof(ULONG) bytes per entry
im948_rx_queue_buffer,
IM948_RX_QUEUE_SIZE * sizeof(ULONG));
HCBle_SendData("✅ BLE RX/TX 线程和队列初始化完成\r\n");
return TX_SUCCESS;
}
@@ -193,7 +176,6 @@ void MX_ThreadX_Init(void)
/* USER CODE BEGIN Before_Kernel_Start */
HCBle_InitEventFlags(); // 这必须在任何使用前调用一次
/* USER CODE END Before_Kernel_Start */
tx_kernel_enter();
/* USER CODE BEGIN Kernel_Start_Error */
@@ -203,4 +185,5 @@ void MX_ThreadX_Init(void)
/* USER CODE BEGIN 1 */
/* USER CODE END 1 */