mirror of
https://github.com/tinygo-org/drivers.git
synced 2026-08-14 03:43:42 +00:00
all: use interfaces for UART objects
This makes it possible to replace UART objects with dummy implementations, for example. Or allows changing the `machine.UART` type to `*machine.UART` without breaking compatibility.
This commit is contained in:
committed by
Ron Evans
parent
1345bc2161
commit
e77e9249cd
+2
-3
@@ -4,7 +4,6 @@ package gps // import "tinygo.org/x/drivers/gps"
|
||||
import (
|
||||
"encoding/hex"
|
||||
"errors"
|
||||
"machine"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
@@ -21,13 +20,13 @@ type Device struct {
|
||||
buffer []byte
|
||||
bufIdx int
|
||||
sentence strings.Builder
|
||||
uart *machine.UART
|
||||
uart drivers.UART
|
||||
bus drivers.I2C
|
||||
address uint16
|
||||
}
|
||||
|
||||
// NewUART creates a new UART GPS connection. The UART must already be configured.
|
||||
func NewUART(uart *machine.UART) Device {
|
||||
func NewUART(uart drivers.UART) Device {
|
||||
return Device{
|
||||
uart: uart,
|
||||
buffer: make([]byte, bufferSize),
|
||||
|
||||
Reference in New Issue
Block a user