File tree Expand file tree Collapse file tree 4 files changed +19
-71
lines changed
CircuitPython_SDCard_ListFiles
CircuitPython_SDCard_Write Expand file tree Collapse file tree 4 files changed +19
-71
lines changed Load Diff This file was deleted.
Original file line number Diff line number Diff line change 33
44"""
55CircuitPython Essentials SD Card Read Demo
6- * Not compatible with CircuitPython 10.x
76"""
87
98import os
1615# The SD_CS pin is the chip select line.
1716SD_CS = board .SD_CS
1817
18+ # For CircuitPython 9.x we must initialize and mount the SD card manually.
19+ # On CircuitPython 10.x the core will automatically initialize and mount the SD.
20+ # This try/except block can be removed with 10.x has a stable release.
1921try :
20- # Connect to the card and mount the filesystem.
22+ # Initialize the Chip Select pin for the SD card
2123 cs = digitalio .DigitalInOut (SD_CS )
24+ # Initialize the SD card
2225 sdcard = adafruit_sdcard .SDCard (
2326 busio .SPI (board .SD_SCK , board .SD_MOSI , board .SD_MISO ), cs
2427 )
28+ # Mount the SD card
2529 vfs = storage .VfsFat (sdcard )
2630 storage .mount (vfs , "/sd" )
2731except ValueError :
28- # SD_CS in use error happens if CircuitPython core initialized the SD automatically
32+ # "ValueError SD_CS in use" error happen on CircuitPython 10.x
33+ # because the core initialized the SD automatically. The error
34+ # can be ignored on 10.x.
2935 pass
3036
3137# Use the filesystem as normal! Our files are under /sd
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 44
55"""
66CircuitPython Essentials SD Card Write Demo
7- REMOVE THIS LINE AND ALL BELOW IT BEFORE SUBMITTING TO LEARN
8- Update CHIP_SELECT_PIN to match the CS pin on your board.
9-
10- For example, for the Metro ESP32-S3, you would use: board.SD_CS.
11-
12- This code stops working with CircuitPython 10.x which automounts /sd
137"""
148
159import time
2317# The SD_CS pin is the chip select line.
2418SD_CS = board .SD_CS
2519
20+
21+ # For CircuitPython 9.x we must initialize and mount the SD card manually.
22+ # On CircuitPython 10.x the core will automatically initialize and mount the SD.
23+ # This try/except block can be removed with 10.x has a stable release.
2624try :
27- # Connect to the card and mount the filesystem.
25+ # Initialize the Chip Select pin for the SD card
2826 cs = digitalio .DigitalInOut (SD_CS )
27+ # Initialize the SD card
2928 sdcard = adafruit_sdcard .SDCard (
3029 busio .SPI (board .SD_SCK , board .SD_MOSI , board .SD_MISO ), cs
3130 )
31+ # Mount the SD card
3232 vfs = storage .VfsFat (sdcard )
3333 storage .mount (vfs , "/sd" )
3434except ValueError :
35- # SD_CS in use error happens if CircuitPython core initialized the SD automatically
35+ # "ValueError SD_CS in use" error happen on CircuitPython 10.x
36+ # because the core initialized the SD automatically. The error
37+ # can be ignored on 10.x.
3638 pass
3739
3840# Use the filesystem as normal! Our files are under /sd
You can’t perform that action at this time.
0 commit comments