Keil Logo

MCI Driver

MCI Driver describes the low-level routines to interface the SD/MMC flash memory cards in SD-Native mode. The host controller must have a Memory Card Interface peripheral that supports SD/MMC Memory Card interfacing in native mode. An MCI Driver is not required when the device is used in SPI mode.

Driver modules are located in the folder \ARM\RL\FlashFS\Drivers and have the file name MCI_device_family.c. Copy the driver module to the project folder. Any module can be used as a template for creating new drivers.

The driver control block structure is defined in the file File_Config.h as follows:

typedef struct {
  BOOL (*Init)       (void);
  BOOL (*UnInit)     (void);
  void (*Delay)      (U32 us);
  BOOL (*BusMode)    (U32 mode);
  BOOL (*BusWidth)   (U32 width);
  BOOL (*BusSpeed)   (U32 kbaud);
  U32  (*Command)    (U8  cmd, U32 arg, U32 resp, U32 *rp);
  BOOL (*ReadBlock)  (U32 bl, U8 *buf, U32 cnt);
  BOOL (*WriteBlock) (U32 bl, U8 *buf, U32 cnt);
  BOOL (*SetDma)     (U32 mode, U8 *buf, U32 cnt); /* NULL for local DMA or non DMA  */
  U32  (*CheckMedia) (void);                       /* Optional, NULL if not existing */
} const MCI_DRV;

Developers can adapt the code in the following functions:

  • Init()
    This function is called when the RL-FlashFS is initialized by the finit function.
  • UnInit()
    This function is called to uninitialize the MCI interface by the funinit function.
  • Delay()
    This function is called to delay a program execution in the driver.
  • BusMode()
    This function is used to set the bus mode to push-pull or open-drain.
  • BusWidth()
    This function is used to set the bus width to 1-bit or 4-bit bus.
  • BusSpeed()
    This function is used to set the desired baud rate speed.
  • Command()
    This function is used to send SD/MMC Command.
  • ReadBlock()
    This function is used to read block(s) of data from SD/MMC memory card.
  • WriteBlock()
    This function is used to write block(s) of data to SD/MMC memory card.
  • SetDma()
    This function is used to set the DMA for data transfer.
  • CheckMedia()
    This function is used to check the SD/MMC media status (Card Inserted, Write Protected).
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.