PDL for FM4  Version1.2
Peripheral Driverl Library for FM4
sd.c File Reference
#include "sd.h"
Include dependency graph for sd.c:

Go to the source code of this file.

Macros

#define SD_PCG   0x4003C120
 
#define PCG_ENABLE   (1UL<<8)
 
#define DELAYUNIT   5000
 
#define WAITTIME   50000
 
#define RETRYTIMES   100
 

Functions

static void dly_1unit (uint32_t u32Delay)
 Delay according to specified number. More...
 
static void SdInitPins (void)
 Init the IO configuration for SDIF. More...
 
static boolean_t SdEnablePCG (void)
 Enable SD I/F peripheral clock. More...
 
static void SdDisablePCG (void)
 Disable SD I/F peripheral clock. More...
 
static void SdInitHostInternalData (volatile stc_sd_config_t *pstcSdCfg, stc_sd_comdconfig_t *pstcCmdCfg)
 Initial the SDIF internal data. More...
 
static boolean_t SdGetCmdComplete (void)
 Check whether the command complete. More...
 
static void SdClearCmdComplete (void)
 Clear command complete flag. More...
 
static boolean_t SdGetTrsComplete (void)
 Check whether the transfer complete. More...
 
static void SdGetCardStatus (volatile FM4_SDIF_TypeDef *pstcSd, volatile stc_sd_config_t *pstcCfg)
 Wait for card status stable and set the card status flag. More...
 
static void SdIrqHandler (void)
 SD interrupt handler. More...
 
static void SdGetResponse (volatile FM4_SDIF_TypeDef *pstcSd, en_sd_response_t enSdresponse, uint32_t *pu32Buf)
 get response More...
 
static boolean_t SdSendCmdOnly (volatile FM4_SDIF_TypeDef *pstcSd, stc_sd_comdconfig_t *pstcCmdCfg)
 Send command without data transfer using DAT line. More...
 
static boolean_t SdSendCmdDatLine (volatile FM4_SDIF_TypeDef *pstcSd, stc_sd_comdconfig_t *pstcCmdCfg)
 Send command with data transfer using DAT line. More...
 
static boolean_t SdTxData (volatile FM4_SDIF_TypeDef *pstcSd, stc_sd_comdconfig_t *pstcCmdCfg, uint32_t *pu32Buf)
 Send data segment using DAT line. More...
 
static boolean_t SdRxRsp (volatile FM4_SDIF_TypeDef *pstcSd, stc_sd_comdconfig_t *pstcCmdCfg, uint32_t *pu32Buf)
 Get response data after command. More...
 
static boolean_t SdRxData (volatile FM4_SDIF_TypeDef *pstcSd, stc_sd_comdconfig_t *pstcCmdCfg, uint32_t *pu32Buf)
 Receive data segment using DAT line. More...
 
en_result_t Sd_EnableInt (volatile FM4_SDIF_TypeDef *pstcSd)
 Enable the interrupt flag of SD. More...
 
en_result_t Sd_DisableInt (volatile FM4_SDIF_TypeDef *pstcSd)
 Disable the interrupt flag of SD. More...
 
en_sd_existing_t Sd_CardDetect (volatile stc_sd_config_t *pstcCmdCfg)
 Detect the SD card insertion status. More...
 
en_result_t Sd_ClockSupply (volatile FM4_SDIF_TypeDef *pstcSd, en_sd_clk_t enClk)
 Supply clock to an SD card. More...
 
en_result_t Sd_ClockStop (volatile FM4_SDIF_TypeDef *pstcSd)
 stop clock More...
 
en_result_t Sd_BusPowerControl (volatile FM4_SDIF_TypeDef *pstcSd, en_sd_busvoltage_t enVoltage)
 Provide power for SD card. More...
 
boolean_t Sd_SendCmd (en_sd_transaction_t enTran, volatile FM4_SDIF_TypeDef *pstcSd, stc_sd_comdconfig_t *pstcCmdCfg, uint32_t *pu32Buf)
 Transmit commands and check the corresponding response. More...
 
boolean_t Sd_TxData (volatile FM4_SDIF_TypeDef *pstcSd, stc_sd_comdconfig_t *pstcCmdCfg, uint32_t *pu32Buf)
 Transmit data segment for write commands only. More...
 
boolean_t Sd_RxData (en_sd_transaction_t enTran, volatile FM4_SDIF_TypeDef *pstcSd, stc_sd_comdconfig_t *pstcCmdCfg, uint32_t *pu32Buf)
 Receive the data of read command. More...
 
en_result_t Sd_SoftwareReset (volatile FM4_SDIF_TypeDef *pstcSd, uint8_t u8reset)
 software reset for command and data line More...
 
void Sd_Handler (void)
 SD interrupt entry. More...
 
en_result_t Sd_HostInit (void)
 Initialize SD host. More...
 
en_result_t Sd_HostDeInit (void)
 Deinitializes SD. More...
 

Variables

volatile stc_sd_config_t Sd_stcCfg
 
stc_sd_comdconfig_t Sd_stcCmdCfg
 
volatile FM4_SDIF_TypeDef * Sd_stcCtrl = (volatile FM4_SDIF_TypeDef *)FM4_SDIF_BASE
 

Detailed Description

History:

  • 2013-04-16 1.0 QXu First version.
  • 2013-07-24 1.1 RQian Modification.

Definition in file sd.c.