CMSIS Driver  Version 1.10 - Preliminary
Middleware Driver API for microcontroller peripherals
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
MCI Interface

Driver API for Memory Card Interface using SDIO or SPI (Driver_MCI.h) More...

Data Structures

struct  ARM_DRIVER_MCI
 Access structure of the MCI Driver. More...
 
struct  ARM_MCI_CAPABILITIES
 MCI Driver Capabilities. More...
 
struct  ARM_MCI_SWITCH
 MCI Card Switch. More...
 

Typedefs

typedef void(* ARM_MCI_SignalEvent_t )(ARM_MCI_EVENT event)
 Pointer to ARM_MCI_SignalEvent : Signal MCI Card Event.
 

Enumerations

enum  ARM_MC_COMMAND {
  ARM_MC_CMD_GO_IDLE_STATE = 0,
  ARM_MC_CMD_SEND_OP_COND = 1,
  ARM_MC_CMD_ALL_SEND_CID = 2,
  ARM_MC_CMD_SEND_RELATIVE_ADDR = 3,
  ARM_MC_CMD_SET_BUS_WIDTH = 6,
  ARM_MC_CMD_SELECT_DESELECT_CARD = 7,
  ARM_MC_CMD_SEND_IF_COND = 8,
  ARM_MC_CMD_SEND_CSD = 9,
  ARM_MC_CMD_SEND_CID = 10,
  ARM_MC_CMD_VOLTAGE_SWITCH = 11,
  ARM_MC_CMD_STOP_TRANSMISSION = 12,
  ARM_MC_CMD_SEND_STATUS = 13,
  ARM_MC_CMD_SET_BLOCKLEN = 16,
  ARM_MC_CMD_READ_SINGLE_BLOCK = 17,
  ARM_MC_CMD_READ_MULTIPLE_BLOCK = 18,
  ARM_MC_CMD_SEND_TUNING_BLOCK = 19,
  ARM_MC_CMD_WRITE_SINGLE_BLOCK = 24,
  ARM_MC_CMD_WRITE_MULTIPLE_BLOCK = 25,
  ARM_MC_CMD_SET_WRITE_PROT = 28,
  ARM_MC_CMD_CLR_WRITE_PROT = 29,
  ARM_MC_CMD_SEND_WRITE_PROT = 30,
  ARM_MC_CMD_SD_SEND_OP_COND = 41,
  ARM_MC_CMD_LOCK_UNLOCK = 42,
  ARM_MC_CMD_APP_CMD = 55,
  ARM_MC_CMD_READ_OCR = 58,
  ARM_MC_CMD_CRC_ON_OFF = 59
}
 Memory Card Command Set. More...
 
enum  ARM_MC_RESPONSE {
  ARM_MC_RESPONSE_NONE = 0,
  ARM_MC_RESPONSE_R1,
  ARM_MC_RESPONSE_R1b,
  ARM_MC_RESPONSE_R2,
  ARM_MC_RESPONSE_R3,
  ARM_MC_RESPONSE_R4,
  ARM_MC_RESPONSE_R5,
  ARM_MC_RESPONSE_R5b,
  ARM_MC_RESPONSE_R6,
  ARM_MC_RESPONSE_R7
}
 Memory Card Response Types. More...
 
enum  ARM_MCI_EVENT {
  ARM_MCI_EVENT_INSERTED,
  ARM_MCI_EVENT_REMOVED,
  ARM_MCI_EVENT_BUSY_DEASSERTED
}
 MCI Card Event. More...
 
enum  ARM_MCI_POWER {
  ARM_MCI_POWER_OFF = 0,
  ARM_MCI_POWER_VDD_3V3,
  ARM_MCI_POWER_VDD_1V8
}
 MCI Card Power. More...
 
enum  ARM_MCI_BUS_MODE {
  ARM_MCI_BUS_OPEN_DRAIN,
  ARM_MCI_BUS_PUSH_PULL
}
 MCI Bus Mode. More...
 
enum  ARM_MCI_BUS_DATA_WIDTH {
  ARM_MCI_BUS_DATA_WIDTH_1,
  ARM_MCI_BUS_DATA_WIDTH_4,
  ARM_MCI_BUS_DATA_WIDTH_8
}
 MCI Bus Data Width. More...
 
enum  ARM_MCI_BUS_SIGNALING {
  ARM_MCI_BUS_SIGNALING_3V3,
  ARM_MCI_BUS_SIGNALING_1V8
}
 MCI Bus Signaling. More...
 
enum  ARM_MCI_TRANSFER_MODE {
  ARM_MCI_TRANSFER_READ,
  ARM_MCI_TRANSFER_WRITE
}
 MCI Transfer Mode. More...
 
enum  ARM_MCI_STATUS {
  ARM_MCI_OK = 0,
  ARM_MCI_ERROR = 1,
  ARM_MCI_ERROR_UNSUPPORTED = 2,
  ARM_MCI_ERROR_RESPONSE = 3,
  ARM_MCI_ERROR_COMMAND_TIMEOUT = 4,
  ARM_MCI_ERROR_TRANSFER_TIMEOUT = 5,
  ARM_MCI_ERROR_CRC = 6
}
 MCI Status of executed operation. More...
 

Functions

ARM_DRV_VERSION ARM_MCI_GetVersion (void)
 Get driver version.
 
ARM_MCI_CAPABILITIES ARM_MCI_GetCapabilities (void)
 Get driver capabilities.
 
ARM_MCI_STATUS ARM_MCI_Initialize (ARM_MCI_SignalEvent_t cb_event, bool spi_mode)
 Initialize the Memory Card Interface.
 
ARM_MCI_STATUS ARM_MCI_Uninitialize (void)
 De-initialize Memory Card Interface.
 
ARM_MCI_STATUS ARM_MCI_PowerControl (ARM_POWER_STATE state)
 Control Memory Card Interface Power.
 
ARM_MCI_STATUS ARM_MCI_BusMode (ARM_MCI_BUS_MODE mode)
 Setup the bus mode for Memory Card transfers.
 
ARM_MCI_STATUS ARM_MCI_BusDataWidth (ARM_MCI_BUS_DATA_WIDTH width)
 Setup bus data width for Memory Card transfers.
 
ARM_MCI_STATUS ARM_MCI_BusSignaling (ARM_MCI_BUS_SIGNALING voltage)
 Set bus signaling voltage for MCI transfers.
 
uint32_t ARM_MCI_BusSpeed (uint32_t bps)
 Setup bus speed for Memory Card transfers.
 
ARM_MCI_STATUS ARM_MCI_CardPower (ARM_MCI_POWER voltage)
 Set Memory Card supply voltage.
 
ARM_MCI_SWITCH ARM_MCI_CardSwitchRead (void)
 Read state of Memory Card switches.
 
ARM_MCI_STATUS ARM_MCI_CardInitialize (void)
 Perform Memory Card initialization sequence.
 
ARM_MCI_STATUS ARM_MCI_SendCommand (ARM_MC_COMMAND cmd, uint32_t cmd_arg, ARM_MC_RESPONSE response_type, uint32_t *ptr_response)
 Send Command to card and get the response.
 
ARM_MCI_STATUS ARM_MCI_SetupTransfer (uint8_t *data, uint32_t block_count, uint32_t block_size, ARM_MCI_TRANSFER_MODE mode)
 Setup read or write transfer operation.
 
ARM_MCI_STATUS ARM_MCI_ReadTransfer (uint8_t *data, uint32_t block_count, uint32_t block_size)
 Perform read transfer.
 
ARM_MCI_STATUS ARM_MCI_WriteTransfer (uint8_t *data, uint32_t block_count, uint32_t block_size)
 Perform write transfer.
 
ARM_MCI_STATUS ARM_MCI_AbortTransfer (void)
 Abort current read/write data transfer.
 
void ARM_MCI_SignalEvent (ARM_MCI_EVENT event)
 Callback function that signals a MCI Card Event.
 

Description

Driver API for Memory Card Interface using SDIO or SPI (Driver_MCI.h)

The Memory Card Interface (MCI) implements the hardware abstraction layer for Secure Digital (SD) memory that is typically used as file storage. For embedded systems, SD devices are available as memory cards in several forms (SD, miniSD, microSD) or as non-removable devices that are directly soldered to the PCB.

References:

MCI Structure

The MCI driver allows to exchange data of the SD memory via SDIO or SPI Bus mode. The following modes are supported by SD memory cards:

SPI_BusMode.png
SD memory connected via SPI interface

 

SD_1BitBusMode.png
SD memory connected via 1-bit SD Bus Mode

 

SD_4BitBusMode.png
SD memory connected via 4-bit SD Bus Mode

MCI API

The following header files define the Application Programming Interface (API) for the MCI interface:

The driver implementation is a typical part of the Device Family Pack (DFP) that supports the peripherals of the microcontroller family.

Driver Functions

The driver functions are published in the access struct as explained in Driver Functions

A typical setup sequence for the driver is shown below:

Example Code:


Data Structure Documentation

struct ARM_DRIVER_MCI

Access structure of the MCI Driver.

The functions of the MCI are accessed by function pointers exposed by this structure. Refer to Driver Functions for overview information.

Each instance of an MCI provides such an access structure. The instance is identified by a postfix number in the symbol name of the access structure, for example:

  • ARM_DRIVER_MCI0 is the name of the access struct of the first instance (no. 0).
  • ARM_DRIVER_MCI1 is the name of the access struct of the second instance (no. 1).

A configuration setting in the middleware allows connecting the middleware to a specific driver instance ARM_DRIVER_MCIn. The default is 0, which connects a middleware to the first instance of a driver.

Data Fields

ARM_DRV_VERSION(* GetVersion )(void)
 Pointer to ARM_MCI_GetVersion : Get driver version.
 
ARM_MCI_CAPABILITIES(* GetCapabilities )(void)
 Pointer to ARM_MCI_GetCapabilities : Get driver capabilities.
 
ARM_MCI_STATUS(* Initialize )(ARM_MCI_SignalEvent_t cb_event, bool spi_mode)
 Pointer to ARM_MCI_Initialize : Initialize MCI Interface.
 
ARM_MCI_STATUS(* Uninitialize )(void)
 Pointer to ARM_MCI_Uninitialize : De-initialize MCI Interface.
 
ARM_MCI_STATUS(* PowerControl )(ARM_POWER_STATE state)
 Pointer to ARM_MCI_PowerControl : Control MCI Interface Power.
 
ARM_MCI_STATUS(* BusMode )(ARM_MCI_BUS_MODE mode)
 Pointer to ARM_MCI_BusMode : Set bus mode for MCI transfers.
 
ARM_MCI_STATUS(* BusDataWidth )(ARM_MCI_BUS_DATA_WIDTH width)
 Pointer to ARM_MCI_BusDataWidth : Set bus data width for MCI transfers.
 
ARM_MCI_STATUS(* BusSignaling )(ARM_MCI_BUS_SIGNALING voltage)
 Pointer to ARM_MCI_BusSignaling : Set bus signaling voltage for MCI transfers.
 
uint32_t(* BusSpeed )(uint32_t bps)
 Pointer to ARM_MCI_BusSpeed : Set bus speed for MCI transfers.
 
ARM_MCI_STATUS(* CardPower )(ARM_MCI_POWER voltage)
 Pointer to ARM_MCI_CardPower : Set card power supply voltage.
 
ARM_MCI_SWITCH(* CardSwitchRead )(void)
 Pointer to ARM_MCI_CardSwitchRead : Read state of Card switches.
 
ARM_MCI_STATUS(* CardInitialize )(void)
 Pointer to ARM_MCI_CardInitialize : Perform Card initialization sequence.
 
ARM_MCI_STATUS(* SendCommand )(ARM_MC_COMMAND cmd, uint32_t cmd_arg, ARM_MC_RESPONSE response_type, uint32_t *ptr_response)
 Pointer to ARM_MCI_SendCommand : Send Command to card and get the response.
 
ARM_MCI_STATUS(* SetupTransfer )(uint8_t *data, uint32_t block_count, uint32_t block_size, ARM_MCI_TRANSFER_MODE mode)
 Pointer to ARM_MCI_SetupTransfer : Setup transfer operation.
 
ARM_MCI_STATUS(* ReadTransfer )(uint8_t *data, uint32_t block_count, uint32_t block_size)
 Pointer to ARM_MCI_ReadTransfer : Perform read transfer.
 
ARM_MCI_STATUS(* WriteTransfer )(uint8_t *data, uint32_t block_count, uint32_t block_size)
 Pointer to ARM_MCI_WriteTransfer : Perform write transfer.
 
ARM_MCI_STATUS(* AbortTransfer )(void)
 Pointer to ARM_MCI_AbortTransfer : Abort current read/write transfer.
 

Field Documentation

ARM_MCI_STATUS(* AbortTransfer)(void)

Pointer to ARM_MCI_AbortTransfer : Abort current read/write transfer.

ARM_MCI_STATUS(* BusDataWidth)(ARM_MCI_BUS_DATA_WIDTH width)

Pointer to ARM_MCI_BusDataWidth : Set bus data width for MCI transfers.

ARM_MCI_STATUS(* BusMode)(ARM_MCI_BUS_MODE mode)

Pointer to ARM_MCI_BusMode : Set bus mode for MCI transfers.

ARM_MCI_STATUS(* BusSignaling)(ARM_MCI_BUS_SIGNALING voltage)

Pointer to ARM_MCI_BusSignaling : Set bus signaling voltage for MCI transfers.

uint32_t(* BusSpeed)(uint32_t bps)

Pointer to ARM_MCI_BusSpeed : Set bus speed for MCI transfers.

ARM_MCI_STATUS(* CardInitialize)(void)

Pointer to ARM_MCI_CardInitialize : Perform Card initialization sequence.

ARM_MCI_STATUS(* CardPower)(ARM_MCI_POWER voltage)

Pointer to ARM_MCI_CardPower : Set card power supply voltage.

ARM_MCI_SWITCH(* CardSwitchRead)(void)

Pointer to ARM_MCI_CardSwitchRead : Read state of Card switches.

ARM_MCI_CAPABILITIES(* GetCapabilities)(void)

Pointer to ARM_MCI_GetCapabilities : Get driver capabilities.

ARM_DRV_VERSION(* GetVersion)(void)

Pointer to ARM_MCI_GetVersion : Get driver version.

ARM_MCI_STATUS(* Initialize)(ARM_MCI_SignalEvent_t cb_event, bool spi_mode)

Pointer to ARM_MCI_Initialize : Initialize MCI Interface.

ARM_MCI_STATUS(* PowerControl)(ARM_POWER_STATE state)

Pointer to ARM_MCI_PowerControl : Control MCI Interface Power.

ARM_MCI_STATUS(* ReadTransfer)(uint8_t *data, uint32_t block_count, uint32_t block_size)

Pointer to ARM_MCI_ReadTransfer : Perform read transfer.

ARM_MCI_STATUS(* SendCommand)(ARM_MC_COMMAND cmd, uint32_t cmd_arg, ARM_MC_RESPONSE response_type, uint32_t *ptr_response)

Pointer to ARM_MCI_SendCommand : Send Command to card and get the response.

ARM_MCI_STATUS(* SetupTransfer)(uint8_t *data, uint32_t block_count, uint32_t block_size, ARM_MCI_TRANSFER_MODE mode)

Pointer to ARM_MCI_SetupTransfer : Setup transfer operation.

ARM_MCI_STATUS(* Uninitialize)(void)

Pointer to ARM_MCI_Uninitialize : De-initialize MCI Interface.

ARM_MCI_STATUS(* WriteTransfer)(uint8_t *data, uint32_t block_count, uint32_t block_size)

Pointer to ARM_MCI_WriteTransfer : Perform write transfer.

struct ARM_MCI_CAPABILITIES

MCI Driver Capabilities.

An MCI driver can be implemented with different capabilities. The bitfield members of this struct encode the capabilities implemented by this driver.

Returned by:

Data Fields
uint32_t busy_event: 1 Signal Busy de-asserted event.
uint32_t cd_event: 1 Signal Card Detect change event.
uint32_t cd_state: 1 Card Detect State available.
uint32_t data_width_4: 1 Supports 4-bit data.
uint32_t data_width_8: 1 Supports 8-bit data.
uint32_t power_off: 1 Supports Card Power Off.
uint32_t reserved: 23 reserved for future use
uint32_t signaling_1v8: 1 Supports 1.8V Signaling.
uint32_t vdd_1v8: 1 Supports 1.8V Card Power.
uint32_t wp_state: 1 Write Protect State available.
struct ARM_MCI_SWITCH

MCI Card Switch.

The MCI Card Switch information provides information about optional switches available on some memory cards.

Returned by:

Data Fields
uint8_t cd_state: 1 Card Detect (CD) state (1 = card inserted)
uint8_t wp_state: 1 Write Protect (WP) state (1 = write protected)

Typedef Documentation

ARM_MCI_SignalEvent_t

Pointer to ARM_MCI_SignalEvent : Signal MCI Card Event.

Provides the typedef for the callback function ARM_MCI_SignalEvent.

Parameter for:

Enumeration Type Documentation

Memory Card Command Set.

Defines the command set for a memory card.

Parameter for:

Enumerator:
ARM_MC_CMD_GO_IDLE_STATE 

Reset card to idle state MMC,SD.

ARM_MC_CMD_SEND_OP_COND 

Send Op.Cond. Register MMC,–.

ARM_MC_CMD_ALL_SEND_CID 

Send Card CID number MMC,SD.

ARM_MC_CMD_SEND_RELATIVE_ADDR 

Set Relative Address MMC,SD.

ARM_MC_CMD_SET_BUS_WIDTH 

Set Bus Width 1bit/4bits —,SD.

ARM_MC_CMD_SELECT_DESELECT_CARD 

Select/Deselect the Card MMC,SD.

ARM_MC_CMD_SEND_IF_COND 

Send Interface Condition —,SD.

ARM_MC_CMD_SEND_CSD 

Send Card Specific Data MMC,SD.

ARM_MC_CMD_SEND_CID 

Send Card Identificat.Data MMC,SD.

ARM_MC_CMD_VOLTAGE_SWITCH 

Switch to 1.8V bus signaling —,SD.

ARM_MC_CMD_STOP_TRANSMISSION 

Stop Read or Write transm. MMC,SD.

ARM_MC_CMD_SEND_STATUS 

Send Status Register MMC,SD.

ARM_MC_CMD_SET_BLOCKLEN 

Set Block Length in bytes MMC,SD.

ARM_MC_CMD_READ_SINGLE_BLOCK 

Read a Single Block MMC,SD.

ARM_MC_CMD_READ_MULTIPLE_BLOCK 

Read Multiple Blocks MMC,SD.

ARM_MC_CMD_SEND_TUNING_BLOCK 

Send 64 bytes tuning pattern MMC,SD.

ARM_MC_CMD_WRITE_SINGLE_BLOCK 

Write a Block MMC,SD.

ARM_MC_CMD_WRITE_MULTIPLE_BLOCK 

Write Multiple Blocks MMC,SD.

ARM_MC_CMD_SET_WRITE_PROT 

Sets write protection bit MMC,SD.

ARM_MC_CMD_CLR_WRITE_PROT 

Clears write protection bit MMC,SD.

ARM_MC_CMD_SEND_WRITE_PROT 

Send write protection status MMC,SD.

ARM_MC_CMD_SD_SEND_OP_COND 

Send App. Op.Cond Register —,SD.

ARM_MC_CMD_LOCK_UNLOCK 

Set/reset the password MMC,SD.

ARM_MC_CMD_APP_CMD 

App.Specific Cmd follows MMC,SD.

ARM_MC_CMD_READ_OCR 

Read OCR Register MMC,SD.

ARM_MC_CMD_CRC_ON_OFF 

Turn CRC7 checking on/off MMC,SD.

Memory Card Response Types.

Defines the response type for a memory card.

Parameter for:

Enumerator:
ARM_MC_RESPONSE_NONE 

No response expected.

ARM_MC_RESPONSE_R1 

Normal response command (48-bit)

ARM_MC_RESPONSE_R1b 

R1 response with busy signal (48-bit)

ARM_MC_RESPONSE_R2 

CID, CSD register response (136-bit)

ARM_MC_RESPONSE_R3 

OCR register response (48-bit)

ARM_MC_RESPONSE_R4 

Fast I/O response (48-bit)

ARM_MC_RESPONSE_R5 

Interrupt request response (48-bit)

ARM_MC_RESPONSE_R5b 

R5 response with busy signal (48-bit)

ARM_MC_RESPONSE_R6 

Published RCA response (48-bit)

ARM_MC_RESPONSE_R7 

Card interface condition (48-bit)

MCI Bus Data Width.

MCI Bus Data Width specifies the number of data I/O pins on the SDIO interface. For high-speed memory cards, a 4-bit bus data width should be used. The bitfields ARM_MCI_CAPABILITIES.data_width_4 and ARM_MCI_CAPABILITIES.data_width_8 encode whether the driver supports a specific bus data with.

Parameter for:

Enumerator:
ARM_MCI_BUS_DATA_WIDTH_1 

Bus data width: 1 bit.

ARM_MCI_BUS_DATA_WIDTH_4 

Bus data width: 4 bits.

ARM_MCI_BUS_DATA_WIDTH_8 

Bus data width: 8 bits.

MCI Bus Mode.

The MCI Bus Mode specifies open drain (which allows ganging multiple cards on the same interface) or push-pull (which achieves in practice higher speeds and a more reliable communication) bus operation. Parameter for:

Enumerator:
ARM_MCI_BUS_OPEN_DRAIN 

Open Drain CMD line.

ARM_MCI_BUS_PUSH_PULL 

Push-Pull CMD line.

MCI Bus Signaling.

Lists the supported bus signaling voltage. Initially, all SD card families use a 3.3 volt electrical interface. Some SD cards can switch to 1.8 volt operation. For example, the use of ultra-high-speed (UHS) SD cards requires 1.8 volt operation and a 4-bit bus data width. The bitfield ARM_MCI_CAPABILITIES.signaling_1v8 encodes whether the driver supports 1.8 volt signaling.

Parameter for:

See Also
Enumerator:
ARM_MCI_BUS_SIGNALING_3V3 

Bus signaling: 3.3V.

ARM_MCI_BUS_SIGNALING_1V8 

Bus signaling: 1.8V.

MCI Card Event.

Specifies the MCI Card Event for the ARM_MCI_SignalEvent callback function (which is registered by the function ARM_MCI_Initialize). The function ARM_MCI_GetCapabilities returns information about the implemented callback events in a driver.

Parameter for:

Enumerator:
ARM_MCI_EVENT_INSERTED 

Memory Card inserted.

ARM_MCI_EVENT_REMOVED 

Memory Card removed.

ARM_MCI_EVENT_BUSY_DEASSERTED 

Memory Card Busy flag de-asserted.

MCI Card Power.

Lists the supported power supply for a memory card.

Parameter for:

Enumerator:
ARM_MCI_POWER_OFF 

Power turned off.

ARM_MCI_POWER_VDD_3V3 

Power VDD = 3.3V.

ARM_MCI_POWER_VDD_1V8 

Power VDD = 1.8V.

MCI Status of executed operation.

Defines status and error codes returned by most of the MCI driver functions.

Returned by:

Enumerator:
ARM_MCI_OK 

Operation succeeded.

ARM_MCI_ERROR 

Unspecified error.

ARM_MCI_ERROR_UNSUPPORTED 

Operation not supported.

ARM_MCI_ERROR_RESPONSE 

Invalid response received.

ARM_MCI_ERROR_COMMAND_TIMEOUT 

Command response timeout.

ARM_MCI_ERROR_TRANSFER_TIMEOUT 

Data transfer timeout.

ARM_MCI_ERROR_CRC 

CRC check failed.

MCI Transfer Mode.

Lists the supported data transfer directions (read from MCI; write to MCI).

Parameter for:

Enumerator:
ARM_MCI_TRANSFER_READ 

Read Transfer (from MCI)

ARM_MCI_TRANSFER_WRITE 

Write Transfer (to MCI)

Function Documentation

ARM_MCI_STATUS ARM_MCI_AbortTransfer ( void  )

Abort current read/write data transfer.

Returns
execution status ARM_MCI_STATUS

Abort a data transfer operation initiated with ARM_MCI_ReadTransfer or ARM_MCI_WriteTransfer.

Note
This function is not available when the SPI mode is used.
ARM_MCI_STATUS ARM_MCI_BusDataWidth ( ARM_MCI_BUS_DATA_WIDTH  width)

Setup bus data width for Memory Card transfers.

Parameters
[in]widthRequested bus data width
Returns
execution status ARM_MCI_STATUS

Set the bus data width of the MCI interface as specified by ARM_MCI_BUS_DATA_WIDTH in width. For example, the use of ultra-high-speed (UHS) SD cards requires 1.8 volt operation and 4-bit bus data width.

Note
This function is not available when the SPI mode is used.
ARM_MCI_STATUS ARM_MCI_BusMode ( ARM_MCI_BUS_MODE  mode)

Setup the bus mode for Memory Card transfers.

Parameters
[in]modeRequested bus mode
Returns
execution status ARM_MCI_STATUS

Set the bus mode of the MCI interface as specified by ARM_MCI_BUS_MODE in mode.

  • push-pull operation allows reliable high-speed communication and should be preferred.
  • open drain operation allows to use multiple SD memory devices at the same bus.
Note
This function is not available when the SPI mode is used.
ARM_MCI_STATUS ARM_MCI_BusSignaling ( ARM_MCI_BUS_SIGNALING  voltage)

Set bus signaling voltage for MCI transfers.

Parameters
[in]voltageRequested signaling voltage
Returns
execution status ARM_MCI_STATUS

Set the bus signal voltage of the MCI interface as specified by ARM_MCI_BUS_SIGNALING in voltage. All SD card families initially use a 3.3 volt electrical interface. On command, some SD cards can switch to 1.8 volt operation. For example, the use of ultra-high-speed (UHS) SD cards requires 1.8 volt operation and 4-bit bus data width.

Note
This function is not available when the SPI mode is used.
uint32_t ARM_MCI_BusSpeed ( uint32_t  bps)

Setup bus speed for Memory Card transfers.

Parameters
[in]bpsRequested speed in bits/s
Returns
Configured bus speed in bits/s

Set the data transfer speed of the MCI to the requested baud rate in bits per second.

Note
This function is not available when the SPI mode is used.
ARM_MCI_STATUS ARM_MCI_CardInitialize ( void  )

Perform Memory Card initialization sequence.

Returns
execution status ARM_MCI_STATUS

Send card initialization sequence.

Note
This function is not available when the SPI mode is used.
ARM_MCI_STATUS ARM_MCI_CardPower ( ARM_MCI_POWER  voltage)

Set Memory Card supply voltage.

Parameters
[in]voltageMemory Card supply voltage ARM_MCI_POWER
Returns
execution status ARM_MCI_STATUS

Switch the SD memory power supply voltage.

Note
This function is not available when the SPI mode is used.
ARM_MCI_SWITCH ARM_MCI_CardSwitchRead ( void  )

Read state of Memory Card switches.

Returns
execution status ARM_MCI_SWITCH

Read the status of optional card switches.

ARM_MCI_CAPABILITIES ARM_MCI_GetCapabilities ( void  )

Get driver capabilities.

Returns
ARM_MCI_CAPABILITIES

Retrieves information about capabilities in this driver implementation. The bitfield members of the struct ARM_MCI_CAPABILITIES encode various capabilities, for example if a hardware is write protected or is able to create signal events using the ARM_MCI_SignalEvent callback function.

Example:

extern ARM_DRIVER_MCI ARM_Driver_MCI0;
ARM_DRIVER_MCI *drv_info;
void read_capabilities (void) {
ARM_MCI_CAPABILITIES drv_capabilities;
drv_info = &ARM_Driver_MCI0;
drv_capablilities = drv_info->GetCapabilities ();
// interrogate capabilities
}
ARM_DRV_VERSION ARM_MCI_GetVersion ( void  )

Get driver version.

Returns
ARM_DRV_VERSION

Returns version information of the driver implementation in ARM_DRV_VERSION

  • API version is the version of the CMSIS-Driver specification used to implement this driver.
  • Driver version is source code version of the actual driver implementation.

Example:

extern ARM_DRIVER_MCI ARM_Driver_MCI;
ARM_DRIVER_MCI *drv_info;
void setup_mci (void) {
ARM_DRV_VERSION version;
drv_info = &ARM_DRIVER_MCI0;
version = drv_info->GetVersion ();
if (version.api < 0x10A) { // requires at minimum API version 1.10 or higher
// error handling
return;
}
}
ARM_MCI_STATUS ARM_MCI_Initialize ( ARM_MCI_SignalEvent_t  cb_event,
bool  spi_mode 
)

Initialize the Memory Card Interface.

Parameters
[in]cb_eventPointer to ARM_MCI_SignalEvent
[in]spi_modeSPI Mode (default is native MMC/SD Mode)
Returns
execution status ARM_MCI_STATUS

The function initializes the MCI interface. It is called when the middleware component starts operation.

The function performs the following operations:

  • Initializes the resources needed for the MCI interface.
  • Registers the ARM_MCI_SignalEvent callback function.
  • Sets the peripheral to ARM_POWER_LOW power mode.
  • Sets or disables the SPI mode.

The parameter cb_event is a pointer to the ARM_MCI_SignalEvent callback function; use a NULL pointer when no callback signals are required.

The parameter spi_mode is a boolean value indicating whether the device is running in SPI mode or not.

Example:

ARM_MCI_STATUS ARM_MCI_PowerControl ( ARM_POWER_STATE  state)

Control Memory Card Interface Power.

Parameters
[in]statePower state ARM_POWER_STATE
Returns
execution status ARM_MCI_STATUS

Controls the power modes of the MCI interface.

state can be:

  • ARM_POWER_OFF: MCI peripheral is turned off.
  • ARM_POWER_FULL: MCI peripheral is turned on and fully operational.
  • ARM_POWER_LOW: no available on a MCI interface.

If state specifies an unsupported mode, the function returns ARM_MCI_ERROR_UNSUPPORTED.

ARM_MCI_STATUS ARM_MCI_ReadTransfer ( uint8_t *  data,
uint32_t  block_count,
uint32_t  block_size 
)

Perform read transfer.

Parameters
[out]dataPointer to data block(s) to be read
[in]block_countNumber of blocks
[in]block_sizeSize of a block in bytes
Returns
execution status ARM_MCI_STATUS

Read data from the SD memory.

Note
This function is not available when the SPI mode is used.
ARM_MCI_STATUS ARM_MCI_SendCommand ( ARM_MC_COMMAND  cmd,
uint32_t  cmd_arg,
ARM_MC_RESPONSE  response_type,
uint32_t *  ptr_response 
)

Send Command to card and get the response.

Parameters
[in]cmdMemory Card command ARM_MC_COMMAND
[in]cmd_argCommand argument
[in]response_typeExpected response type
[out]ptr_responsePointer to response
Returns
execution status ARM_MCI_STATUS

Send commands to the SD memory and return the command response.

Note
This function is not available when the SPI mode is used.
ARM_MCI_STATUS ARM_MCI_SetupTransfer ( uint8_t *  data,
uint32_t  block_count,
uint32_t  block_size,
ARM_MCI_TRANSFER_MODE  mode 
)

Setup read or write transfer operation.

Parameters
[in,out]dataPointer to data block(s) to be written or read
[in]block_countNumber of blocks
[in]block_sizeSize of a block in bytes
[in]modeRead or write transfer mode
Returns
execution status ARM_MCI_STATUS

Setup a data transfer operation.

Note
This function is not available when the SPI mode is used.
void ARM_MCI_SignalEvent ( ARM_MCI_EVENT  event)

Callback function that signals a MCI Card Event.

Parameters
[in]eventARM_MCI_EVENT
Returns
none

Signal that a SD card operation has been completed or information about the card status. This optional call back function is implemented in the middleware and published to the driver by the function ARM_MCI_Initialize.

ARM_MCI_STATUS ARM_MCI_Uninitialize ( void  )

De-initialize Memory Card Interface.

Returns
execution status ARM_MCI_STATUS

The function ARM_MCI_Uninitialize de-initializes the resources of I2C interface and sets the peripheral to ARM_POWER_OFF power mode.

It is called when the middleware component stops operation and releases the software resources used by the interface.

ARM_MCI_STATUS ARM_MCI_WriteTransfer ( uint8_t *  data,
uint32_t  block_count,
uint32_t  block_size 
)

Perform write transfer.

Parameters
[in]dataPointer to data block(s) to be written
[in]block_countNumber of blocks
[in]block_sizeSize of a block in bytes
Returns
execution status ARM_MCI_STATUS

Write data to the SD memory.

Note
This function is not available when the SPI mode is used.