IoT-MBBR (masterthesis)
Masterthesis upgrading a Moving Bed BioReactor with extra sensors and cloud connectivity.
interrupt.h File Reference

Interrupt functionality. More...

#include <stdint.h>
#include <stdbool.h>

Go to the source code of this file.

Functions

void initGPIOwakeup (void)
 Initialize GPIO wake-up functionality. More...
 
bool BTN_getTriggered (void)
 Getter for the BTN_triggered variable. More...
 
void BTN_setTriggered (bool value)
 Setter for the BTN_triggered variable. More...
 
bool PULSE_getTriggered (uint8_t number)
 Getter for the PULSE0/1_triggered variable. More...
 
void PULSE_setTriggered (uint8_t number, bool value)
 Setter for the PULSE0/1_triggered variable. More...
 

Detailed Description

Interrupt functionality.

Version
4.0
Author
Brecht Van Eeckhoudt

License

Copyright (C) 2020 - 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 interrupt.h.

Function Documentation

◆ BTN_getTriggered()

bool BTN_getTriggered ( void  )

Getter for the BTN_triggered variable.

Returns
The value of BTN_triggered.

Definition at line 137 of file interrupt.c.

138 {
139  return (BTN_triggered);
140 }
volatile bool BTN_triggered
Definition: interrupt.c:79

◆ BTN_setTriggered()

void BTN_setTriggered ( bool  value)

Setter for the BTN_triggered variable.

Parameters
[in]valueThe boolean value to set to the selected variable.

Definition at line 150 of file interrupt.c.

151 {
152  BTN_triggered = value;
153 }
volatile bool BTN_triggered
Definition: interrupt.c:79

◆ initGPIOwakeup()

void initGPIOwakeup ( void  )

Initialize GPIO wake-up functionality.

Initialize falling-edge interrupts.

Definition at line 91 of file interrupt.c.

92 {
93  /* Enable necessary clocks (just in case) */
94  CMU_ClockEnable(cmuClock_HFPER, true); /* GPIO is a High Frequency Peripheral */
95  CMU_ClockEnable(cmuClock_GPIO, true);
96 
97  /* Configure inputs (external pull-up-resistors), the last argument enables the filter */
98  GPIO_PinModeSet(BTN_PORT, BTN_PIN, gpioModeInput, 1);
99  GPIO_PinModeSet(PULSE0_PORT, PULSE0_PIN, gpioModeInput, 1);
100  GPIO_PinModeSet(PULSE1_PORT, PULSE1_PIN, gpioModeInput, 1);
101 
102  /* Clear all odd pin interrupt flags (just in case)
103  * NVIC_ClearPendingIRQ(GPIO_ODD_IRQn); would also work but is less "readable" */
104  GPIO_IntClear(0xAAAA);
105 
106  /* Clear all even pin interrupt flags (just in case)
107  * NVIC_ClearPendingIRQ(GPIO_EVEN_IRQn); would also work but is less "readable" */
108  GPIO_IntClear(0x5555);
109 
110  /* All pending interrupts can be cleared with GPIO_IntClear(0xFFFF); */
111 
112  /* Enable IRQ for even numbered GPIO pins */
113  NVIC_EnableIRQ(GPIO_EVEN_IRQn);
114 
115  /* Enable IRQ for odd numbered GPIO pins */
116  NVIC_EnableIRQ(GPIO_ODD_IRQn);
117 
118  /* Enable falling-edge interrupts */
119  GPIO_ExtIntConfig(BTN_PORT, BTN_PIN, BTN_PIN, false, true, true);
120  GPIO_ExtIntConfig(PULSE0_PORT, PULSE0_PIN, PULSE0_PIN, false, true, true);
121  GPIO_ExtIntConfig(PULSE1_PORT, PULSE1_PIN, PULSE1_PIN, false, true, true);
122 
123 #if DEBUG_DBPRINT == 1 /* DEBUG_DBPRINT */
124  dbinfo("GPIO wake-up initialized");
125 #endif /* DEBUG_DBPRINT */
126 
127 }
#define BTN_PIN
Definition: pin_mapping.h:62
#define PULSE1_PIN
Definition: pin_mapping.h:112
void dbinfo(char *message)
Print an info string (char array) to USARTx and go to the next line.
Definition: dbprint.c:505
#define PULSE0_PORT
Definition: pin_mapping.h:109
#define PULSE1_PORT
Definition: pin_mapping.h:111
#define BTN_PORT
Definition: pin_mapping.h:61
#define PULSE0_PIN
Definition: pin_mapping.h:110

◆ PULSE_getTriggered()

bool PULSE_getTriggered ( uint8_t  number)

Getter for the PULSE0/1_triggered variable.

Parameters
[in]number
  • 0 - PULSE0 selected.
  • 1 - PULSE1 selected.
Returns
The value of PULSE0/1_triggered.

Definition at line 167 of file interrupt.c.

168 {
169  if (number == 0) return (PULSE0_triggered);
170  else if (number == 1) return (PULSE1_triggered);
171 
172  return (false);
173 }
volatile bool PULSE0_triggered
Definition: interrupt.c:80
volatile bool PULSE1_triggered
Definition: interrupt.c:81

◆ PULSE_setTriggered()

void PULSE_setTriggered ( uint8_t  number,
bool  value 
)

Setter for the PULSE0/1_triggered variable.

Parameters
[in]number
  • 0 - PULSE0 selected.
  • 1 - PULSE1 selected.
[in]valueThe boolean value to set to the selected variable.

Definition at line 187 of file interrupt.c.

188 {
189  if (number == 0) PULSE0_triggered = value;
190  else if (number == 1) PULSE1_triggered = value;
191 }
volatile bool PULSE0_triggered
Definition: interrupt.c:80
volatile bool PULSE1_triggered
Definition: interrupt.c:81