Files
tinygo/src/machine/board_arduino_nano33_baremetal.go
T
Ayke van Laethem aa5b8d0df7 machine: make UART objects pointer receivers
This means that machine.UART0, machine.UART1, etc are of type
*machine.UART, not machine.UART. This makes them easier to pass around
and avoids surprises when they are passed around by value while they
should be passed around by reference.

There is a small code size impact in some cases, but it is relatively
minor.
2021-05-13 16:43:37 +02:00

64 lines
1.0 KiB
Go

// +build sam,atsamd21,arduino_nano33
package machine
import (
"device/sam"
"runtime/interrupt"
)
// UART1 on the Arduino Nano 33 connects to the onboard NINA-W102 WiFi chip.
var (
UART1 = &_UART1
_UART1 = UART{
Buffer: NewRingBuffer(),
Bus: sam.SERCOM3_USART,
SERCOM: 3,
}
)
// UART2 on the Arduino Nano 33 connects to the normal TX/RX pins.
var (
UART2 = &_UART2
_UART2 = UART{
Buffer: NewRingBuffer(),
Bus: sam.SERCOM5_USART,
SERCOM: 5,
}
)
func init() {
UART1.Interrupt = interrupt.New(sam.IRQ_SERCOM3, _UART1.handleInterrupt)
UART2.Interrupt = interrupt.New(sam.IRQ_SERCOM5, _UART2.handleInterrupt)
}
// I2C on the Arduino Nano 33.
var (
I2C0 = &I2C{
Bus: sam.SERCOM4_I2CM,
SERCOM: 4,
}
)
// SPI on the Arduino Nano 33.
var (
SPI0 = SPI{
Bus: sam.SERCOM1_SPI,
SERCOM: 1,
}
)
// SPI1 is connected to the NINA-W102 chip on the Arduino Nano 33.
var (
SPI1 = SPI{
Bus: sam.SERCOM2_SPI,
SERCOM: 2,
}
NINA_SPI = SPI1
)
// I2S on the Arduino Nano 33.
var (
I2S0 = I2S{Bus: sam.I2S}
)