Skip to content

Commit 7b154bb

Browse files
committed
Fix I2C configuration for xiao-rp2040 and xiao-ble
1 parent 8c10c9d commit 7b154bb

File tree

3 files changed

+33
-2
lines changed

3 files changed

+33
-2
lines changed

targets/sgkey/main.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,22 @@ type RCS struct {
2929
state keyboard.State
3030
}
3131

32+
var (
33+
i2c = machine.I2C0
34+
sclPin machine.Pin
35+
sdaPin machine.Pin
36+
)
37+
3238
func run() error {
33-
machine.I2C0.Configure(machine.I2CConfig{
39+
i2c.Configure(machine.I2CConfig{
3440
Frequency: machine.TWI_FREQ_400KHZ,
41+
SCL: sclPin,
42+
SDA: sdaPin,
3543
})
3644

3745
ch := make(chan RCS, 16)
3846

39-
display := ssd1306.NewI2C(machine.I2C0)
47+
display := ssd1306.NewI2C(i2c)
4048
display.Configure(ssd1306.Config{
4149
Address: 0x3C,
4250
Width: 128,

targets/sgkey/xiao-ble.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
//go:build xiao_ble
2+
3+
package main
4+
5+
import (
6+
"machine"
7+
)
8+
9+
func init() {
10+
sclPin = machine.SCL0_PIN
11+
sdaPin = machine.SDA0_PIN
12+
}

targets/sgkey/xiao-rp2040.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
//go:build xiao_rp2040
2+
3+
package main
4+
5+
import (
6+
"machine"
7+
)
8+
9+
func init() {
10+
i2c = machine.I2C1
11+
}

0 commit comments

Comments
 (0)