aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/machine/board_itsybitsy-m0.go
blob: 0d7248c6260fb70790ae024eaae7e828682ccf93 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
// +build sam,atsamd21,itsybitsy_m0

package machine

import (
	"device/sam"
)

// used to reset into bootloader
const RESET_MAGIC_VALUE = 0xf01669ef

// GPIO Pins
const (
	D0  = PA11 // UART0 RX
	D1  = PA10 // UART0 TX
	D2  = PA14
	D3  = PA09 // PWM available
	D4  = PA08 // PWM available
	D5  = PA15 // PWM available
	D6  = PA20 // PWM available
	D7  = PA21 // PWM available
	D8  = PA06 // PWM available
	D9  = PA07 // PWM available
	D10 = PA18 // can be used for PWM or UART1 TX
	D11 = PA16 // can be used for PWM or UART1 RX
	D12 = PA19 // PWM available
	D13 = PA17 // PWM available
)

// Analog pins
const (
	A0 = PA02 // ADC/AIN[0]
	A1 = PB08 // ADC/AIN[2]
	A2 = PB09 // ADC/AIN[3]
	A3 = PA04 // ADC/AIN[4]
	A4 = PA05 // ADC/AIN[5]
	A5 = PB02 // ADC/AIN[10]
)

const (
	LED = D13
)

// UART0 aka USBCDC pins
const (
	USBCDC_DM_PIN = PA24
	USBCDC_DP_PIN = PA25
)

// UART1 pins
const (
	UART_TX_PIN = D10
	UART_RX_PIN = D11
)

// UART1 on the ItsyBitsy M0.
var (
	UART1 = UART{Bus: sam.SERCOM1_USART,
		Buffer: NewRingBuffer(),
		Mode:   PinSERCOM,
		IRQVal: sam.IRQ_SERCOM1,
	}
)

//go:export SERCOM1_IRQHandler
func handleUART1() {
	defaultUART1Handler()
}

// I2C pins
const (
	SDA_PIN = PA22 // SDA: SERCOM3/PAD[0]
	SCL_PIN = PA23 // SCL: SERCOM3/PAD[1]
)

// I2C on the ItsyBitsy M0.
var (
	I2C0 = I2C{
		Bus:    sam.SERCOM3_I2CM,
		SERCOM: 3,
	}
)

// SPI pins
const (
	SPI0_SCK_PIN  = PB11 // SCK: SERCOM4/PAD[3]
	SPI0_MOSI_PIN = PB10 // MOSI: SERCOM4/PAD[2]
	SPI0_MISO_PIN = PA12 // MISO: SERCOM4/PAD[0]
)

// SPI on the ItsyBitsy M0.
var (
	SPI0 = SPI{
		Bus:    sam.SERCOM4_SPI,
		SERCOM: 4,
	}
)

// "Internal" SPI pins; SPI flash is attached to these on ItsyBitsy M0
const (
	SPI1_CS_PIN   = PA27
	SPI1_SCK_PIN  = PB23
	SPI1_MOSI_PIN = PB22
	SPI1_MISO_PIN = PB03
)

// "Internal" SPI on Sercom 5
var (
	SPI1 = SPI{
		Bus:    sam.SERCOM5_SPI,
		SERCOM: 5,
	}
)

// I2S pins
const (
	I2S_SCK_PIN = PA10
	I2S_SD_PIN  = PA08
	I2S_WS_PIN  = NoPin // TODO: figure out what this is on ItsyBitsy M0.
)

// I2S on the ItsyBitsy M0.
var (
	I2S0 = I2S{Bus: sam.I2S}
)