STM32 RTOS 0.2.3
Bare-metal preemptive RTOS for STM32F446RE
Loading...
Searching...
No Matches
exti.h File Reference

EXTI driver: route a GPIO pin to an EXTI line, choose its edges, and manage its interrupt and pending bit. More...

#include "driver_status.h"
#include "exti_reg.h"
#include "gpio_reg.h"
#include "syscfg_reg.h"
#include <stdbool.h>
#include <stdint.h>
Include dependency graph for exti.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define EXTI_LINE_MAX   (22U)
 Highest EXTI line on the F446.
#define EXTI_GPIO_LINE_MAX   (15U)
 Highest line fed by a GPIO pin.

Typedefs

typedef enum ExtiEdge_e ExtiEdge_e
 Which edges of a line's input set its pending bit.

Enumerations

enum  ExtiEdge_e { EXTI_EDGE_RISING = 1 , EXTI_EDGE_FALLING = 2 , EXTI_EDGE_BOTH = 3 }
 Which edges of a line's input set its pending bit. More...

Functions

DRIVER_MUST_CHECK DriverStatus_e extiSelectPort (SyscfgRegisters_t *syscfg, uint32_t line, const GpioRegisters_t *port)
 Route GPIO pin line of port to EXTI line line.
DRIVER_MUST_CHECK DriverStatus_e extiConfigure (ExtiRegisters_t *exti, uint32_t line, ExtiEdge_e edge)
 Set which edges trigger line; the other edge is cleared.
DRIVER_MUST_CHECK DriverStatus_e extiEnableInterrupt (ExtiRegisters_t *exti, uint32_t line)
 Unmask line's interrupt (IMR).
DRIVER_MUST_CHECK DriverStatus_e extiDisableInterrupt (ExtiRegisters_t *exti, uint32_t line)
 Mask line's interrupt (IMR).
DRIVER_MUST_CHECK DriverStatus_e extiTriggerSoftware (ExtiRegisters_t *exti, uint32_t line)
 Raise line's interrupt from software (SWIER).
DRIVER_MUST_CHECK DriverStatus_e extiIsPending (const ExtiRegisters_t *exti, uint32_t line, bool *pending)
 Report whether line's pending bit (PR) is set.
DRIVER_MUST_CHECK DriverStatus_e extiClearPending (ExtiRegisters_t *exti, uint32_t line)
 Clear line's pending bit, and its SWIER bit with it.

Detailed Description

EXTI driver: route a GPIO pin to an EXTI line, choose its edges, and manage its interrupt and pending bit.

Lines 0-15 come from GPIO pin n of the port extiSelectPort() picks; lines 16-22 are the internal sources in exti_reg.h. Line 19 has no source on the F446. Lines 0-4 have their own NVIC vector; 5-9 share EXTI9_5_IRQn and 10-15 share EXTI15_10_IRQn, so a shared handler checks each line with extiIsPending(). The B1 button (PC13), falling edge:

if (nvicEnableIrq(NVIC, EXTI15_10_IRQn) != DRIVER_STATUS_OK) { ... }
// in EXTI15_10_IRQHandler: extiClearPending(EXTI, 13U)
@ DRIVER_STATUS_OK
Succeeded.
DRIVER_MUST_CHECK DriverStatus_e extiSelectPort(SyscfgRegisters_t *syscfg, uint32_t line, const GpioRegisters_t *port)
Route GPIO pin line of port to EXTI line line.
Definition exti.c:86
DRIVER_MUST_CHECK DriverStatus_e extiEnableInterrupt(ExtiRegisters_t *exti, uint32_t line)
Unmask line's interrupt (IMR).
Definition exti.c:154
DRIVER_MUST_CHECK DriverStatus_e extiConfigure(ExtiRegisters_t *exti, uint32_t line, ExtiEdge_e edge)
Set which edges trigger line; the other edge is cleared.
Definition exti.c:118
@ EXTI_EDGE_FALLING
Falling edge only (FTSR).
Definition exti.h:45
#define EXTI
The EXTI instance.
Definition exti_reg.h:32
#define GPIOC
Port C.
Definition gpio_reg.h:50
DRIVER_MUST_CHECK DriverStatus_e nvicEnableIrq(NvicRegisters_t *nvic, IRQn_e irqn)
Enable a device interrupt.
Definition nvic.c:97
#define NVIC
The NVIC instance.
Definition nvic_reg.h:45
void rccSyscfgClockEnable(RccRegisters_t *rcc)
Enable SYSCFG's clock; needed before any SYSCFG access (e.g.
Definition rcc.c:118
#define RCC
The RCC instance.
Definition rcc_reg.h:61
#define SYSCFG
The SYSCFG instance.
Definition syscfg_reg.h:31

Event mode (EMR, for WFE) is not offered: nothing uses it yet.

Definition in file exti.h.