Master Thesis  V1.0
Research and Design of Sensor Node for NMSD Treatment
main.c
Go to the documentation of this file.
1 /* Masterproef Design Sensor Node */
2 /* Made By Jona Cappelle */
3 
4 /*************************************************/
5 /**** ********/
6 /****** MAIN FILE ******/
7 /**** ********/
8 /*************************************************/
9 
10 /***************************************************************************/
49 /*
50  * Measurement of time
51  *
52  * uint32_t start = millis();
53  * uint32_t duration = millis() - start;
54  *
55  */
56 
57 /* Include system libraries */
58 #include <adc.h>
59 #include "em_system.h"
60 #include "em_device.h"
61 #include "em_chip.h"
62 #include "em_cmu.h"
63 #include "em_emu.h"
64 #include "em_gpio.h"
65 #include "em_usart.h"
66 #include "em_rtc.h"
67 #include "em_adc.h"
68 //#include "em_wdog.h"
69 #include "rtcdriver.h"
70 #include "em_core.h"
71 
72 /* Include home made libraries */
73 #include "debug_dbprint.h"
74 #include "delay.h"
75 #include "ICM20948.h"
76 #include "interrupt.h"
77 #include "ble.h"
78 #include "uart.h"
79 #include "timer.h"
80 #include "datatypes.h"
81 #include "util.h"
82 
83 /* Need to make a separate file called "rtcdrv_config.h" and place:
84  *
85  * #define EMDRV_RTCDRV_WALLCLOCK_CONFIG
86  * To enable clock functionality
87  // */
88 #include "rtcdrv_config.h" // voor millis();
89 
90 /* Separate file for Pins and Constants */
91 #include "pinout.h"
92 
93 /* Needed to use uintx_t */
94 #include <stdint.h>
95 #include <stdbool.h>
96 //#include "stdio.h"
97 
98 /* Communication */
99 #include "I2C.h"
100 //#include "em_i2c.h"
101 //#include "i2cspm.h" /* I2C higher level library to easily setup and use I2C */
102 
103 /* Sensor fusion */
104 #include "MadgwickAHRS.h"
105 #include "math.h"
106 
107 /* LED's */
108 #include "bsp.h"
109 
110 /* Energy profiles trace code */
111 #include "bsp_trace.h"
112 
113 /*************************************************/
114 /*************************************************/
115 
116 #define DIY 1
118 /* The use of switch - cases makes the code more user friendly */
119 static volatile APP_State_t appState;
121 /* Keep the measurement data */
124 /* bool to check if bluetooth is connected */
125 bool bleConnected = false;
126 bool IMU_MEASURING = false;
127 bool IDLE = false;
128 bool _sleep = false;
130 uint8_t idle_count = 0;
133 uint32_t interruptStatus[1];
135 /* Timer for IMU idle checking */
136 RTCDRV_TimerID_t IMU_Idle_Timer;
138 /* Test pin to check frequency of execution */
139 
140 bool helft = false;
142 uint8_t teller = 0;
143 uint8_t teller_accuracy = 0;
145 volatile float beta = 1.0f;
148 /*************************************************/
149 /*************************************************/
150 
151 /**************************************************************************/
163 void CheckIMUidle( void )
164 {
165 
166  /* Read battery in percent */
168 
169  float mean_gyro = (uint8_t) ( data.ICM_20948_gyro[0] + data.ICM_20948_gyro[1] + data.ICM_20948_gyro[2] ) / 3;
170 
171  /* Add 1 sec to the count of idle seconds */
172  if( mean_gyro < 0.1 )
173  {
174  idle_count++;
175  }else{ /* If there is movement, reset idle seconds */
176  idle_count = 0;
177  }
178 
179 
180  if( (idle_count > 60) || (ble_sec_not_connected > 5*5)) // 5sec * 75Hz
181  {
182  idle_count = 0;
184  teller_accuracy = 0;
185  beta = 1.0f;
186  /* Dont't check idle state in sleep */
187  RTCDRV_StopTimer( IMU_Idle_Timer );
188  /* Stop generating interrupts */
189  ICM_20948_interruptEnable(false, false);
190  appState = SLEEP;
191  _sleep = true;
192  }
193  // Reset timer is BLE is connected
194  if(bleConnected)
195  {
197  }
198 
199 /* For visual representation where in the code */
200 #if DIY == 0
201  BSP_LedToggle(1);
202 #endif
203 
204  if(teller_accuracy < 10)
205  {
206  teller_accuracy++;
207  }
208 
209  if(teller_accuracy >= 10)
210  {
211  beta = 0.05f;
212  }
213 
214 }
215 
216 /**************************************************************************/
234 void measure_send( void )
235 {
236 
237  /* Check connection */
238 #if DEBUG_DBPRINT == 0 /* DEBUG_DBPRINT */
240  if (!bleConnected)
241  {
243  BLE_power(true);
244  delay(200);
245  BLE_connect();
246  }
247 
248 #endif /* DEBUG_DBPRINT */
249 
250  /* Read all sensors */
254 
255  // TODO: embedded ICM_20948_magn_to_angle( ICM_20948_magn, ICM_20948_magn_angle );
256 
257 // uint32_t start = millis();
258 
259  /* Sensor fusion */
261  data.ICM_20948_gyro[1] * M_PI / 180.0f,
262  data.ICM_20948_gyro[2] * M_PI / 180.0f,
266 
267 
268 
269 // uint32_t duration = millis() - start;
270 
271  /* Convert float's to uint8_t arrays for transmission over BLE */
274 
275 // helft = !helft;
276 
277 
278 #if DEBUG_DBPRINT == 0 /* DEBUG_DBPRINT */
279 // if(helft == 1)
280 // {
281 
282 // if(teller < 3)
283 // {
285  /* Test frequency */
286  GPIO_PinOutSet(gpioPortE, 11);
287  GPIO_PinOutClear(gpioPortE, 11);
288 // }else{
289 // teller = 0;
290 // }
291 // teller++;
292 
293 
294 // }
295 #endif /* DEBUG_DBPRINT */
296 
297 #if DIY == 0
298  BSP_LedToggle(0);
299 #endif
300 
301 
302 }
303 
304 
305 /**************************************************************************/
316 int main(void)
317 {
318 
319  /* Start with initialization */
320  appState = INIT;
321 
322  /* Infinite loop */
323  while (1)
324  {
325  switch (appState)
326  {
327  /***************************/
328  case SYS_IDLE:
329  {
330  /* Wait in EM2 */
331 // EMU_EnterEM2(true);
332 
333  }
334  break;
335  /***************************/
336  case INIT:
337  {
338  /* Chip errata */
339  CHIP_Init();
340 
341 
342  /* ENABLE CODE CORRELATION -- uses SWO */
343  /* If first word of user data page is non-zero, enable eA Profiler trace */
344 // BSP_TraceProfilerSetup();
345 
346  /* FULL SPEED */
347  CMU_ClockSelectSet(cmuClock_HF, cmuSelect_HFXO);
348 // CMU_OscillatorEnable(cmuOsc_HFRCO, false, false);
349 
350  CMU_ClockEnable(cmuClock_HFPER, true);
351  CMU_ClockEnable(cmuClock_GPIO, true);
352 
353  /* Set output pin to check frequency of execution */
354 
355  GPIO_PinModeSet(gpioPortE, 11, gpioModePushPull, 0);
356 
357 #if DIY == 1
358  GPIO_PinModeSet(LED_PORT, LED_PIN, gpioModePushPull, 1);
359  delay(1000);
360  GPIO_PinModeSet(LED_PORT, LED_PIN, gpioModeDisabled, 0);
361 
362  blink(3);
363 #endif
364 
365  /* Leds on development board */
366 #if DIY == 0
367  BSP_LedsInit();
368 #endif
369 
370  /* Setup printing to virtual COM port, w */
371 #if DEBUG_DBPRINT == 1 /* DEBUG_DBPRINT */
372  dbprint_INIT(USART1, 4, true, false);
373 #endif /* DEBUG_DBPRINT */
374 
375  /* Timer init */
376  RTCDRV_Init();
377  RTCDRV_AllocateTimer(&IMU_Idle_Timer);
378 
379 
380  /* Initialize ICM_20948 + SPI interface */
381  ICM_20948_Init();
382  //ICM_20948_Init_SPI();
383 
384  /* Initialize GPIO interrupts on port C 2 */
386 
387  /* Initialize ADC to read battery voltage */
388  initADC();
389 // ADC_get_batt(data.batt);
390 
391 
392 
393 #if DEBUG_DBPRINT == 1 /* DEBUG_DBPRINT */
394  dbprintln("INIT");
395 #endif /* DEBUG_DBPRINT */
396 
397  /* Bluetooth */
398 #if DEBUG_DBPRINT == 0 /* DEBUG_DBPRINT */
399  BLE_Init();
400 #endif /* DEBUG_DBPRINT */
401 
402  delay(200);
403  /* Set output power */
404 // BLE_set_output_power(BLE_OUTPUT_POWER_0DB);
405 // delay(100);
406 
407  // TODO Temporary
408  /* Check connection */
409 #if DEBUG_DBPRINT == 0 /* DEBUG_DBPRINT */
411  if (!bleConnected)
412  {
413  BLE_power(true);
414  delay(1000);
415  BLE_connect();
416  }
417 #endif /* DEBUG_DBPRINT */
418 
419  /* Set interrupt to trigger every 100ms when the data is ready */
420  IMU_MEASURING = true;
421  ICM_20948_interruptEnable(true, false);
422 
423  /* Fancy LED's */
424 #if DIY == 0
425  for(uint8_t i=0; i<8; i++)
426  {
427  BSP_LedSet(0);
428  BSP_LedSet(1);
429  delay(100);
430  BSP_LedClear(0);
431  BSP_LedClear(1);
432  delay(100);
433  }
434 #endif
435 
436  /* Timer for checking if IMU is idle */
437  RTCDRV_StartTimer( IMU_Idle_Timer, rtcdrvTimerTypePeriodic, 2000, (RTCDRV_Callback_t)CheckIMUidle, NULL);
438 
439 
440 
441  appState = SYS_IDLE;
442 
443 
444  }
445  break;
446  /***************************/
447  case SENSORS_READ:
448  {
449 
450 #if DEBUG_DBPRINTs == 1 /* DEBUG_DBPRINT */
451  dbprintln("SENSORS_READ");
452 #endif /* DEBUG_DBPRINT */
453 
454  measure_send();
455 
456 #if DEBUG_DBPRINTs == 1 /* DEBUG_DBPRINT */
457  dbprintInt((int) ( data.ICM_20948_gyro[0]*100) );
458  dbprint(",");
459  dbprintInt((int) (data.ICM_20948_gyro[1] *100) );
460  dbprint(",");
461  dbprintInt((int) (data.ICM_20948_gyro[2] *100) );
462  dbprint(",");
463  dbprintInt((int) ( data.ICM_20948_accel[0]*100) );
464  dbprint(",");
465  dbprintInt((int) (data.ICM_20948_accel[1] *100) );
466  dbprint(",");
467  dbprintlnInt((int) (data.ICM_20948_accel[2] *100) );
468 #endif /* DEBUG_DBPRINT */
469 
470 #if DEBUG_DBPRINTs == 1 /* DEBUG_DBPRINT */
471  //dbprint(" roll: ");
472  dbprintInt((int) (ICM_20948_euler_angles[0] *100) );
473  //dbprint(" pitch: ");
474  dbprint("\t");
475  dbprintInt((int) (ICM_20948_euler_angles[1] *100) );
476  //dbprint(" yaw: ");
477  dbprint("\t");
478  dbprintlnInt((int) (ICM_20948_euler_angles[2] *100) );
479 #endif /* DEBUG_DBPRINT */
480 
481 #if DEBUG_DBPRINTs == 1 /* DEBUG_DBPRINT */
482  dbprintInt((int) ICM_20948_magn[0] );
483  dbprint(",");
484  dbprintInt((int) ICM_20948_magn[1] );
485  dbprint(",");
486  dbprintlnInt((int) ICM_20948_magn[2] );
487 #endif /* DEBUG_DBPRINT */
488 
489 
490  /* If imu is idle, give it the chance to go to sleep */
491  if(!_sleep)
492  {
493  appState = SYS_IDLE;
494  }
495  }
496  break;
497  /***************************/
498  case BATT_READ:
499  {
500  ADC_Batt_Read();
502 
503 #if DEBUG_DBPRINT == 1 /* DEBUG_DBPRINT */
504  dbprintln("BATT_READ");
505 #endif /* DEBUG_DBPRINT */
506 
507  appState = SYS_IDLE;
508  }
509  break;
510  /***************************/
511  case SLEEP:
512  {
513  //RTCDRV_StartTimer( IMU_Idle_Timer, rtcdrvTimerTypeOneshot, 2000, test, NULL);
514 
515  RTCDRV_StopTimer( IMU_Idle_Timer );
516  RTCDRV_DeInit();
517 
518  BLE_disconnect();
519  delay(100);
520  BLE_power( false);
521  BLE_rxtx_enable( false );
522 
523  bleConnected = false;
524 
525  CMU_ClockEnable(cmuClock_ADC0, false);
526 // GPIO_PinModeSet(gpioPortD, 4, gpioModeDisabled, 0);
527 
528  GPIO_PinModeSet(gpioPortE, 11, gpioModeDisabled, 0);
529 
530 
531  /* Shut down magnetometer */
533  delay(100);
534 
535  uint8_t temp1[8];
536  ICM_20948_read_mag_register(0x31, 1, temp1);
537  /* Update data by reading through till ST2 register */
538  ICM_20948_read_mag_register(0x11, 8, temp1);
539 
540 
541  /* Wake on motion: 50 mg's (0.05 G) */
542  ICM_20948_wakeOnMotionITEnable(true, 20, 2.2);
543 // ICM_20948_sleepModeEnable(true);
544  delay(400);
545 
546  IIC_Enable(false);
547 
548 
549  /* Disable Systicks before going to sleep */
550  EMU_EnterEM2(true);
551 
552 
554  /* When waking up, initialize everything */
556 
557  CMU_ClockSelectSet(cmuClock_HF, cmuSelect_HFXO);
558 
559  IIC_Enable(true);
560  BLE_power(true);
561  BLE_rxtx_enable( true );
562  CMU_ClockEnable(cmuClock_ADC0, true);
563 
564  _sleep = false;
565 
566  /* Setup IMU */
567  ICM_20948_lowPowerModeEnter(false, false, false);
568  ICM_20948_Init2();
569 
570 
571  /* Timer for checking if IMU is idle */
572  RTCDRV_Init();
573  RTCDRV_AllocateTimer(&IMU_Idle_Timer);
574  RTCDRV_StartTimer( IMU_Idle_Timer, rtcdrvTimerTypePeriodic, 2000, (RTCDRV_Callback_t)CheckIMUidle, NULL);
575 
576  /* Set interrupt to trigger every 100ms when the data is ready */
577  IMU_MEASURING = true;
578  ICM_20948_interruptEnable(true, false);
579 
580  GPIO_PinModeSet(gpioPortE, 11, gpioModePushPull, 0);
581 
582  appState = SYS_IDLE;
583 
584 #if DEBUG_DBPRINT == 1 /* DEBUG_DBPRINT */
585  dbprintln("SLEEP");
586 #endif /* DEBUG_DBPRINT */
587  }
588  break;
589  /***************************/
590  case CALLIBRATE:
591  {
592 #if DEBUG_DBPRINT == 1 /* DEBUG_DBPRINT */
593  dbprintln("CALLIBRATE");
594 #endif /* DEBUG_DBPRINT */
595 
598 
599  appState = SYS_IDLE;
600  }
601  break;
602  /***************************/
603  } //switch
604 
605  } //while
606 } //main
607 
608 
609 
610 
611 
612 
613 
614 
615 /**************************************************************************/
619 {
620  // Clear all even pin interrupt flags
621  GPIO_IntClear(0x5555);
622 #if DEBUG_DBPRINTs == 1 /* DEBUG_DBPRINT */
623  dbprint("Interrupt fired! 1");
624 #endif /* DEBUG_DBPRINT */
625 
626 // measure_send();
627 
628 // ICM_20948_interruptStatusRead(interruptStatus);
629 //
630 // /* AND with mask to check only bit 4 of byte 1 */
631 // if( (interruptStatus[0] & 8) == 8 ) /* If interrupt is bit WOM interrupt */
632 // {
633 // appState = SLEEP;
634 // }else{
635 
636  /* If sensor is not trying to sleep, read sensors
637  * Otherwise bug when trying to sleep but still last interrupts occurring, sensor won't go to sleep
638  */
639  if(appState != SLEEP)
640  {
641  appState = SENSORS_READ;
642  }
643 
644 
645 // }
646 }
647 
648 /**************************************************************************/
652 {
653  // Clear all odd pin interrupt flags
654  GPIO_IntClear(0xAAAA);
655 
656 #if DEBUG_DBPRINTs == 1 /* DEBUG_DBPRINT */
657  dbprint("Interrupt fired! 2");
658 #endif /* DEBUG_DBPRINT */
659 
660 // appState = SENSORS_READ;
661 }
662 
663 
664 
665 
MeasurementData_t::magOffset
float magOffset[3]
Definition: datatypes.h:47
teller_accuracy
uint8_t teller_accuracy
Definition: main.c:143
CheckIMUidle
void CheckIMUidle(void)
Function called by RTC timer every second.
Definition: main.c:163
MeasurementData_t::ICM_20948_gyro
float ICM_20948_gyro[3]
Definition: datatypes.h:35
dbprint_INIT
void dbprint_INIT(USART_TypeDef *pointer, uint8_t location, bool vcom, bool interrupts)
data
MeasurementData_t data
Definition: main.c:122
BLE_sendData
void BLE_sendData(uint8_t *data, uint8_t *batt, uint8_t length, uint8_t *ble_data)
Send all the data over BLE.
Definition: ble.c:261
ICM_20948_accelDataRead
uint32_t ICM_20948_accelDataRead(float *accel)
Read RAW accelerometer data.
Definition: ICM20948.c:1170
MeasurementData_t
Definition: datatypes.h:32
ICM_20948_lowPowerModeEnter
uint32_t ICM_20948_lowPowerModeEnter(bool enAccel, bool enGyro, bool enTemp)
Enter low power mode for selected sensors.
Definition: ICM20948.c:1037
MeasurementData_t::BLE_data
uint8_t BLE_data[sizeof(float) *3+5]
Definition: datatypes.h:42
interruptStatus
uint32_t interruptStatus[1]
Definition: main.c:133
helft
bool helft
Definition: main.c:140
IMU_Idle_Timer
RTCDRV_TimerID_t IMU_Idle_Timer
Definition: main.c:136
BLE_power
void BLE_power(bool enable)
Turn power on/off for BLE module.
Definition: ble.c:84
ble_sec_not_connected
uint8_t ble_sec_not_connected
Definition: main.c:131
ICM_20948_wakeOnMotionITEnable
uint32_t ICM_20948_wakeOnMotionITEnable(bool enable, uint8_t womThreshold, float sampleRate)
Set wake on motion interrupt.
Definition: ICM20948.c:1295
dbprint
void dbprint(char *message)
delay
void delay(uint32_t msDelay)
Wait for a certain amount of milliseconds in EM2/3.
Definition: delay.c:116
adc.h
Read battery voltage.
dbprintInt
void dbprintInt(int32_t value)
ICM20948.h
Advanced funcions to control and read data from the ICM-20948.
SENSORS_READ
Definition: datatypes.h:25
rtcdrv_config.h
RTC timer config file.
BLE_rxtx_enable
void BLE_rxtx_enable(bool enable)
Enable disable RX/TX pins from BLE module.
Definition: ble.c:128
teller
uint8_t teller
Definition: main.c:142
datatypes.h
Datatypes.
IMU_MEASURING
bool IMU_MEASURING
Definition: main.c:126
idle_count
uint8_t idle_count
Definition: main.c:130
APP_State_t
enum app_states APP_State_t
MeasurementData_t::ICM_20948_accel
float ICM_20948_accel[3]
Definition: datatypes.h:36
BLE_check_connect
void BLE_check_connect()
Check if LED pin on BLE is high to check if the module is connected to a receiver.
Definition: ble.c:179
uart.h
UART communication with BLE.
interrupt.h
Code to detect and generate interrupts.
blink
void blink(uint8_t times)
Function to blink LED on sensor node.
Definition: util.c:57
LED_PORT
#define LED_PORT
Definition: pinout.h:20
ICM_20948_Init
void ICM_20948_Init()
Init function for ICM20948.
Definition: ICM20948.c:85
initADC
void initADC(void)
Initialisation of the ADC.
Definition: adc.c:32
bleConnected
bool bleConnected
Definition: main.c:125
dbprintlnInt
void dbprintlnInt(int32_t value)
IIC_Enable
void IIC_Enable(bool enable)
Definition: I2C.c:71
SLEEP
Definition: datatypes.h:27
ICM_20948_gyroDataRead
uint32_t ICM_20948_gyroDataRead(float *gyro)
Read gyroscope data from IMU.
Definition: ICM20948.c:783
MadgwickAHRS.h
Sensor fusion.
measure_send
void measure_send(void)
Function called by interrupt from IMU @50 Hz.
Definition: main.c:234
timer.h
millis and micros functionality
ADC_Batt_Read
void ADC_Batt_Read(void)
Do single ADC conversion (read)
Definition: adc.c:100
MeasurementData_t::batt
uint8_t batt[1]
Definition: datatypes.h:51
BLE_connect
void BLE_connect()
Connect sequence BLE.
Definition: ble.c:152
ICM_20948_Init2
void ICM_20948_Init2()
Second init function for ICM20948, use when waking from sleep.
Definition: ICM20948.c:169
ICM_20948_interruptEnable
uint32_t ICM_20948_interruptEnable(bool dataReadyEnable, bool womEnable)
Enable interrupt for data ready or wake on motion.
Definition: ICM20948.c:885
MeasurementData_t::ICM_20948_magn
float ICM_20948_magn[3]
Definition: datatypes.h:37
SYS_IDLE
Definition: datatypes.h:29
ICM_20948_read_mag_register
void ICM_20948_read_mag_register(uint8_t addr, uint8_t numBytes, uint8_t *data)
Read register in the AK09916 magnetometer device.
Definition: ICM20948.c:1594
delay.h
Delay functionality.
ICM_20948_set_mag_mode
uint32_t ICM_20948_set_mag_mode(uint8_t magMode)
Set magnetometer mode (sample rate / on-off)
Definition: ICM20948.c:1670
ICM_20948_calibrate_mag
bool ICM_20948_calibrate_mag(float *offset, float *scale)
Magnetometer calibration function. Get magnetometer minimum and maximum values, while moving the devi...
Definition: ICM20948.c:2289
ADC_get_batt
void ADC_get_batt(uint8_t *percent)
Get battery in percentage.
Definition: adc.c:132
GPIO_EVEN_IRQHandler
void GPIO_EVEN_IRQHandler(void)
GPIO Even IRQ for pushbuttons on even-numbered pins.
Definition: main.c:618
LED_PIN
#define LED_PIN
Definition: pinout.h:21
beta
volatile float beta
Definition: main.c:145
initGPIO_interrupt
void initGPIO_interrupt(void)
GPIO interrupt initialization.
Definition: interrupt.c:42
pinout.h
File to keep track of most the pins used, pins for BLE are in own file BLE.h.
IDLE
bool IDLE
Definition: main.c:127
main
int main(void)
Main function.
Definition: main.c:316
MeasurementData_t::ICM_20948_euler_angles
float ICM_20948_euler_angles[3]
Definition: datatypes.h:38
AK09916_BIT_MODE_POWER_DOWN
#define AK09916_BIT_MODE_POWER_DOWN
Definition: pinout.h:384
MeasurementData_t::gyroCal
float gyroCal[3]
Definition: datatypes.h:46
ICM_20948_magDataRead
void ICM_20948_magDataRead(float *magn)
Convert raw magnetometer values to calibrated and scaled ones.
Definition: ICM20948.c:1745
ICM_20948_accelGyroCalibrate
uint32_t ICM_20948_accelGyroCalibrate(float *accelBiasScaled, float *gyroBiasScaled)
Accelerometer and gyroscope calibration function. Reads the gyroscope and accelerometer values while ...
Definition: ICM20948.c:1820
GPIO_ODD_IRQHandler
void GPIO_ODD_IRQHandler(void)
GPIO Odd IRQ for pushbuttons on odd-numbered pins.
Definition: main.c:651
MeasurementData_t::accelCal
float accelCal[3]
Definition: datatypes.h:45
QuaternionsToEulerAngles
void QuaternionsToEulerAngles(float *euler_angles)
Convert quaternions to euler angles.
Definition: MadgwickAHRS.c:351
INIT
Definition: datatypes.h:24
CALLIBRATE
Definition: datatypes.h:28
float_to_uint8_t_x3
void float_to_uint8_t_x3(float *in, uint8_t *out)
Float to uint8_t conversion x3.
Definition: ble.c:419
MeasurementData_t::BLE_euler_angles
uint8_t BLE_euler_angles[sizeof(float) *3]
Definition: datatypes.h:41
MeasurementData_t::magScale
float magScale[3]
Definition: datatypes.h:48
_sleep
bool _sleep
Definition: main.c:128
M_PI
#define M_PI
Definition: ICM20948.c:41
dbprintln
void dbprintln(char *message)
MadgwickAHRSupdate
void MadgwickAHRSupdate(float gx, float gy, float gz, float ax, float ay, float az, float mx, float my, float mz)
Madgwick algorithm.
Definition: MadgwickAHRS.c:92
util.h
Handy functions.
BATT_READ
Definition: datatypes.h:26
debug_dbprint.h
Enable or disable printing to UART with dbprint.
BLE_disconnect
void BLE_disconnect()
Disconnect BLE from receiver.
Definition: ble.c:195
BLE_Init
void BLE_Init()
BLE chip init.
Definition: ble.c:61
ble.h
Send data via BLE wirelessly.
I2C.h
I2C function to read-write the I2C bus, based on DRAMCO code.