FEEU Ultra-Low-Power Apollo Evaluation Kit Platform
Chapter 2 Using the Hardware
© Fujitsu Electronics Europe GmbH
- 17 -
EEU-UG-2017120001-10
2.5.2 Drive buttons via IRQ
Start with the FEEU MCU Temlate for Apollo 1 or Apollo 2. Enable GPIO FEEU Low-Level-
Driver for Apollo in
RTE_Device.h
(in
example\source\config
):
Add
apollogpio.c
to your project and include
apollogpio.h
in you C-file. Following code gives
an example how to use GPIOs with callbacks:
#define APOLLOGPIO ENABLED 1
#include "mcu.h"
#include "apollogpio.h"
static volatile boolean_t bSw1CallbackHappened = FALSE;
void Sw1_Callback(uint8_t u8Gpio)
{
bSw1CallbackHappened = TRUE;
}
int main(void)
{
ApolloGpio_RegisterIrq(PIN_GPIO28,
GpioFallingEdge,
Sw1_Callback); //set GPIO28 to IRQ usage
NVIC_ClearPendingIRQ(GPIO_IRQn); //clear pending flag
NVIC_EnableIRQ(GPIO_IRQn); //enable IRQ
NVIC_SetPriority(GPIO_IRQn,1); //set priority of IRQ
//smaller value means
//higher priority
while(1)
{
if (bSw1CallbackHappened) //button SW1 is pressed
{
bSw1CallbackHappened = FALSE;
//do the script executing code
}
}
}