tinygo.org/x/drivers@v0.27.1-0.20240509133757-7dbca2a54349/examples/sdcard/console/main.go (about) 1 package main 2 3 import ( 4 "fmt" 5 "machine" 6 "time" 7 8 "tinygo.org/x/drivers/sdcard" 9 ) 10 11 var ( 12 spi *machine.SPI 13 sckPin machine.Pin 14 sdoPin machine.Pin 15 sdiPin machine.Pin 16 csPin machine.Pin 17 ledPin machine.Pin 18 ) 19 20 func main() { 21 fmt.Printf("sdcard console\r\n") 22 23 led := ledPin 24 led.Configure(machine.PinConfig{Mode: machine.PinOutput}) 25 26 sd := sdcard.New(spi, sckPin, sdoPin, sdiPin, csPin) 27 err := sd.Configure() 28 if err != nil { 29 fmt.Printf("%s\r\n", err.Error()) 30 for { 31 time.Sleep(time.Hour) 32 } 33 } 34 35 go RunFor(&sd) 36 37 for { 38 led.High() 39 time.Sleep(200 * time.Millisecond) 40 led.Low() 41 time.Sleep(200 * time.Millisecond) 42 } 43 }