STM32 RTOS 0.2.3
Bare-metal preemptive RTOS for STM32F446RE
Loading...
Searching...
No Matches
EXTI

GPIO-to-line routing, edge triggers, interrupt mask and pending bits. More...

Collaboration diagram for EXTI:

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.
#define EXTI_LINE_UNUSED   (19U)
 The line with no source on the F446 (RM0390 section 10.2.5).

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.
static DriverStatus_e extiValidateLine (uint32_t line)
 Accept a line that exists: 0 to EXTI_LINE_MAX, except 19.
static DriverStatus_e extiPortSelector (const GpioRegisters_t *port, uint32_t *selector)
 Map a GPIO port to its EXTICR selector.

Detailed Description

GPIO-to-line routing, edge triggers, interrupt mask and pending bits.

Macro Definition Documentation

◆ EXTI_LINE_MAX

#define EXTI_LINE_MAX   (22U)

Highest EXTI line on the F446.

Definition at line 38 of file exti.h.

Referenced by extiValidateLine().

◆ EXTI_GPIO_LINE_MAX

#define EXTI_GPIO_LINE_MAX   (15U)

Highest line fed by a GPIO pin.

Definition at line 39 of file exti.h.

Referenced by extiSelectPort().

◆ EXTI_LINE_UNUSED

#define EXTI_LINE_UNUSED   (19U)

The line with no source on the F446 (RM0390 section 10.2.5).

Definition at line 15 of file exti.c.

Referenced by extiValidateLine().

Enumeration Type Documentation

◆ ExtiEdge_e

enum ExtiEdge_e

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

Enumerator
EXTI_EDGE_RISING 1 

Rising edge only (RTSR).

EXTI_EDGE_FALLING 2 

Falling edge only (FTSR).

EXTI_EDGE_BOTH 3 

Both edges.

Definition at line 42 of file exti.h.

Function Documentation

◆ extiSelectPort()

DriverStatus_e extiSelectPort ( SyscfgRegisters_t * syscfg,
uint32_t line,
const GpioRegisters_t * port )

Route GPIO pin line of port to EXTI line line.

Parameters
syscfgSYSCFG block (e.g. SYSCFG).
line0 to EXTI_GPIO_LINE_MAX.
portGPIOA to GPIOH; compared by address, never dereferenced. GPIOH has only pins 0 and 1.
Precondition
SYSCFG's clock is on (rccSyscfgClockEnable()).
Return values
DRIVER_STATUS_OKThe line's EXTICR field selects port.
DRIVER_STATUS_ERR_INVALID_PARAMline is above 15, port is not GPIOA to GPIOH, or it is GPIOH with line above 1. Nothing written.

Definition at line 86 of file exti.c.

References DRIVER_STATUS_ERR_INVALID_PARAM, DRIVER_STATUS_OK, EXTI_GPIO_LINE_MAX, SyscfgRegisters_t::EXTICR, extiPortSelector(), extiSelectPort(), and SYSCFG_EXTICR_PH.

Referenced by extiSelectPort().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ extiConfigure()

DriverStatus_e extiConfigure ( ExtiRegisters_t * exti,
uint32_t line,
ExtiEdge_e edge )

Set which edges trigger line; the other edge is cleared.

An edge that arrives while RTSR or FTSR is being written is not latched (RM0390 section 10.3). Configure a line while its interrupt is masked, and clear its pending bit before unmasking it.

Parameters
extiEXTI block (e.g. EXTI).
line0 to EXTI_LINE_MAX, except 19.
edgeEdges to trigger on.
Return values
DRIVER_STATUS_OKRTSR and FTSR set for line.
DRIVER_STATUS_ERR_INVALID_PARAMline or edge is invalid. Nothing written.

Definition at line 118 of file exti.c.

References DRIVER_STATUS_ERR_INVALID_PARAM, DRIVER_STATUS_OK, EXTI_EDGE_BOTH, EXTI_EDGE_FALLING, EXTI_EDGE_RISING, extiConfigure(), extiValidateLine(), ExtiRegisters_t::FTSR, and ExtiRegisters_t::RTSR.

Referenced by extiConfigure().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ extiEnableInterrupt()

DriverStatus_e extiEnableInterrupt ( ExtiRegisters_t * exti,
uint32_t line )

Unmask line's interrupt (IMR).

Parameters
extiEXTI block (e.g. EXTI).
line0 to EXTI_LINE_MAX, except 19.
Return values
DRIVER_STATUS_OKUnmasked.
DRIVER_STATUS_ERR_INVALID_PARAMline is invalid. Nothing written.

Definition at line 154 of file exti.c.

References DRIVER_STATUS_OK, extiEnableInterrupt(), extiValidateLine(), and ExtiRegisters_t::IMR.

Referenced by extiEnableInterrupt().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ extiDisableInterrupt()

DriverStatus_e extiDisableInterrupt ( ExtiRegisters_t * exti,
uint32_t line )

Mask line's interrupt (IMR).

Its pending bit is left alone.

Parameters
extiEXTI block (e.g. EXTI).
line0 to EXTI_LINE_MAX, except 19.
Return values
DRIVER_STATUS_OKMasked.
DRIVER_STATUS_ERR_INVALID_PARAMline is invalid. Nothing written.

Definition at line 166 of file exti.c.

References DRIVER_STATUS_OK, extiDisableInterrupt(), extiValidateLine(), and ExtiRegisters_t::IMR.

Referenced by extiDisableInterrupt().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ extiTriggerSoftware()

DriverStatus_e extiTriggerSoftware ( ExtiRegisters_t * exti,
uint32_t line )

Raise line's interrupt from software (SWIER).

Sets the pending bit only if the line's interrupt is unmasked; the edge configuration does not matter. Hardware clears SWIER when the pending bit is cleared.

Parameters
extiEXTI block (e.g. EXTI).
line0 to EXTI_LINE_MAX, except 19.
Return values
DRIVER_STATUS_OKSWIER bit set.
DRIVER_STATUS_ERR_INVALID_PARAMline is invalid. Nothing written.

Definition at line 178 of file exti.c.

References DRIVER_STATUS_OK, extiTriggerSoftware(), extiValidateLine(), and ExtiRegisters_t::SWIER.

Referenced by extiTriggerSoftware().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ extiIsPending()

DriverStatus_e extiIsPending ( const ExtiRegisters_t * exti,
uint32_t line,
bool * pending )

Report whether line's pending bit (PR) is set.

Parameters
extiEXTI block (e.g. EXTI).
line0 to EXTI_LINE_MAX, except 19.
pendingReceives the bit; written only on success.
Return values
DRIVER_STATUS_OKpending written.
DRIVER_STATUS_ERR_INVALID_PARAMline is invalid or pending is NULL.

Definition at line 191 of file exti.c.

References DRIVER_STATUS_ERR_INVALID_PARAM, DRIVER_STATUS_OK, extiIsPending(), extiValidateLine(), and ExtiRegisters_t::PR.

Referenced by extiIsPending().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ extiClearPending()

DriverStatus_e extiClearPending ( ExtiRegisters_t * exti,
uint32_t line )

Clear line's pending bit, and its SWIER bit with it.

PR is write-1-to-clear, so this is a single store of the line's bit: it cannot clear another line's pending bit and needs no serialising.

Parameters
extiEXTI block (e.g. EXTI).
line0 to EXTI_LINE_MAX, except 19.
Return values
DRIVER_STATUS_OKCleared.
DRIVER_STATUS_ERR_INVALID_PARAMline is invalid. Nothing written.
Warning
Clear it in the handler before returning. Otherwise the interrupt is taken again at once.

Definition at line 208 of file exti.c.

References DRIVER_STATUS_OK, extiClearPending(), extiValidateLine(), and ExtiRegisters_t::PR.

Referenced by extiClearPending().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ extiValidateLine()

DriverStatus_e extiValidateLine ( uint32_t line)
static

Accept a line that exists: 0 to EXTI_LINE_MAX, except 19.

Parameters
lineCandidate line.
Return values
DRIVER_STATUS_OKValid.
DRIVER_STATUS_ERR_INVALID_PARAMOtherwise.

Definition at line 23 of file exti.c.

References DRIVER_STATUS_ERR_INVALID_PARAM, DRIVER_STATUS_OK, EXTI_LINE_MAX, EXTI_LINE_UNUSED, and extiValidateLine().

Referenced by extiClearPending(), extiConfigure(), extiDisableInterrupt(), extiEnableInterrupt(), extiIsPending(), extiTriggerSoftware(), and extiValidateLine().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ extiPortSelector()

DriverStatus_e extiPortSelector ( const GpioRegisters_t * port,
uint32_t * selector )
static

Map a GPIO port to its EXTICR selector.

Parameters
portPort to identify, compared by address.
selectorReceives a SYSCFG_EXTICR_P* value; untouched on failure.
Return values
DRIVER_STATUS_OKport is GPIOA to GPIOH.
DRIVER_STATUS_ERR_INVALID_PARAMOtherwise.

Definition at line 42 of file exti.c.

References DRIVER_STATUS_ERR_INVALID_PARAM, DRIVER_STATUS_OK, extiPortSelector(), GPIOA, GPIOB, GPIOC, GPIOD, GPIOE, GPIOF, GPIOG, GPIOH, SYSCFG_EXTICR_PA, SYSCFG_EXTICR_PB, SYSCFG_EXTICR_PC, SYSCFG_EXTICR_PD, SYSCFG_EXTICR_PE, SYSCFG_EXTICR_PF, SYSCFG_EXTICR_PG, and SYSCFG_EXTICR_PH.

Referenced by extiPortSelector(), and extiSelectPort().

Here is the call graph for this function:
Here is the caller graph for this function: