Embedded System Design 2 - Project
main.c File Reference

The main file for Project 2 from Embedded System Design 2 - Lab. More...

#include <stdint.h>
#include <stdbool.h>
#include "em_device.h"
#include "em_chip.h"
#include "em_cmu.h"
#include "em_gpio.h"
#include "em_rtc.h"
#include "pin_mapping.h"
#include "debug_dbprint.h"
#include "delay.h"
#include "util.h"
#include "interrupt.h"
#include "ADXL362.h"
#include "DS18B20.h"
#include "adc.h"
#include "cable.h"
#include "lora_wrappers.h"
#include "datatypes.h"

Go to the source code of this file.

Macros

#define WAKE_UP_PERIOD_S   180
 
#define STORM_INTERRUPTS   8
 
#define ADXL_THRESHOLD   7
 
#define ADXL_RANGE   ADXL_RANGE_8G
 
#define ADXL_ODR   ADXL_ODR_12_5_HZ
 
#define LED_ENABLED   0
 

Functions

bool checkBTNinterrupts (void)
 Method to check if any interrupts are triggered by buttons. More...
 
int main (void)
 Main function. More...
 
void NMI_Handler (void)
 NMI interrupt service routine. More...
 
void HardFault_Handler (void)
 HardFault interrupt service routine. More...
 
void SVC_Handler (void)
 SVC interrupt service routine. More...
 
void PendSV_Handler (void)
 PendSV interrupt service routine. More...
 

Variables

static MCU_State_t MCUstate
 
MeasurementData_t data
 

Detailed Description

The main file for Project 2 from Embedded System Design 2 - Lab.

Version
5.2
Author
Brecht Van Eeckhoudt

Versions

Please check https://github.com/Fescron/Project-LabEmbeddedDesign2/tree/master/software to find the latest version!

  • v1.0: Started from https://github.com/Fescron/Project-LabEmbeddedDesign1 and added code for the DS18B20 temperature sensor and the selfmade link breakage sensor. Reformatted some of these imported methods.
  • v1.1: Removed unused files, add cable-checking method.
  • v1.2: Moved initRTCcomp method to "util.c".
  • v1.3: Stopped using deprecated function "GPIO_IntConfig".
  • v1.4: Started using get/set method for the static variable "ADXL_triggered".
  • v1.5: Reworked the code a lot (stopped disabling cmuClock_GPIO, ...).
  • v1.6: Moved all documentation above source files to this file.
  • v1.7: Updated documentation, started using a state-machine.
  • v1.8: Moved checkCable method to "other.c" and started using readVBAT method.
  • v1.9: Cleaned up documentation and TODO's.
  • v2.0: Updated code with new DEFINE checks.
  • v2.1: Updated code with new ADC functionality.
  • v2.2: Started using working temperature sensor code.
  • v2.3: Started using working cable checking code and added "SEND" mcu_state.
  • v2.4: Started using a struct to keep the measurements in, added line to disable the RN2483.
  • v2.5: Started using custom enum types for the accelerometer settings.
  • v2.6: Added ADXL testing functionality.
  • v2.7: Removed USTIMER logic from this file.
  • v2.8: Added functionality to detect a storm.
  • v2.9: Started adding LoRaWAN functionality, added more wake-up/sleep functionality.
  • v3.0: Started using updated LoRaWAN send methods.
  • v3.1: Added functionality to enable/disable the LED blinking when measuring/sending data.
  • v3.2: Fixed button wake-up when sleeping for WAKE_UP_PERIOD_S/2.
  • v3.3: Moved data.index reset to LoRaWAN sending functionality and updated documentation.
  • v3.4: Moved data.index reset back to main.c.
  • v3.5: Added functionality to go back to the remaining sleep time on an accelerometer wake-up.
  • v3.6: Updated code to handle underlying changes.
  • v4.0: Updated documentation and version number.
  • v4.1: Added definitions to easily change the accelerometer's configuration settings.
  • v5.0: Updated sleep logic when waking up using the accelerometer.
  • v5.1: Added extra ISR handlers.
  • v5.2: Removed static before a local variable (not necessary).

Todo:
Optimalisations:
  • Change LoRaWAN Spreading Factor and send power, and check the effect on the power usage.
  • Add some time to the while increment escape counters?
  • Check power usage effect of disabling PM_SENS_EXT.
  • Check difference between absolute/referenced mode for the accelerometer.
  • Change mode to release.
Todo:
Future improvements:
  • Use IAR toolchain instead of GCC, see section Optimizing code in documentation.h
  • Sleep for some time in while loops instead of just incrementing the escape-counter.
    • First separate ULFRCO definition in `delay.c
  • Try to shorten delays (for example: 40 ms power-up time for the RN2483...)
  • Fix sleepLoRaWAN and wakeLoRaWAN functionality (also see lora_wrappers.c).

License

Copyright (C) 2019 - Brecht Van Eeckhoudt

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

A copy of the GNU General Public License can be found in the LICENSE file along with this source code.


Some methods also use code obtained from examples from Silicon Labs' GitHub. These sections are licensed under the Silabs License Agreement. See the file "Silabs_License_Agreement.txt" for details. Before using this software for any purpose, you must agree to the terms of that agreement.


Attention
See the file documentation.h for a lot of useful documentation about this project!

Errors

If in this project something unexpected occurs, an error method gets called. What happens in this method can be selected in util.h with the definition ERROR_FORWARDING. If it's value is 0 the MCU displays (if dbprint is enabled) a UART message and gets put in a while(true) to flash the LED. If it's value is 1 then certain values (all values except 30 - 55 since these are errors in the LoRaWAN functionality itself) get forwarded to the cloud using LoRaWAN functionality and the MCU resumes it's code.

When calling an error method, the following things were kept in mind:

  • Values 0 - 9: Reserved for reset and other critical functionality.
    • 1: Send once after a reset (firstBoot == true in main.c)
    • 9: Used in sendTest(data); method (lora_wrappers.c)
  • Values 10 - ... : Available to use for anything else.

Below is a list of values which correspond to certain functionality:


LoRaWAN sensor channels

  • LPP_VBAT_CHANNEL 0x10 // 16
  • LPP_TEMPERATURE_CHANNEL_INT 0x11 // 17
  • LPP_TEMPERATURE_CHANNEL_EXT 0x12 // 18
  • LPP_STORM_CHANNEL 0x13 // 19
  • LPP_CABLE_BROKEN_CHANNEL 0x14 // 20
  • LPP_STATUS_CHANNEL 0x15 // 21

Definition in file main.c.

Macro Definition Documentation

◆ ADXL_ODR

#define ADXL_ODR   ADXL_ODR_12_5_HZ

The ODR setting to configure the accelerometer with

Definition at line 176 of file main.c.

◆ ADXL_RANGE

#define ADXL_RANGE   ADXL_RANGE_8G

The g range to configure the accelerometer with

Definition at line 173 of file main.c.

◆ ADXL_THRESHOLD

#define ADXL_THRESHOLD   7

The threshold value [g] for the accelerometer to detect and send an interrupt to wake-up the MCU

Definition at line 170 of file main.c.

◆ LED_ENABLED

#define LED_ENABLED   0

Public definition to select if the LED is turned on while measuring or sending data

  • 1 - Enable the LED when while measuring or sending data.
  • 0 - Don't enable the LED while measuring or sending data.

Definition at line 181 of file main.c.

◆ STORM_INTERRUPTS

#define STORM_INTERRUPTS   8

Amount of PIN interrupt wakeups (before a RTC wake-up) to be considered as a storm

Definition at line 167 of file main.c.

◆ WAKE_UP_PERIOD_S

#define WAKE_UP_PERIOD_S   180

Time between each wake-up in seconds

  • max 500 seconds when using LFXO delay
  • 3600 seconds (one hour) works fine when using ULFRCO delay

Definition at line 164 of file main.c.

Function Documentation

◆ checkBTNinterrupts()

bool checkBTNinterrupts ( void  )

Method to check if any interrupts are triggered by buttons.

Returns
  • true - A button interrupt was triggered.
  • false - No button interrupt was triggered.

Definition at line 200 of file main.c.

201 {
202  bool value = false;
203 
204  if (BTN_getTriggered(0))
205  {
206 
207 #if DEBUG_DBPRINT == 1 /* DEBUG_DBPRINT */
208  dbprintln_color("PB0 pushed!", 4);
209 #endif /* DEBUG_DBPRINT */
210 
211  value = true;
212 
213  BTN_setTriggered(0, false); /* Clear variable */
214  }
215 
216 
217  if (BTN_getTriggered(1))
218  {
219 
220 #if DEBUG_DBPRINT == 1 /* DEBUG_DBPRINT */
221  dbprintln_color("PB1 pushed!", 4);
222 #endif /* DEBUG_DBPRINT */
223 
224  value = true;
225 
226  BTN_setTriggered(1, false); /* Clear variable */
227  }
228 
229  return (value);
230 }
void BTN_setTriggered(uint8_t number, bool value)
Setter for the PB0_triggered and PB1_triggered variable.
Definition: interrupt.c:174
bool BTN_getTriggered(uint8_t number)
Getter for the PB0_triggered and PB1_triggered variables.
Definition: interrupt.c:145
void dbprintln_color(char *message, dbprint_color_t color)
Print a string (char array) to USARTx in a given color and go to the next line.
Definition: dbprint.c:480

◆ HardFault_Handler()

void HardFault_Handler ( void  )

HardFault interrupt service routine.

Note
The weak definition for this method is located in startup_gcc_efm32hg.h.

Definition at line 565 of file main.c.

566 {
567  while(1);
568 }

◆ main()

int main ( void  )

Main function.

Definition at line 237 of file main.c.

238 {
239  /* Keep a value if a storm has been detected */
240  bool stormDetected = false;
241 
242  /* Value used to send one test LoRaWAN message after booting */
243  bool firstBoot = true;
244 
245  /* Value to keep the remaining sleep time when waking up using the accelerometer */
246  uint32_t remainingSleeptime = 0;
247 
248  /* Set the index to put the measurements in */
249  data.index = 0;
250 
251  while (1)
252  {
253  switch (MCUstate)
254  {
255  case INIT:
256  {
257  CHIP_Init(); /* Initialize chip */
258 
259 #if DEBUG_DBPRINT == 1 /* DEBUG_DBPRINT */
260 #if CUSTOM_BOARD == 1 /* Custom Happy Gecko pinout */
261  dbprint_INIT(DBG_UART, DBG_UART_LOC, false, false);
262  dbwarn("CUSTOM board pinout selected");
263 #else /* Regular Happy Gecko pinout */
264  dbprint_INIT(USART1, 4, true, false); /* VCOM */
265  dbwarn("REGULAR board pinout selected");
266 #endif /* Board pinout selection */
267 #endif /* DEBUG_DBPRINT */
268 
269  led(true); /* Enable (and initialize) LED */
270 
271  delay(4000); /* 4 second delay to notice initialization */
272  led(false);
273  delay(100);
274  led(true);
275 
276  initGPIOwakeup(); /* Initialize GPIO wake-up */
277 
278  initADC(BATTERY_VOLTAGE); /* Initialize ADC to read battery voltage */
279 
280  /* Initialize pin and disable power to RN2483 */
281  GPIO_PinModeSet(PM_RN2483_PORT, PM_RN2483_PIN, gpioModePushPull, 0);
282 
283  /* Initialize pin and disable external sensor power on DRAMCO shield */
284  GPIO_PinModeSet(PM_SENS_EXT_PORT, PM_SENS_EXT_PIN, gpioModePushPull, 0); // TODO: check power usage effect?
285 
286  /* Initialize accelerometer */
287  if (true)
288  {
289  /* Go through all of the accelerometer ODR settings to see the influence they have on power usage. */
290  if (false)
291  {
292  initADXL(); /* Initialize the accelerometer */
293 
294  led(false);
295  testADXL();
296  led(true);
297  }
298 
299  initADXL(); /* Initialize the accelerometer */
300 
301  ADXL_configRange(ADXL_RANGE); /* Set the measurement range */
302 
303  ADXL_configODR(ADXL_ODR); /* Configure ODR */
304 
305  if (false) ADXL_readValues(); /* Read and display values forever */
306 
307  ADXL_configActivity(ADXL_THRESHOLD); /* Configure (referenced) activity threshold mode on INT1 [g] */
308 
309  ADXL_enableMeasure(true); /* Enable measurements */
310 
311  delay(300);
312 
313  ADXL_ackInterrupt(); /* ADXL gives interrupt, capture this and acknowledge it by reading from it's status register */
314 
315  ADXL_enableSPI(false); /* Disable SPI after the initializations */
316 
317  ADXL_clearCounter(); /* Clear the trigger counter */
318  }
319 
320 #if DEBUG_DBPRINT == 1 /* DEBUG_DBPRINT */
321  dbprintln("");
322 #endif /* DEBUG_DBPRINT */
323 
324  led(false); /* Disable LED */
325 
326  MCUstate = MEASURE;
327  } break;
328 
329  case MEASURE:
330  {
331 
332 #if LED_ENABLED == 1 /* LED_ENABLED */
333  led(true); /* Enable LED */
334 #endif /* LED_ENABLED */
335 
336  /* Measure and store the external temperature */
338 
339  /* Measure and store the battery voltage */
341 
342  /* Measure and store the internal temperature */
344 
345 #if DEBUG_DBPRINT == 1 /* DEBUG_DBPRINT */
346  dbinfoInt("Measurement ", data.index + 1, "");
347  dbinfoInt("Temperature: ", data.extTemp[data.index], "");
348  dbinfoInt("Battery voltage: ", data.voltage[data.index], "");
349  dbinfoInt("Internal temperature: ", data.intTemp[data.index], "");
350 #endif /* DEBUG_DBPRINT */
351 
352  /* Increase the index to put the next measurements in */
353  data.index++;
354 
355  /* Check if the cable is intact and send LoRaWAN data if necessary */
356  if (checkCable(data)) data.index = 0; /* If measurements have been send, reset the index */
357 
358  if (firstBoot && (data.index > 0))
359  {
360 
361 #if DEBUG_DBPRINT == 1 /* DEBUG_DBPRINT */
362  dbwarn("Sending first measurements ...");
363 #endif /* DEBUG_DBPRINT */
364 
365  initLoRaWAN(); /* Initialize LoRaWAN functionality */
366 
367  sendStatus(1); /* Send the status data */
368 
369  sendMeasurements(data); /* Send the measurements */
370 
371  disableLoRaWAN(); /* Disable RN2483 */
372 
373  data.index = 0; /* Reset the index to put the measurements in (needs to be here for the correct data to be affected) */
374 
375  firstBoot = false;
376  }
377 
378 #if LED_ENABLED == 1 /* LED_ENABLED */
379  led(false); /* Disable LED */
380 #endif /* LED_ENABLED */
381 
382  /* Decide if 6 measurements are taken or not and react accordingly */
383  if (data.index == 6) MCUstate = SEND;
384  else MCUstate = SLEEP;
385  } break;
386 
387  case SEND:
388  {
389 
390 #if LED_ENABLED == 1 /* LED_ENABLED */
391  led(true); /* Enable LED */
392 #endif /* LED_ENABLED */
393 
394 #if DEBUG_DBPRINT == 1 /* DEBUG_DBPRINT */
395  dbwarnInt("Sending ", data.index, " measurements ...");
396 #endif /* DEBUG_DBPRINT */
397 
398  initLoRaWAN(); /* Initialize LoRaWAN functionality */
399 
400  sendMeasurements(data); /* Send the measurements */
401 
402  disableLoRaWAN(); /* Disable RN2483 */
403 
404  data.index = 0; /* Reset the index to put the measurements in (needs to be here for the correct data to be affected) */
405 
406 #if LED_ENABLED == 1 /* LED_ENABLED */
407  led(false); /* Disable LED */
408 #endif /* LED_ENABLED */
409 
410  MCUstate = SLEEP;
411  } break;
412 
413  case SEND_STORM:
414  {
415 
416 #if LED_ENABLED == 1 /* LED_ENABLED */
417  led(true); /* Enable LED */
418 #endif /* LED_ENABLED */
419 
420 #if DEBUG_DBPRINT == 1 /* DEBUG_DBPRINT */
421  dbwarnInt("STORM DETECTED! Sending ", data.index, " measurement(s) ...");
422 #endif /* DEBUG_DBPRINT */
423 
424  initLoRaWAN(); /* Initialize LoRaWAN functionality */
425 
426  sendStormDetected(true); /* Send a message to indicate that a storm has been detected */
427 
428  if (data.index > 0)
429  {
430  sendMeasurements(data); /* Send the already gathered measurements */
431 
432  data.index = 0; /* Reset the index to put the measurements in (needs to be here for the correct data to be affected) */
433  }
434 
435  disableLoRaWAN(); /* Disable RN2483 */
436 
437  stormDetected = true; /* Indicate that a storm has been detected */
438 
439 #if LED_ENABLED == 1 /* LED_ENABLED */
440  led(false); /* Disable LED */
441 #endif /* LED_ENABLED */
442 
444  } break;
445 
446  case SLEEP:
447  {
448  sleep(WAKE_UP_PERIOD_S); /* Go to sleep for xx seconds */
449 
450  MCUstate = WAKEUP;
451  } break;
452 
453  case SLEEP_HALFTIME:
454  {
455  sleep(WAKE_UP_PERIOD_S/2); /* Go to sleep for xx seconds */
456 
457  MCUstate = WAKEUP;
458  } break;
459 
460  case WAKEUP:
461  {
462 
463 #if LED_ENABLED == 1 /* LED_ENABLED */
464  led(true); /* Enable LED */
465 #endif /* LED_ENABLED */
466 
467  /* Check if we woke up using buttons */
468  if (checkBTNinterrupts())
469  {
470  ADXL_clearCounter(); /* Clear the trigger counter */
471  remainingSleeptime = 0; /* Reset passed sleeping time */
472 
473  MCUstate = MEASURE; /* Take measurements on "case WAKEUP" exit */
474  }
475 
476  /* Check if we woke up using the RTC sleep functionality and act accordingly */
477  if (RTC_checkWakeup())
478  {
479  RTC_clearWakeup(); /* Clear variable */
480 
481  ADXL_clearCounter(); /* Clear the trigger counter because we woke up "normally" */
482  remainingSleeptime = 0; /* Reset passed sleeping time since it's an RTC wakeup */
483 
484  MCUstate = MEASURE; /* Take measurements on "case WAKEUP" exit */
485  }
486 
487  /* Check if we woke up using the accelerometer */
488  if (ADXL_getTriggered())
489  {
490  /* Check if we detected a storm */
492  {
493  RTC_Enable(false); /* Disable the counter */
494 
495  MCUstate = SEND_STORM; /* Storm detected, send a message on "case WAKEUP" exit */
496  }
497  else
498  {
499 
500 #if DEBUG_DBPRINT == 1 /* DEBUG_DBPRINT */
501  dbprintln_color("INT-PD7 triggered!", 4);
502 #endif /* DEBUG_DBPRINT */
503 
504  ADXL_enableSPI(true); /* Enable SPI functionality */
505  ADXL_ackInterrupt(); /* Acknowledge ADXL interrupt by reading the status register */
506  ADXL_enableSPI(false); /* Disable SPI functionality */
507 
508  /* Check if a storm was detected before going to sleep for WAKE_UP_PERIOD_S/2 */
509  if (stormDetected)
510  {
511  stormDetected = false; /* Reset variable */
512  MCUstate = MEASURE; /* Take measurements on "case WAKEUP" exit */
513  }
514  else
515  {
516  remainingSleeptime += RTC_getPassedSleeptime(); /* Add the time spend sleeping to the variable */
517 
518 #if LED_ENABLED == 1 /* LED_ENABLED */
519  led(false); /* Disable LED */
520 #endif /* LED_ENABLED */
521 
522  /* Go back to sleep for the remaining time until another measurement (we only take measurements on RTC/button wake-up) */
523  sleep(WAKE_UP_PERIOD_S - remainingSleeptime);
524 
525  MCUstate = WAKEUP; /* Go back to this case if we wake-up */
526  }
527  }
528  }
529 
530 #if LED_ENABLED == 1 /* LED_ENABLED */
531  led(false); /* Disable LED */
532 #endif /* LED_ENABLED */
533 
534  } break;
535 
536  default:
537  {
538  error(10);
539  } break;
540  }
541  }
542 }
bool checkBTNinterrupts(void)
Method to check if any interrupts are triggered by buttons.
Definition: main.c:200
Definition: datatypes.h:60
void initADC(ADC_Measurement_t peripheral)
Method to initialize the ADC to later check the battery voltage or internal temperature.
Definition: adc.c:86
#define DBG_UART
Definition: pin_mapping.h:95
void dbprintln(char *message)
Print a string (char array) to USARTx and go to the next line.
Definition: dbprint.c:395
void dbinfoInt(char *message1, int32_t value, char *message2)
Print an info value surrounded by two strings (char array) to USARTx.
Definition: dbprint.c:567
bool checkCable(MeasurementData_t data)
Method to check if the wire is broken.
Definition: cable.c:92
void ADXL_readValues(void)
Read and display "g" values forever with a 100ms interval.
Definition: ADXL362.c:515
bool ADXL_getTriggered(void)
Getter for the ADXL_triggered variable.
Definition: ADXL362.c:216
void ADXL_configODR(ADXL_ODR_t givenODR)
Configure the Output Data Rate (ODR).
Definition: ADXL362.c:411
MeasurementData_t data
Definition: main.c:189
#define DBG_UART_LOC
Definition: pin_mapping.h:96
void dbwarn(char *message)
Print a warning string (char array) in yellow to USARTx and go to the next line.
Definition: dbprint.c:521
void ADXL_clearCounter(void)
Method to set the ADXL_triggercounter variable back to zero.
Definition: ADXL362.c:188
#define PM_RN2483_PIN
Definition: pin_mapping.h:134
#define PM_SENS_EXT_PIN
Definition: pin_mapping.h:136
void dbwarnInt(char *message1, int32_t value, char *message2)
Print a warning value surrounded by two strings (char array) to USARTx.
Definition: dbprint.c:598
void sendStormDetected(bool stormDetected)
Send a packet to the cloud using LoRaWAN to indicate that a storm has been detected.
uint16_t ADXL_getCounter(void)
Getter for the ADXL_triggercounter variable.
Definition: ADXL362.c:178
void ADXL_enableMeasure(bool enabled)
Enable or disable measurement mode.
Definition: ADXL362.c:310
void testADXL(void)
This method goes through all of the ODR settings to see the influence they have on power usage...
Definition: ADXL362.c:571
void initADXL(void)
Initialize the accelerometer.
Definition: ADXL362.c:132
int32_t intTemp[6]
Definition: datatypes.h:73
void ADXL_enableSPI(bool enabled)
Enable or disable the SPI pins and USART0/1 clock and peripheral to the accelerometer.
Definition: ADXL362.c:245
#define PM_RN2483_PORT
Definition: pin_mapping.h:133
void error(uint8_t number)
Error method.
Definition: util.c:131
void sendMeasurements(MeasurementData_t data)
Send measured battery voltages and internal and external temperatures to the cloud using LoRaWAN...
void ADXL_ackInterrupt(void)
Acknowledge the interrupt from the accelerometer.
Definition: ADXL362.c:230
uint32_t RTC_getPassedSleeptime(void)
Method to get the time spend sleeping (in seconds) in the case of GPIO wake-up.
Definition: delay.c:428
#define ADXL_ODR
Definition: main.c:176
void disableLoRaWAN(void)
Disable LoRaWAN functionality.
void initGPIOwakeup(void)
Initialize GPIO wake-up functionality.
Definition: interrupt.c:91
#define ADXL_RANGE
Definition: main.c:173
void initLoRaWAN(void)
Initialize LoRaWAN functionality.
Definition: lora_wrappers.c:92
void dbprint_INIT(USART_TypeDef *pointer, uint8_t location, bool vcom, bool interrupts)
Initialize USARTx.
Definition: dbprint.c:148
void sendStatus(uint8_t status)
Send a packet to indicate a status.
void RTC_clearWakeup(void)
Method to clear RTC_sleep_wakeup.
Definition: delay.c:414
int32_t extTemp[6]
Definition: datatypes.h:74
void delay(uint32_t msDelay)
Wait for a certain amount of milliseconds in EM2/3.
Definition: delay.c:124
void ADXL_configRange(ADXL_Range_t givenRange)
Configure the measurement range and store the selected one in a global variable for later (internal) ...
Definition: ADXL362.c:358
void ADXL_configActivity(uint8_t gThreshold)
Configure the accelerometer to work in (referenced) activity threshold mode.
Definition: ADXL362.c:468
#define WAKE_UP_PERIOD_S
Definition: main.c:164
static MCU_State_t MCUstate
Definition: main.c:186
#define STORM_INTERRUPTS
Definition: main.c:167
#define PM_SENS_EXT_PORT
Definition: pin_mapping.h:135
#define ADXL_THRESHOLD
Definition: main.c:170
int32_t readADC(ADC_Measurement_t peripheral)
Method to read the battery voltage or internal temperature.
Definition: adc.c:164
Definition: datatypes.h:58
int32_t voltage[6]
Definition: datatypes.h:72
bool RTC_checkWakeup(void)
Method to check if the wakeup was caused by the RTC.
Definition: delay.c:404
void dbprintln_color(char *message, dbprint_color_t color)
Print a string (char array) to USARTx in a given color and go to the next line.
Definition: dbprint.c:480
void sleep(uint32_t sSleep)
Sleep for a certain amount of seconds in EM2/3.
Definition: delay.c:276
void led(bool enabled)
Enable or disable the LED.
Definition: util.c:103
int32_t readTempDS18B20(void)
Get a temperature value from the DS18B20.
Definition: DS18B20.c:113

◆ NMI_Handler()

void NMI_Handler ( void  )

NMI interrupt service routine.

Note
The weak definition for this method is located in startup_gcc_efm32hg.h.

Definition at line 552 of file main.c.

553 {
554  while(1);
555 }

◆ PendSV_Handler()

void PendSV_Handler ( void  )

PendSV interrupt service routine.

Note
The weak definition for this method is located in startup_gcc_efm32hg.h.

Definition at line 591 of file main.c.

592 {
593  while(1);
594 }

◆ SVC_Handler()

void SVC_Handler ( void  )

SVC interrupt service routine.

Note
The weak definition for this method is located in startup_gcc_efm32hg.h.

Definition at line 578 of file main.c.

579 {
580  while(1);
581 }

Variable Documentation

◆ data

Keep the measurement data

Definition at line 189 of file main.c.

◆ MCUstate

MCU_State_t MCUstate
static

Keep the state of the state machine

Definition at line 186 of file main.c.