Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions espat/espat.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,17 @@ package espat // import "tinygo.org/x/drivers/espat"

import (
"errors"
"machine"
"strconv"
"strings"
"time"

"tinygo.org/x/drivers"
"tinygo.org/x/drivers/net"
)

// Device wraps UART connection to the ESP8266/ESP32.
type Device struct {
bus machine.UART
bus drivers.UART

// command responses that come back from the ESP8266/ESP32
response []byte
Expand All @@ -43,7 +43,7 @@ type Device struct {
var ActiveDevice *Device

// New returns a new espat driver. Pass in a fully configured UART bus.
func New(b machine.UART) *Device {
func New(b drivers.UART) *Device {
return &Device{bus: b, response: make([]byte, 512), socketdata: make([]byte, 0, 1024)}
}

Expand Down
5 changes: 2 additions & 3 deletions gps/gps.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ package gps // import "tinygo.org/x/drivers/gps"
import (
"encoding/hex"
"errors"
"machine"
"strings"
"time"

Expand All @@ -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),
Expand Down
12 changes: 12 additions & 0 deletions uart.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package drivers

import "io"

// UART represents a UART connection. It is implemented by the machine.UART
// type.
type UART interface {
io.Reader
io.Writer

Buffered() int
}