mirror of
https://github.com/tinygo-org/drivers.git
synced 2026-07-26 10:38:41 +00:00
9f6783670f
The instances of SPI interfaces SPI0, SPI1, ... are pointers to SPI types on rp2040 machines, rather plain values like other machines. This needs restructuring the sdcard API to take a pointer to the SPI interface rather the SPI type itself. Removed waitserial() since it needs modem control lines not available on most boards
44 lines
637 B
Go
44 lines
637 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"machine"
|
|
"time"
|
|
|
|
"tinygo.org/x/drivers/sdcard"
|
|
)
|
|
|
|
var (
|
|
spi *machine.SPI
|
|
sckPin machine.Pin
|
|
sdoPin machine.Pin
|
|
sdiPin machine.Pin
|
|
csPin machine.Pin
|
|
ledPin machine.Pin
|
|
)
|
|
|
|
func main() {
|
|
fmt.Printf("sdcard console\r\n")
|
|
|
|
led := ledPin
|
|
led.Configure(machine.PinConfig{Mode: machine.PinOutput})
|
|
|
|
sd := sdcard.New(spi, sckPin, sdoPin, sdiPin, csPin)
|
|
err := sd.Configure()
|
|
if err != nil {
|
|
fmt.Printf("%s\r\n", err.Error())
|
|
for {
|
|
time.Sleep(time.Hour)
|
|
}
|
|
}
|
|
|
|
go RunFor(&sd)
|
|
|
|
for {
|
|
led.High()
|
|
time.Sleep(200 * time.Millisecond)
|
|
led.Low()
|
|
time.Sleep(200 * time.Millisecond)
|
|
}
|
|
}
|