.. currentmodule:: machine .. _machine.SDCard: class SDCard -- secure digital memory card SDCard -- 安全的数字记忆卡 ========================================== SD cards are one of the most common small form factor removable storage media. SD cards come in a variety of sizes and physical form factors. MMC cards are similar removable storage devices while eMMC devices are electrically similar storage devices designed to be embedded into other systems. All three form share a common protocol for communication with their host system and high-level support looks the same for them all. As such in MicroPython they are implemented in a single class called :class:`machine.SDCard` . SD卡是最常见的小型可移动存储介质之一。 SD卡有各种大小和物理形式。MMC卡 相似的可移动存储设备,而eMMC设备在电方面相似 设计嵌入到其他系统中的存储设备。所有三个形式 共享一个通用协议,用于与它们的主机系统和高层进行通信 他们的支持看起来都是一样的。因此在MicroPython中它们是被实现的 在一个名为:class: ' machine的类中。SDCard”。 Both SD and MMC interfaces support being accessed with a variety of bus widths. When being accessed with a 1-bit wide interface they can be accessed using the SPI protocol. Different MicroPython hardware platforms support different widths and pin configurations but for most platforms there is a standard configuration for any given hardware. In general constructing an ``SDCard`` object with without passing any parameters will initialise the interface to the default card slot for the current hardware. The arguments listed below represent the common arguments that might need to be set in order to use either a non-standard slot or a non-standard pin assignment. The exact subset of arguments supported will vary from platform to platform. SD和MMC接口都支持使用各种总线宽度访问。 当使用1位宽接口访问时,可以使用 SPI协议。不同的MicroPython硬件平台支持不同的宽度 但对于大多数平台,都有一个标准配置 对于任何给定的硬件。一般构造一个' ' ' ' SDCard ' '对象与没有 传递任何参数将初始化接口到默认卡槽 用于当前硬件。下面列出的参数表示共性 要使用非标准槽可能需要设置的参数 或一个非标准的pin分配。支持意志的确切的论点子集 因平台而异。 .. class:: SDCard(slot=1, width=1, cd=None, wp=None, sck=None, miso=None, mosi=None, cs=None) This class provides access to SD or MMC storage cards using either a dedicated SD/MMC interface hardware or through an SPI channel. The class implements the block protocol defined by :class:`uos.AbstractBlockDev`. This allows the mounting of an SD card to be as simple as:: 这个类提供对SD或MMC存储卡的访问 专用的SD/MMC接口硬件或通过SPI通道。 这个类实现了:class: ' ui . abstractblockdev '定义的块协议。 这允许安装一个SD卡简单如:: uos.mount(machine.SDCard(), "/sd") The constructor takes the following parameters: 构造函数接受以下参数: - *slot* selects which of the available interfaces to use. Leaving this unset will select the default interface. - *插槽*选择使用哪个可用接口。离开这 unset将选择默认接口。 - *width* selects the bus width for the SD/MMC interface. - *width* 选择SD/MMC接口的总线宽度。 - *cd* can be used to specify a card-detect pin. - *cd* 可用于指定卡检测pin。 - *wp* can be used to specify a write-protect pin. - *wp* 可用于指定写保护引脚。 - *sck* can be used to specify an SPI clock pin. - *sck* 可以用来指定一个SPI时钟针。 - *miso* can be used to specify an SPI miso pin. - *miso* 可用于指定SPI味噌pin。 - *mosi* can be used to specify an SPI mosi pin. - *mosi* 可用于指定一个SPI mosi引脚。 - *cs* can be used to specify an SPI chip select pin. - *cs* 可以用来指定一个SPI芯片选择引脚。 Implementation-specific details 实施的细节 ------------------------------- Different implementations of the ``SDCard`` class on different hardware support varying subsets of the options above. ``SDCard``类在不同硬件支持上的不同实现 以上选项的不同子集。 PyBoard ``````` The standard PyBoard has just one slot. No arguments are necessary or supported. 标准的PyBoard只有一个插槽。没有争论是必要的或支持。 ESP32 ````` The ESP32 provides two channels of SD/MMC hardware and also supports access to SD Cards through either of the two SPI ports that are generally available to the user. As a result the *slot* argument can take a value between 0 and 3, inclusive. Slots 0 and 1 use the built-in SD/MMC hardware while slots 2 and 3 use the SPI ports. Slot 0 supports 1, 4 or 8-bit wide access while slot 1 supports 1 or 4-bit access; the SPI slots only support 1-bit access. ESP32提供了两个SD/MMC硬件通道,也支持 通过两个SPI端口访问SD卡 一般对用户可用。因此,*槽*参数可以 取一个0到3之间的值。槽0和1使用 内置SD/MMC硬件,而插槽2和3使用SPI端口。槽0 支持1位、4位或8位宽访问,而插槽1支持1位或4位 访问;SPI插槽只支持1位访问。 .. note:: Slot 0 is used to communicate with on-board flash memory on most ESP32 modules and so will be unavailable to the user. .. 注意:: 槽0用于与板上闪存通信。 在大多数ESP32模块,因此将不可用的 用户。 .. note:: Most ESP32 modules that provide an SD card slot using the dedicated hardware only wire up 1 data pin, so the default value for *width* is 1. .. note:: 大多数提供SD卡插槽的ESP32模块使用 专用硬件只连接1个数据引脚,所以默认 宽度*的值为1。 The pins used by the dedicated SD/MMC hardware are fixed. The pins used by the SPI hardware can be reassigned. 专用SD/MMC硬件使用的引脚是固定的。针脚 可以重新分配由SPI硬件使用的数据。 .. note:: If any of the SPI signals are remapped then all of the SPI signals will pass through a GPIO multiplexer unit which can limit the performance of high frequency signals. Since the normal operating speed for SD cards is 40MHz this can cause problems on some cards. .. note:: 如果任何SPI信号都被重新映射,那么所有SPI都被重新映射 信号将通过一个GPIO多路复用器单元 可以限制高频信号的性能。自 SD卡的正常运行速度是40MHz 在一些卡片上造成问题。 The default (and preferred) pin assignment are as follows: 默认(和首选)的pin分配如下: ====== ====== ====== ====== ====== Slot 0 1 2 3 ------ ------ ------ ------ ------ Signal Pin Pin Pin Pin ====== ====== ====== ====== ====== sck 6 14 18 14 cmd 11 15 cs 5 15 miso 19 12 mosi 23 13 D0 7 2 D1 8 4 D2 9 12 D3 10 13 D4 16 D5 17 D6 5 D7 18 ====== ====== ====== ====== ====== cc3200 `````` You can set the pins used for SPI access by passing a tuple as the *pins* argument. 的元组,可以设置用于SPI访问的大头针 *pins* 参数。 *Note:* The current cc3200 SD card implementation names the this class :class:`machine.SD` rather than :class:`machine.SDCard` . *Note:* 当前cc3200 SD卡实现命名为这个类 :类:`machine.SD`而不是:class:`machine.SDCard`。