Embedded System Design 2 - Project
|
Utility functionality. More...
#include <stdint.h>
#include <stdbool.h>
#include "em_cmu.h"
#include "em_gpio.h"
#include "util.h"
#include "pin_mapping.h"
#include "debug_dbprint.h"
#include "delay.h"
Go to the source code of this file.
Functions | |
static void | initLED (void) |
Initialize the LED. More... | |
void | led (bool enabled) |
Enable or disable the LED. More... | |
void | error (uint8_t number) |
Error method. More... | |
Variables | |
uint8_t | errorNumber = 0 |
bool | LED_initialized = false |
Utility functionality.
GPIO_PinOutClear
line in initLED. main.c
to here, added delay functionality which goes into EM1 or EM2. Error()
to error()
, added a global variable to keep the error number and initialize the pin of the LED automatically. static
before the local variables (not necessary).GOTO
is supported in C but is dangerous to use (nested loops, ...)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 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.
Definition in file util.c.
void error | ( | uint8_t | number | ) |
Error method.
ERROR_FORWARDING == 0
The method flashes the LED, displays a UART message and holds the MCU forever in a loop until it gets reset. The error value gets stored in a global variable.
ERROR_FORWARDING == 1
The method sends the error value to the cloud using LoRaWAN if the error number doesn't correspond to LoRaWAN-related functionality (numbers 30 - 55).
[in] | number | The number to indicate where in the code the error was thrown. |
Definition at line 131 of file util.c.
|
static |
Initialize the LED.
Definition at line 194 of file util.c.
void led | ( | bool | enabled | ) |