Interrupt Drivers

An interrupt driver, found in source files mcu_irq.c/.h is provided for each of the supported microcontrollers within the Embedded SDK. The driver provides methods for managing and receiving interrupt requests from the MCU.

The available interrupt sources are provided by the 'IRQ' enumeration defined within mcu_irq.h. The driver maintains an array of handler functions for each of the possible interrupt sources. Thus, interrupt handler functions must be registered with driver, using IRQ_RegisterHandler() function, prior to enabling them.

Basic Usage

The code snippet below illustrates how to provide a handler function for an interrupt (e.g. DMA interrupt).
#include "mcu_irq.h"
#include <assert.h>

static void APP_IrqHandler(void);                   /* Local interrupt handler */

void APP_Example(void)
{
    STATUS status;


    status = IRQ_RegisterHandler(IRQ_DMA,           /* Register a function to handle the DMA interrupt */
                                 APP_IrqHandler);   /* Function to handle the interrupt request */
    assert(status == SUCCESS);


    status = IRQ_Enable(IRQ_DMA);                   /* Enable the interrupt */
    assert(status == SUCCESS);
}

static void APP_IrqHandler(void)
{
    /* Process and clear the interrupt */
}

Interrupt API

STATUS IRQ_RegisterHandler(IRQ irq, IRQHANDLER handler)
Registers an application-defined handler for an interrupt request.
PARAMETERS
irq The target interrupt request to be handled.
handler An application-defined function to be called to handle the request.
RETURNS
SUCCESS The handler was registered.
STATUS IRQ_Enable(IRQ irq)
Enables an interrupt.
PARAMETERS
irq The interrupt to be enabled.
RETURNS
SUCCESS The interrupt has been enabled.
STATUS IRQ_Disable(IRQ irq)
Disables an interrupt.
PARAMETERS
irq The interrupt to be disabled.
RETURNS
SUCCESS The interrupt has been disabled.
BOOLEAN IRQ_IsEnabled(IRQ irq)
Returns an indication of whether an interrupt is currently enabled.
PARAMETERS
irq The interrupt to be checked if enabled.
RETURNS
TRUE if the specified interrupt is enabled; otherwise FALSE.
BYTE IRQ_Priority(IRQ irq)
Returns the priority for an interrupt.
PARAMETERS
irq The target interrupt.
RETURNS
The current priority for the given interrupt.
STATUS IRQ_SetPriority(IRQ irq, BYTE priority)
Sets a new priority for an interrupt.
PARAMETERS
irq The interrupt to receive the new priority value.
priority The new priority for the interrupt. Value range depends upon MCU, and for ARM, a lower value indicates a higher priority.
RETURNS
SUCCESS The new priority has been assigned.