Compare commits

...

1 Commits

Author SHA1 Message Date
BCG 277b3f71e3 Added no-op io.Reader implementation to machine.NullSerial 2022-01-29 15:19:25 -05:00
2 changed files with 17 additions and 3 deletions
+2 -2
View File
@@ -10,7 +10,7 @@ import (
"unsafe" "unsafe"
) )
type io struct { type rpio struct {
status volatile.Register32 status volatile.Register32
ctrl volatile.Register32 ctrl volatile.Register32
} }
@@ -22,7 +22,7 @@ type irqCtrl struct {
} }
type ioBank0Type struct { type ioBank0Type struct {
io [30]io io [30]rpio
intR [4]volatile.Register32 intR [4]volatile.Register32
proc0IRQctrl irqCtrl proc0IRQctrl irqCtrl
proc1IRQctrl irqCtrl proc1IRQctrl irqCtrl
+15 -1
View File
@@ -1,6 +1,9 @@
package machine package machine
import "errors" import (
"errors"
"io"
)
var errNoByte = errors.New("machine: no byte read") var errNoByte = errors.New("machine: no byte read")
@@ -44,3 +47,14 @@ func (ns NullSerial) Buffered() int {
func (ns NullSerial) Write(p []byte) (n int, err error) { func (ns NullSerial) Write(p []byte) (n int, err error) {
return len(p), nil return len(p), nil
} }
// Read is a no-op; always returns that zero bytes were read with no error
func (ns NullSerial) Read(p []byte) (n int, err error) {
return 0, nil
}
// type check to ensure NullSerial implements interfaces for drivers.UART
var (
_ io.Reader = NullSerial{}
_ io.Writer = NullSerial{}
)