mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-16 02:33:28 +00:00
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.
This commit is contained in:
committed by
Ron Evans
parent
7c949ad386
commit
aa5b8d0df7
@@ -56,7 +56,8 @@ const (
|
||||
|
||||
// UART1 on the ItsyBitsy M0.
|
||||
var (
|
||||
UART1 = UART{
|
||||
UART1 = &_UART1
|
||||
_UART1 = UART{
|
||||
Buffer: NewRingBuffer(),
|
||||
Bus: sam.SERCOM1_USART,
|
||||
SERCOM: 1,
|
||||
@@ -64,7 +65,7 @@ var (
|
||||
)
|
||||
|
||||
func init() {
|
||||
UART1.Interrupt = interrupt.New(sam.IRQ_SERCOM1, UART1.handleInterrupt)
|
||||
UART1.Interrupt = interrupt.New(sam.IRQ_SERCOM1, _UART1.handleInterrupt)
|
||||
}
|
||||
|
||||
// I2C pins
|
||||
|
||||
Reference in New Issue
Block a user