mirror of
https://github.com/tinygo-org/drivers.git
synced 2026-08-03 14:37:46 +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
41 lines
684 B
Go
41 lines
684 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"machine"
|
|
"time"
|
|
|
|
"tinygo.org/x/drivers/examples/sdcard/tinyfs/console"
|
|
"tinygo.org/x/drivers/sdcard"
|
|
"tinygo.org/x/tinyfs/fatfs"
|
|
)
|
|
|
|
var (
|
|
spi *machine.SPI
|
|
sckPin machine.Pin
|
|
sdoPin machine.Pin
|
|
sdiPin machine.Pin
|
|
csPin machine.Pin
|
|
ledPin machine.Pin
|
|
)
|
|
|
|
func main() {
|
|
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)
|
|
}
|
|
}
|
|
|
|
filesystem := fatfs.New(&sd)
|
|
|
|
// Configure FATFS with sector size (must match value in ff.h - use 512)
|
|
filesystem.Configure(&fatfs.Config{
|
|
SectorSize: 512,
|
|
})
|
|
|
|
console.RunFor(&sd, filesystem)
|
|
}
|