PDL for FM4  Version1.2
Peripheral Driverl Library for FM4
sd.h File Reference
#include "pdl.h"
#include "sd_cfg.h"
Include dependency graph for sd.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  stc_sd_cmdconfig
 SD command configure data. More...
 
struct  stc_sd_config
 SD configure data. More...
 

Macros

#define stc_sd_t   FM4_SDIF_TypeDef
 
#define SD_TIMEOUT_DATLINE   1000
 
#define RESET_DAT   (1<<2)
 
#define RESET_CMD   (1<<1)
 
#define RESET_ALL   1
 

Typedefs

typedef void(* func_ptr_sd_arg32_t )(volatile FM4_SDIF_TypeDef *)
 
typedef enum en_sd_clk en_sd_clk_t
 SD clock SDCLK frequency. More...
 
typedef enum en_sd_transaction en_sd_transaction_t
 SD transaction cases (with or without data line) More...
 
typedef enum en_sd_dir en_sd_dir_t
 SD transfer direction. More...
 
typedef enum en_sd_cmd_type en_sd_scmd_type_t
 SD special command. More...
 
typedef enum en_sd_existing en_sd_existing_t
 SD card exist status. More...
 
typedef enum en_sd_buswidth en_sd_buswidth_t
 SD bus width. More...
 
typedef enum en_sd_busvoltage en_sd_busvoltage_t
 SD bus voltage level. More...
 
typedef enum en_sd_response en_sd_response_t
 SD response. More...
 
typedef enum en_sd_auto_cmd en_sd_auto_cmd_t
 SD auto command functions. More...
 
typedef enum en_sd_boundary en_sd_boundary_t
 
typedef struct stc_sd_cmdconfig stc_sd_comdconfig_t
 SD command configure data. More...
 
typedef struct stc_sd_config stc_sd_config_t
 SD configure data. More...
 

Enumerations

enum  en_sd_clk {
  CLK_25M = 25,
  CLK_50M = 50
}
 SD clock SDCLK frequency. More...
 
enum  en_sd_transaction {
  NO_RESPONSE = 0,
  NO_DATA,
  SINGLE_BLOCK,
  MULTI_BLOCK
}
 SD transaction cases (with or without data line) More...
 
enum  en_sd_dir {
  SD_WRITE = 0,
  SD_READ = 1
}
 SD transfer direction. More...
 
enum  en_sd_cmd_type {
  NORMAL = 0,
  SUSPEND = 1,
  RESUME = 2,
  ABORT = 3
}
 SD special command. More...
 
enum  en_sd_existing {
  DEBOUNCING = 0,
  INSERTED = 1,
  REMOVAL = 2
}
 SD card exist status. More...
 
enum  en_sd_buswidth {
  BIT_1 = 0,
  BIT_4 = 1
}
 SD bus width. More...
 
enum  en_sd_busvoltage {
  V1_8 = 0x05,
  V3_0 = 0x06,
  V3_3 = 0x07
}
 SD bus voltage level. More...
 
enum  en_sd_response {
  NO_RSP = 0,
  R1NORMAL_R5_R6_R7,
  R1AUTO,
  R1B_NORMAL,
  R1B_AUTO,
  R2,
  R3_R4,
  R5B
}
 SD response. More...
 
enum  en_sd_auto_cmd {
  AUTO_DISABLE = 0,
  AUTO_CMD12 = 1,
  AUTO_CMD23 =2
}
 SD auto command functions. More...
 
enum  en_sd_boundary {
  BOUND_4K = 0,
  BOUND_8K = 1,
  BOUND_16K = 2,
  BOUND_32K = 3,
  BOUND_64K = 4,
  BOUND_128K = 5,
  BOUND_256K = 6,
  BOUND_512K = 7
}
 

Functions

en_result_t Sd_HostInit (void)
 Initialize SD host. More...
 
en_result_t Sd_HostDeInit (void)
 Deinitializes SD. More...
 
en_result_t Sd_SoftwareReset (volatile FM4_SDIF_TypeDef *pstcSd, uint8_t u8reset)
 software reset for command and data line 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...
 
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...
 
void Sd_Handler (void)
 SD interrupt entry. 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...
 
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...
 

Variables

volatile stc_sd_config_t Sd_stcCfg
 
stc_sd_comdconfig_t Sd_stcCmdCfg
 
volatile FM4_SDIF_TypeDef * Sd_stcCtrl
 

Detailed Description

Headerfile for SD functions

History:

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

Definition in file sd.h.