Challenge

Project 2 - Integrate following sensors to the Dev Board

  1. Initialize and configure UART for GPS communication with interrupt-based reception.
  2. Read GPS data using UART reception interrupt and detect GPS connection/disconnection.
  3. Set up I2C communication for IMU sensor (Accelerometer + Gyroscope).
  4. Create a task to handle IMU data and separate them based on the sensor type (Accelerometer and Gyroscope).
  5. Implement a task to monitor GPS data for location changes greater than 100m and print the coordinates along with IMU sensor values over UART.

CODE;

#include "FreeRTOS.h"

#include "task.h"

#include "queue.h"

#include "stm32f4xx_hal.h"

// Define UART and I2C configurations and handles

// Define constants for 100m distance

QueueHandle_t imuAccQueue; // Queue for accelerometer data

QueueHandle_t imuGyroQueue; // Queue for gyroscope data

void uartGPS_RxCpltCallback(UART_HandleTypeDef *huart) {

    // UART receive interrupt callback for GPS

    // Process GPS data and detect connection/disconnection

}

void i2cIMU_Handler() {

    // I2C interrupt handler for IMU sensor

    // Read IMU data and separate them based on sensor type

}

void imuDataTask(void *pvParameters) {

    // Task to handle IMU data

    // Separate accelerometer and gyroscope data based on the queue

    while (1) {

        // Process IMU data from the respective queues

    }

}

void gpsMonitorTask(void *pvParameters) {

    // Task to monitor GPS location changes

    while (1) {

        // Check for GPS location change > 100m

        // If there is a change, print coordinates along with IMU sensor values over UART

    }

}

int main(void) {

    // Initialize hardware and FreeRTOS

    // Initialize UART for GPS communication with interrupt-based reception

    // Initialize I2C for IMU sensor communication

    // Create queues for IMU data (accelerometer and gyroscope)

    imuAccQueue = xQueueCreate(/* Queue length */, sizeof(/* Data structure for accelerometer data */));

    imuGyroQueue = xQueueCreate(/* Queue length */, sizeof(/* Data structure for gyroscope data */));

    // Create tasks for IMU data processing and GPS monitoring

    xTaskCreate(imuDataTask, "IMUDataTask", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY + 1, NULL);

    xTaskCreate(gpsMonitorTask, "GPSMonitorTask", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY + 2, NULL);

    vTaskStartScheduler();

    // Code should never reach here

    while (1) {

    }

}

Your portfolio, next

Ship work like this
in your own course.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.