2016-06-07 17:46:27 -04:00
|
|
|
.. currentmodule:: machine
|
2015-10-14 06:32:01 -04:00
|
|
|
.. _machine.SD:
|
2015-06-10 17:29:56 -04:00
|
|
|
|
|
|
|
class SD -- secure digital memory card
|
|
|
|
======================================
|
|
|
|
|
|
|
|
The SD card class allows to configure and enable the memory card
|
|
|
|
module of the WiPy and automatically mount it as ``/sd`` as part
|
|
|
|
of the file system. There are several pin combinations that can be
|
|
|
|
used to wire the SD card socket to the WiPy and the pins used can
|
|
|
|
be specified in the constructor. Please check the `pinout and alternate functions
|
|
|
|
table. <https://raw.githubusercontent.com/wipy/wipy/master/docs/PinOUT.png>`_ for
|
|
|
|
more info regarding the pins which can be remapped to be used with a SD card.
|
|
|
|
|
|
|
|
Example usage::
|
|
|
|
|
2015-10-14 06:32:01 -04:00
|
|
|
from machine import SD
|
|
|
|
import os
|
|
|
|
# clk cmd and dat0 pins must be passed along with
|
2015-06-10 17:29:56 -04:00
|
|
|
# their respective alternate functions
|
2015-10-14 06:32:01 -04:00
|
|
|
sd = machine.SD(pins=('GP10', 'GP11', 'GP15'))
|
|
|
|
os.mount(sd, '/sd')
|
2015-08-11 10:06:43 -04:00
|
|
|
# do normal file operations
|
2015-06-10 17:29:56 -04:00
|
|
|
|
|
|
|
Constructors
|
|
|
|
------------
|
|
|
|
|
2015-10-14 06:32:01 -04:00
|
|
|
.. class:: machine.SD(id,... )
|
2015-06-10 17:29:56 -04:00
|
|
|
|
2015-10-20 10:24:25 -04:00
|
|
|
Create a SD card object. See ``init()`` for parameters if initialization.
|
2015-06-10 17:29:56 -04:00
|
|
|
|
|
|
|
Methods
|
|
|
|
-------
|
|
|
|
|
2015-10-20 10:24:25 -04:00
|
|
|
.. method:: sd.init(id=0, pins=('GP10', 'GP11', 'GP15'))
|
2015-06-10 17:29:56 -04:00
|
|
|
|
2015-10-20 10:24:25 -04:00
|
|
|
Enable the SD card. In order to initalize the card, give it a 3-tuple:
|
|
|
|
``(clk_pin, cmd_pin, dat0_pin)``.
|
2015-06-10 17:29:56 -04:00
|
|
|
|
2015-08-11 10:06:43 -04:00
|
|
|
.. method:: sd.deinit()
|
2015-06-10 17:29:56 -04:00
|
|
|
|
2015-10-14 06:32:01 -04:00
|
|
|
Disable the SD card.
|