mirror of
https://github.com/tinygo-org/drivers.git
synced 2026-08-16 21:03:23 +00:00
apply @gen2thomas suggestions
This commit is contained in:
+1
-1
@@ -38,7 +38,7 @@ func New(b drivers.SPI) *Device {
|
||||
// NewSoftwareSPI returns a new APA102 driver that will use a software based
|
||||
// implementation of the SPI protocol.
|
||||
func NewSoftwareSPI(sckPin, sdoPin legacy.PinOutput, delay uint32) *Device {
|
||||
return New(&bbSPI{SCK: sckPin.Set, SDO: sdoPin.Set, Delay: delay, config: func() {
|
||||
return New(&bbSPI{SCK: sckPin.Set, SDO: sdoPin.Set, Delay: delay, configurePins: func() {
|
||||
legacy.ConfigurePinOut(sckPin)
|
||||
legacy.ConfigurePinOut(sdoPin)
|
||||
}})
|
||||
|
||||
+6
-6
@@ -11,18 +11,18 @@ import (
|
||||
// most purposes other than the APA102 package. It might be desirable to make
|
||||
// this more generic and include it in the TinyGo "machine" package instead.
|
||||
type bbSPI struct {
|
||||
SCK drivers.PinOutput
|
||||
SDO drivers.PinOutput
|
||||
Delay uint32
|
||||
config func()
|
||||
SCK drivers.PinOutput
|
||||
SDO drivers.PinOutput
|
||||
Delay uint32
|
||||
configurePins func()
|
||||
}
|
||||
|
||||
// Configure sets up the SCK and SDO pins as outputs and sets them low
|
||||
func (s *bbSPI) Configure() {
|
||||
if s.config == nil {
|
||||
if s.configurePins == nil {
|
||||
panic(legacy.ErrConfigBeforeInstantiated)
|
||||
}
|
||||
s.config()
|
||||
s.configurePins()
|
||||
s.SCK(false)
|
||||
s.SDO(false)
|
||||
if s.Delay == 0 {
|
||||
|
||||
Reference in New Issue
Block a user