We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 044bd8e commit b4e4528Copy full SHA for b4e4528
src/machine/machine_rp2040_i2c.go
@@ -103,21 +103,23 @@ func (i2c *I2C) Configure(config I2CConfig) error {
103
config.SDA = I2C1_SDA_PIN
104
}
105
106
- var okSDA, okSCL bool
+ var okSCL, okSDA bool
107
switch i2c.Bus {
108
case rp.I2C0:
109
- okSDA = config.SDA%4 == 0
110
- okSCL = (config.SCL+1)%4 == 0
+ okSCL = (config.SCL+3)%4 == 0
+ okSDA = (config.SDA+4)%4 == 0
111
case rp.I2C1:
112
+ okSCL = (config.SCL+1)%4 == 0
113
okSDA = (config.SDA+2)%4 == 0
- okSCL = (config.SCL+3)%4 == 0
114
115
116
- if !okSDA {
117
- return errInvalidI2CSDA
118
- } else if !okSCL {
+ switch {
+ case !okSCL:
119
return errInvalidI2CSCL
+ case !okSDA:
120
+ return errInvalidI2CSDA
121
122
+
123
if config.Frequency == 0 {
124
config.Frequency = defaultBaud
125
0 commit comments