Skip to content

Commit 3a91d88

Browse files
committed
yaw added
1 parent 0674885 commit 3a91d88

33 files changed

+26375
-19989
lines changed

Core/Inc/mpu9250.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ typedef struct {
6262
typedef struct {
6363
volatile float roll;
6464
volatile float pitch;
65+
volatile float yaw;
6566
} IMU_Angles_t;
6667

6768

Core/Src/main.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ int main(void)
121121
HAL_TIM_Base_Start_IT(&htim2); // Enable TIM2 interrupt
122122
char buffer[40] = {'\0'};
123123
mpu9250_setup();
124-
// bmp388_setup();
124+
bmp388_setup();
125125
/* USER CODE END 2 */
126126

127127
/* Infinite loop */
@@ -134,11 +134,11 @@ int main(void)
134134
timer_flag = 0; //reset timer flag
135135

136136
mpu9250_getProcessedAngle();
137-
// bmp388_getData();
137+
bmp388_getData();
138138
}
139139

140140
//send data through UART
141-
//snprintf(buffer, sizeof(buffer), "%.4f,%.4f\n", pitch_angle, roll_angle);
141+
snprintf(buffer, sizeof(buffer), "%.4f,%.4f,%.4f\n", imu_angles.pitch, imu_angles.roll, imu_angles.yaw);
142142
//snprintf(buffer, sizeof(buffer), "%lu, %lu\n", bmp388_rawData.temperature, bmp388_rawData.pressure);
143143
//HAL_UART_Transmit(&huart2, (uint8_t*)buffer, strlen(buffer), HAL_MAX_DELAY);
144144

Core/Src/mpu9250.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,9 +180,11 @@ void mpu9250_getProcessedAngle()
180180
/* Quternion to Euler */
181181
float radPitch = asinf(-2.0f * (quat[1] * quat[3] - quat[0] * quat[2]));
182182
float radRoll = atan2f(2.0f * (quat[0] * quat[1] + quat[2] * quat[3]), 2.0f * (quat[0] * quat[0] + quat[3] * quat[3]) - 1.0f);
183+
float radYaw = atan2f(2.0f * (quat[0] * quat[3] + quat[1] * quat[2]), 2.0f * (quat[0] * quat[0] + quat[1] * quat[1]) - 1.0f);
183184
/* Radian to Degree*/
184185
imu_angles.pitch = radPitch * RAD_TO_DEG;
185186
imu_angles.roll = radRoll * RAD_TO_DEG;
187+
imu_angles.yaw = radYaw * RAD_TO_DEG;
186188

187189
}
188190

Debug/Core/Src/main.o

660 Bytes
Binary file not shown.

Debug/Core/Src/main.su

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
../Drivers/CMSIS/Include/core_cm7.h:2660:26:ITM_SendChar 16 static,ignoring_inline_asm
2-
../Core/Src/main.c:88:5:main 48 static
2+
../Core/Src/main.c:88:5:main 72 static
33
../Core/Src/main.c:156:6:SystemClock_Config 120 static
44
../Core/Src/main.c:216:13:MX_SPI1_Init 8 static
55
../Core/Src/main.c:264:13:MX_SPI2_Init 8 static

Debug/Core/Src/mpu9250.o

236 Bytes
Binary file not shown.

Debug/Core/Src/mpu9250.su

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44
../Core/Src/mpu9250.c:64:6:mpu9250_init_ak8963 16 static
55
../Core/Src/mpu9250.c:114:6:mpu9250_calibrateGyro 32 static
66
../Core/Src/mpu9250.c:145:6:mpu9250_getRawData 16 static
7-
../Core/Src/mpu9250.c:160:6:mpu9250_getProcessedAngle 16 static
7+
../Core/Src/mpu9250.c:160:6:mpu9250_getProcessedAngle 24 static
-52 Bytes
Binary file not shown.
-28 Bytes
Binary file not shown.
-32 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)