2016-06-07 22:46:27 +01:00
|
|
|
.. currentmodule:: machine
|
2017-04-18 06:27:37 +01:00
|
|
|
.. _machine.SD:
|
2015-06-10 22:29:56 +01: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 11:32:01 +01:00
|
|
|
from machine import SD
|
|
|
|
import os
|
|
|
|
# clk cmd and dat0 pins must be passed along with
|
2015-06-10 22:29:56 +01:00
|
|
|
# their respective alternate functions
|
2015-10-14 11:32:01 +01:00
|
|
|
sd = machine.SD(pins=('GP10', 'GP11', 'GP15'))
|
|
|
|
os.mount(sd, '/sd')
|
2015-08-11 15:06:43 +01:00
|
|
|
# do normal file operations
|
2015-06-10 22:29:56 +01:00
|
|
|
|
|
|
|
Constructors
|
|
|
|
------------
|
|
|
|
|
2016-06-09 01:03:53 +01:00
|
|
|
.. class:: SD(id,... )
|
2015-06-10 22:29:56 +01:00
|
|
|
|
2015-10-20 15:24:25 +01:00
|
|
|
Create a SD card object. See ``init()`` for parameters if initialization.
|
2015-06-10 22:29:56 +01:00
|
|
|
|
|
|
|
Methods
|
|
|
|
-------
|
|
|
|
|
2016-06-07 23:33:49 +01:00
|
|
|
.. method:: SD.init(id=0, pins=('GP10', 'GP11', 'GP15'))
|
2015-06-10 22:29:56 +01:00
|
|
|
|
2015-10-20 15:24:25 +01: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 22:29:56 +01:00
|
|
|
|
2016-06-07 23:33:49 +01:00
|
|
|
.. method:: SD.deinit()
|
2015-06-10 22:29:56 +01:00
|
|
|
|
2015-10-14 11:32:01 +01:00
|
|
|
Disable the SD card.
|