machine/i2c: add interface check and implementation where missing for SetBaudRate() (#3406)

* machine/i2c: add interface check and placeholder implementation where missing for SetBaudRate()
This commit is contained in:
Ron Evans
2023-10-14 13:17:24 +02:00
committed by GitHub
parent 72b715fa99
commit 935a293106
11 changed files with 104 additions and 42 deletions
+9
View File
@@ -107,6 +107,12 @@ func (i2c *I2C) Configure(config I2CConfig) error {
return nil
}
// SetBaudRate sets the I2C frequency.
func (i2c *I2C) SetBaudRate(br uint32) error {
i2cSetBaudRate(i2c.Bus, br)
return nil
}
// Tx does a single I2C transaction at the specified address.
func (i2c *I2C) Tx(addr uint16, w, r []byte) error {
i2cTransfer(i2c.Bus, &w[0], len(w), &r[0], len(r))
@@ -117,6 +123,9 @@ func (i2c *I2C) Tx(addr uint16, w, r []byte) error {
//export __tinygo_i2c_configure
func i2cConfigure(bus uint8, scl Pin, sda Pin)
//export __tinygo_i2c_set_baud_rate
func i2cSetBaudRate(bus uint8, br uint32)
//export __tinygo_i2c_transfer
func i2cTransfer(bus uint8, w *byte, wlen int, r *byte, rlen int) int