Skip to main content

Module driver

Module driver 

Source
Expand description

What the drivers share: how a register-mapped part is reached over a bus.

Bosch’s BME280 and BMP280 speak one register protocol over two buses, I2C and SPI. RegisterBus names the two operations that protocol needs, a multi-byte read starting at a register and a single-byte write, and I2cRegisters and SpiRegisters implement them: over I2C the register address is written and the data read back in one transaction, over SPI bit 7 of the control byte is the read/write flag and the address increments on its own, as the BME280 datasheet’s interface chapter lays out. A driver written against the trait runs on either bus.

Texas Instruments’ parts keep 16-bit registers that travel most significant byte first over I2C; read_word and write_word are that shape.

Structs§

I2cRegisters
A register map behind an I2C address.
SpiRegisters
A register map behind an SPI chip select, in the Bosch framing.

Constants§

SPI_ADDRESS_MASK
The mask that leaves the seven address bits of a Bosch SPI control byte.
SPI_READ
The read/write flag in a Bosch SPI control byte: set to read, clear to write.

Traits§

RegisterBus
A part’s register map reached over some bus.

Functions§

read_word
Reads a 16-bit register that travels most significant byte first.
write_word
Writes a 16-bit register that travels most significant byte first.