Interrupts
This commit is contained in:
parent
f4f866a347
commit
44836847a1
1 changed files with 10 additions and 4 deletions
14
main.c
14
main.c
|
@ -56,6 +56,7 @@ void configure_interrupt() {
|
||||||
|
|
||||||
int main(void) {
|
int main(void) {
|
||||||
int16_t accel_data[3]; // Array to store accelerometer data (X, Y, Z)
|
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;
|
int32_t iteration = 0;
|
||||||
|
|
||||||
// Set the watchdog timer to 8 seconds
|
// Set the watchdog timer to 8 seconds
|
||||||
|
@ -78,17 +79,22 @@ int main(void) {
|
||||||
MPU6050_Init();
|
MPU6050_Init();
|
||||||
UART_println("MPU6050 Initialized!");
|
UART_println("MPU6050 Initialized!");
|
||||||
|
|
||||||
|
configure_interrupt();
|
||||||
while (1) {
|
while (1) {
|
||||||
// Pat the dog
|
|
||||||
wdt_reset();
|
|
||||||
|
|
||||||
UART_println("%d Hello, World!", iteration++);
|
UART_println("%d Hello, World!", iteration++);
|
||||||
|
|
||||||
// Read accelerometer data
|
// Read accelerometer data
|
||||||
UART_println("Reading MPU6050 accelerometer data...");
|
UART_println("Reading MPU6050 accelerometer data...");
|
||||||
MPU6050_Read_Accel(accel_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]);
|
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();
|
sleep_mode();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue