diff options
author | Ayke van Laethem <[email protected]> | 2021-05-13 12:32:12 +0200 |
---|---|---|
committer | Ron Evans <[email protected]> | 2021-05-13 16:43:37 +0200 |
commit | aa5b8d0df733330147fb7cc2912a9c4fb44a8b47 (patch) | |
tree | 8455be579dde2e4398cb6bd4494d0267d1860f8e /src/machine/machine_atsamd51.go | |
parent | 7c949ad386ef36eb0be100eb54a4190740f6f24d (diff) | |
download | tinygo-aa5b8d0df733330147fb7cc2912a9c4fb44a8b47.tar.gz tinygo-aa5b8d0df733330147fb7cc2912a9c4fb44a8b47.zip |
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.
Diffstat (limited to 'src/machine/machine_atsamd51.go')
-rw-r--r-- | src/machine/machine_atsamd51.go | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/machine/machine_atsamd51.go b/src/machine/machine_atsamd51.go index f21d0173d..4b6333896 100644 --- a/src/machine/machine_atsamd51.go +++ b/src/machine/machine_atsamd51.go @@ -961,7 +961,7 @@ const ( ) // Configure the UART. -func (uart UART) Configure(config UARTConfig) error { +func (uart *UART) Configure(config UARTConfig) error { // Default baud rate to 115200. if config.BaudRate == 0 { config.BaudRate = 115200 @@ -1064,7 +1064,7 @@ func (uart UART) Configure(config UARTConfig) error { } // SetBaudRate sets the communication speed for the UART. -func (uart UART) SetBaudRate(br uint32) { +func (uart *UART) SetBaudRate(br uint32) { // Asynchronous fractional mode (Table 24-2 in datasheet) // BAUD = fref / (sampleRateValue * fbaud) // (multiply by 8, to calculate fractional piece) @@ -1078,7 +1078,7 @@ func (uart UART) SetBaudRate(br uint32) { } // WriteByte writes a byte of data to the UART. -func (uart UART) WriteByte(c byte) error { +func (uart *UART) WriteByte(c byte) error { // wait until ready to receive for !uart.Bus.INTFLAG.HasBits(sam.SERCOM_USART_INT_INTFLAG_DRE) { } |