mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-15 08:23:41 +00:00
i2c: implement target mode for rp2040 and nrf
This commit is contained in:
@@ -23,6 +23,37 @@ var (
|
||||
errI2CSignalStopTimeout = errors.New("I2C timeout on signal stop")
|
||||
errI2CAckExpected = errors.New("I2C error: expected ACK not NACK")
|
||||
errI2CBusError = errors.New("I2C bus error")
|
||||
errI2COverflow = errors.New("I2C receive buffer overflow")
|
||||
errI2COverread = errors.New("I2C transmit buffer overflow")
|
||||
)
|
||||
|
||||
// I2CTargetEvent reflects events on the I2C bus
|
||||
type I2CTargetEvent uint8
|
||||
|
||||
const (
|
||||
// I2CReceive indicates target has received a message from the controller.
|
||||
I2CReceive I2CTargetEvent = iota
|
||||
|
||||
// I2CRequest indicates the controller is expecting a message from the target.
|
||||
I2CRequest
|
||||
|
||||
// I2CFinish indicates the controller has ended the transaction.
|
||||
//
|
||||
// I2C controllers can chain multiple receive/request messages without
|
||||
// relinquishing the bus by doing 'restarts'. I2CFinish indicates the
|
||||
// bus has been relinquished by an I2C 'stop'.
|
||||
I2CFinish
|
||||
)
|
||||
|
||||
// I2CMode determines if an I2C peripheral is in Controller or Target mode.
|
||||
type I2CMode int
|
||||
|
||||
const (
|
||||
// I2CModeController represents an I2C peripheral in controller mode.
|
||||
I2CModeController I2CMode = iota
|
||||
|
||||
// I2CModeTarget represents an I2C peripheral in target mode.
|
||||
I2CModeTarget
|
||||
)
|
||||
|
||||
// WriteRegister transmits first the register and then the data to the
|
||||
|
||||
Reference in New Issue
Block a user