From 8d7e83113be581dc1812e677a38c70b52c0aa1fb Mon Sep 17 00:00:00 2001 From: Drew Bednar Date: Fri, 24 Apr 2020 22:41:42 -0400 Subject: [PATCH] adding an SDCard Example for the ESP-Wrover-kit --- basics/boot.py | 2 ++ esp_wrover_kit_v4_1/sdcard/README.md | 13 +++++++++++++ esp_wrover_kit_v4_1/sdcard/main.py | 20 ++++++++++++++++++++ scripts/profile | 8 ++++++++ 4 files changed, 43 insertions(+) create mode 100644 esp_wrover_kit_v4_1/sdcard/README.md create mode 100644 esp_wrover_kit_v4_1/sdcard/main.py diff --git a/basics/boot.py b/basics/boot.py index 514a936..b3e62b2 100644 --- a/basics/boot.py +++ b/basics/boot.py @@ -23,3 +23,5 @@ def connect(): # def no_debug(): # import esp # esp.osdebug(None) + +connect() \ No newline at end of file diff --git a/esp_wrover_kit_v4_1/sdcard/README.md b/esp_wrover_kit_v4_1/sdcard/README.md new file mode 100644 index 0000000..dad7194 --- /dev/null +++ b/esp_wrover_kit_v4_1/sdcard/README.md @@ -0,0 +1,13 @@ +# SD Card example + +Here are the [docs for the SDCard pins](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/hw-reference/esp32/get-started-wrover-kit.html#get-started-esp-wrover-kit-v4-1-microsd-card-slot). + +| . | ESP32 Pin | MicroSD Signal | +|---|---------------|----------------| +| 1 | MTDI / GPIO12 | DATA2 | +| 2 | MTCK / GPIO13 | CD / DATA | +| 3 | MTDO / GPIO15 | CMD | +| 4 | MTMS / GPIO14 | CLK | +| 5 | GPIO2 | DATA0 | +| 6 | GPIO4 | DATA1 | +| 7 | GPIO21 | CD | diff --git a/esp_wrover_kit_v4_1/sdcard/main.py b/esp_wrover_kit_v4_1/sdcard/main.py new file mode 100644 index 0000000..d5ef9a0 --- /dev/null +++ b/esp_wrover_kit_v4_1/sdcard/main.py @@ -0,0 +1,20 @@ +import machine, uos + +# machine.SDCard(slot=1, width=1, cd=None, wp=None, sck=None, miso=None, mosi=None, cs=None) + +sd = machine.SDCard() + +uos.mount(sd, '/sd') + + +def cat(file, encoding='utf8'): + """Prints the file.""" + with open(file, mode='r', encoding=encoding) as f: + for line in f.readlines(): + print(line) + + +def to_file(file, text='', encoding='utf8'): + """Simple function to write some text to a file.""" + with open(file, mode='r', encoding=encoding) as f: + f.write(text) diff --git a/scripts/profile b/scripts/profile index 4e15780..fa50bcc 100644 --- a/scripts/profile +++ b/scripts/profile @@ -1,6 +1,14 @@ export AMPY_PORT=/dev/cu.SLAB_USBtoUART export BAUD_RATE=115200 +ARG=$1 + +if [ "$ARG" = '--kit' ] || [ "$ARG" = '-k' ]; then + echo "Using ESP-WOVER-kit_v4.1" + export AMPY_PORT=/dev/cu.usbserial-143101 +fi + + function repl_connect (){ echo "Connecting to $AMPY_PORT" screen $AMPY_PORT $BAUD_RATE