Skip to content

Commit 6e8df2f

Browse files
aykevldeadprogram
authored andcommitted
samd21: define and use hardware pin numbers
1 parent 902f408 commit 6e8df2f

File tree

2 files changed

+92
-24
lines changed

2 files changed

+92
-24
lines changed

src/machine/board_itsybitsy-m0.go

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

55
// GPIO Pins
66
const (
7-
D0 = 11 // UART0 RX
8-
D1 = 10 // UART0 TX
9-
D2 = 14
10-
D3 = 9 // PWM available
11-
D4 = 8 // PWM available
12-
D5 = 15 // PWM available
13-
D6 = 20 // PWM available
14-
D7 = 21 // PWM available
15-
D8 = 6 // PWM available
16-
D9 = 7 // PWM available
17-
D10 = 18 // can be used for PWM or UART1 TX
18-
D11 = 16 // can be used for PWM or UART1 RX
19-
D12 = 19 // PWM available
20-
D13 = 17 // PWM available
7+
D0 = PA11 // UART0 RX
8+
D1 = PA10 // UART0 TX
9+
D2 = PA14
10+
D3 = PA09 // PWM available
11+
D4 = PA08 // PWM available
12+
D5 = PA15 // PWM available
13+
D6 = PA20 // PWM available
14+
D7 = PA21 // PWM available
15+
D8 = PA06 // PWM available
16+
D9 = PA07 // PWM available
17+
D10 = PA18 // can be used for PWM or UART1 TX
18+
D11 = PA16 // can be used for PWM or UART1 RX
19+
D12 = PA19 // PWM available
20+
D13 = PA17 // PWM available
2121
)
2222

2323
// Analog pins
2424
const (
25-
A0 = 2 // ADC/AIN[0]
26-
// A1 = 8 // ADC/AIN[2] TODO: requires PORTB
27-
// A2 = 9 // ADC/AIN[3] TODO: requires PORTB
28-
A3 = 4 // ADC/AIN[4]
29-
A4 = 5 // ADC/AIN[5]
30-
//A5 = 2 // ADC/AIN[10] TODO: requires PORTB
25+
A0 = PA02 // ADC/AIN[0]
26+
A1 = PB08 // ADC/AIN[2]
27+
A2 = PB09 // ADC/AIN[3]
28+
A3 = PA04 // ADC/AIN[4]
29+
A4 = PA05 // ADC/AIN[5]
30+
A5 = PB02 // ADC/AIN[10]
3131
)
3232

3333
const (
@@ -36,8 +36,8 @@ const (
3636

3737
// UART0 aka USBCDC pins
3838
const (
39-
USBCDC_DM_PIN = 24
40-
USBCDC_DP_PIN = 25
39+
USBCDC_DM_PIN = PA24
40+
USBCDC_DP_PIN = PA25
4141
)
4242

4343
// UART1 pins
@@ -48,6 +48,6 @@ const (
4848

4949
// I2C pins
5050
const (
51-
SDA_PIN = 22 // SDA: SERCOM3/PAD[0]
52-
SCL_PIN = 23 // SCL: SERCOM3/PAD[1]
51+
SDA_PIN = PA22 // SDA: SERCOM3/PAD[0]
52+
SCL_PIN = PA23 // SCL: SERCOM3/PAD[1]
5353
)

src/machine/machine_atsamd21.go

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,74 @@ const (
3636
GPIO_PWM_ALT = GPIO_TIMER_ALT
3737
)
3838

39+
// Hardware pins
40+
const (
41+
PA00 = 0
42+
PA01 = 1
43+
PA02 = 2
44+
PA03 = 3
45+
PA04 = 4
46+
PA05 = 5
47+
PA06 = 6
48+
PA07 = 7
49+
PA08 = 8
50+
PA09 = 9
51+
PA10 = 10
52+
PA11 = 11
53+
PA12 = 12
54+
PA13 = 13
55+
PA14 = 14
56+
PA15 = 15
57+
PA16 = 16
58+
PA17 = 17
59+
PA18 = 18
60+
PA19 = 19
61+
PA20 = 20
62+
PA21 = 21
63+
PA22 = 22
64+
PA23 = 23
65+
PA24 = 24
66+
PA25 = 25
67+
PA26 = 26
68+
PA27 = 27
69+
PA28 = 28
70+
PA29 = 29
71+
PA30 = 30
72+
PA31 = 31
73+
PB00 = 32
74+
PB01 = 33
75+
PB02 = 34
76+
PB03 = 35
77+
PB04 = 36
78+
PB05 = 37
79+
PB06 = 38
80+
PB07 = 39
81+
PB08 = 40
82+
PB09 = 41
83+
PB10 = 42
84+
PB11 = 43
85+
PB12 = 44
86+
PB13 = 45
87+
PB14 = 46
88+
PB15 = 47
89+
PB16 = 48
90+
PB17 = 49
91+
PB18 = 50
92+
PB19 = 51
93+
PB20 = 52
94+
PB21 = 53
95+
PB22 = 54
96+
PB23 = 55
97+
PB24 = 56
98+
PB25 = 57
99+
PB26 = 58
100+
PB27 = 59
101+
PB28 = 60
102+
PB29 = 61
103+
PB30 = 62
104+
PB31 = 63
105+
)
106+
39107
// Configure this pin with the given configuration.
40108
func (p GPIO) Configure(config GPIOConfig) {
41109
switch config.Mode {

0 commit comments

Comments
 (0)