Skip to content

Commit e23b0ea

Browse files
committed
Improve the docs.
1 parent 42c52fa commit e23b0ea

File tree

3 files changed

+54
-13
lines changed

3 files changed

+54
-13
lines changed

README.rst

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,18 @@ Introduction
1010
:target: https://gitter.im/adafruit/circuitpython?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge
1111
:alt: Gitter
1212
13-
TODO
13+
.. image :: https://img.shields.io/discord/327254708534116352.svg
14+
:target: https://adafru.it/discord
15+
:alt: Discord
16+
17+
CircuitPython driver for SD cards. This implements the basic reading and writing
18+
block functionality needed to mount an SD card using `storage.VfsFat`.
1419

1520
Dependencies
1621
=============
1722
This driver depends on:
1823

19-
* `Adafruit CircuitPython <https://github.com/adafruit/circuitpython>`_
24+
* `Adafruit CircuitPython 2.0.0+ <https://github.com/adafruit/circuitpython>`_
2025
* `Bus Device <https://github.com/adafruit/Adafruit_CircuitPython_BusDevice>`_
2126

2227
Please ensure all dependencies are available on the CircuitPython filesystem.
@@ -26,7 +31,31 @@ This is easily achieved by downloading
2631
Usage Example
2732
=============
2833

29-
TODO
34+
Mounting a filesystem on an SD card so that its available through the normal Python
35+
ways is easy.
36+
37+
Below is an example for the Feather M0 Adalogger. Most of this will stay the same
38+
across different boards with the exception of the pins for the SPI and chip
39+
select (cs) connections.
40+
41+
.. code-block:: python
42+
43+
import adafruit_sdcard
44+
import busio
45+
import digitalio
46+
import board
47+
import storage
48+
49+
# Connect to the card and mount the filesystem.
50+
spi = busio.SPI(board.SCK, board.MOSI, board.MISO)
51+
cs = digitalio.DigitalInOut(board.SD_CS)
52+
sdcard = adafruit_sdcard.SDCard(spi, cs)
53+
vfs = storage.VfsFat(sdcard)
54+
storage.mount(vfs, "/sd")
55+
56+
# Use the filesystem as normal.
57+
with open("/sd/test.txt", "w") as f:
58+
f.write("Hello world\n")
3059
3160
Contributing
3261
============

adafruit_sdcard.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2222
# THE SOFTWARE.
2323
"""
24-
`adafruit_sdcard`
24+
`adafruit_sdcard` - SD card over SPI driver
2525
====================================================
2626
2727
CircuitPython driver for SD cards using SPI bus.
@@ -31,15 +31,18 @@
3131
3232
Example usage:
3333
34+
.. code-block:: python
35+
3436
import busio
35-
import filesystem
37+
import storage
3638
import adafruit_sdcard
3739
import os
3840
import board
3941
4042
spi = busio.SPI(SCK, MOSI, MISO)
4143
sd = adafruit_sdcard.SDCard(spi, board.SD_CS)
42-
filesystem.mount(sd, '/sd2')
44+
vfs = storage.VfsFat(sdcard)
45+
storage.mount(vfs, '/sd')
4346
os.listdir('/')
4447
4548
* Author(s): Scott Shawcroft
@@ -63,6 +66,10 @@
6366
_TOKEN_DATA = const(0xfe)
6467

6568
class SDCard:
69+
"""Controls an SD card over SPI.
70+
71+
:param ~busio.SPI spi: The SPI bus
72+
:param ~digitalio.DigitalInOut cs: The chip select connected to the card"""
6673
def __init__(self, spi, cs):
6774
# This is the init baudrate. We create a second device for high speed.
6875
self._spi = spi_device.SPIDevice(spi, cs, baudrate=250000, extra_clocks=8)

conf.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,12 @@
1515
'sphinx.ext.viewcode',
1616
]
1717

18-
intersphinx_mapping = {'python': ('https://docs.python.org/3.4', None),'BusDevice': ('https://circuitpython.readthedocs.io/projects/bus_device/en/latest/', None),'CircuitPython': ('https://circuitpython.readthedocs.io/en/latest/', None)}
18+
19+
autodoc_mock_imports = ["adafruit_bus_device", "micropython"]
20+
21+
intersphinx_mapping = {'python': ('https://docs.python.org/3.4', None),
22+
'BusDevice': ('https://circuitpython.readthedocs.io/projects/bus_device/en/latest/', None),
23+
'CircuitPython': ('https://circuitpython.readthedocs.io/en/latest/', None)}
1924

2025
# Add any paths that contain templates here, relative to this directory.
2126
templates_path = ['_templates']
@@ -26,7 +31,7 @@
2631
master_doc = 'README'
2732

2833
# General information about the project.
29-
project = u'Adafruit SDCARD Library'
34+
project = u'Adafruit SD Card Library'
3035
copyright = u'2017 Scott Shawcroft'
3136
author = u'Scott Shawcroft'
3237

@@ -91,7 +96,7 @@
9196
html_static_path = ['_static']
9297

9398
# Output file base name for HTML help builder.
94-
htmlhelp_basename = 'AdafruitSDCARDLibrarydoc'
99+
htmlhelp_basename = 'AdafruitSD CardLibrarydoc'
95100

96101
# -- Options for LaTeX output ---------------------------------------------
97102

@@ -117,7 +122,7 @@
117122
# (source start file, target name, title,
118123
# author, documentclass [howto, manual, or own class]).
119124
latex_documents = [
120-
(master_doc, 'AdafruitSDCARDLibrary.tex', u'Adafruit SDCARD Library Documentation',
125+
(master_doc, 'AdafruitSD CardLibrary.tex', u'Adafruit SD Card Library Documentation',
121126
u'Phiilip Moyer', 'manual'),
122127
]
123128

@@ -126,7 +131,7 @@
126131
# One entry per manual page. List of tuples
127132
# (source start file, name, description, authors, manual section).
128133
man_pages = [
129-
(master_doc, 'adafruitSDCARDlibrary', u'Adafruit SDCARD Library Documentation',
134+
(master_doc, 'adafruitSD Cardlibrary', u'Adafruit SD Card Library Documentation',
130135
[author], 1)
131136
]
132137

@@ -136,7 +141,7 @@
136141
# (source start file, target name, title, author,
137142
# dir menu entry, description, category)
138143
texinfo_documents = [
139-
(master_doc, 'AdafruitSDCARDLibrary', u'Adafruit SDCARD Library Documentation',
140-
author, 'AdafruitSDCARDLibrary', 'One line description of project.',
144+
(master_doc, 'AdafruitSD CardLibrary', u'Adafruit SD Card Library Documentation',
145+
author, 'AdafruitSD CardLibrary', 'One line description of project.',
141146
'Miscellaneous'),
142147
]

0 commit comments

Comments
 (0)