From 44836847a117b4f794d95e6d21d4d5905742e111 Mon Sep 17 00:00:00 2001 From: Imbus <> Date: Mon, 25 Mar 2024 10:51:05 +0100 Subject: [PATCH] Interrupts --- main.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/main.c b/main.c index fc213ae..4c83114 100644 --- a/main.c +++ b/main.c @@ -56,6 +56,7 @@ void configure_interrupt() { int main(void) { int16_t accel_data[3]; // Array to store accelerometer data (X, Y, Z) + int16_t gyro_data[3]; // Array to store gyroscope data (X, Y, Z) int32_t iteration = 0; // Set the watchdog timer to 8 seconds @@ -78,17 +79,22 @@ int main(void) { MPU6050_Init(); UART_println("MPU6050 Initialized!"); + configure_interrupt(); while (1) { - // Pat the dog - wdt_reset(); - UART_println("%d Hello, World!", iteration++); // Read accelerometer data UART_println("Reading MPU6050 accelerometer data..."); MPU6050_Read_Accel(accel_data); - UART_println("Accelerometer (mg): X=%d, Y=%d, Z=%d", accel_data[0], accel_data[1], accel_data[2]); + + // Read gyroscope data + UART_println("Reading MPU6050 gyroscope data..."); + MPU6050_Read_Gyro(gyro_data); + UART_println("Gyroscope (deg/s): X=%d, Y=%d, Z=%d", gyro_data[0], gyro_data[1], gyro_data[2]); + + // Pat the dog and go to sleep + wdt_reset(); sleep_mode(); }