I2C bus driver for the SF32LB I2C controller.
More...
I2C bus driver for the SF32LB I2C controller.
Transfers are interrupt driven and issue any message sequence. Deep sleep is blocked while a transfer is in flight. A bus given a DMA channel receives PBL_I2C_MSG_DMA_SAFE reads of I2C_SF32LB_DMA_MIN_BYTES or more through DMA, so the CPU can sleep through them instead of taking an interrupt per byte; the DMA channel needs no interrupt.
An instance connects its controller interrupt itself, with priority CONFIG_I2C_SF32LB_IRQ_PRIO:
&s_i2c2_default, &s_i2c2_dma);
#define SF32LB_HPSYS_RCC
HPSYS RCC clock controller.
Definition sf32lb.h:27
#define SF32LB52_HPSYS_CLK_I2C2
Definition sf32lb.h:55
#define PBL_CLK(_ctrl, _id)
Initializer for a struct pbl_clk.
Definition clk.h:132
#define SF32LB_DMA_PL_HIGH
High priority.
Definition sf32lb.h:46
#define SF32LB52_DMA_REQ_I2C2
Definition sf32lb.h:77
A channel, as used by a consumer.
Definition dma.h:91
#define PBL_DMA_CHAN(_ctrl, _channel, _request, _config)
Initializer for a struct pbl_dma_chan.
Definition dma.h:110
#define PBL_I2C_SF32LB_DEFINE(sym, _name, _base, _irq, _clk, _clock_hz, _pinctrl, _dma)
Define a bus on an SF32LB I2C controller.
Definition sf32lb.h:96
#define SF32LB52_PINCTRL
HPSYS pin controller.
Definition sf32lb52.h:127
#define PBL_PINCTRL_SF32LB52_INPUT
Input buffer enabled.
Definition sf32lb52.h:85
#define PBL_PINCTRL_STATE_DEFINE(sym, _ctrl,...)
Define a pin state.
Definition pinctrl.h:98
◆ pbl_i2c_sf32lb
| Data Fields |
|
uintptr_t |
base |
Registers. |
|
struct pbl_i2c_bus |
bus |
I2C bus. |
|
struct pbl_clk |
clk |
Controller clock. |
|
uint32_t |
clock_hz |
Bus clock frequency, in Hz. |
|
const struct pbl_dma_chan * |
dma |
Receive DMA channel, or NULL. |
|
pbl_irq_t |
irq |
Interrupt line. |
|
struct pbl_pinctrl |
pinctrl |
SCL and SDA pins. |
|
struct pbl_i2c_sf32lb_state * |
state |
Driver runtime state. |
◆ I2C_SF32LB_DMA_MIN_BYTES
| #define I2C_SF32LB_DMA_MIN_BYTES 32 |
Shortest read that goes through DMA.
◆ PBL_I2C_SF32LB_DEFINE
| #define PBL_I2C_SF32LB_DEFINE |
( |
|
sym, |
|
|
|
_name, |
|
|
|
_base, |
|
|
|
_irq, |
|
|
|
_clk, |
|
|
|
_clock_hz, |
|
|
|
_pinctrl, |
|
|
|
_dma |
|
) |
| |
Value:
static struct pbl_i2c_sf32lb_state sym##_sf32lb_state; \
.state = &sym##_sf32lb_state, \
.dma = (_dma), \
.clk = _clk, \
.base = (_base), \
.clock_hz = (_clock_hz), \
.irq = (_irq), \
}; \
SF32LB I2C bus.
Definition sf32lb.h:61
void pbl_i2c_sf32lb_irq_handler(const struct pbl_i2c_sf32lb *i2c)
Controller interrupt handler, connected by PBL_I2C_SF32LB_DEFINE().
An I2C controller.
Definition i2c.h:113
#define PBL_I2C_BUS_INIT(sym, _name, _parent, _ops)
Initializer for the struct pbl_i2c_bus of bus sym.
Definition i2c.h:155
#define PBL_I2C_BUS_STATE_DEFINE(sym)
Define the class state of bus sym, for the PBL_I2C_*_DEFINE() macro of a driver.
Definition i2c.h:143
#define PBL_PINCTRL(_default, _sleep, _reg)
Initializer for a struct pbl_pinctrl.
Definition pinctrl.h:132
Define a bus on an SF32LB I2C controller.
- Parameters
-
| sym | Symbol of the bus, a struct pbl_i2c_bus. |
| _name | Name. |
| _base | Registers. |
| _irq | Interrupt line, a plain number such as PBL_SOC_IRQN_I2C1. |
| _clk | Controller clock, from PBL_CLK(). |
| _clock_hz | Bus clock frequency. |
| _pinctrl | Pin state with SCL and SDA. |
| _dma | Receive DMA channel, or NULL. |
◆ pbl_i2c_sf32lb_irq_handler()