PebbleOS v4.48.0-75-g7416f78a1
Loading...
Searching...
No Matches
Interrupt controller

Secondary interrupt controller class. More...

Modules

 Interrupt controller drivers
 Interface for interrupt controller drivers.
 
 STM32H7 EXTI
 The extended interrupt and event controller of the STM32H7: each line raises an interrupt of the NVIC, given by the tree, which lines may share.
 

Data Structures

struct  pbl_irq_spec
 An interrupt line, as used by a consumer. More...
 

Macros

#define PBL_IRQ_SPEC(_intc, _hwirq, _type)   {.intc = (_intc), .hwirq = (_hwirq), .type = (_type)}
 Initializer for a struct pbl_irq_spec.
 

Typedefs

typedef void(* pbl_intc_handler_t) (void *arg)
 Line handler, called in ISR context.
 

Functions

static bool pbl_irq_spec_is_connected (const struct pbl_irq_spec *spec)
 Check whether an interrupt line is connected.
 
int pbl_intc_request (const struct pbl_irq_spec *spec, pbl_intc_handler_t handler, void *arg)
 Install the handler of a line and set its trigger type.
 
int pbl_intc_free (const struct pbl_irq_spec *spec)
 Disable a line and remove its handler.
 
int pbl_intc_enable (const struct pbl_irq_spec *spec)
 Enable a requested line.
 
int pbl_intc_disable (const struct pbl_irq_spec *spec)
 Disable a requested line.
 
int pbl_intc_set_wake (const struct pbl_irq_spec *spec, uint32_t type)
 Let a requested line wake the system from power-off, or stop it.
 
int pbl_intc_trigger (const struct pbl_irq_spec *spec)
 Raise a requested line by software, as if the device behind it had.
 

Trigger types

Physical trigger of a line, as wired on the board.

#define PBL_IRQ_TYPE_EDGE_RISING   1U
 Rising edge.
 
#define PBL_IRQ_TYPE_EDGE_FALLING   2U
 Falling edge.
 
#define PBL_IRQ_TYPE_EDGE_BOTH   (PBL_IRQ_TYPE_EDGE_RISING | PBL_IRQ_TYPE_EDGE_FALLING)
 Both edges.
 
#define PBL_IRQ_TYPE_LEVEL_HIGH   4U
 High level.
 
#define PBL_IRQ_TYPE_LEVEL_LOW   8U
 Low level.
 

Detailed Description

Secondary interrupt controller class.

A secondary interrupt controller, a GPIO port or a peripheral that funnels several interrupt sources into one SoC line, is a struct pbl_intc device. SoC lines themselves are bound at build time with PBL_IRQ_CONNECT() (see Interrupts) and are not part of this class.

A consumer holds a struct pbl_irq_spec naming the controller, the line on it and its trigger type, as wired on the board, and lists the controller among its device dependencies. It requests the line once and enables it while it wants interrupts:

.int1 = PBL_IRQ_SPEC(&dt_gpio1_intc, 38, PBL_IRQ_TYPE_EDGE_RISING),
static void prv_int1_handler(void *arg) {
// ISR context
}
pbl_intc_request(&dev->int1, prv_int1_handler, dev);
pbl_intc_enable(&dev->int1);
int pbl_intc_enable(const struct pbl_irq_spec *spec)
Enable a requested line.
#define PBL_IRQ_TYPE_EDGE_RISING
Rising edge.
Definition intc.h:47
int pbl_intc_request(const struct pbl_irq_spec *spec, pbl_intc_handler_t handler, void *arg)
Install the handler of a line and set its trigger type.
#define PBL_IRQ_SPEC(_intc, _hwirq, _type)
Initializer for a struct pbl_irq_spec.
Definition intc.h:80

The controller driver calls pbl_intc_dispatch() from its SoC interrupt handler for each pending line.


Data Structure Documentation

◆ pbl_irq_spec

struct pbl_irq_spec

An interrupt line, as used by a consumer.

Data Fields
uint16_t hwirq Line number on the controller.
const struct pbl_intc * intc Controller, NULL if not connected.
uint8_t type Trigger type.

Macro Definition Documentation

◆ PBL_IRQ_SPEC

#define PBL_IRQ_SPEC (   _intc,
  _hwirq,
  _type 
)    {.intc = (_intc), .hwirq = (_hwirq), .type = (_type)}

Initializer for a struct pbl_irq_spec.

Parameters
_intcInterrupt controller.
_hwirqLine number on the controller.
_typeTrigger type.

◆ PBL_IRQ_TYPE_EDGE_BOTH

#define PBL_IRQ_TYPE_EDGE_BOTH   (PBL_IRQ_TYPE_EDGE_RISING | PBL_IRQ_TYPE_EDGE_FALLING)

Both edges.

◆ PBL_IRQ_TYPE_EDGE_FALLING

#define PBL_IRQ_TYPE_EDGE_FALLING   2U

Falling edge.

◆ PBL_IRQ_TYPE_EDGE_RISING

#define PBL_IRQ_TYPE_EDGE_RISING   1U

Rising edge.

◆ PBL_IRQ_TYPE_LEVEL_HIGH

#define PBL_IRQ_TYPE_LEVEL_HIGH   4U

High level.

◆ PBL_IRQ_TYPE_LEVEL_LOW

#define PBL_IRQ_TYPE_LEVEL_LOW   8U

Low level.

Typedef Documentation

◆ pbl_intc_handler_t

typedef void(* pbl_intc_handler_t) (void *arg)

Line handler, called in ISR context.

Function Documentation

◆ pbl_intc_disable()

int pbl_intc_disable ( const struct pbl_irq_spec *  spec)

Disable a requested line.

Parameters
specRequested line.
Returns
0, -EINVAL if the line is not requested, or another negative errno.

◆ pbl_intc_enable()

int pbl_intc_enable ( const struct pbl_irq_spec *  spec)

Enable a requested line.

Parameters
specRequested line.
Returns
0, -EINVAL if the line is not requested, or another negative errno.

◆ pbl_intc_free()

int pbl_intc_free ( const struct pbl_irq_spec *  spec)

Disable a line and remove its handler.

Parameters
specRequested line.
Returns
0, -EINVAL if the line is not requested, or another negative errno.

◆ pbl_intc_request()

int pbl_intc_request ( const struct pbl_irq_spec *  spec,
pbl_intc_handler_t  handler,
void *  arg 
)

Install the handler of a line and set its trigger type.

The line is left disabled.

Parameters
specLine, on a ready controller.
handlerHandler, called in ISR context.
argHandler argument.
Returns
0, -EBUSY if the line is already requested, -EINVAL for an invalid line or type, -ENOTSUP if the controller does not support the type, or another negative errno.

◆ pbl_intc_set_wake()

int pbl_intc_set_wake ( const struct pbl_irq_spec *  spec,
uint32_t  type 
)

Let a requested line wake the system from power-off, or stop it.

The controller arms the line when the SoC powers off, whatever its trigger type. With PBL_IRQ_TYPE_LEVEL_HIGH or PBL_IRQ_TYPE_LEVEL_LOW it wakes the system on that level, at once if the line is already at it. With PBL_IRQ_TYPE_EDGE_BOTH it wakes the system on a change from the level at power-off.

Parameters
specRequested line.
typeWake type, or 0 for the line not to wake the system.
Returns
0, -EINVAL if the line is not requested or for an invalid type, -ENOTSUP if the controller cannot wake the system on it, or another negative errno.

◆ pbl_intc_trigger()

int pbl_intc_trigger ( const struct pbl_irq_spec *  spec)

Raise a requested line by software, as if the device behind it had.

The handler runs from the interrupt of the line, once enabled.

Parameters
specRequested line.
Returns
0, -EINVAL if the line is not requested, -ENOTSUP if the controller cannot raise it, or another negative errno.

◆ pbl_irq_spec_is_connected()

static bool pbl_irq_spec_is_connected ( const struct pbl_irq_spec *  spec)
inlinestatic

Check whether an interrupt line is connected.

Parameters
specLine.
Returns
True if the line has a controller.

References pbl_irq_spec::intc.