stm32_eval_spi_sd.h File Reference

This file contains all the functions prototypes for the stm32_eval_spi_sd firmware driver. More...

#include "stm32_eval.h"

Go to the source code of this file.

Data Structures

struct  SD_CardInfo
 SD Card information. More...
struct  SD_CID
 Card Identification Data: CID Register. More...
struct  SD_CSD
 Card Specific Data: CSD Register. More...

Defines

#define SD_BLOCK_SIZE   0x200
 Block Size.
#define SD_CMD_CLR_WRITE_PROT   29
#define SD_CMD_ERASE   38
#define SD_CMD_ERASE_GRP_END   36
#define SD_CMD_ERASE_GRP_START   35
#define SD_CMD_GO_IDLE_STATE   0
 Commands: CMDxx = CMD-number | 0x40.
#define SD_CMD_PROG_CSD   27
#define SD_CMD_READ_MULT_BLOCK   18
#define SD_CMD_READ_SINGLE_BLOCK   17
#define SD_CMD_SD_ERASE_GRP_END   33
#define SD_CMD_SD_ERASE_GRP_START   32
#define SD_CMD_SEND_CID   10
#define SD_CMD_SEND_CSD   9
#define SD_CMD_SEND_OP_COND   1
#define SD_CMD_SEND_STATUS   13
#define SD_CMD_SEND_WRITE_PROT   30
#define SD_CMD_SET_BLOCK_COUNT   23
#define SD_CMD_SET_BLOCKLEN   16
#define SD_CMD_SET_WRITE_PROT   28
#define SD_CMD_STOP_TRANSMISSION   12
#define SD_CMD_UNTAG_ERASE_GROUP   37
#define SD_CMD_UNTAG_SECTOR   34
#define SD_CMD_WRITE_MULT_BLOCK   25
#define SD_CMD_WRITE_SINGLE_BLOCK   24
#define SD_CS_HIGH()   GPIO_SetBits(SD_CS_GPIO_PORT, SD_CS_PIN)
 Deselect SD Card: ChipSelect pin high.
#define SD_CS_LOW()   GPIO_ResetBits(SD_CS_GPIO_PORT, SD_CS_PIN)
 Select SD Card: ChipSelect pin low.
#define SD_DUMMY_BYTE   0xFF
 Dummy byte.
#define SD_NOT_PRESENT   ((uint8_t)0x00)
#define SD_PRESENT   ((uint8_t)0x01)
 SD detection on its memory slot.
#define SD_START_DATA_MULTIPLE_BLOCK_READ   0xFE
#define SD_START_DATA_MULTIPLE_BLOCK_WRITE   0xFD
#define SD_START_DATA_SINGLE_BLOCK_READ   0xFE
 Start Data tokens: Tokens (necessary because at nop/idle (and CS active) only 0xff is on the data/command line).
#define SD_START_DATA_SINGLE_BLOCK_WRITE   0xFE
#define SD_STOP_DATA_MULTIPLE_BLOCK_WRITE   0xFD

Enumerations

enum  SD_Error {
  SD_CMD_CRC_FAIL = (1), SD_DATA_CRC_FAIL = (2), SD_CMD_RSP_TIMEOUT = (3), SD_DATA_TIMEOUT = (4),
  SD_TX_UNDERRUN = (5), SD_RX_OVERRUN = (6), SD_START_BIT_ERR = (7), SD_CMD_OUT_OF_RANGE = (8),
  SD_ADDR_MISALIGNED = (9), SD_BLOCK_LEN_ERR = (10), SD_ERASE_SEQ_ERR = (11), SD_BAD_ERASE_PARAM = (12),
  SD_WRITE_PROT_VIOLATION = (13), SD_LOCK_UNLOCK_FAILED = (14), SD_COM_CRC_FAILED = (15), SD_ILLEGAL_CMD = (16),
  SD_CARD_ECC_FAILED = (17), SD_CC_ERROR = (18), SD_GENERAL_UNKNOWN_ERROR = (19), SD_STREAM_READ_UNDERRUN = (20),
  SD_STREAM_WRITE_OVERRUN = (21), SD_CID_CSD_OVERWRITE = (22), SD_WP_ERASE_SKIP = (23), SD_CARD_ECC_DISABLED = (24),
  SD_ERASE_RESET = (25), SD_AKE_SEQ_ERROR = (26), SD_INVALID_VOLTRANGE = (27), SD_ADDR_OUT_OF_RANGE = (28),
  SD_SWITCH_ERROR = (29), SD_SDIO_DISABLED = (30), SD_SDIO_FUNCTION_BUSY = (31), SD_SDIO_FUNCTION_FAILED = (32),
  SD_SDIO_UNKNOWN_FUNCTION = (33), SD_INTERNAL_ERROR, SD_NOT_CONFIGURED, SD_REQUEST_PENDING,
  SD_REQUEST_NOT_APPLICABLE, SD_INVALID_PARAMETER, SD_UNSUPPORTED_FEATURE, SD_UNSUPPORTED_HW,
  SD_ERROR, SD_OK, SD_RESPONSE_NO_ERROR = (0x00), SD_IN_IDLE_STATE = (0x01),
  SD_ERASE_RESET = (0x02), SD_ILLEGAL_COMMAND = (0x04), SD_COM_CRC_ERROR = (0x08), SD_ERASE_SEQUENCE_ERROR = (0x10),
  SD_ADDRESS_ERROR = (0x20), SD_PARAMETER_ERROR = (0x40), SD_RESPONSE_FAILURE = (0xFF), SD_DATA_OK = (0x05),
  SD_DATA_CRC_ERROR = (0x0B), SD_DATA_WRITE_ERROR = (0x0D), SD_DATA_OTHER_ERROR = (0xFF)
}

Functions

void SD_DeInit (void)
 DeInitializes the SDIO interface.
uint8_t SD_Detect (void)
 Detect if SD card is correctly plugged in the memory slot.
SD_Error SD_GetCardInfo (SD_CardInfo *cardinfo)
 Returns information about specific card.
SD_Error SD_GetCIDRegister (SD_CID *SD_cid)
 Read the CID card register.
SD_Error SD_GetCSDRegister (SD_CSD *SD_csd)
 Read the CSD card register.
uint8_t SD_GetDataResponse (void)
 Get SD card data response.
SD_Error SD_GetResponse (uint8_t Response)
 Returns the SD response.
uint16_t SD_GetStatus (void)
 Gets the cuurent sd card data transfer status.
SD_Error SD_GoIdleState (void)
 Put SD in Idle state.
SD_Error SD_Init (void)
 Initializes the SD Card and put it into StandBy State (Ready for data transfer).
SD_Error SD_ReadBlock (uint8_t *pBuffer, uint32_t ReadAddr, uint16_t BlockSize)
 Allows to read one block from a specified address in a card.
uint8_t SD_ReadByte (void)
 Read a byte from the SD.
SD_Error SD_ReadMultiBlocks (uint8_t *pBuffer, uint32_t ReadAddr, uint16_t BlockSize, uint32_t NumberOfBlocks)
 Allows to read blocks from a specified address in a card.
void SD_SendCmd (uint8_t Cmd, uint32_t Arg, uint8_t Crc)
 Send 5 bytes command to the SD card.
SD_Error SD_WriteBlock (uint8_t *pBuffer, uint32_t WriteAddr, uint16_t BlockSize)
 Allows to write one block starting from a specified address in a card.
uint8_t SD_WriteByte (uint8_t byte)
 Write a byte on the SD.
SD_Error SD_WriteMultiBlocks (uint8_t *pBuffer, uint32_t WriteAddr, uint16_t BlockSize, uint32_t NumberOfBlocks)
 Allows to write blocks starting from a specified address in a card.

Detailed Description

This file contains all the functions prototypes for the stm32_eval_spi_sd firmware driver.

Author:
MCD Application Team
Version:
V4.3.0
Date:
10/15/2010

THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.

© COPYRIGHT 2010 STMicroelectronics

Definition in file stm32_eval_spi_sd.h.

STM32F10x Standard Peripherals Library: Footer

 

 

 

      For complete documentation on STM32(CORTEX M3) 32-bit Microcontrollers platform visit  www.st.com/STM32