mirror of
https://github.com/tinygo-org/drivers.git
synced 2026-08-12 19:03:42 +00:00
legacy.PinOutput->pin.Output and add High+Low methods on drivers.PinOutput and use them in drivers
This commit is contained in:
committed by
deadprogram
parent
2e007a6de7
commit
8ac285e821
+4
-3
@@ -5,6 +5,7 @@ package max72xx
|
||||
import (
|
||||
"tinygo.org/x/drivers"
|
||||
"tinygo.org/x/drivers/internal/legacy"
|
||||
"tinygo.org/x/drivers/internal/pin"
|
||||
)
|
||||
|
||||
type Device struct {
|
||||
@@ -16,7 +17,7 @@ type Device struct {
|
||||
// NewDriver creates a new max7219 connection. The SPI wire must already be configured
|
||||
// The SPI frequency must not be higher than 10MHz.
|
||||
// parameter cs: the datasheet also refers to this pin as "load" pin.
|
||||
func NewDevice(bus drivers.SPI, cs legacy.PinOutput) *Device {
|
||||
func NewDevice(bus drivers.SPI, cs pin.Output) *Device {
|
||||
return &Device{
|
||||
bus: bus,
|
||||
cs: cs.Set,
|
||||
@@ -93,8 +94,8 @@ func (driver *Device) writeByte(data byte) {
|
||||
|
||||
// WriteCommand write data to a given register.
|
||||
func (driver *Device) WriteCommand(register, data byte) {
|
||||
driver.cs(false)
|
||||
driver.cs.Low()
|
||||
driver.writeByte(register)
|
||||
driver.writeByte(data)
|
||||
driver.cs(true)
|
||||
driver.cs.High()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user