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:
Ayke van Laethem
2021-05-13 12:32:12 +02:00
committed by Ron Evans
parent 7c949ad386
commit aa5b8d0df7
46 changed files with 246 additions and 179 deletions
+6 -4
View File
@@ -57,7 +57,8 @@ const (
var (
// Console UART (LPUSART1)
UART0 = UART{
UART0 = &_UART0
_UART0 = UART{
Buffer: NewRingBuffer(),
Bus: stm32.LPUART1,
TxAltFuncSelector: 6,
@@ -65,7 +66,8 @@ var (
}
// Gps UART
UART1 = UART{
UART1 = &_UART1
_UART1 = UART{
Buffer: NewRingBuffer(),
Bus: stm32.USART1,
TxAltFuncSelector: 0,
@@ -88,6 +90,6 @@ var (
func init() {
// Enable UARTs Interrupts
UART0.Interrupt = interrupt.New(stm32.IRQ_AES_RNG_LPUART1, UART0.handleInterrupt)
UART1.Interrupt = interrupt.New(stm32.IRQ_USART1, UART1.handleInterrupt)
UART0.Interrupt = interrupt.New(stm32.IRQ_AES_RNG_LPUART1, _UART0.handleInterrupt)
UART1.Interrupt = interrupt.New(stm32.IRQ_USART1, _UART1.handleInterrupt)
}