mirror of
https://github.com/tinygo-org/drivers.git
synced 2026-08-19 06:03:57 +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
+6
-6
@@ -23,8 +23,8 @@ func (s *bbSPI) Configure() {
|
||||
panic(legacy.ErrConfigBeforeInstantiated)
|
||||
}
|
||||
s.configurePins()
|
||||
s.SCK(false)
|
||||
s.SDO(false)
|
||||
s.SCK.Low()
|
||||
s.SDO.Low()
|
||||
if s.Delay == 0 {
|
||||
s.Delay = 1
|
||||
}
|
||||
@@ -53,19 +53,19 @@ func (s *bbSPI) Transfer(b byte) (byte, error) {
|
||||
for i := uint8(0); i < 8; i++ {
|
||||
|
||||
// half clock cycle high to start
|
||||
s.SCK(true)
|
||||
s.SCK.High()
|
||||
s.delay()
|
||||
|
||||
// write the value to SDO (MSB first)
|
||||
if b&(1<<(7-i)) == 0 {
|
||||
s.SDO(false)
|
||||
s.SDO.Low()
|
||||
} else {
|
||||
s.SDO(true)
|
||||
s.SDO.High()
|
||||
}
|
||||
s.delay()
|
||||
|
||||
// half clock cycle low
|
||||
s.SCK(false)
|
||||
s.SCK.Low()
|
||||
s.delay()
|
||||
|
||||
// for actual SPI would try to read the SDI value here
|
||||
|
||||
Reference in New Issue
Block a user