Midnight Sun Firmware
Loading...
Searching...
No Matches
interrupts.h
1#pragma once
2
3/************************************************************************************************
4 * @file interrupts.h
5 *
6 * @brief Interrupts Library Header file
7 *
8 * @date 2024-10-27
9 * @author Midnight Sun Team #24 - MSXVI
10 ************************************************************************************************/
11
12/* Standard library Headers */
13#include <stdbool.h>
14#include <stdint.h>
15
16/* Inter-component Headers */
17#include "FreeRTOSConfig.h"
18
19/* Intra-component Headers */
20#include "gpio.h"
21#include "status.h"
22
32typedef enum {
37
46typedef enum {
47 INTERRUPT_PRIORITY_HIGH = configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY,
48 INTERRUPT_PRIORITY_NORMAL,
49 INTERRUPT_PRIORITY_LOW,
50 NUM_INTERRUPT_PRIORITIES,
52
58typedef enum {
64
68typedef struct InterruptSettings {
73
75#define NUM_STM32L433X_INTERRUPT_CHANNELS 83U
76
78#define NUM_STM32L433X_EXTI_LINES 16U
79
85void interrupt_init(void);
86
94StatusCode interrupt_nvic_enable(uint8_t irq_channel, InterruptPriority priority);
95
104
112
120StatusCode interrupt_exti_get_pending(uint8_t line, uint8_t *pending_bit);
121
129
137StatusCode interrupt_exti_set_mask(uint8_t line, bool masked);
138
139#ifdef MS_PLATFORM_X86
140
142typedef void (*x86InterruptHandler)(uint8_t interrupt_id);
143
153StatusCode interrupt_nvic_register_handler(uint8_t irq_channel, x86InterruptHandler handler, const InterruptSettings *settings);
154
164StatusCode interrupt_exti_register_handler(uint8_t line, x86InterruptHandler handler, const InterruptSettings *settings);
165
166#endif
167
StatusCode interrupt_exti_enable(GpioAddress *address, const InterruptSettings *settings)
Enables an external interrupt line with the given settings.
Definition: interrupts.c:40
StatusCode interrupt_exti_clear_pending(uint8_t line)
Clears the pending flag for an external interrupt.
Definition: interrupts.c:93
StatusCode interrupt_nvic_enable(uint8_t irq_channel, InterruptPriority priority)
Enables the nested interrupt vector controller for a given channel.
Definition: interrupts.c:31
StatusCode interrupt_exti_get_pending(uint8_t line, uint8_t *pending_bit)
Get the pending flag for an external interrupt.
Definition: interrupts.c:84
InterruptClass
Interrupt class selection.
Definition: interrupts.h:32
void interrupt_init(void)
Initializes the interrupt internals.
Definition: interrupts.c:23
InterruptEdge
Defines on what edge of an input signal the interrupt triggers on.
Definition: interrupts.h:58
InterruptPriority
Interrupt priority level selection.
Definition: interrupts.h:46
StatusCode interrupt_exti_trigger(uint8_t line)
Triggers a software interrupt on a given external interrupt channel.
Definition: interrupts.c:76
StatusCode interrupt_exti_set_mask(uint8_t line, bool masked)
Masks or clears the external interrupt on a given line.
Definition: interrupts.c:101
@ NUM_INTERRUPT_CLASSES
Definition: interrupts.h:35
@ INTERRUPT_TYPE_INTERRUPT
Definition: interrupts.h:33
@ INTERRUPT_TYPE_EVENT
Definition: interrupts.h:34
@ INTERRUPT_EDGE_FALLING
Definition: interrupts.h:60
@ INTERRUPT_EDGE_TRANSITION
Definition: interrupts.h:61
@ NUM_INTERRUPT_EDGES
Definition: interrupts.h:62
@ INTERRUPT_EDGE_RISING
Definition: interrupts.h:59
StatusCode
StatusCodes for various errors.
Definition: status.h:27
Port and pin data.
Definition: gpio.h:112
Interrupt configuration structure.
Definition: interrupts.h:68
InterruptEdge edge
Definition: interrupts.h:71
InterruptPriority priority
Definition: interrupts.h:70