aboutsummaryrefslogtreecommitdiff
path: root/ports/nrf/examples/mountsd.py
blob: 037b3258c53447c86ee9ff3cd821494ad9c39225 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
"""

Example for pca10040 / nrf52832 to show how mount
and list a sdcard connected over SPI.


Direct wiring on SD card (SPI):
   ______________________________
  |                              \
  |             9.    | NC    |   \
  |             1.      | ~CS   | |
  |             2.      | MOSI  | |
  |             3.      | GND   | |
  |             4.      | VCC3.3| |
  |             5.      | SCK   | |
  |             6.      | GND   | |
  |             7.      | MISO  | |
  |             8.      | NC    | |
  |                               |
  ---------------------------------
"""

import os
from machine import SPI, Pin
from sdcard import SDCard

def mnt():
    cs = Pin("P22", mode=Pin.OUT)
    sd = SDCard(SPI(0), cs)
    os.mount(sd, '/')

def list():
    files = os.listdir()
    print(files)