diff --git a/src/machine/machine_nrf.go b/src/machine/machine_nrf.go index cc68c1d916..0ed3771be5 100644 --- a/src/machine/machine_nrf.go +++ b/src/machine/machine_nrf.go @@ -171,7 +171,7 @@ var ( ) // Configure the UART. -func (uart *UART) Configure(config UARTConfig) { +func (uart *UART) Configure(config UARTConfig) error { // Default baud rate to 115200. if config.BaudRate == 0 { config.BaudRate = 115200 @@ -196,6 +196,8 @@ func (uart *UART) Configure(config UARTConfig) { intr := interrupt.New(nrf.IRQ_UART0, _UART0.handleInterrupt) intr.SetPriority(0xc0) // low priority intr.Enable() + + return nil } // SetBaudRate sets the communication speed for the UART. diff --git a/src/machine/serial.go b/src/machine/serial.go index fd02d6ca00..9c994d2a32 100644 --- a/src/machine/serial.go +++ b/src/machine/serial.go @@ -44,3 +44,13 @@ func (ns NullSerial) Buffered() int { func (ns NullSerial) Write(p []byte) (n int, err error) { return len(p), nil } + +type Serialer interface { + WriteByte(c byte) error + Write(data []byte) (n int, err error) + Configure(config UARTConfig) error + Buffered() int + ReadByte() (byte, error) + DTR() bool + RTS() bool +} diff --git a/src/machine/uart.go b/src/machine/uart.go index eeeb7d6a0b..7c0297a413 100644 --- a/src/machine/uart.go +++ b/src/machine/uart.go @@ -23,6 +23,8 @@ const ( ParityOdd ) +var _ Serialer = (*UART)(nil) + // To implement the UART interface for a board, you must declare a concrete type as follows: // // type UART struct { @@ -104,3 +106,13 @@ func (uart *UART) Buffered() int { func (uart *UART) Receive(data byte) { uart.Buffer.Put(data) } + +func (uart *UART) DTR() bool { + // Not Implemented ... part of machine.Serialer interface + return false +} + +func (uart *UART) RTS() bool { + // Not Implemented ... part of machine.Serialer interface + return false +} diff --git a/src/machine/usb.go b/src/machine/usb.go index c114e70956..8e16b9789d 100644 --- a/src/machine/usb.go +++ b/src/machine/usb.go @@ -19,16 +19,6 @@ var ( USBCDC Serialer ) -type Serialer interface { - WriteByte(c byte) error - Write(data []byte) (n int, err error) - Configure(config UARTConfig) error - Buffered() int - ReadByte() (byte, error) - DTR() bool - RTS() bool -} - var usbDescriptor descriptor.Descriptor func usbVendorID() uint16 {