Skyward boardcore
Loading...
Searching...
No Matches
external_interrupts.cpp File Reference
#include "external_interrupts.h"
#include <miosix.h>
#include "kernel/logging.h"
Include dependency graph for external_interrupts.cpp:

Go to the source code of this file.

Functions

void unexpectedInterrupt ()
 
void Default_EXTI_Handler ()
 
void __attribute__ ((weak)) EXTI0_IRQHandlerImpl()
 
void __attribute__ ((naked)) EXTI0_IRQHandler()
 
void __attribute__ ((used)) EXTI9_5_IRQHandlerImpl()
 
constexpr unsigned ConvertGPIO_BASEtoUnsigned (unsigned P)
 
constexpr unsigned GetEXTI_IRQn (unsigned N)
 
constexpr unsigned GetEXTICR_register_value (unsigned P, unsigned N)
 
constexpr unsigned GetEXTICR_register_mask (unsigned P, unsigned N)
 
void enableExternalInterrupt (unsigned int gpioPort, unsigned int gpioNum, InterruptTrigger trigger, unsigned int priority)
 Enables external interrupts on the provided pin. Remember to set the GPIO to input mode!
 
void disableExternalInterrupt (unsigned int gpioPort, unsigned int gpioNum)
 Disables external interrupts on the provided pin.
 
void changeInterruptTrigger (unsigned int gpioPort, unsigned int gpioNum, InterruptTrigger trigger)
 Changes interrupt trigger on an enabled interrupt.
 

Function Documentation

◆ __attribute__() [1/3]

void __attribute__ ( (naked) )

Implementation of the IRQHandler that is triggered when external interrupt 0 is raised.

Implementation of the IRQHandler that is triggered when external interrupt 1 is raised.

Implementation of the IRQHandler that is triggered when external interrupt 2 is raised.

Implementation of the IRQHandler that is triggered when external interrupt 3 is raised.

Implementation of the IRQHandler that is triggered when external interrupt 4 is raised.

Implementation of the IRQHandler that is triggered when any external interrupt between 5 and 9 is raised.

Implementation of the IRQHandler that is triggered when any external interrupt between 10 and 15 is raised.

Definition at line 162 of file external_interrupts.cpp.

◆ __attribute__() [2/3]

void __attribute__ ( (used) )

Read from the PR register which interrupt is pending and call the corresponding IRQHandler. If no flag in the range covered by this IRQ is set, call default handler.

Definition at line 246 of file external_interrupts.cpp.

◆ __attribute__() [3/3]

void __attribute__ ( (weak) )

Declaration of a separate IRQHandler for each external interrupt. If no further implementation is provided, the Default_Handler will be called.

Definition at line 78 of file external_interrupts.cpp.

◆ changeInterruptTrigger()

void changeInterruptTrigger ( unsigned int gpioPort,
unsigned int gpioNum,
InterruptTrigger trigger )

Changes interrupt trigger on an enabled interrupt.

Parameters
gpioPortPort of the pin (eg: GPIOC_BASE)
gpioNumPin number (eg: 4 for PC4)
triggerInterrupt detection trigger (rising edge, falling or both)

Definition at line 411 of file external_interrupts.cpp.

◆ ConvertGPIO_BASEtoUnsigned()

constexpr unsigned ConvertGPIO_BASEtoUnsigned ( unsigned P)
constexpr

Definition at line 321 of file external_interrupts.cpp.

◆ Default_EXTI_Handler()

void Default_EXTI_Handler ( )

Definition at line 68 of file external_interrupts.cpp.

◆ disableExternalInterrupt()

void disableExternalInterrupt ( unsigned int gpioPort,
unsigned int gpioNum )

Disables external interrupts on the provided pin.

Parameters
gpioPortPort of the pin (eg: GPIOC_BASE)
gpioNumPin number (eg: 4 for PC4)

Definition at line 396 of file external_interrupts.cpp.

◆ enableExternalInterrupt()

void enableExternalInterrupt ( unsigned int gpioPort,
unsigned int gpioNum,
InterruptTrigger trigger,
unsigned int priority = 15 )

Enables external interrupts on the provided pin. Remember to set the GPIO to input mode!

Parameters
gpioPortPort of the pin (eg: GPIOC_BASE)
gpioNumPin number (eg: 4 for PC4)
triggerInterrupt detection trigger (rising edge, falling or both)
priorityInterrupt priority [0-15], 0 = Highest priority

Definition at line 366 of file external_interrupts.cpp.

◆ GetEXTI_IRQn()

constexpr unsigned GetEXTI_IRQn ( unsigned N)
constexpr

Definition at line 341 of file external_interrupts.cpp.

◆ GetEXTICR_register_mask()

constexpr unsigned GetEXTICR_register_mask ( unsigned P,
unsigned N )
constexpr

Definition at line 361 of file external_interrupts.cpp.

◆ GetEXTICR_register_value()

constexpr unsigned GetEXTICR_register_value ( unsigned P,
unsigned N )
constexpr

Definition at line 356 of file external_interrupts.cpp.

◆ unexpectedInterrupt()

void unexpectedInterrupt ( )
extern

Since in the stm32 interrupts greater than 5 are handled in groups (from 5 to 9 and from 10 to 15), this class provides a way to address single interrupts in this range.

In particular, an EXTIxx_IRQHandlerImpl() function is declared for every interrupt from 5 to 15, and defined in a similar fashion as miosix's 'stage_1_boot', i.e. handlers are "weak" and, if not overridden, will be assigned to a default handler.

NOTE: you will still have to enable the corresponding interrupt if you want to use it, defining an IRQHandlerImpl is not enough.

USAGE EXAMPLE:

Handle External Interrupt 9 void attribute((used)) EXTI9_IRQHandlerImpl() { Do some small operation, e.g. set a boolean flag No need to clear interrupt No need to use naked function }

int main() {

  1. Set SYSCFG and EXTI registers (IMR, FTSR/RTSR) ...
  2. NVIC settings NVIC_EnableIRQ(EXTI9_5_IRQn); NVIC_SetPriority(EXTI9_5_IRQn, choose_a_priority); }