ChibiOS/HAL  6.1.0
hal_mmc_spi.c File Reference

MMC over SPI driver code. More...

#include <string.h>
#include "hal.h"

Go to the source code of this file.

Functions

static uint8_t crc7 (uint8_t crc, const uint8_t *buffer, size_t len)
 Calculate the MMC standard CRC-7 based on a lookup table. More...
 
static void wait (MMCDriver *mmcp)
 Waits an idle condition. More...
 
static void send_hdr (MMCDriver *mmcp, uint8_t cmd, uint32_t arg)
 Sends a command header. More...
 
static uint8_t recvr1 (MMCDriver *mmcp)
 Receives a single byte response. More...
 
static uint8_t recvr3 (MMCDriver *mmcp, uint8_t *buffer)
 Receives a three byte response. More...
 
static uint8_t send_command_R1 (MMCDriver *mmcp, uint8_t cmd, uint32_t arg)
 Sends a command an returns a single byte response. More...
 
static uint8_t send_command_R3 (MMCDriver *mmcp, uint8_t cmd, uint32_t arg, uint8_t *response)
 Sends a command which returns a five bytes response (R3). More...
 
static bool read_CxD (MMCDriver *mmcp, uint8_t cmd, uint32_t cxd[4])
 Reads the CSD. More...
 
static void sync (MMCDriver *mmcp)
 Waits that the card reaches an idle state. More...
 
void mmcInit (void)
 MMC over SPI driver initialization. More...
 
void mmcObjectInit (MMCDriver *mmcp)
 Initializes an instance. More...
 
void mmcStart (MMCDriver *mmcp, const MMCConfig *config)
 Configures and activates the MMC peripheral. More...
 
void mmcStop (MMCDriver *mmcp)
 Disables the MMC peripheral. More...
 
bool mmcConnect (MMCDriver *mmcp)
 Performs the initialization procedure on the inserted card. More...
 
bool mmcDisconnect (MMCDriver *mmcp)
 Brings the driver in a state safe for card removal. More...
 
bool mmcStartSequentialRead (MMCDriver *mmcp, uint32_t startblk)
 Starts a sequential read. More...
 
bool mmcSequentialRead (MMCDriver *mmcp, uint8_t *buffer)
 Reads a block within a sequential read operation. More...
 
bool mmcStopSequentialRead (MMCDriver *mmcp)
 Stops a sequential read gracefully. More...
 
bool mmcStartSequentialWrite (MMCDriver *mmcp, uint32_t startblk)
 Starts a sequential write. More...
 
bool mmcSequentialWrite (MMCDriver *mmcp, const uint8_t *buffer)
 Writes a block within a sequential write operation. More...
 
bool mmcStopSequentialWrite (MMCDriver *mmcp)
 Stops a sequential write gracefully. More...
 
bool mmcSync (MMCDriver *mmcp)
 Waits for card idle condition. More...
 
bool mmcGetInfo (MMCDriver *mmcp, BlockDeviceInfo *bdip)
 Returns the media info. More...
 
bool mmcErase (MMCDriver *mmcp, uint32_t startblk, uint32_t endblk)
 Erases blocks. More...
 

Variables

static const struct MMCDriverVMT mmc_vmt
 Virtual methods table. More...
 
static const uint8_t crc7_lookup_table [256]
 Lookup table for CRC-7 ( based on polynomial x^7 + x^3 + 1). More...
 

Detailed Description

MMC over SPI driver code.

Definition in file hal_mmc_spi.c.