I2C bus driver for the nRF5 TWIM peripheral.
More...
|
| #define | I2C_NRF5_BOUNCE_BUF_SIZE 16 |
| | Longest write made of several messages, which the driver gathers in one buffer.
|
| |
| #define | PBL_I2C_NRF5_DEFINE(sym, _name, _base, _irq, _clock_hz, _scl, _sda) |
| | Define a bus on an nRF5 TWIM instance.
|
| |
I2C bus driver for the nRF5 TWIM peripheral.
The TWIM issues one write, one read, or a write then a read after a repeated START; writes continued with PBL_I2C_MSG_NOSTART are gathered in a buffer of I2C_NRF5_BOUNCE_BUF_SIZE bytes. Other sequences fail with -ENOTSUP.
SCL and SDA are configured as open-drain inputs with their wiring flags, e.g. the pull-up, and keep that configuration while the bus is disabled. An instance connects its TWIM interrupt itself, with priority CONFIG_I2C_NRF5_IRQ_PRIO:
PBL_SOC_IRQN_SPI0_SPIM0_SPIS0_TWI0_TWIM0_TWIS0, 400000,
PBL_GPIO(&dt_gpio0, 25,
#define PBL_GPIO(_port, _pin, _flags)
Initializer for a struct pbl_gpio.
Definition gpio.h:158
#define PBL_GPIO_PULL_UP
Enable the pull-up.
Definition gpio.h:52
#define PBL_I2C_NRF5_DEFINE(sym, _name, _base, _irq, _clock_hz, _scl, _sda)
Define a bus on an nRF5 TWIM instance.
Definition nrf5.h:81
◆ pbl_i2c_nrf5
| Data Fields |
|
uintptr_t |
base |
Registers. |
|
struct pbl_i2c_bus |
bus |
I2C bus. |
|
uint32_t |
clock_hz |
Bus clock frequency, in Hz. |
|
pbl_irq_t |
irq |
Interrupt line. |
|
struct pbl_gpio |
scl |
SCL pin. |
|
struct pbl_gpio |
sda |
SDA pin. |
|
struct pbl_i2c_nrf5_state * |
state |
Driver runtime state. |
◆ I2C_NRF5_BOUNCE_BUF_SIZE
| #define I2C_NRF5_BOUNCE_BUF_SIZE 16 |
Longest write made of several messages, which the driver gathers in one buffer.
◆ PBL_I2C_NRF5_DEFINE
| #define PBL_I2C_NRF5_DEFINE |
( |
|
sym, |
|
|
|
_name, |
|
|
|
_base, |
|
|
|
_irq, |
|
|
|
_clock_hz, |
|
|
|
_scl, |
|
|
|
_sda |
|
) |
| |
Value:
static struct pbl_i2c_nrf5_state sym##_nrf5_state; \
.state = &sym##_nrf5_state, \
.base = (_base), \
.irq = (_irq), \
.clock_hz = (_clock_hz), \
.scl = _scl, \
.sda = _sda, \
}; \
nRF5 I2C bus.
Definition nrf5.h:49
void pbl_i2c_nrf5_irq_handler(const struct pbl_i2c_nrf5 *i2c)
TWIM interrupt handler, connected by PBL_I2C_NRF5_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 a bus on an nRF5 TWIM instance.
- Parameters
-
| sym | Symbol of the bus, a struct pbl_i2c_bus. |
| _name | Name. |
| _base | Registers. |
| _irq | Interrupt line, a plain number. |
| _clock_hz | Bus clock frequency: 100000, 250000 or 400000. |
| _scl | SCL pin, from PBL_GPIO(). |
| _sda | SDA pin, from PBL_GPIO(). |
◆ pbl_i2c_nrf5_irq_handler()
| void pbl_i2c_nrf5_irq_handler |
( |
const struct pbl_i2c_nrf5 * |
i2c | ) |
|