Master Thesis  V1.0
Research and Design of Sensor Node for NMSD Treatment
interrupt.c
Go to the documentation of this file.
1 /*
2  * interrupt.c
3  *
4  * Created on: Nov 13, 2019
5  * Author: jonac
6  */
7 
8 
9 /***************************************************************************/
16 #include "interrupt.h"
17 #include "pinout.h"
18 #include "debug_dbprint.h"
19 #include "delay.h"
20 //#include "ICM20948.h"
21 
22 #include "em_usart.h"
23 
24 #include "em_device.h"
25 #include "em_chip.h"
26 #include "em_cmu.h"
27 #include "em_emu.h"
28 #include "em_gpio.h"
29 #include "bsp.h"
30 
31 #include <stdint.h>
32 
33 
34 
35 
36 /**************************************************************************/
43 {
44  // Configure GPIO pins
45  CMU_ClockEnable(cmuClock_GPIO, true);
46 
47  // Configure PB0 and PB1 as input with glitch filter enabled
48  GPIO_PinModeSet(ICM_20948_INTERRUPT_PORT, ICM_20948_INTERRUPT_PIN, gpioModeInputPullFilter, 0);
49 
50 
51  /* Clear all odd pin interrupt flags (just in case)
52  * NVIC_ClearPendingIRQ(GPIO_ODD_IRQn); would also work but is less "readable" */
53  GPIO_IntClear(0xAAAA);
54 
55  /* Clear all even pin interrupt flags (just in case)
56  * NVIC_ClearPendingIRQ(GPIO_EVEN_IRQn); would also work but is less "readable" */
57  GPIO_IntClear(0x5555);
58 
59  // Enable IRQ for even numbered GPIO pins
60  NVIC_EnableIRQ(GPIO_EVEN_IRQn);
61 
62  // Enable IRQ for odd numbered GPIO pins
63  NVIC_EnableIRQ(GPIO_ODD_IRQn);
64 
65  /* Enable rising-edge interrupts for ICM_20948 */
66  GPIO_ExtIntConfig(ICM_20948_INTERRUPT_PORT, ICM_20948_INTERRUPT_PIN, ICM_20948_INTERRUPT_PIN, true, false, true);
67 }
68 
69 
70 
interrupt.h
Code to detect and generate interrupts.
delay.h
Delay functionality.
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.
ICM_20948_INTERRUPT_PIN
#define ICM_20948_INTERRUPT_PIN
Definition: pinout.h:40
debug_dbprint.h
Enable or disable printing to UART with dbprint.
ICM_20948_INTERRUPT_PORT
#define ICM_20948_INTERRUPT_PORT
Definition: pinout.h:41