Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type I2C ¶
type I2C struct {
// contains filtered or unexported fields
}
I2C is an I2C implementation by Software. Since it is implemented by software, it can be used with microcontrollers that do not have I2C function. This is not efficient but works around broken or missing drivers.
func New ¶
New returns the i2csoft driver. For the arguments, specify the pins to be used as SCL and SDA. As I2C is implemented in software, any GPIO pin can be specified.
func (*I2C) ReadRegister ¶
ReadRegister transmits the register, restarts the connection as a read operation, and reads the response.
Many I2C-compatible devices are organized in terms of registers. This method is a shortcut to easily read such registers. Also, it only works for devices with 7-bit addresses, which is the vast majority.
func (*I2C) SetBaudRate ¶
SetBaudRate sets the communication speed for the I2C.
func (*I2C) Tx ¶
Tx does a single I2C transaction at the specified address. It clocks out the given address, writes the bytes in w, reads back len(r) bytes and stores them in r, and generates a stop condition on the bus.
func (*I2C) WriteRegister ¶
WriteRegister transmits first the register and then the data to the peripheral device.
Many I2C-compatible devices are organized in terms of registers. This method is a shortcut to easily write to such registers. Also, it only works for devices with 7-bit addresses, which is the vast majority.