generic<C: I2cChip> struct I2cBus {
&volatile unsigned int base;
unsigned int speed;
C chip;
}Fields
MMIO base address
bus speed in Hz
Methods
§
static struct I2cBus<C> new(
&volatile unsigned int base,
unsigned int speed,
unsigned int clock_hz,
)source · definitionInitialize an I2C master at base for speed Hz, from a clock_hz
peripheral clock (STM32: the APB1 clock; ignored by I2cGeneric). The chip
type comes from the target.
Write data to the 7-bit address addr. Returns I2C_OK on success.
Read data.len bytes into data from device at addr. Returns I2C_OK on success.
§
int write_read(unsigned char addr, []const unsigned char wr, []unsigned char rd)source · definitionWrite, then read (e.g. a register address, then its value). Returns I2C_OK on success.
Probe: address the device with no data. Returns 1 if it acknowledges.