Keil Logo

SPI Driver

SPI Driver describes the low-level routines to interface the SD/MMC Flash memory cards or SPI data Flash memory.

Driver modules are located in the folder \ARM\RL\FlashFS\Drivers and have the file name SPI_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);
  U8   (*Send)       (U8 outb);
  BOOL (*SendBuf)    (U8 *buf, U32 sz);
  BOOL (*RecBuf)     (U8 *buf, U32 sz);
  BOOL (*BusSpeed)   (U32 kbaud);
  BOOL (*SetSS)      (U32 ss);
  U32  (*CheckMedia) (void);              /* Optional, NULL if not existing */
} const SPI_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 SPI interface by the funinit function.
  • Send()
    This function is used to send and read a byte on the SPI interface.
  • SendBuf()
    This function is used to send a block of data to the SPI interface.
  • RecBuf()
    This function is used to receive a block of data from the SPI interface.
  • BusSpeed()
    This function is used to set the desired baud rate speed.
  • SetSS()
    This function is used to enable or disable SPI Slave Select signal (drive it high or low).
  • 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.