EXTI (JSAPI_EXTI)

The external interrupts and events controller (EXTI) manages internal and external events and interrupts, and acts as an interface between the CPU and the NVIC (Nested Vectored Interrupt Controller) unit in the MCU. The JSAPI_EXTI class lets you use EXTI to manage input triggers on a GPIO input pin.

Object

extern JSAPI_EXTI

exti0, exti1, exti2, exti3, exti4,  exti5, exti6, exti7, exti8, exti9, exti10, exti11, exti12, exti13, exti14, exti15;

Enum

enum EDGE_TRIGGER {

    RISING_EDGE = 1,

    FALLING_EDGE,   

    BOTH_EDGES     

};

 

enum PUPDR {

    PUPDR_NONE = 0,    

    PUPDR_UP,          

    PUPDR_DOWN

};        

Make an EXTI object

bool MakeEXTI(

    JSAPI_GPIO *port,

    enum PUPDR pupdr,

    enum EDGE_TRIGGER edge,

    int priority,

    void (*isr)(void)

);

Debounce the port

void Debounce(void);

Enable the EXTI interrupt

void Enable(void);

Disable the EXTI interrupt

void Disable(void);

 

The GPIO port pins are multiplexed into EXTI input lines. For example, EXTI2 is the multiplexed input of pin number 2 of all the GPIO ports. Typically, you will only enable one pin from a single port as the trigger input.

How to Use

To use the JumpStart EXTI API, with a JSAPI_EXTI object (e.g. exti1):

1.       Write an interrupt handler to perform whatever actions need to be performed.

2.       Call MakeEXTI to initialize the EXTI object, with the interrupt handler as one of the arguments.

Note that you do not need to call MakeInput on the GPIO pin, as the MakeEXTI function does that as part of its operation.

Example

This example detects when the blue button on the ST-Nucleo has been pressed.

    printf("EXTI button test. Click the blue button to see an 'x'”

            “appearing on the terminal.\n");

 

    exti13.MakeEXTI(&portc, PUPDR_UP, FALLING_EDGE, 0, SWx_closed);