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
+3 -2
View File
@@ -1228,12 +1228,13 @@ func (i2c *I2C) Configure(config I2CConfig) error {
return nil
}
// SetBaudRate sets the communication speed for the I2C.
func (i2c *I2C) SetBaudRate(br uint32) {
// SetBaudRate sets the communication speed for I2C.
func (i2c *I2C) SetBaudRate(br uint32) error {
// Synchronous arithmetic baudrate, via Adafruit SAMD51 implementation:
// sercom->I2CM.BAUD.bit.BAUD = SERCOM_FREQ_REF / ( 2 * baudrate) - 1 ;
baud := SERCOM_FREQ_REF/(2*br) - 1
i2c.Bus.BAUD.Set(baud)
return nil
}
// Tx does a single I2C transaction at the specified address.