Midnight Sun Firmware
Loading...
Searching...
No Matches
Interrupts

Interrupts library. More...

Classes

struct  InterruptSettings
 Interrupt configuration structure. More...
 

Macros

#define NUM_STM32L433X_INTERRUPT_CHANNELS   83U
 Indexed number of STM32L433 NVIC entires from data sheet and IRQn_Type enum.
 
#define NUM_STM32L433X_EXTI_LINES   16U
 Number of external interrupt lines.
 

Typedefs

typedef struct InterruptSettings InterruptSettings
 Interrupt configuration structure.
 

Enumerations

enum  InterruptClass { INTERRUPT_TYPE_INTERRUPT = 0 , INTERRUPT_TYPE_EVENT , NUM_INTERRUPT_CLASSES }
 Interrupt class selection. More...
 
enum  InterruptPriority { INTERRUPT_PRIORITY_HIGH = configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY , INTERRUPT_PRIORITY_NORMAL , INTERRUPT_PRIORITY_LOW , NUM_INTERRUPT_PRIORITIES }
 Interrupt priority level selection. More...
 
enum  InterruptEdge { INTERRUPT_EDGE_RISING = 0 , INTERRUPT_EDGE_FALLING , INTERRUPT_EDGE_TRANSITION , NUM_INTERRUPT_EDGES }
 Defines on what edge of an input signal the interrupt triggers on. More...
 

Functions

void interrupt_init (void)
 Initializes the interrupt internals. More...
 
StatusCode interrupt_nvic_enable (uint8_t irq_channel, InterruptPriority priority)
 Enables the nested interrupt vector controller for a given channel. More...
 
StatusCode interrupt_exti_enable (GpioAddress *address, const InterruptSettings *settings)
 Enables an external interrupt line with the given settings. More...
 
StatusCode interrupt_exti_trigger (uint8_t line)
 Triggers a software interrupt on a given external interrupt channel. More...
 
StatusCode interrupt_exti_get_pending (uint8_t line, uint8_t *pending_bit)
 Get the pending flag for an external interrupt. More...
 
StatusCode interrupt_exti_clear_pending (uint8_t line)
 Clears the pending flag for an external interrupt. More...
 
StatusCode interrupt_exti_set_mask (uint8_t line, bool masked)
 Masks or clears the external interrupt on a given line. More...
 

Detailed Description

Interrupts library.

Enumeration Type Documentation

◆ InterruptClass

Interrupt class selection.

Enumerator
INTERRUPT_TYPE_INTERRUPT 

Interrupt type runs a callback as soon as the interrupt is triggered

INTERRUPT_TYPE_EVENT 

Event type wakes the device without running a callback

NUM_INTERRUPT_CLASSES 

Number of supported interrupt classes

◆ InterruptEdge

Defines on what edge of an input signal the interrupt triggers on.

Not necessarily applicable for all interrupts, however external interrupts will use them

Enumerator
INTERRUPT_EDGE_RISING 

Rising edge interrupt triggers when a signal goes from LOW to HIGH

INTERRUPT_EDGE_FALLING 

Falling edge interrupt triggers when a signal goes from HIGH to LOW

INTERRUPT_EDGE_TRANSITION 

Transition interrupt triggers when a signal goes from LOW to HIGH or from HIGH to LOW

NUM_INTERRUPT_EDGES 

Number of supported interrupt edges

◆ InterruptPriority

Interrupt priority level selection.

Start counting at configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY, as ISR safe FreeRTOS API can only be called from interrupts that have a priority <= configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY. Since priorities decrease with greater value (0 is highest priority, but is reserved), interrupt priorities must be greater than configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY.

Function Documentation

◆ interrupt_exti_clear_pending()

StatusCode interrupt_exti_clear_pending ( uint8_t  line)

Clears the pending flag for an external interrupt.

Parameters
lineNumeric ID of the EXTI line (GPIO Pin number)
Returns
STATUS_CODE_OK if the channel is successfully initialized STATUS_CODE_INVALID_ARGS if one of the parameters are incorrect

◆ interrupt_exti_enable()

StatusCode interrupt_exti_enable ( GpioAddress address,
const InterruptSettings settings 
)

Enables an external interrupt line with the given settings.

Parameters
addressPointer to the GPIO address
settingsPointer to the interrupt settings
Returns
STATUS_CODE_OK if the channel is successfully initialized STATUS_CODE_INVALID_ARGS if one of the parameters are incorrect

◆ interrupt_exti_get_pending()

StatusCode interrupt_exti_get_pending ( uint8_t  line,
uint8_t *  pending_bit 
)

Get the pending flag for an external interrupt.

Parameters
lineNumeric ID of the EXTI line (GPIO Pin number)
pending_bitPointer to a variable that is updated with the pending bit
Returns
STATUS_CODE_OK if the channel is successfully initialized STATUS_CODE_INVALID_ARGS if one of the parameters are incorrect

◆ interrupt_exti_set_mask()

StatusCode interrupt_exti_set_mask ( uint8_t  line,
bool  masked 
)

Masks or clears the external interrupt on a given line.

Parameters
lineNumeric ID of the EXTI line (GPIO Pin number)
masked0: Clears the interrupt 1: Mask the lines interrupt
Returns
STATUS_CODE_OK if the channel is successfully initialized STATUS_CODE_INVALID_ARGS if one of the parameters are incorrect

◆ interrupt_exti_trigger()

StatusCode interrupt_exti_trigger ( uint8_t  line)

Triggers a software interrupt on a given external interrupt channel.

Parameters
lineNumeric ID of the EXTI line (GPIO Pin number)
Returns
STATUS_CODE_OK if the channel is successfully initialized STATUS_CODE_INVALID_ARGS if one of the parameters are incorrect

◆ interrupt_init()

void interrupt_init ( void  )

Initializes the interrupt internals.

If called multiple times the subsequent attempts will clear everything resulting in needing to re-initialize all interrupts

◆ interrupt_nvic_enable()

StatusCode interrupt_nvic_enable ( uint8_t  irq_channel,
InterruptPriority  priority 
)

Enables the nested interrupt vector controller for a given channel.

Parameters
irq_channelNumeric ID of the interrupt channel from the NVIC
priorityPriority level of the interrupt
Returns
STATUS_CODE_OK if the channel is successfully initialized STATUS_CODE_INVALID_ARGS if one of the parameters are incorrect