tinygo/src/machine/board_pyportal_baremetal.go
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

38 строки
506 Б
Go

// +build sam,atsamd51,pyportal
package machine
import (
"device/sam"
"runtime/interrupt"
)
var (
UART1 = &_UART1
_UART1 = UART{
Buffer: NewRingBuffer(),
Bus: sam.SERCOM4_USART_INT,
SERCOM: 4,
}
)
func init() {
UART1.Interrupt = interrupt.New(sam.IRQ_SERCOM4_2, _UART1.handleInterrupt)
}
// I2C on the PyPortal.
var (
I2C0 = &I2C{
Bus: sam.SERCOM5_I2CM,
SERCOM: 5,
}
)
// SPI on the PyPortal.
var (
SPI0 = SPI{
Bus: sam.SERCOM2_SPIM,
SERCOM: 2,
}
NINA_SPI = SPI0
)