GPIOINT - GPIO Interrupt

Description

GPIOINT General Purpose Input/Output Interrupt dispatcher.

The source files for the GPIO interrupt dispatcher library resides in the emdrv/gpiointerrupt folder, and are named gpiointerrupt.c and gpiointerrupt.h.


Introduction

EFM32/EZR32/EFR32 has two GPIO interrupts lines, Odd and Even. If more than two interrupts are used then interrupt routine must dispatch from a callback register. This module provides small dispatcher for both GPIO interrupts enabling handling of up to 32 GPIO pin interrupts.

It is up to the user to configure and enable interrupt on given pin. This can be done using the GPIO library (emlib). This module handles the dispatch register and clearing of interrupt flags.

In order to use this dispatcher, it has to be initialized first by calling GPIOINT_Init() . Then each pin interrupt number must be configured by first registering the callback function for given interrupt number and then configure and enabling the interrupt number in the GPIO module.


The API

This section contain brief descriptions of the functions in the API. You will find detailed information on parameters by clicking on the hyperlinked function names.

Your application code must include one header file: gpiointerrupt.h .

GPIOINT_Init()
This functions initializes the dispatcher register. Typically GPIOINT_Init() is called once in your startup code.

GPIOINT_CallbackRegister()
Register a callback function on a pin interrupt number.

GPIOINT_CallbackUnRegister()
Un-register a callback function on a pin interrupt number.


Example

#include "em_gpio.h"
#include "em_int.h"
#include "gpiointerrupt.h"
int main( void )
{
CHIP_Init();
// Enable clock for GPIO module, initialize GPIOINT
CMU_ClockEnable(cmuClock_GPIO, true );
// Register callback functions and enable interrupts
GPIOINT_CallbackRegister (1, gpioCallback1);
GPIOINT_CallbackRegister (3, gpioCallback3);
GPIOINT_CallbackRegister (8, gpioCallback8);
GPIO_IntEnable(1<<1 | 1<<3 | 1<<8);
while ( true );
}

Functions

void GPIOINT_Init (void)
Initialization of GPIOINT module.
void GPIOINT_CallbackRegister (uint8_t intNo, GPIOINT_IrqCallbackPtr_t callbackPtr)
Registers user callback for given pin interrupt number.
void GPIOINT_CallbackUnRegister (uint8_t intNo)
Unregister user callback for a given pin interrupt number.

Typedefs

typedef void(* GPIOINT_IrqCallbackPtr_t ) (uint8_t intNo)
GPIO interrupt callback function pointer.

Function Documentation

GPIOINT_Init()

void GPIOINT_Init ( void )

Initialization of GPIOINT module.

GPIOINT_CallbackRegister()

void GPIOINT_CallbackRegister ( uint8_t intNo,
GPIOINT_IrqCallbackPtr_t callbackPtr
)

Registers user callback for given pin interrupt number.

Use this function to register a callback which shall be called upon interrupt generated for a given pin interrupt number. Interrupt itself must be configured externally. Function overwrites previously registered callback.

Parameters
[in] intNo Pin interrupt number for the callback.
[in] callbackPtr A pointer to callback function.

GPIOINT_CallbackUnRegister()

void GPIOINT_CallbackUnRegister ( uint8_t intNo )
inline

Unregister user callback for a given pin interrupt number.

Use this function to unregister a callback.

Parameters
[in] intNo Pin interrupt number for the callback.

Typedef Documentation

GPIOINT_IrqCallbackPtr_t

typedef void(* GPIOINT_IrqCallbackPtr_t) (uint8_t intNo)

GPIO interrupt callback function pointer.

Parameters:

  • intNo - The pin interrupt number the callback function is invoked for.