45 #include "em_device.h" 68 #define SEND_STATUS_BOOT 1 71 #define SENDING_DATA 1 74 #define MAX_LENGTH_MM 300 79 #define WAKE_UP_PERIOD_S 3600 122 if (data.
t1 > 9999) temp1 /= 10;
124 uint8_t temp1R = temp1 - ((temp1 / 100) * 100);
125 char temp1L_char[10];
126 char temp1R_char[10];
136 if (data.
t2 > 9999) temp2 /= 10;
138 uint8_t temp2R = temp2 - ((temp2 / 100) * 100);
139 char temp2L_char[10];
140 char temp2R_char[10];
164 char carbon_char[10];
207 #if DEBUG_DBPRINT == 1 233 #if SENDING_DATA == 1 237 #if SEND_STATUS_BOOT == 1 239 #if DEBUG_DBPRINT == 1 240 dbwarn(
"Sending startup status ...");
246 #if SENDING_DATA == 1 263 if (temp < 0) data.
t1 = 0;
267 if (temp < 0) data.
t2 = 0;
275 #if DEBUG_DBPRINT == 1 276 dbinfoInt(
"distance = ", distance,
" mm");
288 #if DEBUG_DBPRINT == 1 306 #if DEBUG_DBPRINT == 1 307 dbwarn(
"Sending measurements ...");
314 #if SENDING_DATA == 1 324 #if DEBUG_DBPRINT == 1 325 dbwarn(
"Sending STATUS ...");
351 #if DEBUG_DBPRINT == 1 356 remainingSleeptime = 0;
364 #if DEBUG_DBPRINT == 1 369 remainingSleeptime = 0;
377 #if DEBUG_DBPRINT == 1 389 #if DEBUG_DBPRINT == 1 390 dbwarn(
"Sending P1 pulses ...");
393 #if SENDING_DATA == 1 402 #if DEBUG_DBPRINT == 1 403 dbwarn(
"Sending P2 pulses ...");
406 #if SENDING_DATA == 1 bool checkBTNinterrupts(void)
Method to check if any interrupts are triggered by buttons.
void initADC(ADC_Measurement_t peripheral)
Method to initialize the ADC to later check the battery voltage or internal temperature.
void sendStatus(int8_t status)
Send status to the cloud using NB-IoT.
void dbprintln(char *message)
Print a string (char array) to USARTx and go to the next line.
void dbinfoInt(char *message1, int32_t value, char *message2)
Print an info value surrounded by two strings (char array) to USARTx.
int8_t initVL53L1X(void)
Initialize the sensor.
void SVC_Handler(void)
SVC interrupt service routine.
int8_t clearLCD(void)
Clear the LCD.
Definitions of the custom data-types used.
void dbwarn(char *message)
Print a warning string (char array) in yellow to USARTx and go to the next line.
String (char array) conversion functionality.
void initBG96(void)
Initialize the GPIO pins and UART0 module necessary to communicate with the BG96 module.
void sendMeasurements(MeasurementData_t *data)
Send measurements to the cloud using NB-IoT.
ADC functionality for reading the (battery) voltage and internal temperature.
uint16_t measureVL53L1X(void)
Get a sensor reading.
Code for the VL53L1X sensor.
void PendSV_Handler(void)
PendSV interrupt service routine.
int8_t writeStringLCD(char *message)
Print a string (char array) to the LCD.
void error(uint8_t number)
Error method.
static void uint32_to_charDec(char *buf, uint32_t value)
Convert a uint32_t value to a decimal char array (string).
uint32_t RTC_getPassedSleeptime(void)
Method to get the time spend sleeping (in seconds) in the case of GPIO wake-up.
int int32_t
Typedef defining 32 bit int type. The developer should modify this to suit the platform being deploye...
void initGPIOwakeup(void)
Initialize GPIO wake-up functionality.
The pin definitions for the custom board.
void PULSE_setTriggered(uint8_t number, bool value)
Setter for the PULSE0/1_triggered variable.
void dbprint_INIT(USART_TypeDef *pointer, uint8_t location, bool vcom, bool interrupts)
Initialize USARTx.
void RTC_clearWakeup(void)
Method to clear RTC_sleep_wakeup.
bool PULSE_getTriggered(uint8_t number)
Getter for the PULSE0/1_triggered variable.
bool BTN_getTriggered(void)
Getter for the BTN_triggered variable.
Enable or disable printing to UART with dbprint.
void delay(uint32_t msDelay)
Wait for a certain amount of milliseconds in EM2/3.
void displayMeas(void)
Method to display the latest measurements on the LCD.
int8_t setCursorLCD(uint8_t col, uint8_t row)
Set the cursor to a specific location on the LCD.
BG96 AT-command driver functionality.
void sendPulse(uint8_t number, uint8_t pulse)
Send current pulses to the cloud using NB-IoT.
static MCU_State_t MCUstate
enum mcu_states MCU_State_t
int32_t readADC(ADC_Measurement_t peripheral)
Method to read the battery voltage or internal temperature.
void HardFault_Handler(void)
HardFault interrupt service routine.
void BTN_setTriggered(bool value)
Setter for the BTN_triggered variable.
void NMI_Handler(void)
NMI interrupt service routine.
bool RTC_checkWakeup(void)
Method to check if the wakeup was caused by the RTC.
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.
void sleep(uint32_t sSleep)
Sleep for a certain amount of seconds in EM2/3.
int32_t readTempDS18B20(uint8_t number)
Get a temperature value from the DS18B20.
int main(void)
Main function.
unsigned short uint16_t
Typedef defining 16 bit unsigned short type. The developer should modify this to suit the platform be...
unsigned char uint8_t
Typedef defining 8 bit unsigned char type. The developer should modify this to suit the platform bein...
unsigned int uint32_t
Typedef defining 32 bit unsigned int type. The developer should modify this to suit the platform bein...
All code for the DS18B20 temperature sensor.