tinygo.org/x/drivers@v0.27.1-0.20240509133757-7dbca2a54349/i2c.go (about)

     1  package drivers
     2  
     3  // I2C represents an I2C bus. It is notably implemented by the
     4  // machine.I2C type.
     5  type I2C interface {
     6  	// Tx performs a [I²C] transaction with address addr.
     7  	// Most I2C peripherals have some sort of register mapping scheme to allow
     8  	// users to interact with them:
     9  	//
    10  	//  bus.Tx(addr, []byte{reg}, buf) // Reads register reg into buf.
    11  	//  bus.Tx(addr, append([]byte{reg}, buf...), nil) // Writes buf into register reg.
    12  	//
    13  	// The semantics of most I2C transactions require that the w write buffer be non-empty.
    14  	//
    15  	// [I²C]: https://en.wikipedia.org/wiki/I%C2%B2C
    16  	Tx(addr uint16, w, r []byte) error
    17  }