generated from Template/H563ZI-HAL-CMake-Template
IMU Angle Z get Successful
This commit is contained in:
@@ -51,13 +51,13 @@ Mcu.Name=STM32H563ZITx
|
||||
Mcu.Package=LQFP144
|
||||
Mcu.Pin0=PH0-OSC_IN(PH0)
|
||||
Mcu.Pin1=PH1-OSC_OUT(PH1)
|
||||
Mcu.Pin10=PC6
|
||||
Mcu.Pin11=PC7
|
||||
Mcu.Pin12=PC8
|
||||
Mcu.Pin13=PC9
|
||||
Mcu.Pin14=PA13(JTMS/SWDIO)
|
||||
Mcu.Pin15=PA14(JTCK/SWCLK)
|
||||
Mcu.Pin16=PC10
|
||||
Mcu.Pin10=PG3
|
||||
Mcu.Pin11=PC6
|
||||
Mcu.Pin12=PC7
|
||||
Mcu.Pin13=PC8
|
||||
Mcu.Pin14=PC9
|
||||
Mcu.Pin15=PA13(JTMS/SWDIO)
|
||||
Mcu.Pin16=PA14(JTCK/SWCLK)
|
||||
Mcu.Pin17=PC11
|
||||
Mcu.Pin18=PC12
|
||||
Mcu.Pin19=PD2
|
||||
@@ -84,8 +84,8 @@ Mcu.Pin4=PG0
|
||||
Mcu.Pin5=PG1
|
||||
Mcu.Pin6=PE9
|
||||
Mcu.Pin7=PE11
|
||||
Mcu.Pin8=PG2
|
||||
Mcu.Pin9=PG3
|
||||
Mcu.Pin8=PB10
|
||||
Mcu.Pin9=PG2
|
||||
Mcu.PinsNb=37
|
||||
Mcu.ThirdPartyNb=0
|
||||
Mcu.UserConstants=
|
||||
@@ -125,15 +125,15 @@ PB1.GPIOParameters=GPIO_Label
|
||||
PB1.GPIO_Label=PWMB
|
||||
PB1.Locked=true
|
||||
PB1.Signal=S_TIM3_CH4
|
||||
PB10.Locked=true
|
||||
PB10.Mode=Asynchronous
|
||||
PB10.Signal=USART3_TX
|
||||
PB8.Locked=true
|
||||
PB8.Mode=Asynchronous
|
||||
PB8.Signal=UART4_RX
|
||||
PB9.Locked=true
|
||||
PB9.Mode=Asynchronous
|
||||
PB9.Signal=UART4_TX
|
||||
PC10.Locked=true
|
||||
PC10.Mode=Asynchronous
|
||||
PC10.Signal=USART3_TX
|
||||
PC11.Locked=true
|
||||
PC11.Mode=Asynchronous
|
||||
PC11.Signal=USART3_RX
|
||||
@@ -353,7 +353,7 @@ UART4.IPParameters=BaudRate
|
||||
USART2.BaudRate=9600
|
||||
USART2.IPParameters=VirtualMode-Asynchronous,BaudRate
|
||||
USART2.VirtualMode-Asynchronous=VM_ASYNC
|
||||
USART3.BaudRate=9600
|
||||
USART3.BaudRate=115200
|
||||
USART3.IPParameters=VirtualMode-Asynchronous,BaudRate
|
||||
USART3.VirtualMode-Asynchronous=VM_ASYNC
|
||||
VP_BOOTPATH_VS_BOOTPATH.Mode=BP_Activate
|
||||
|
||||
@@ -49,16 +49,15 @@ extern "C" {
|
||||
/* USER CODE BEGIN PD */
|
||||
// <20>¼<EFBFBD><C2BC><EFBFBD>־<EFBFBD><D6BE><EFBFBD><EFBFBD>
|
||||
#define EVENT_OBSTACLE_DETECTED 0x01
|
||||
#define EVENT_GPS_DATA_READY 0x02
|
||||
#define EVENT_BLE_COMMAND_RECEIVED 0x04
|
||||
#define IMU_UPDATE_EVENT 0x08
|
||||
#define EVENT_LOCATION_UPDATED 0x10
|
||||
#define EVENT_IMU_DATA_READY 0x20 // <20><><EFBFBD><EFBFBD>IMU<4D><55><EFBFBD>ݾ<EFBFBD><DDBE><EFBFBD><EFBFBD>¼<EFBFBD>
|
||||
|
||||
|
||||
#define TEST 1
|
||||
extern TX_QUEUE ble_tx_queue;
|
||||
extern TX_EVENT_FLAGS_GROUP system_events;
|
||||
|
||||
extern TX_EVENT_FLAGS_GROUP sensor_events; //传感器事件组
|
||||
//typedef struct
|
||||
//{
|
||||
//// uint32_t msg_type; // 应该使用 int --- 4字节
|
||||
|
||||
@@ -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 */
|
||||
|
||||
@@ -48,7 +48,7 @@
|
||||
/* Private variables ---------------------------------------------------------*/
|
||||
|
||||
/* USER CODE BEGIN PV */
|
||||
|
||||
uint8_t rx_byte; // imu_<75><5F><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
/* USER CODE END PV */
|
||||
|
||||
/* Private function prototypes -----------------------------------------------*/
|
||||
@@ -101,6 +101,8 @@ int main(void)
|
||||
MX_TIM1_Init();
|
||||
MX_TIM8_Init();
|
||||
/* USER CODE BEGIN 2 */
|
||||
|
||||
imu600_init();
|
||||
// HCBle_InitDMAReception();
|
||||
// HAL_Delay(200);
|
||||
// GPS_Init();
|
||||
|
||||
@@ -135,7 +135,7 @@ void MX_USART3_UART_Init(void)
|
||||
|
||||
/* USER CODE END USART3_Init 1 */
|
||||
huart3.Instance = USART3;
|
||||
huart3.Init.BaudRate = 9600;
|
||||
huart3.Init.BaudRate = 115200;
|
||||
huart3.Init.WordLength = UART_WORDLENGTH_8B;
|
||||
huart3.Init.StopBits = UART_STOPBITS_1;
|
||||
huart3.Init.Parity = UART_PARITY_NONE;
|
||||
@@ -404,12 +404,20 @@ void HAL_UART_MspInit(UART_HandleTypeDef* uartHandle)
|
||||
/* USART3 clock enable */
|
||||
__HAL_RCC_USART3_CLK_ENABLE();
|
||||
|
||||
__HAL_RCC_GPIOB_CLK_ENABLE();
|
||||
__HAL_RCC_GPIOC_CLK_ENABLE();
|
||||
/**USART3 GPIO Configuration
|
||||
PC10 ------> USART3_TX
|
||||
PB10 ------> USART3_TX
|
||||
PC11 ------> USART3_RX
|
||||
*/
|
||||
GPIO_InitStruct.Pin = GPIO_PIN_10|GPIO_PIN_11;
|
||||
GPIO_InitStruct.Pin = GPIO_PIN_10;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
||||
GPIO_InitStruct.Alternate = GPIO_AF7_USART3;
|
||||
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
|
||||
|
||||
GPIO_InitStruct.Pin = GPIO_PIN_11;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
||||
@@ -484,10 +492,12 @@ void HAL_UART_MspDeInit(UART_HandleTypeDef* uartHandle)
|
||||
__HAL_RCC_USART3_CLK_DISABLE();
|
||||
|
||||
/**USART3 GPIO Configuration
|
||||
PC10 ------> USART3_TX
|
||||
PB10 ------> USART3_TX
|
||||
PC11 ------> USART3_RX
|
||||
*/
|
||||
HAL_GPIO_DeInit(GPIOC, GPIO_PIN_10|GPIO_PIN_11);
|
||||
HAL_GPIO_DeInit(GPIOB, GPIO_PIN_10);
|
||||
|
||||
HAL_GPIO_DeInit(GPIOC, GPIO_PIN_11);
|
||||
|
||||
/* USART3 interrupt Deinit */
|
||||
HAL_NVIC_DisableIRQ(USART3_IRQn);
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -210,6 +210,21 @@
|
||||
<WinNumber>1</WinNumber>
|
||||
<ItemText>status</ItemText>
|
||||
</Ww>
|
||||
<Ww>
|
||||
<count>12</count>
|
||||
<WinNumber>1</WinNumber>
|
||||
<ItemText>UartFifo</ItemText>
|
||||
</Ww>
|
||||
<Ww>
|
||||
<count>13</count>
|
||||
<WinNumber>1</WinNumber>
|
||||
<ItemText>temp</ItemText>
|
||||
</Ww>
|
||||
<Ww>
|
||||
<count>14</count>
|
||||
<WinNumber>1</WinNumber>
|
||||
<ItemText>isNewData</ItemText>
|
||||
</Ww>
|
||||
</WatchWindow1>
|
||||
<WatchWindow2>
|
||||
<Ww>
|
||||
@@ -217,6 +232,26 @@
|
||||
<WinNumber>2</WinNumber>
|
||||
<ItemText>json_buf[128]</ItemText>
|
||||
</Ww>
|
||||
<Ww>
|
||||
<count>1</count>
|
||||
<WinNumber>2</WinNumber>
|
||||
<ItemText>x</ItemText>
|
||||
</Ww>
|
||||
<Ww>
|
||||
<count>2</count>
|
||||
<WinNumber>2</WinNumber>
|
||||
<ItemText>rx_byte</ItemText>
|
||||
</Ww>
|
||||
<Ww>
|
||||
<count>3</count>
|
||||
<WinNumber>2</WinNumber>
|
||||
<ItemText>buf[5+CmdPacketMaxDatSizeRx]</ItemText>
|
||||
</Ww>
|
||||
<Ww>
|
||||
<count>4</count>
|
||||
<WinNumber>2</WinNumber>
|
||||
<ItemText>AngleZ</ItemText>
|
||||
</Ww>
|
||||
</WatchWindow2>
|
||||
<Tracepoint>
|
||||
<THDelay>0</THDelay>
|
||||
|
||||
@@ -190,7 +190,7 @@
|
||||
<hadIRAM2>0</hadIRAM2>
|
||||
<hadIROM2>0</hadIROM2>
|
||||
<StupSel>8</StupSel>
|
||||
<useUlib>0</useUlib>
|
||||
<useUlib>1</useUlib>
|
||||
<EndSel>0</EndSel>
|
||||
<uLtcg>0</uLtcg>
|
||||
<nSecure>0</nSecure>
|
||||
|
||||
Binary file not shown.
@@ -22,11 +22,15 @@ Dialog DLL: TCM.DLL V1.56.4.0
|
||||
|
||||
<h2>Project:</h2>
|
||||
D:\advance_stick\AutoGuideStick\MDK-ARM\AutoGuideStick.uvprojx
|
||||
Project File Date: 06/29/2025
|
||||
Project File Date: 07/01/2025
|
||||
|
||||
<h2>Output:</h2>
|
||||
*** Using Compiler 'V6.21', folder: 'D:\keil5\ARM\ARMCLANG\Bin'
|
||||
Build target 'AutoGuideStick'
|
||||
compiling imu948.c...
|
||||
linking...
|
||||
Program Size: Code=82196 RO-data=1164 RW-data=20 ZI-data=12836
|
||||
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:02
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -202,7 +202,7 @@
|
||||
"autoguidestick\imu.o"
|
||||
"autoguidestick\motor.o"
|
||||
"autoguidestick\imu948.o"
|
||||
--strict --scatter "AutoGuideStick\AutoGuideStick.sct"
|
||||
--library_type=microlib --strict --scatter "AutoGuideStick\AutoGuideStick.sct"
|
||||
--summary_stderr --info summarysizes --map --load_addr_map_info --xref --callgraph --symbols
|
||||
--info sizes --info totals --info unused --info veneers
|
||||
--list "AutoGuideStick.map" -o AutoGuideStick\AutoGuideStick.axf
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
26
fun/HCBle.c
26
fun/HCBle.c
@@ -41,7 +41,9 @@ TX_EVENT_FLAGS_GROUP ble_event_flags;
|
||||
|
||||
|
||||
void HCBle_InitEventFlags(void)
|
||||
{ tx_event_flags_create(&ble_event_flags, "BLE Events");}
|
||||
{ tx_event_flags_create(&ble_event_flags, "BLE Events");
|
||||
// tx_event_flags_create(&sensor_events,"Sensor Events");
|
||||
}
|
||||
|
||||
//<2F><>ʼ<EFBFBD><CABC>DMA<4D><41><EFBFBD>պ<EFBFBD><D5BA><EFBFBD>
|
||||
void HCBle_InitDMAReception(void)
|
||||
@@ -109,6 +111,7 @@ void HAL_UARTEx_RxEventCallback(UART_HandleTypeDef *huart, uint16_t Size)
|
||||
HAL_UARTEx_ReceiveToIdle_IT(&huart2,GPS_DMA_RX_BUF,GPS_DMA_RX_BUF_LEN);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -127,12 +130,7 @@ void HCBle_ParseAndHandleFrame(const char *frame)
|
||||
return;
|
||||
}
|
||||
|
||||
// if (sscanf(frame, "%*[^0-9]%d%*[^0-9]%d", &left, &right) == 2) {
|
||||
// cmd.LeftSpeed = left;
|
||||
// cmd.RightSpeed = right;
|
||||
// HCBle_SendData("? <20><><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD>: <20><>=%d, <20><>=%d\r\n", left, right);
|
||||
// return;
|
||||
// }
|
||||
|
||||
|
||||
HCBle_SendData("? <20><><EFBFBD><EFBFBD>ʧ<EFBFBD><CAA7>: %s\r\n", frame);
|
||||
}
|
||||
@@ -195,13 +193,13 @@ void ble_tx_task_entry(ULONG thread_input) {
|
||||
BleMessage msg;
|
||||
while(1) {
|
||||
|
||||
// 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,&msg,TX_WAIT_FOREVER) == TX_SUCCESS)
|
||||
{
|
||||
HCBle_SendData("#{\"lat\":%.6f,\"lon\":%.6f,\"angle\":%.1f}\n",
|
||||
msg.lat,msg.lon,msg.angle);
|
||||
}
|
||||
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,&msg,TX_WAIT_FOREVER) == TX_SUCCESS)
|
||||
// {
|
||||
// HCBle_SendData("#{\"lat\":%.6f,\"lon\":%.6f,\"angle\":%.1f}\n",
|
||||
// 23.123456, 113.654321,msg.angle);
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
18
fun/IMU.c
18
fun/IMU.c
@@ -1037,23 +1037,15 @@ char IMU_Send_Data[128]; //
|
||||
/******
|
||||
IMU <20><><EFBFBD>ڷ<EFBFBD><DAB7><EFBFBD>
|
||||
*******/
|
||||
void IMU_SendData(char *p,...)
|
||||
int UART_Write(uint8_t n, uint8_t *buf, int Len)
|
||||
{
|
||||
va_list ap;
|
||||
va_start(ap,p);
|
||||
vsprintf(IMU_Send_Data,p,ap);
|
||||
va_end(ap);
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
// <20><>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD>ӿ<EFBFBD>
|
||||
HAL_UART_Transmit(&huart3,(uint8_t *)IMU_Send_Data,strlen(IMU_Send_Data),10);
|
||||
// HAL_UART_Transmi(&huart1,(uint8_t *)formatBuf,strlen(formatBuf),1);
|
||||
// <20><><EFBFBD><EFBFBD>û<EFBFBD><C3BB>ʹ<EFBFBD><CAB9><EFBFBD>жϵĴ<CFB5><C4B4>ڷ<EFBFBD><DAB7>ͣ<EFBFBD><CDA3><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
HAL_UART_Transmit_IT(&huart3, buf, Len);
|
||||
|
||||
return Len;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><>Ҫ<EFBFBD>û<EFBFBD>ʵ<EFBFBD><CAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ĵ<EFBFBD><C4B4>ڷ<EFBFBD><DAB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݷ<EFBFBD><DDB7><EFBFBD>-------------------------------------
|
||||
* @param pBuf Ҫ<><D2AA><EFBFBD>͵<EFBFBD><CDB5><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8>
|
||||
@@ -1062,7 +1054,7 @@ void IMU_SendData(char *p,...)
|
||||
static void Cmd_Write(U8 *pBuf, int Len)
|
||||
{
|
||||
// ͨ<><CDA8>UART_Write<74><65><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͨ<EFBFBD><CDA8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD>Եײ<D4B5>Ӳ<EFBFBD><D3B2>ʵ<EFBFBD><CAB5>UART_Write<74><65><EFBFBD><EFBFBD><EFBFBD><EFBFBD>bufָ<66><D6B8>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD>Len<65>ֽ<EFBFBD><D6BD><EFBFBD><EFBFBD>ݷ<EFBFBD><DDB7>ͳ<EFBFBD>ȥ<EFBFBD><C8A5><EFBFBD><EFBFBD>
|
||||
IMU_SendData(0, pBuf, Len);
|
||||
UART_Write(0, pBuf, Len);
|
||||
|
||||
Dbp_U8_buf("tx: ", "\r\n",
|
||||
"%02X ",
|
||||
|
||||
@@ -59,10 +59,10 @@ extern struct_UartFifo UartFifo;
|
||||
|
||||
|
||||
// ===============================<3D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>====================================
|
||||
#define __Debug // ʹ<>õ<EFBFBD><C3B5>Կ<EFBFBD><D4BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ,<2C><>ʹ<EFBFBD>õ<EFBFBD><C3B5><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD>α<EFBFBD><CEB1>伴<EFBFBD><E4BCB4>
|
||||
// #define __Debug // ʹ<>õ<EFBFBD><C3B5>Կ<EFBFBD><D4BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ,<2C><>ʹ<EFBFBD>õ<EFBFBD><C3B5><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD>α<EFBFBD><CEB1>伴<EFBFBD><E4BCB4>
|
||||
#ifdef __Debug
|
||||
#define Dbp(fmt, args...) printf(fmt, ##args) // <20><><EFBFBD><EFBFBD>Ҫʹ<D2AA>õ<EFBFBD><C3B5><EFBFBD><EFBFBD><EFBFBD>Ϣ, <20>û<EFBFBD><C3BB>Խ<EFBFBD>Dbp<62><70><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
// extern void Dbp_U8_buf(char *sBeginInfo, char *sEndInfo, char *sFormat, const U8 *Buf, U32 Len);
|
||||
extern void Dbp_U8_buf(char *sBeginInfo, char *sEndInfo, char *sFormat, const U8 *Buf, U32 Len);
|
||||
#else
|
||||
#define Dbp(fmt, args...)
|
||||
#define Dbp_U8_buf(sBeginInfo, sEndInfo, sFormat, Buf, Len)
|
||||
|
||||
@@ -32,7 +32,8 @@ typedef struct GPSData
|
||||
|
||||
extern _GPSData GPS;
|
||||
extern uint8_t GPS_DMA_RX_BUF[GPS_DMA_RX_BUF_LEN];
|
||||
|
||||
double Convert_to_degrees(char *data);
|
||||
void parseGpsBuffer();
|
||||
void gps_thread_entry(ULONG thread_input);
|
||||
void GPS_Init(void);
|
||||
|
||||
|
||||
113
fun/imu948.c
113
fun/imu948.c
@@ -2,7 +2,61 @@
|
||||
|
||||
extern _GPSData gps_data;
|
||||
extern TX_QUEUE ble_tx_queue;
|
||||
extern uint8_t rx_byte;
|
||||
extern TX_EVENT_FLAGS_GROUP sensor_events;
|
||||
|
||||
void imu600_init(void)
|
||||
{
|
||||
|
||||
HAL_UART_Receive_IT(&huart3,&rx_byte,1);
|
||||
HAL_Delay(6000);
|
||||
|
||||
//------- <20><><EFBFBD>Ѵ<EFBFBD><D1B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>úô<C3BA><C3B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȼ<EFBFBD><C8BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϱ<EFBFBD>-----
|
||||
Cmd_03(); //<2F><><EFBFBD>Ѵ<EFBFBD><D1B4><EFBFBD><EFBFBD><EFBFBD>
|
||||
HAL_Delay(500);
|
||||
/**
|
||||
* <20><><EFBFBD><EFBFBD><EFBFBD>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD>
|
||||
* @param accStill <20>ߵ<EFBFBD>-<2D><>ֹ״̬<D7B4><CCAC><EFBFBD>ٶȷ<D9B6>ֵ <20><>λdm/s?
|
||||
* @param stillToZero <20>ߵ<EFBFBD>-<2D><>ֹ<EFBFBD><D6B9><EFBFBD><EFBFBD><EFBFBD>ٶ<EFBFBD>(<28><>λcm/s) 0:<3A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 255:<3A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
* @param moveToZero <20>ߵ<EFBFBD>-<2D><>̬<EFBFBD><CCAC><EFBFBD><EFBFBD><EFBFBD>ٶ<EFBFBD>(<28><>λcm/s) 0:<3A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
* @param isCompassOn 1=<3D>迪<EFBFBD><E8BFAA><EFBFBD>ų<EFBFBD> 0=<3D><><EFBFBD>رմų<D5B4>
|
||||
* @param barometerFilter <20><>ѹ<EFBFBD>Ƶ<EFBFBD><C6B5>˲<EFBFBD><CBB2>ȼ<EFBFBD>[ȡֵ0-3],<2C><>ֵԽ<D6B5><D4BD>Խƽ<D4BD>ȵ<EFBFBD>ʵʱ<CAB5><CAB1>Խ<EFBFBD><D4BD>
|
||||
* @param reportHz <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϱ<EFBFBD><CFB1>Ĵ<EFBFBD><C4B4><EFBFBD>֡<EFBFBD><D6A1>[ȡֵ0-250HZ], 0<><30>ʾ0.5HZ
|
||||
* @param gyroFilter <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˲<EFBFBD>ϵ<EFBFBD><CFB5>[ȡֵ0-2],<2C><>ֵԽ<D6B5><D4BD>Խƽ<D4BD>ȵ<EFBFBD>ʵʱ<CAB5><CAB1>Խ<EFBFBD><D4BD>
|
||||
* @param accFilter <20><><EFBFBD>ټ<EFBFBD><D9BC>˲<EFBFBD>ϵ<EFBFBD><CFB5>[ȡֵ0-4],<2C><>ֵԽ<D6B5><D4BD>Խƽ<D4BD>ȵ<EFBFBD>ʵʱ<CAB5><CAB1>Խ<EFBFBD><D4BD>
|
||||
* @param compassFilter <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˲<EFBFBD>ϵ<EFBFBD><CFB5>[ȡֵ0-9],<2C><>ֵԽ<D6B5><D4BD>Խƽ<D4BD>ȵ<EFBFBD>ʵʱ<CAB5><CAB1>Խ<EFBFBD><D4BD>
|
||||
* @param Cmd_ReportTag <20><><EFBFBD>ܶ<EFBFBD><DCB6>ı<EFBFBD>ʶ
|
||||
*/
|
||||
Cmd_12(5, 255, 0, 0, 3, 2, 2, 4, 9, 0xFFF);// 2 <20><><EFBFBD><EFBFBD><EFBFBD>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD>(<28><><EFBFBD><EFBFBD>1) ֻ<><D6BB><EFBFBD><EFBFBD>ŷ<EFBFBD><C5B7><EFBFBD><EFBFBD>
|
||||
HAL_Delay(500);
|
||||
Cmd_19();// 3 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϱ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ҾͲ<D2BE><CDB2><EFBFBD><EFBFBD>и<EFBFBD><D0B8><EFBFBD><EFBFBD><EFBFBD>
|
||||
}
|
||||
|
||||
//void IM948_Init(void)
|
||||
//{
|
||||
// HAL_UART_Receive_IT(&huart3, &rx_byte, 1);
|
||||
|
||||
// // <20><>ģ<EFBFBD><C4A3><EFBFBD>ϵ<EFBFBD>
|
||||
// tx_thread_sleep( TX_TIMER_TICKS_PER_SECOND * 5 );
|
||||
|
||||
|
||||
// Cmd_03(); // <20><><EFBFBD><EFBFBD>
|
||||
// tx_thread_sleep( TX_TIMER_TICKS_PER_SECOND / 10 );
|
||||
|
||||
// // ֻ<><D6BB><EFBFBD><EFBFBD>ŷ<EFBFBD><C5B7><EFBFBD><EFBFBD>
|
||||
// Cmd_12(
|
||||
// 5, 255, 0,
|
||||
// 0, 3, 5,
|
||||
// 2, 2, 4,
|
||||
// 0x0040 // ֻҪŷ<D2AA><C5B7><EFBFBD><EFBFBD>
|
||||
// );
|
||||
// tx_thread_sleep( TX_TIMER_TICKS_PER_SECOND / 10 );
|
||||
|
||||
// Cmd_19(); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϱ<EFBFBD>
|
||||
//}
|
||||
|
||||
|
||||
extern TX_QUEUE im948_uart_rx_queue;
|
||||
/***
|
||||
<EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD> <20><>IMU.c<><63>Ϊ<EFBFBD>ײ<EFBFBD><D7B2><EFBFBD><EFBFBD><EFBFBD> Base
|
||||
<EFBFBD><EFBFBD><EFBFBD>ڱ<EFBFBD>дӦ<EFBFBD>ò<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
@@ -10,22 +64,49 @@ extern TX_QUEUE ble_tx_queue;
|
||||
|
||||
void imu_angle_ble_task_entry(ULONG thread_input)
|
||||
{
|
||||
BleMessage msg;
|
||||
UINT sta; // ״̬
|
||||
while(1)
|
||||
ULONG rx_data;
|
||||
|
||||
// <20><>ʼ<EFBFBD><CABC>ģ<EFBFBD><C4A3>
|
||||
// IM948_Init();
|
||||
// HCBle_SendData("halo");
|
||||
while(1)
|
||||
{
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD>ȶ<EFBFBD><C8B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>д<EFBFBD><D0B4>ڽ<EFBFBD><DABD><EFBFBD>
|
||||
if (tx_queue_receive(&im948_uart_rx_queue, &rx_data, TX_WAIT_FOREVER) == TX_SUCCESS)
|
||||
{
|
||||
Cmd_GetPkt( (uint8_t)rx_data );
|
||||
}
|
||||
|
||||
// <20><><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD>°<EFBFBD>
|
||||
if (isNewData)
|
||||
{
|
||||
isNewData = 0;
|
||||
|
||||
float angle = AngleZ;
|
||||
HCBle_SendData("Z:%.2f\r\n",AngleZ);
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>angle<6C><65>ä<EFBFBD>ȳ<EFBFBD><C8B3><EFBFBD><EFBFBD>ж<EFBFBD>
|
||||
// <20><><EFBFBD><EFBFBD>:
|
||||
if(angle > 30.0f) {
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD>
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD>úý<C3BA><C3BD>պ<EFBFBD><D5BA><EFBFBD>
|
||||
void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart)
|
||||
{
|
||||
if(huart->Instance == USART3)
|
||||
{
|
||||
// ֻҪ<D6BB><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݣ<EFBFBD><DDA3>ʹ<EFBFBD><CDB4><EFBFBD>
|
||||
tx_thread_sleep(500); // ÿ20ms<6D><73><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>
|
||||
|
||||
//<2F><>ȡ<EFBFBD><C8A1><EFBFBD>½Ƕ<C2BD>
|
||||
msg.angle = 96.7;
|
||||
|
||||
// <EFBFBD><EFBFBD><EFBFBD>͵<EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
sta = tx_queue_send(&ble_tx_queue,&msg,TX_NO_WAIT);
|
||||
if(sta != TX_SUCCESS)
|
||||
{
|
||||
HCBle_SendData("Queue is full,IMU's Data was abandon");
|
||||
}
|
||||
// HCBle_SendData("RX USART3: 0x%02X (%c)\r\n", rx_byte, rx_byte);
|
||||
|
||||
// Fifo_in(rx_byte);
|
||||
ULONG rx_data = rx_byte;
|
||||
tx_queue_send(&im948_uart_rx_queue, &rx_data, TX_NO_WAIT);
|
||||
// tx_event_flags_set(&sensor_events, EVENT_IMU_DATA_READY, TX_OR);
|
||||
//<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>жϣ<EFBFBD><EFBFBD>Ա<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
HAL_UART_Receive_IT(huart,&rx_byte,1);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -4,6 +4,6 @@
|
||||
#include "headfile.h"
|
||||
|
||||
void imu_angle_ble_task_entry(ULONG thread_input);
|
||||
|
||||
void imu600_init(void);
|
||||
|
||||
#endif
|
||||
@@ -8,8 +8,8 @@ typedef struct
|
||||
float angle;
|
||||
}BleMessage;
|
||||
|
||||
|
||||
|
||||
#define EVENT_GPS_DATA_READY (1U << 0)
|
||||
#define EVENT_IMU_DATA_READY (1U << 1)
|
||||
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user