Skip to content

Commit b3da00a

Browse files
aykevldeadprogram
authored andcommitted
machine: add I2C pin comments
Similar to PWM, I2C can only be used on some pins. To automatically generate this information per board, we need to add extra comments that can then be interpreted by doc-gen for the tinygo.org website.
1 parent e454ad1 commit b3da00a

File tree

7 files changed

+84
-80
lines changed

7 files changed

+84
-80
lines changed

src/machine/board_atmega328p.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ const (
2727
PC1 = portC + 1
2828
PC2 = portC + 2
2929
PC3 = portC + 3
30-
PC4 = portC + 4
31-
PC5 = portC + 5
30+
PC4 = portC + 4 // peripherals: I2C0 SDA
31+
PC5 = portC + 5 // peripherals: I2C0 SCL
3232
PC6 = portC + 6
3333
PC7 = portC + 7
3434
PD0 = portD + 0

src/machine/board_atmega328pb.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ const (
2828
PC1 = portC + 1
2929
PC2 = portC + 2
3030
PC3 = portC + 3
31-
PC4 = portC + 4
32-
PC5 = portC + 5
31+
PC4 = portC + 4 // peripherals: I2C0 SDA
32+
PC5 = portC + 5 // peripherals: I2C0 SCL
3333
PC6 = portC + 6
3434
PC7 = portC + 7
3535
PD0 = portD + 0
@@ -40,8 +40,8 @@ const (
4040
PD5 = portD + 5 // peripherals: Timer0 channel B
4141
PD6 = portD + 6 // peripherals: Timer0 channel A
4242
PD7 = portD + 7
43-
PE0 = portE + 0
44-
PE1 = portE + 1
43+
PE0 = portE + 0 // peripherals: I2C1 SDA
44+
PE1 = portE + 1 // peripherals: I2C1 SCL
4545
PE2 = portE + 2
4646
PE3 = portE + 3
4747
PE4 = portE + 4

src/machine/board_atsamd21.go

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,32 +7,36 @@ func CPUFrequency() uint32 {
77
return 48000000
88
}
99

10+
// Note that the below pins have a few I2C pins listed that according to the
11+
// datasheet don't support I2C yet they are used in practice on boards from
12+
// Adafruit and Arduino. See machine_atsamd21_simulator.go for details.
13+
1014
// Hardware pins
1115
const (
12-
PA00 Pin = 0 // peripherals: TCC2 channel 0
13-
PA01 Pin = 1 // peripherals: TCC2 channel 1
16+
PA00 Pin = 0 // peripherals: TCC2 channel 0, sercomI2CM1 SDA
17+
PA01 Pin = 1 // peripherals: TCC2 channel 1, sercomI2CM1 SCL
1418
PA02 Pin = 2
1519
PA03 Pin = 3
1620
PA04 Pin = 4 // peripherals: TCC0 channel 0
1721
PA05 Pin = 5 // peripherals: TCC0 channel 1
1822
PA06 Pin = 6 // peripherals: TCC1 channel 0
1923
PA07 Pin = 7 // peripherals: TCC1 channel 1
20-
PA08 Pin = 8 // peripherals: TCC0 channel 0, TCC1 channel 2
21-
PA09 Pin = 9 // peripherals: TCC0 channel 1, TCC1 channel 3
24+
PA08 Pin = 8 // peripherals: TCC0 channel 0, TCC1 channel 2, sercomI2CM0 SDA, sercomI2CM2 SDA
25+
PA09 Pin = 9 // peripherals: TCC0 channel 1, TCC1 channel 3, sercomI2CM0 SCL, sercomI2CM2 SCL
2226
PA10 Pin = 10 // peripherals: TCC1 channel 0, TCC0 channel 2
2327
PA11 Pin = 11 // peripherals: TCC1 channel 1, TCC0 channel 3
24-
PA12 Pin = 12 // peripherals: TCC2 channel 0, TCC0 channel 2
25-
PA13 Pin = 13 // peripherals: TCC2 channel 1, TCC0 channel 3
28+
PA12 Pin = 12 // peripherals: TCC2 channel 0, TCC0 channel 2, sercomI2CM2 SDA, sercomI2CM4 SDA
29+
PA13 Pin = 13 // peripherals: TCC2 channel 1, TCC0 channel 3, sercomI2CM2 SCL, sercomI2CM4 SCL
2630
PA14 Pin = 14 // peripherals: TCC0 channel 0
2731
PA15 Pin = 15 // peripherals: TCC0 channel 1
28-
PA16 Pin = 16 // peripherals: TCC2 channel 0, TCC0 channel 2
29-
PA17 Pin = 17 // peripherals: TCC2 channel 1, TCC0 channel 3
32+
PA16 Pin = 16 // peripherals: TCC2 channel 0, TCC0 channel 2, sercomI2CM1 SDA, sercomI2CM3 SDA
33+
PA17 Pin = 17 // peripherals: TCC2 channel 1, TCC0 channel 3, sercomI2CM1 SCL, sercomI2CM3 SCL
3034
PA18 Pin = 18 // peripherals: TCC0 channel 2
3135
PA19 Pin = 19 // peripherals: TCC0 channel 3
3236
PA20 Pin = 20 // peripherals: TCC0 channel 2
3337
PA21 Pin = 21 // peripherals: TCC0 channel 3
34-
PA22 Pin = 22 // peripherals: TCC0 channel 0
35-
PA23 Pin = 23 // peripherals: TCC0 channel 1
38+
PA22 Pin = 22 // peripherals: TCC0 channel 0, sercomI2CM3 SDA, sercomI2CM5 SDA
39+
PA23 Pin = 23 // peripherals: TCC0 channel 1, sercomI2CM3 SCL, sercomI2CM5 SCL
3640
PA24 Pin = 24 // peripherals: TCC1 channel 2
3741
PA25 Pin = 25 // peripherals: TCC1 channel 3
3842
PA26 Pin = 26
@@ -43,22 +47,22 @@ const (
4347
PA31 Pin = 31 // peripherals: TCC1 channel 1
4448
PB00 Pin = 32
4549
PB01 Pin = 33
46-
PB02 Pin = 34
47-
PB03 Pin = 35
50+
PB02 Pin = 34 // peripherals: sercomI2CM5 SDA
51+
PB03 Pin = 35 // peripherals: sercomI2CM5 SCL
4852
PB04 Pin = 36
4953
PB05 Pin = 37
5054
PB06 Pin = 38
5155
PB07 Pin = 39
52-
PB08 Pin = 40
53-
PB09 Pin = 41
56+
PB08 Pin = 40 // peripherals: sercomI2CM4 SDA
57+
PB09 Pin = 41 // peripherals: sercomI2CM4 SCL
5458
PB10 Pin = 42 // peripherals: TCC0 channel 0
5559
PB11 Pin = 43 // peripherals: TCC0 channel 1
56-
PB12 Pin = 44 // peripherals: TCC0 channel 2
57-
PB13 Pin = 45 // peripherals: TCC0 channel 3
60+
PB12 Pin = 44 // peripherals: TCC0 channel 2, sercomI2CM4 SDA
61+
PB13 Pin = 45 // peripherals: TCC0 channel 3, sercomI2CM4 SCL
5862
PB14 Pin = 46
5963
PB15 Pin = 47
60-
PB16 Pin = 48 // peripherals: TCC0 channel 0
61-
PB17 Pin = 49 // peripherals: TCC0 channel 1
64+
PB16 Pin = 48 // peripherals: TCC0 channel 0, sercomI2CM5 SDA
65+
PB17 Pin = 49 // peripherals: TCC0 channel 1, sercomI2CM5 SCL
6266
PB18 Pin = 50
6367
PB19 Pin = 51
6468
PB20 Pin = 52
@@ -71,6 +75,6 @@ const (
7175
PB27 Pin = 59
7276
PB28 Pin = 60
7377
PB29 Pin = 61
74-
PB30 Pin = 62 // peripherals: TCC0 channel 0, TCC1 channel 2
75-
PB31 Pin = 63 // peripherals: TCC0 channel 1, TCC1 channel 3
78+
PB30 Pin = 62 // peripherals: TCC0 channel 0, TCC1 channel 2, sercomI2CM5 SDA
79+
PB31 Pin = 63 // peripherals: TCC0 channel 1, TCC1 channel 3, sercomI2CM5 SCL
7680
)

src/machine/machine_atmega1280.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ const (
4949
PC5 = portC + 5
5050
PC6 = portC + 6
5151
PC7 = portC + 7
52-
PD0 = portD + 0
53-
PD1 = portD + 1
52+
PD0 = portD + 0 // peripherals: I2C0 SCL
53+
PD1 = portD + 1 // peripherals: I2C0 SDA
5454
PD2 = portD + 2
5555
PD3 = portD + 3
5656
PD7 = portD + 7

src/machine/machine_atsamd51.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -81,22 +81,22 @@ const (
8181
PA05 Pin = 5
8282
PA06 Pin = 6
8383
PA07 Pin = 7
84-
PA08 Pin = 8 // peripherals: TCC0 channel 0, TCC1 channel 4
85-
PA09 Pin = 9 // peripherals: TCC0 channel 1, TCC1 channel 5
84+
PA08 Pin = 8 // peripherals: TCC0 channel 0, TCC1 channel 4, sercomI2CM0 SDA, sercomI2CM2 SDA
85+
PA09 Pin = 9 // peripherals: TCC0 channel 1, TCC1 channel 5, sercomI2CM0 SCL, sercomI2CM2 SCL
8686
PA10 Pin = 10 // peripherals: TCC0 channel 2, TCC1 channel 6
8787
PA11 Pin = 11 // peripherals: TCC0 channel 3, TCC1 channel 7
88-
PA12 Pin = 12 // peripherals: TCC0 channel 6, TCC1 channel 2
89-
PA13 Pin = 13 // peripherals: TCC0 channel 7, TCC1 channel 3
88+
PA12 Pin = 12 // peripherals: TCC0 channel 6, TCC1 channel 2, sercomI2CM2 SDA, sercomI2CM4 SDA
89+
PA13 Pin = 13 // peripherals: TCC0 channel 7, TCC1 channel 3, sercomI2CM2 SCL, sercomI2CM4 SCL
9090
PA14 Pin = 14 // peripherals: TCC2 channel 0, TCC1 channel 2
9191
PA15 Pin = 15 // peripherals: TCC2 channel 1, TCC1 channel 3
92-
PA16 Pin = 16 // peripherals: TCC1 channel 0, TCC0 channel 4
93-
PA17 Pin = 17 // peripherals: TCC1 channel 1, TCC0 channel 5
92+
PA16 Pin = 16 // peripherals: TCC1 channel 0, TCC0 channel 4, sercomI2CM1 SDA, sercomI2CM3 SDA
93+
PA17 Pin = 17 // peripherals: TCC1 channel 1, TCC0 channel 5, sercomI2CM1 SCL, sercomI2CM3 SCL
9494
PA18 Pin = 18 // peripherals: TCC1 channel 2, TCC0 channel 6
9595
PA19 Pin = 19 // peripherals: TCC1 channel 3, TCC0 channel 7
9696
PA20 Pin = 20 // peripherals: TCC1 channel 4, TCC0 channel 0
9797
PA21 Pin = 21 // peripherals: TCC1 channel 5, TCC0 channel 1
98-
PA22 Pin = 22 // peripherals: TCC1 channel 6, TCC0 channel 2
99-
PA23 Pin = 23 // peripherals: TCC1 channel 7, TCC0 channel 3
98+
PA22 Pin = 22 // peripherals: TCC1 channel 6, TCC0 channel 2, sercomI2CM3 SDA, sercomI2CM5 SDA
99+
PA23 Pin = 23 // peripherals: TCC1 channel 7, TCC0 channel 3, sercomI2CM3 SCL, sercomI2CM5 SCL
100100
PA24 Pin = 24 // peripherals: TCC2 channel 2
101101
PA25 Pin = 25 // peripherals: TCC2 channel 3
102102
PA26 Pin = 26
@@ -177,8 +177,8 @@ const (
177177
PD05 Pin = 101
178178
PD06 Pin = 102
179179
PD07 Pin = 103
180-
PD08 Pin = 104 // peripherals: TCC0 channel 1
181-
PD09 Pin = 105 // peripherals: TCC0 channel 2
180+
PD08 Pin = 104 // peripherals: TCC0 channel 1, sercomI2CM6 SDA, sercomI2CM7 SDA
181+
PD09 Pin = 105 // peripherals: TCC0 channel 2, sercomI2CM6 SCL, sercomI2CM7 SCL
182182
PD10 Pin = 106 // peripherals: TCC0 channel 3
183183
PD11 Pin = 107 // peripherals: TCC0 channel 4
184184
PD12 Pin = 108 // peripherals: TCC0 channel 5

src/machine/machine_rp2_2350b.go

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,24 @@ package machine
55
// RP2350B has additional pins.
66

77
const (
8-
GPIO30 Pin = 30 // peripherals: PWM7 channel A
9-
GPIO31 Pin = 31 // peripherals: PWM7 channel B
10-
GPIO32 Pin = 32 // peripherals: PWM8 channel A
11-
GPIO33 Pin = 33 // peripherals: PWM8 channel B
12-
GPIO34 Pin = 34 // peripherals: PWM9 channel A
13-
GPIO35 Pin = 35 // peripherals: PWM9 channel B
14-
GPIO36 Pin = 36 // peripherals: PWM10 channel A
15-
GPIO37 Pin = 37 // peripherals: PWM10 channel B
16-
GPIO38 Pin = 38 // peripherals: PWM11 channel A
17-
GPIO39 Pin = 39 // peripherals: PWM11 channel B
18-
GPIO40 Pin = 40 // peripherals: PWM8 channel A
19-
GPIO41 Pin = 41 // peripherals: PWM8 channel B
20-
GPIO42 Pin = 42 // peripherals: PWM9 channel A
21-
GPIO43 Pin = 43 // peripherals: PWM9 channel B
22-
GPIO44 Pin = 44 // peripherals: PWM10 channel A
23-
GPIO45 Pin = 45 // peripherals: PWM10 channel B
24-
GPIO46 Pin = 46 // peripherals: PWM11 channel A
25-
GPIO47 Pin = 47 // peripherals: PWM11 channel B
8+
GPIO30 Pin = 30 // peripherals: PWM7 channel A, I2C1 SDA
9+
GPIO31 Pin = 31 // peripherals: PWM7 channel B, I2C1 SCL
10+
GPIO32 Pin = 32 // peripherals: PWM8 channel A, I2C0 SDA
11+
GPIO33 Pin = 33 // peripherals: PWM8 channel B, I2C0 SCL
12+
GPIO34 Pin = 34 // peripherals: PWM9 channel A, I2C1 SDA
13+
GPIO35 Pin = 35 // peripherals: PWM9 channel B, I2C1 SCL
14+
GPIO36 Pin = 36 // peripherals: PWM10 channel A, I2C0 SDA
15+
GPIO37 Pin = 37 // peripherals: PWM10 channel B, I2C0 SCL
16+
GPIO38 Pin = 38 // peripherals: PWM11 channel A, I2C1 SDA
17+
GPIO39 Pin = 39 // peripherals: PWM11 channel B, I2C1 SCL
18+
GPIO40 Pin = 40 // peripherals: PWM8 channel A, I2C0 SDA
19+
GPIO41 Pin = 41 // peripherals: PWM8 channel B, I2C0 SCL
20+
GPIO42 Pin = 42 // peripherals: PWM9 channel A, I2C1 SDA
21+
GPIO43 Pin = 43 // peripherals: PWM9 channel B, I2C1 SCL
22+
GPIO44 Pin = 44 // peripherals: PWM10 channel A, I2C0 SDA
23+
GPIO45 Pin = 45 // peripherals: PWM10 channel B, I2C0 SCL
24+
GPIO46 Pin = 46 // peripherals: PWM11 channel A, I2C1 SDA
25+
GPIO47 Pin = 47 // peripherals: PWM11 channel B, I2C1 SCL
2626
)
2727

2828
// Analog pins on 2350b.

src/machine/machine_rp2_pins.go

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4,34 +4,34 @@ package machine
44

55
const (
66
// GPIO pins
7-
GPIO0 Pin = 0 // peripherals: PWM0 channel A
8-
GPIO1 Pin = 1 // peripherals: PWM0 channel B
9-
GPIO2 Pin = 2 // peripherals: PWM1 channel A
10-
GPIO3 Pin = 3 // peripherals: PWM1 channel B
11-
GPIO4 Pin = 4 // peripherals: PWM2 channel A
12-
GPIO5 Pin = 5 // peripherals: PWM2 channel B
13-
GPIO6 Pin = 6 // peripherals: PWM3 channel A
14-
GPIO7 Pin = 7 // peripherals: PWM3 channel B
15-
GPIO8 Pin = 8 // peripherals: PWM4 channel A
16-
GPIO9 Pin = 9 // peripherals: PWM4 channel B
17-
GPIO10 Pin = 10 // peripherals: PWM5 channel A
18-
GPIO11 Pin = 11 // peripherals: PWM5 channel B
19-
GPIO12 Pin = 12 // peripherals: PWM6 channel A
20-
GPIO13 Pin = 13 // peripherals: PWM6 channel B
21-
GPIO14 Pin = 14 // peripherals: PWM7 channel A
22-
GPIO15 Pin = 15 // peripherals: PWM7 channel B
23-
GPIO16 Pin = 16 // peripherals: PWM0 channel A
24-
GPIO17 Pin = 17 // peripherals: PWM0 channel B
25-
GPIO18 Pin = 18 // peripherals: PWM1 channel A
26-
GPIO19 Pin = 19 // peripherals: PWM1 channel B
27-
GPIO20 Pin = 20 // peripherals: PWM2 channel A
28-
GPIO21 Pin = 21 // peripherals: PWM2 channel B
7+
GPIO0 Pin = 0 // peripherals: PWM0 channel A, I2C0 SDA
8+
GPIO1 Pin = 1 // peripherals: PWM0 channel B, I2C0 SCL
9+
GPIO2 Pin = 2 // peripherals: PWM1 channel A, I2C1 SDA
10+
GPIO3 Pin = 3 // peripherals: PWM1 channel B, I2C1 SCL
11+
GPIO4 Pin = 4 // peripherals: PWM2 channel A, I2C0 SDA
12+
GPIO5 Pin = 5 // peripherals: PWM2 channel B, I2C0 SCL
13+
GPIO6 Pin = 6 // peripherals: PWM3 channel A, I2C1 SDA
14+
GPIO7 Pin = 7 // peripherals: PWM3 channel B, I2C1 SCL
15+
GPIO8 Pin = 8 // peripherals: PWM4 channel A, I2C0 SDA
16+
GPIO9 Pin = 9 // peripherals: PWM4 channel B, I2C0 SCL
17+
GPIO10 Pin = 10 // peripherals: PWM5 channel A, I2C1 SDA
18+
GPIO11 Pin = 11 // peripherals: PWM5 channel B, I2C1 SCL
19+
GPIO12 Pin = 12 // peripherals: PWM6 channel A, I2C0 SDA
20+
GPIO13 Pin = 13 // peripherals: PWM6 channel B, I2C0 SCL
21+
GPIO14 Pin = 14 // peripherals: PWM7 channel A, I2C1 SDA
22+
GPIO15 Pin = 15 // peripherals: PWM7 channel B, I2C1 SCL
23+
GPIO16 Pin = 16 // peripherals: PWM0 channel A, I2C0 SDA
24+
GPIO17 Pin = 17 // peripherals: PWM0 channel B, I2C0 SCL
25+
GPIO18 Pin = 18 // peripherals: PWM1 channel A, I2C1 SDA
26+
GPIO19 Pin = 19 // peripherals: PWM1 channel B, I2C1 SCL
27+
GPIO20 Pin = 20 // peripherals: PWM2 channel A, I2C0 SDA
28+
GPIO21 Pin = 21 // peripherals: PWM2 channel B, I2C0 SCL
2929
GPIO22 Pin = 22 // peripherals: PWM3 channel A
3030
GPIO23 Pin = 23 // peripherals: PWM3 channel B
3131
GPIO24 Pin = 24 // peripherals: PWM4 channel A
3232
GPIO25 Pin = 25 // peripherals: PWM4 channel B
33-
GPIO26 Pin = 26 // peripherals: PWM5 channel A
34-
GPIO27 Pin = 27 // peripherals: PWM5 channel B
33+
GPIO26 Pin = 26 // peripherals: PWM5 channel A, I2C1 SDA
34+
GPIO27 Pin = 27 // peripherals: PWM5 channel B, I2C1 SCL
3535
GPIO28 Pin = 28 // peripherals: PWM6 channel A
3636
GPIO29 Pin = 29 // peripherals: PWM6 channel B
3737
)

0 commit comments

Comments
 (0)