Master Thesis
V1.0
Research and Design of Sensor Node for NMSD Treatment
|
Code used in master thesis, MAIN FILE. More...
#include <adc.h>
#include "em_system.h"
#include "em_device.h"
#include "em_chip.h"
#include "em_cmu.h"
#include "em_emu.h"
#include "em_gpio.h"
#include "em_usart.h"
#include "em_rtc.h"
#include "em_adc.h"
#include "rtcdriver.h"
#include "em_core.h"
#include "debug_dbprint.h"
#include "delay.h"
#include "ICM20948.h"
#include "interrupt.h"
#include "ble.h"
#include "uart.h"
#include "timer.h"
#include "datatypes.h"
#include "util.h"
#include "rtcdrv_config.h"
#include "pinout.h"
#include <stdint.h>
#include <stdbool.h>
#include "I2C.h"
#include "MadgwickAHRS.h"
#include "math.h"
#include "bsp.h"
#include "bsp_trace.h"
Go to the source code of this file.
Macros | |
#define | DIY 1 |
Functions | |
void | CheckIMUidle (void) |
Function called by RTC timer every second. More... | |
void | measure_send (void) |
Function called by interrupt from IMU @50 Hz. More... | |
int | main (void) |
Main function. More... | |
void | GPIO_EVEN_IRQHandler (void) |
GPIO Even IRQ for pushbuttons on even-numbered pins. More... | |
void | GPIO_ODD_IRQHandler (void) |
GPIO Odd IRQ for pushbuttons on odd-numbered pins. More... | |
Variables | |
MeasurementData_t | data |
bool | bleConnected = false |
bool | IMU_MEASURING = false |
bool | IDLE = false |
bool | _sleep = false |
uint8_t | idle_count = 0 |
uint8_t | ble_sec_not_connected = 0 |
uint32_t | interruptStatus [1] |
RTCDRV_TimerID_t | IMU_Idle_Timer |
bool | helft = false |
uint8_t | teller = 0 |
uint8_t | teller_accuracy = 0 |
volatile float | beta = 1.0f |
Code used in master thesis, MAIN FILE.
Development of sensor node to use for threating NMSA
Please check https://github.com/jonacappelle/Master-Thesis to find the latest version!
Copyright (C) 2020 - Jona Cappelle
Definition in file main.c.
#define DIY 1 |
void CheckIMUidle | ( | void | ) |
Function called by RTC timer every second.
Check batt Check gyro idle Check BLE connected Dynamically set Madgwick beta parameter
Definition at line 163 of file main.c.
References ADC_get_batt(), MeasurementData_t::batt, beta, ble_sec_not_connected, data, MeasurementData_t::ICM_20948_gyro, ICM_20948_interruptEnable(), idle_count, IMU_Idle_Timer, and teller_accuracy.
void GPIO_EVEN_IRQHandler | ( | void | ) |
void GPIO_ODD_IRQHandler | ( | void | ) |
int main | ( | void | ) |
Main function.
State diagram BATT_READ and CALLIBRATE will never be reached Future update: calibrate when receiving special BLE packet
Definition at line 316 of file main.c.
void measure_send | ( | void | ) |
Function called by interrupt from IMU @50 Hz.
Measure Gyro + Accel + Magn Sensor fusion with Madgwick filter Convert quaternions to Euler angles Convert floats to uint8_t for transmission Send data via UART to BLE module (interrupt based) Toggle pin to check speed
Definition at line 234 of file main.c.
References MeasurementData_t::batt, BLE_check_connect(), BLE_connect(), MeasurementData_t::BLE_data, MeasurementData_t::BLE_euler_angles, BLE_power(), ble_sec_not_connected, BLE_sendData(), bleConnected, data, delay(), float_to_uint8_t_x3(), MeasurementData_t::ICM_20948_accel, ICM_20948_accelDataRead(), MeasurementData_t::ICM_20948_euler_angles, MeasurementData_t::ICM_20948_gyro, ICM_20948_gyroDataRead(), ICM_20948_magDataRead(), MeasurementData_t::ICM_20948_magn, M_PI, MadgwickAHRSupdate(), and QuaternionsToEulerAngles().
bool _sleep = false |
volatile float beta = 1.0f |
Beta parameter of Madgwick filter
Definition at line 145 of file main.c.
Referenced by CheckIMUidle(), MadgwickAHRSupdate(), and MadgwickAHRSupdateIMU().
uint8_t ble_sec_not_connected = 0 |
200 ms that the BLE is not connected
Definition at line 131 of file main.c.
Referenced by CheckIMUidle(), and measure_send().
bool bleConnected = false |
Keep track of the state of the BLE module
Definition at line 125 of file main.c.
Referenced by BLE_check_connect(), and measure_send().
MeasurementData_t data |
Struct to store al the measured data and calibration values
Definition at line 122 of file main.c.
Referenced by BLE_sendData(), BLE_sendData4(), BLE_sendIMUData(), BLE_set_output_power(), CheckIMUidle(), ICM_20948_accelGyroCalibrate(), ICM_20948_gyroCalibrate(), ICM_20948_lowPowerModeEnter(), ICM_20948_magDataRead(), ICM_20948_magRawDataRead(), ICM_20948_read(), ICM_20948_read_mag_register(), ICM_20948_registerRead(), ICM_20948_registerWrite(), ICM_20948_write_mag_register(), and measure_send().
bool IDLE = false |
uint8_t idle_count = 0 |
RTCDRV_TimerID_t IMU_Idle_Timer |
Timer used for checking variables every second
Definition at line 136 of file main.c.
Referenced by CheckIMUidle().
bool IMU_MEASURING = false |
uint8_t teller_accuracy = 0 |
Counter to keep track when to enter accuracy mode on Madgwick filter
Definition at line 143 of file main.c.
Referenced by CheckIMUidle().