23#ifndef PERIPH_PIO_I2C_H
24#define PERIPH_PIO_I2C_H
158 gpio_t sda, gpio_t scl,
unsigned irq);
189 uint16_t reg,
void *data,
size_t len, uint8_t flags);
205 uint16_t reg,
void *data, uint8_t flags)
224 void *data,
size_t len, uint8_t flags);
239 void *data, uint8_t flags)
258 const void *data,
size_t len, uint8_t flags);
273 uint8_t data, uint8_t flags)
293 uint16_t reg,
const void *data,
size_t len, uint8_t flags);
309 uint16_t reg, uint8_t data, uint8_t flags)
High-level PIO peripheral driver interface.
uint_fast8_t i2c_t
Default i2c_t type definition.
void pio_i2c_acquire(pio_i2c_bus_t *bus)
Get exclusive access to the emulated I2C bus.
pio_i2c_bus_t * pio_i2c_get(pio_i2c_t id)
Get access to a PIO I2C instance configured with PIO_I2C_CONFIG.
i2c_t pio_i2c_t
PIO I2C descriptor type compatible with i2c_t.
static int pio_i2c_write_byte(pio_t pio, pio_sm_t sm, uint16_t addr, uint8_t data, uint8_t flags)
Emulate i2c_write_byte.
int pio_i2c_init_program(pio_t pio)
Create, allocate, and write a PIO I2C program.
void pio_i2c_sm_unlock(pio_i2c_bus_t *i2c)
Release a PIO state machine of PIO pio.
static int pio_i2c_write_reg(pio_t pio, pio_sm_t sm, uint16_t addr, uint16_t reg, uint8_t data, uint8_t flags)
Emulate i2c_write_reg.
int pio_i2c_write_bytes(pio_t pio, pio_sm_t sm, uint16_t addr, const void *data, size_t len, uint8_t flags)
Emulate i2c_write_bytes.
struct pio_i2c_bus pio_i2c_bus_t
PIO I2C emulated bus type.
unsigned pio_i2c_numof(void)
Query the number of PIO I2C instances configured with PIO_I2C_CONFIG.
pio_sm_t pio_i2c_sm_lock(pio_t pio, pio_i2c_bus_t *i2c)
Acquire a PIO state machine of PIO pio to run the PIO I2C program.
void pio_i2c_release(pio_i2c_bus_t *bus)
Release emulated I2C bus.
void pio_i2c_stop_programs(void)
Stop PIO I2C programs configured with PIO_I2C_CONFIG.
static int pio_i2c_read_byte(pio_t pio, pio_sm_t sm, uint16_t addr, void *data, uint8_t flags)
Emulate i2c_read_byte.
int pio_i2c_read_regs(pio_t pio, pio_sm_t sm, uint16_t addr, uint16_t reg, void *data, size_t len, uint8_t flags)
Emulate i2c_read_regs.
static int pio_i2c_read_reg(pio_t pio, pio_sm_t sm, uint16_t addr, uint16_t reg, void *data, uint8_t flags)
Emulate i2c_read_reg.
void pio_i2c_deinit_program(pio_t pio)
Free a PIO I2C program.
int pio_i2c_read_bytes(pio_t pio, pio_sm_t sm, uint16_t addr, void *data, size_t len, uint8_t flags)
Emulate i2c_read_bytes.
const pio_program_i2c_t * pio_i2c_get_program(pio_t pio)
Get const I2C program reference.
int pio_i2c_init(pio_i2c_bus_t *bus, const pio_program_i2c_t *pro, gpio_t sda, gpio_t scl, unsigned irq)
Setup a state machine to run the I2C program.
struct pio_program_i2c pio_program_i2c_t
PIO I2C program type.
int pio_i2c_write_program(pio_t pio, pio_program_i2c_t *pro)
Write a PIO I2C program to instruction memory.
void pio_i2c_start_programs(void)
Start PIO I2C programs configured with PIO_I2C_CONFIG.
int pio_i2c_write_regs(pio_t pio, pio_sm_t sm, uint16_t addr, uint16_t reg, const void *data, size_t len, uint8_t flags)
Emulate i2c_write_regs.
unsigned pio_t
PIO index type.
int pio_sm_t
PIO state machine index type.
Low-level I2C peripheral driver interface definition.
Mutex for thread synchronization.
PIO I2C emulated bus type.
mutex_t mtx
Mutex to protect the bus from concurrent accesses.
pio_sm_t sm
State machine index.
unsigned ref_mask
Mask of referencing PIO state machines.
pio_program_t base
PIO base program.
Struct that models a PIO program.