Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6077d17

Browse files
nickovsdpgeorge
authored andcommitted
docs/machine: Add initial docs for new machine.SDCard class.
1 parent 8e3af7d commit 6077d17

File tree

3 files changed

+125
-2
lines changed

3 files changed

+125
-2
lines changed

docs/library/machine.SD.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
.. currentmodule:: machine
22
.. _machine.SD:
33

4-
class SD -- secure digital memory card
5-
======================================
4+
class SD -- secure digital memory card (cc3200 port only)
5+
=========================================================
66

77
.. warning::
88

docs/library/machine.SDCard.rst

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
.. currentmodule:: machine
2+
.. _machine.SDCard:
3+
4+
class SDCard -- secure digital memory card
5+
==========================================
6+
7+
SD cards are one of the most common small form factor removable storage media.
8+
SD cards come in a variety of sizes and phsyical form factors. MMC cards are
9+
similar removable storage devices while eMMC devices are electically similar
10+
storage devices designed to be embedded into other systems. All three form
11+
share a common protocol for communication with their host system and high-level
12+
support looks the same for them all. As such in MicroPython they are implemented
13+
in a single class called :class:`machine.SDCard` .
14+
15+
Both SD and MMC interfaces support being accessed with a variety of bus widths.
16+
When being accessed with a 1-bit wide interface they can be accessed using the
17+
SPI protocol. Different MicroPython hardware platforms support different widths
18+
and pin configurations but for most platforms there is a standard configuation
19+
for any given hardware. In general constructing an `SDCard`` object with without
20+
passing any parameters will initialise the interface to the default card slot
21+
for the current hardware. The arguments listed below represent the common
22+
arguments that might need to be set in order to use either a non-stanard slot
23+
or a non-standard pin assignment. The exact subset of arguments suported will
24+
vary from platform to platform.
25+
26+
.. class:: SDCard(slot=1, width=1, cd=None, wp=None, sck=None, miso=None, mosi=None, cs=None)
27+
28+
This class provides access to SD or MMC storage cards using either
29+
a dedicated SD/MMC interface hardware or through an SPI channel.
30+
The class implements the block protocol defined by :class:`uos.AbstractBlockDev`.
31+
This allows the mounting of an SD card to be as simple as::
32+
33+
uos.mount(storage.SDCard(), "/sd")
34+
35+
The constrcutor takes the following paramters:
36+
37+
- *slot* selects which of the available interfaces to use. Leaving this
38+
unset will select the default interface.
39+
40+
- *width* selects the bus width for the SD/MMC interface.
41+
42+
- *cd* can be used to specify a card-detect pin.
43+
44+
- *wp* can be used to specify a write-protect pin.
45+
46+
- *sck* can be used to specify an SPI clock pin.
47+
48+
- *miso* can be used to specify an SPI miso pin.
49+
50+
- *mosi* can be used to specify an SPI mosi pin.
51+
52+
- *cs* can be used to specify an SPI chip select pin.
53+
54+
Implementation-specific details
55+
-------------------------------
56+
57+
Different implementations of the ``SDCard`` class on different hardware support
58+
varying subsets of the options above.
59+
60+
PyBoard
61+
```````
62+
63+
The standard PyBoard has just one slot. No arguments are necessary or supported.
64+
65+
ESP32
66+
`````
67+
68+
The ESP32 provides two channels of SD/MMC hardware and also supports
69+
access to SD Cards through either of the two SPI ports that are
70+
generally available to the user. As a result the *slot* argument can
71+
take a value between 0 and 3, inclusive. Slots 0 and 1 use the
72+
built-in SD/MMC hardware while slots 2 and 3 use the SPI ports. Slot 0
73+
supports 1, 4 or 8-bit wide access while slot 1 supports 1 or 4-bit
74+
access; the SPI slots only support 1-bit access.
75+
76+
.. note:: Slot 0 is used to communicate with on-board flash memory
77+
on most ESP32 modules and so will be unavailable to the
78+
user.
79+
80+
.. note:: Most ESP32 modules that provide an SD card slot using the
81+
dedicated hardware only wire up 1 data pin, so the default
82+
value for *width* is 1.
83+
84+
The pins used by the dedicated SD/MMC hardware are fixed. The pins
85+
used by the SPI hardware can be reassigned.
86+
87+
.. note:: If any of the SPI signals are remapped then all of the SPI
88+
signals will pass through a GPIO multiplexer unit which
89+
can limit the performance of high frequency signals. Since
90+
the normal operating speed for SD cards is 40MHz this can
91+
cause problems on some cards.
92+
93+
The default (and preferred) pin assignment are as follows:
94+
95+
====== ====== ====== ====== ======
96+
Slot 0 1 2 3
97+
------ ------ ------ ------ ------
98+
Signal Pin Pin Pin Pin
99+
====== ====== ====== ====== ======
100+
sck 6 14 18 14
101+
cmd 11 15
102+
cs 5 15
103+
miso 19 12
104+
mosi 23 13
105+
D0 7 2
106+
D1 8 4
107+
D2 9 12
108+
D3 10 13
109+
D4 16
110+
D5 17
111+
D6 5
112+
D7 18
113+
====== ====== ====== ====== ======
114+
115+
cc3200
116+
``````
117+
118+
You can set the pins used for SPI access by passing a tuple as the
119+
*pins* argument.
120+
121+
*Note:* The current cc3200 SD card implementation names the this class
122+
:class:`machine.SD` rather than :class:`machine.SDCard` .

docs/library/machine.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,3 +168,4 @@ Classes
168168
machine.Timer.rst
169169
machine.WDT.rst
170170
machine.SD.rst
171+
machine.SDCard.rst

0 commit comments

Comments
 (0)