Kinetis SDK v.1.3 API Reference Manual  Rev. 0
Freescale Semiconductor, Inc.
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages

Overview

This section describes the programming interface of the SDHC HAL driver.

Data Structures

struct  sdhc_hal_basic_info_t
 Data structure to get the basic information of SDHC. More...
 
struct  sdhc_hal_sdclk_config_t
 SD clock configuration to configure the clock of SD protocol unit. More...
 
struct  sdhc_mmcboot_param_t
 Data structure to configure the MMC boot feature. More...
 
struct  sdhc_hal_config_t
 Data structure to initialize the SDHC. More...
 
struct  sdhc_hal_cmd_req_t
 Command request structure. More...
 

Macros

#define SDHC_HAL_ADMA1_ADDR_ALIGN   (4096)
 SDHC ADMA address alignment size and length alignment size.
 

Enumerations

enum  sdhc_hal_mmcboot_t
 MMC card BOOT type.
 
enum  sdhc_hal_led_t
 Led control status.
 
enum  sdhc_hal_dtw_t
 Data transfer width.
 
enum  sdhc_hal_endian_t
 SDHC endian mode.
 
enum  sdhc_hal_dma_mode_t
 SDHC DMA mode.
 
enum  sdhc_hal_curstat_type_t {
  kSdhcHalIsCmdInhibit,
  kSdhcHalIsDataInhibit,
  kSdhcHalIsDataLineActive,
  kSdhcHalIsSdClockStable,
  kSdhcHalIsIpgClockOff,
  kSdhcHalIsSysClockOff,
  kSdhcHalIsPeripheralClockOff,
  kSdhcHalIsSdClkOff,
  kSdhcHalIsWriteTransferActive,
  kSdhcHalIsReadTransferActive,
  kSdhcHalIsBuffWriteEnabled,
  kSdhcHalIsBuffReadEnabled,
  kSdhcHalIsCardInserted,
  kSdhcHalIsCmdLineLevelHigh,
  kSdhcHalGetDataLine0Level,
  kSdhcHalGetDataLine1Level,
  kSdhcHalGetDataLine2Level,
  kSdhcHalGetDataLine3Level,
  kSdhcHalGetDataLine4Level,
  kSdhcHalGetDataLine5Level,
  kSdhcHalGetDataLine6Level,
  kSdhcHalGetDataLine7Level,
  kSdhcHalGetCdTestLevel
}
 Current SDHC status type. More...
 
enum  sdhc_hal_err_type_t {
  kAc12Err,
  kAdmaErr
}
 SDHC error type. More...
 

SDHC HAL FUNCTION

void SDHC_HAL_SendCmd (SDHC_Type *base, const sdhc_hal_cmd_req_t *cmdReq)
 Sends command to card. More...
 
static void SDHC_HAL_SetData (SDHC_Type *base, uint32_t data)
 Fills the the data port. More...
 
static uint32_t SDHC_HAL_GetData (SDHC_Type *base)
 Retrieves the data from the data port. More...
 
bool SDHC_HAL_GetCurState (SDHC_Type *base, sdhc_hal_curstat_type_t stateType)
 Gets the current card's status. More...
 
static void SDHC_HAL_SetDataTransferWidth (SDHC_Type *base, sdhc_hal_dtw_t dtw)
 Sets the data transfer width. More...
 
static void SDHC_HAL_SetContinueRequest (SDHC_Type *base)
 Restarts a transaction which has stopped at the block gap. More...
 
void SDHC_HAL_Config (SDHC_Type *base, const sdhc_hal_config_t *initConfig)
 Initialize the SDHC according to the configuration user input. More...
 
void SDHC_HAL_ConfigSdClock (SDHC_Type *base, sdhc_hal_sdclk_config_t *clkConfItms)
 Sets SDHC SD protocol unit clock. More...
 
static uint32_t SDHC_HAL_GetIntFlags (SDHC_Type *base)
 Gets the current interrupt status. More...
 
static void SDHC_HAL_ClearIntFlags (SDHC_Type *base, uint32_t mask)
 Clears a specified interrupt status. More...
 
void SDHC_HAL_GetAllErrStatus (SDHC_Type *base, sdhc_hal_err_type_t errType, uint32_t *errFlags)
 Gets the error status of SDHC. More...
 
static void SDHC_HAL_SetForceEventFlags (SDHC_Type *base, uint32_t mask)
 Sets the force events according to the given mask. More...
 
static void SDHC_HAL_SetAdmaAddress (SDHC_Type *base, uint32_t address)
 Sets the ADMA address. More...
 
uint32_t SDHC_HAL_GetResponse (SDHC_Type *base, uint32_t index)
 Gets the command response. More...
 
void SDHC_HAL_SetIntSignal (SDHC_Type *base, bool enable, uint32_t mask)
 Enables the specified interrupts. More...
 
void SDHC_HAL_SetIntState (SDHC_Type *base, bool enable, uint32_t mask)
 Enables the specified interrupt state. More...
 
uint32_t SDHC_HAL_Reset (SDHC_Type *base, uint32_t type, uint32_t timeout)
 Performs an SDHC reset. More...
 
uint32_t SDHC_HAL_InitCard (SDHC_Type *base, uint32_t timeout)
 Sends 80 clocks to the card to initialize the card. More...
 
void SDHC_HAL_Init (SDHC_Type *base)
 Initializes the SDHC HAL. More...
 
void SDHC_HAL_GetBasicInfo (SDHC_Type *base, sdhc_hal_basic_info_t *basicInfo)
 Gets the capability of SDHC. More...
 

Data Structure Documentation

struct sdhc_hal_basic_info_t

Data Fields

uint8_t specVer
 Save the specification version.
 
uint8_t vendorVer
 Save the vendor version.
 
uint16_t maxBlkLen
 Save the maximum block length.
 
uint32_t capability
 The capability flags.
 
struct sdhc_hal_sdclk_config_t
struct sdhc_mmcboot_param_t

Data Fields

uint32_t ackTimeout
 Sets the timeout value for the boot ACK. More...
 
sdhc_hal_mmcboot_t mode
 Configures the boot mode. More...
 
uint32_t blockCount
 Configures the the block count for the boot. More...
 

Field Documentation

uint32_t sdhc_mmcboot_param_t::ackTimeout
sdhc_hal_mmcboot_t sdhc_mmcboot_param_t::mode
uint32_t sdhc_mmcboot_param_t::blockCount
struct sdhc_hal_config_t

Data Fields

sdhc_hal_led_t ledState
 Sets the LED state. More...
 
sdhc_hal_endian_t endianMode
 Configures the endian mode. More...
 
sdhc_hal_dma_mode_t dmaMode
 Sets the DMA mode. More...
 
uint8_t writeWatermarkLevel
 Sets the watermark for writing. More...
 
uint8_t readWatermarkLevel
 Sets the watermark for reading. More...
 
uint32_t enFlags
 Enable or disable corresponding feature.
 
sdhc_mmcboot_param_t bootParams
 Configuration read MMC card boot data feature.
 

Field Documentation

sdhc_hal_led_t sdhc_hal_config_t::ledState
sdhc_hal_endian_t sdhc_hal_config_t::endianMode
sdhc_hal_dma_mode_t sdhc_hal_config_t::dmaMode
uint8_t sdhc_hal_config_t::writeWatermarkLevel
uint8_t sdhc_hal_config_t::readWatermarkLevel
struct sdhc_hal_cmd_req_t

Data Fields

uint32_t dataBlkSize
 Command data Block size.
 
uint32_t dataBlkCount
 Command data Block count.
 
uint32_t arg
 Command argument.
 
uint32_t index
 Command index.
 
uint32_t flags
 Command Flags.
 

Enumeration Type Documentation

Enumerator
kSdhcHalIsCmdInhibit 

Checks whether the command inhibit bit is set or not.

kSdhcHalIsDataInhibit 

Checks whether data inhibit bit is set or not.

kSdhcHalIsDataLineActive 

Checks whether data line is active.

kSdhcHalIsSdClockStable 

Checks whether the SD clock is stable or not.

kSdhcHalIsIpgClockOff 

Checks whether the IPG clock is off or not.

kSdhcHalIsSysClockOff 

Checks whether the system clock is off or not.

kSdhcHalIsPeripheralClockOff 

Checks whether the peripheral clock is off or not.

kSdhcHalIsSdClkOff 

Checks whether the SD clock is off or not.

kSdhcHalIsWriteTransferActive 

Checks whether the write transfer is active or not.

kSdhcHalIsReadTransferActive 

Checks whether the read transfer is active or not.

kSdhcHalIsBuffWriteEnabled 

Check whether the buffer write is enabled or not.

kSdhcHalIsBuffReadEnabled 

Checks whether the buffer read is enabled or not.

kSdhcHalIsCardInserted 

Checks whether the card is inserted or not.

kSdhcHalIsCmdLineLevelHigh 

Checks whether the command line signal is high or not.

kSdhcHalGetDataLine0Level 

Gets the data line 0 signal level or not.

kSdhcHalGetDataLine1Level 

Gets the data line 1 signal level or not.

kSdhcHalGetDataLine2Level 

Gets the data line 2 signal level or not.

kSdhcHalGetDataLine3Level 

Gets the data line 3 signal level or not.

kSdhcHalGetDataLine4Level 

Gets the data line 4 signal level or not.

kSdhcHalGetDataLine5Level 

Gets the data line 5 signal level or not.

kSdhcHalGetDataLine6Level 

Gets the data line 6 signal level or not.

kSdhcHalGetDataLine7Level 

Gets the data line 7 signal level or not.

kSdhcHalGetCdTestLevel 

Gets the card detect test level.

Enumerator
kAc12Err 

Auto CMD12 error.

kAdmaErr 

ADMA error.

Function Documentation

void SDHC_HAL_SendCmd ( SDHC_Type *  base,
const sdhc_hal_cmd_req_t cmdReq 
)
Parameters
baseSDHC base address
cmdReqcommand request structure
static void SDHC_HAL_SetData ( SDHC_Type *  base,
uint32_t  data 
)
inlinestatic
Parameters
baseSDHC base address
datathe data about to be sent
static uint32_t SDHC_HAL_GetData ( SDHC_Type *  base)
inlinestatic
Parameters
baseSDHC base address
Returns
the data has been read
bool SDHC_HAL_GetCurState ( SDHC_Type *  base,
sdhc_hal_curstat_type_t  stateType 
)
Parameters
baseSDHC base address
stateTypeThe status type.
Returns
the status if happened corresponding to stateType
  • true: status flag has been set
  • false: status flag has not been set
static void SDHC_HAL_SetDataTransferWidth ( SDHC_Type *  base,
sdhc_hal_dtw_t  dtw 
)
inlinestatic
Parameters
baseSDHC base address
dtwdata transfer width
static void SDHC_HAL_SetContinueRequest ( SDHC_Type *  base)
inlinestatic
Parameters
baseSDHC base address
void SDHC_HAL_Config ( SDHC_Type *  base,
const sdhc_hal_config_t initConfig 
)
Parameters
baseSDHC base address
initConfigThe configuration structure
void SDHC_HAL_ConfigSdClock ( SDHC_Type *  base,
sdhc_hal_sdclk_config_t clkConfItms 
)
Parameters
baseSDHC base address
clkConfItmsSDHC SD protocol unit clock configuration items.
static uint32_t SDHC_HAL_GetIntFlags ( SDHC_Type *  base)
inlinestatic
Parameters
baseSDHC base address
Returns
current interrupt flags
static void SDHC_HAL_ClearIntFlags ( SDHC_Type *  base,
uint32_t  mask 
)
inlinestatic
Parameters
baseSDHC base address
maskto specify interrupts' flags to be cleared
void SDHC_HAL_GetAllErrStatus ( SDHC_Type *  base,
sdhc_hal_err_type_t  errType,
uint32_t *  errFlags 
)
Parameters
baseSDHC base address
errTypethe error type
errFlagsthe result error flags
static void SDHC_HAL_SetForceEventFlags ( SDHC_Type *  base,
uint32_t  mask 
)
inlinestatic
Parameters
baseSDHC base address
maskto specify the force events' flags to be set
static void SDHC_HAL_SetAdmaAddress ( SDHC_Type *  base,
uint32_t  address 
)
inlinestatic
Parameters
baseSDHC base address
addressfor ADMA transfer
uint32_t SDHC_HAL_GetResponse ( SDHC_Type *  base,
uint32_t  index 
)
Parameters
baseSDHC base address
indexof response register, range from 0 to 3
Returns
The command response value.
void SDHC_HAL_SetIntSignal ( SDHC_Type *  base,
bool  enable,
uint32_t  mask 
)
Parameters
baseSDHC base address
enableenable or disable
maskto specify interrupts to be isEnabledd
void SDHC_HAL_SetIntState ( SDHC_Type *  base,
bool  enable,
uint32_t  mask 
)
Parameters
baseSDHC base address
enableenable or disable
maskto specify interrupts' state to be enabled
uint32_t SDHC_HAL_Reset ( SDHC_Type *  base,
uint32_t  type,
uint32_t  timeout 
)
Parameters
baseSDHC base address
typethe type of reset
timeouttimeout for reset
Returns
0 on success, else on error
uint32_t SDHC_HAL_InitCard ( SDHC_Type *  base,
uint32_t  timeout 
)
Parameters
baseSDHC base address
timeouttimeout for initialize card
Returns
0 on success, else on error
void SDHC_HAL_Init ( SDHC_Type *  base)
Parameters
baseSDHC base address
void SDHC_HAL_GetBasicInfo ( SDHC_Type *  base,
sdhc_hal_basic_info_t basicInfo 
)
Parameters
baseSDHC base address
basicInfoPointer to user data structure.