PSoC 6 Peripheral Driver Library

General Description

Functions

cy_en_sd_host_status_t Cy_SD_Host_Init (SDHC_Type *base, const cy_stc_sd_host_init_config_t *config, cy_stc_sd_host_context_t *context)
 Initializes the SD host module. More...
 
void Cy_SD_Host_DeInit (SDHC_Type *base)
 Restores the SD Host block registers back to default. More...
 
void Cy_SD_Host_Enable (SDHC_Type *base)
 Enables the SD host block. More...
 
void Cy_SD_Host_Disable (SDHC_Type *base)
 Disables the SD host block. More...
 
__STATIC_INLINE void Cy_SD_Host_EnableSdClk (SDHC_Type *base)
 Enables the SD clock (SD host drives the SDCLK line). More...
 
__STATIC_INLINE void Cy_SD_Host_DisableSdClk (SDHC_Type *base)
 Disables the SD clock (The SD Host doesn't drive the SDCLK line). More...
 
cy_en_sd_host_status_t Cy_SD_Host_SetSdClkDiv (SDHC_Type *base, uint16_t clkDiv)
 Changes the speed of the SD bus. More...
 
bool Cy_SD_Host_IsWpSet (SDHC_Type const *base)
 Returns the state of the write protect switch on the SD card. More...
 
cy_en_sd_host_status_t Cy_SD_Host_SetHostBusWidth (SDHC_Type *base, cy_en_sd_host_bus_width_t width)
 Only changes the bus width on the host side. More...
 
cy_en_sd_host_status_t Cy_SD_Host_SetBusWidth (SDHC_Type *base, cy_en_sd_host_bus_width_t width, cy_stc_sd_host_context_t const *context)
 Sends out the SD bus width changing command. More...
 
cy_en_sd_host_status_t Cy_SD_Host_SetHostSpeedMode (SDHC_Type *base, cy_en_sd_host_bus_speed_mode_t speedMode)
 Only updates the host register to indicate bus speed mode. More...
 
cy_en_sd_host_status_t Cy_SD_Host_SetBusSpeedMode (SDHC_Type *base, cy_en_sd_host_bus_speed_mode_t speedMode, cy_stc_sd_host_context_t const *context)
 Negotiates with the card to change the bus speed mode of the card and the host. More...
 
cy_en_sd_host_status_t Cy_SD_Host_SelBusVoltage (SDHC_Type *base, bool enable18VSignal, cy_stc_sd_host_context_t *context)
 Negotiates with the SD card to change the bus signaling level to 1.8V. More...
 
void Cy_SD_Host_EnableCardVoltage (SDHC_Type *base)
 Sets the card_if_pwr_en pin high. More...
 
void Cy_SD_Host_DisableCardVoltage (SDHC_Type *base)
 Sets the card_if_pwr_en pin low. More...
 
cy_en_sd_host_status_t Cy_SD_Host_GetResponse (SDHC_Type const *base, uint32_t *responsePtr, bool largeResponse)
 This function reads the response register from the last completed command. More...
 
cy_en_sd_host_status_t Cy_SD_Host_SendCommand (SDHC_Type *base, cy_stc_sd_host_cmd_config_t const *config)
 Starts sending a command on the SD bus. More...
 
cy_en_sd_host_status_t Cy_SD_Host_InitDataTransfer (SDHC_Type *base, cy_stc_sd_host_data_config_t const *dataConfig)
 Initializes the SD block for a data transfer. More...
 
__STATIC_INLINE uint32_t Cy_SD_Host_BufferRead (SDHC_Type const *base)
 Reads 32-bits of data from the read buffer. More...
 
__STATIC_INLINE cy_en_sd_host_status_t Cy_SD_Host_BufferWrite (SDHC_Type *base, uint32_t data)
 Writes 32-bits of data into the write buffer. More...
 
void Cy_SD_Host_ChangeIoVoltage (SDHC_Type *base, cy_en_sd_host_io_voltage_t ioVoltage)
 Changes the logic level on the sd_io_volt_sel line. More...
 
__STATIC_INLINE void Cy_SD_Host_StopAtBlockGap (SDHC_Type *base)
 Commands SD host to stop transmitting at the next block gap. More...
 
__STATIC_INLINE void Cy_SD_Host_ContinueFromBlockGap (SDHC_Type *base)
 Commands SD host to continue transmitting after stopping at the block gap. More...
 
__STATIC_INLINE uint32_t Cy_SD_Host_GetAutoCmdErrStatus (SDHC_Type const *base)
 Gets the SD host error status of the auto command. More...
 
__STATIC_INLINE cy_en_sd_host_status_t Cy_SD_Host_EnableAutoCmd23 (SDHC_Type *base)
 If the card supports AutoCmd23 call this function to enable it in the host. More...
 
__STATIC_INLINE void Cy_SD_Host_DisableAutoCmd23 (SDHC_Type *base)
 Removes support for AutoCmd23 if it was previously set. More...
 
__STATIC_INLINE cy_en_sd_host_status_t Cy_SD_Host_EnableAsyncInterrupt (SDHC_Type *base)
 Enables the Asynchronous Interrupt for SDIO cards. More...
 
__STATIC_INLINE void Cy_SD_Host_DisableAsyncInterrupt (SDHC_Type *base)
 Removes the support for the Asynchronous Interrupt if it was previously set. More...
 
__STATIC_INLINE uint32_t Cy_SD_Host_GetAdmaErrorStatus (SDHC_Type const *base)
 Returns the ADMA Error Status register. More...
 
__STATIC_INLINE void Cy_SD_Host_EMMC_Reset (SDHC_Type *base)
 Resets the eMMC card. More...
 
cy_en_sd_host_status_t Cy_SD_Host_AbortTransfer (SDHC_Type *base, cy_stc_sd_host_context_t const *context)
 Calling this function causes abortion of the currently executing command with data. More...
 
cy_en_sd_host_status_t Cy_SD_Host_WriteProtect (SDHC_Type *base, cy_en_sd_host_write_protect_t writeProtect, cy_stc_sd_host_context_t *context)
 Write protects the blocks of data from the SD card. More...
 
uint32_t Cy_SD_Host_GetCardStatus (SDHC_Type *base, cy_stc_sd_host_context_t const *context)
 Returns the card status. More...
 
cy_en_sd_host_status_t Cy_SD_Host_GetSdStatus (SDHC_Type *base, uint32_t *sdStatus, cy_stc_sd_host_context_t const *context)
 Returns the SD status from the card. More...
 
uint32_t Cy_SD_Host_GetOcr (SDHC_Type *base, cy_stc_sd_host_context_t const *context)
 Reads the Operating Condition Register (OCR) register from the card. More...
 
cy_en_sd_host_status_t Cy_SD_Host_GetCid (SDHC_Type *base, uint32_t *cid)
 Returns the Card Identification Register (CID) contents. More...
 
cy_en_sd_host_status_t Cy_SD_Host_GetCsd (SDHC_Type *base, uint32_t *csd, cy_stc_sd_host_context_t *context)
 Returns the Card Specific Data (CSD) register contents. More...
 
cy_en_sd_host_status_t Cy_SD_Host_GetExtCsd (SDHC_Type *base, uint32_t *extCsd, cy_stc_sd_host_context_t *context)
 Returns the EXTCSD Register contents. More...
 
uint32_t Cy_SD_Host_GetRca (SDHC_Type *base)
 Reads the Relative Card Address (RCA) register from the card. More...
 
cy_en_sd_host_status_t Cy_SD_Host_GetScr (SDHC_Type *base, uint32_t *scr, cy_stc_sd_host_context_t const *context)
 Returns the SD Card Configuration Register (SCR) Register contents. More...
 
uint32_t Cy_SD_Host_GetPresentState (SDHC_Type const *base)
 Returns the values of the present state register. More...
 
bool Cy_SD_Host_IsCardConnected (SDHC_Type const *base)
 Checks to see if a card is currently connected. More...
 
void Cy_SD_Host_SoftwareReset (SDHC_Type *base, cy_en_sd_host_reset_t reset)
 Issues the software reset command to the SD card. More...
 
cy_en_syspm_status_t Cy_SD_Host_DeepSleepCallback (cy_stc_syspm_callback_params_t *callbackParams, cy_en_syspm_callback_mode_t mode)
 This function handles the transition of the SD Host into and out of Deep Sleep mode. More...
 

Function Documentation

◆ Cy_SD_Host_Init()

cy_en_sd_host_status_t Cy_SD_Host_Init ( SDHC_Type *  base,
const cy_stc_sd_host_init_config_t config,
cy_stc_sd_host_context_t context 
)

Initializes the SD host module.

Parameters
*baseThe SD host registers structure pointer.
configThe SD host module configuration.
contextThe pointer to the context structure cy_stc_sd_host_context_t allocated by the user. The structure is used during the SD host operation for internal configuration and data retention. The user must not modify anything in this structure. If only the SD host functions which do not require context will be used, pass NULL as the pointer to the context.
Returns
cy_en_sd_host_status_t

◆ Cy_SD_Host_DeInit()

void Cy_SD_Host_DeInit ( SDHC_Type *  base)

Restores the SD Host block registers back to default.

Parameters
*baseThe SD host registers structure pointer.

◆ Cy_SD_Host_Enable()

void Cy_SD_Host_Enable ( SDHC_Type *  base)

Enables the SD host block.

Parameters
*baseThe SD host registers structure pointer.

◆ Cy_SD_Host_Disable()

void Cy_SD_Host_Disable ( SDHC_Type *  base)

Disables the SD host block.

Parameters
*baseThe SD host registers structure pointer.

◆ Cy_SD_Host_EnableSdClk()

__STATIC_INLINE void Cy_SD_Host_EnableSdClk ( SDHC_Type *  base)

Enables the SD clock (SD host drives the SDCLK line).

Parameters
*baseThe SD host registers structure pointer.

◆ Cy_SD_Host_DisableSdClk()

__STATIC_INLINE void Cy_SD_Host_DisableSdClk ( SDHC_Type *  base)

Disables the SD clock (The SD Host doesn't drive the SDCLK line).

Parameters
*baseThe SD host registers structure pointer.

◆ Cy_SD_Host_SetSdClkDiv()

cy_en_sd_host_status_t Cy_SD_Host_SetSdClkDiv ( SDHC_Type *  base,
uint16_t  clkDiv 
)

Changes the speed of the SD bus.

This function should be called along with Cy_SD_Host_SetHostSpeedMode to configure the bus correctly.

Note
The divider is clocked from the CLK_HF clock (100 MHz). To determine the SD bus speed divide the clock CLK_HF by the divider value passed in this function. The divider value is 2^clkDiv.
Parameters
*baseThe SD host registers structure pointer.
clkDivThe clock divider for the SD clock.
Returns
cy_en_sd_host_status_t

◆ Cy_SD_Host_IsWpSet()

bool Cy_SD_Host_IsWpSet ( SDHC_Type const *  base)

Returns the state of the write protect switch on the SD card.

Parameters
*baseThe SD host registers structure pointer.
Returns
bool true - the write protect is set, false - the write protect is not set.

◆ Cy_SD_Host_SetHostBusWidth()

cy_en_sd_host_status_t Cy_SD_Host_SetHostBusWidth ( SDHC_Type *  base,
cy_en_sd_host_bus_width_t  width 
)

Only changes the bus width on the host side.

It doesn't change the bus width on the card side. To change the bus width on the card, call Cy_SD_Host_SetBusWidth().

Parameters
*baseThe SD host registers structure pointer.
widthThe width of the data bus.
Returns
cy_en_sd_host_status_t

◆ Cy_SD_Host_SetBusWidth()

cy_en_sd_host_status_t Cy_SD_Host_SetBusWidth ( SDHC_Type *  base,
cy_en_sd_host_bus_width_t  width,
cy_stc_sd_host_context_t const *  context 
)

Sends out the SD bus width changing command.

Parameters
*baseThe SD host registers structure pointer.
widthThe width of the data bus.
contextThe pointer to the context structure cy_stc_sd_host_context_t allocated by the user. The structure is used during the SD host operation for internal configuration and data retention. The user must not modify anything in this structure. If only the SD host functions which do not require context will be used, pass NULL as the pointer to the context.
Returns
cy_en_sd_host_status_t

◆ Cy_SD_Host_SetHostSpeedMode()

cy_en_sd_host_status_t Cy_SD_Host_SetHostSpeedMode ( SDHC_Type *  base,
cy_en_sd_host_bus_speed_mode_t  speedMode 
)

Only updates the host register to indicate bus speed mode.

This function doesn't change the speed on the bus, or change anything in the card.

Parameters
*baseThe SD host registers structure pointer.
speedModeBus Speed mode.
Returns
cy_en_sd_host_status_t

◆ Cy_SD_Host_SetBusSpeedMode()

cy_en_sd_host_status_t Cy_SD_Host_SetBusSpeedMode ( SDHC_Type *  base,
cy_en_sd_host_bus_speed_mode_t  speedMode,
cy_stc_sd_host_context_t const *  context 
)

Negotiates with the card to change the bus speed mode of the card and the host.

It doesn't change the SD clock frequency that must be done separately.

Parameters
*baseThe SD host registers structure pointer.
speedModeBus speed mode.
contextThe pointer to the context structure cy_stc_sd_host_context_t allocated by the user. The structure is used during the SD host operation for internal configuration and data retention. The user must not modify anything in this structure. If only the SD host functions which do not require context will be used, pass NULL as the pointer to the context.
Returns
cy_en_sd_host_status_t

◆ Cy_SD_Host_SelBusVoltage()

cy_en_sd_host_status_t Cy_SD_Host_SelBusVoltage ( SDHC_Type *  base,
bool  enable18VSignal,
cy_stc_sd_host_context_t context 
)

Negotiates with the SD card to change the bus signaling level to 1.8V.

After this function is called, the card is in the ready state.

Note
The host needs to change the regulator supplying voltage to the VDDIO of the SD block in order to operate at 1.8V.
This function changes RCA to 0 in the context. RCA in the context should be updated (context.RCA = Cy_SD_Host_GetRca();) when the card is in the Identification state.
This function is applicable for SD cards only.
Parameters
*baseThe SD host registers structure pointer.
enable18VSignalIf true, use the 1.8V signaling, false - use the 3.3V signaling.
contextThe pointer to the context structure cy_stc_sd_host_context_t allocated by the user. The structure is used during the SD host operation for internal configuration and data retention. The user must not modify anything in this structure. If only the SD host functions which do not require context will be used, pass NULL as the pointer to the context.
Returns
cy_en_sd_host_status_t
Note
The SD card power supply should be disabled and initialized again when this function returns CY_SD_HOST_ERROR_UNUSABLE_CARD.
The dedicated io_volt_sel pin is used to change the regulator supplying voltage to the VDDIO of the SD block in order to operate at 1.8V. To configure the custom IO pin in order to control (using the GPIO driver) the regulator supplying voltage, the user must implement weak Cy_SD_Host_ChangeIoVoltage(). Also, this function must set the SIGNALING_EN bit of the SDHC_CORE_HOST_CTRL2_R register when ioVoltage = CY_SD_HOST_IO_VOLT_1_8V.

◆ Cy_SD_Host_EnableCardVoltage()

void Cy_SD_Host_EnableCardVoltage ( SDHC_Type *  base)

Sets the card_if_pwr_en pin high.

This pin can be used to enable a voltage regulator used to power the card.

Parameters
*baseThe SD host registers structure pointer.

◆ Cy_SD_Host_DisableCardVoltage()

void Cy_SD_Host_DisableCardVoltage ( SDHC_Type *  base)

Sets the card_if_pwr_en pin low.

This pin can be used to disable a voltage regulator used to power the card.

Parameters
*baseThe SD host registers structure pointer.

◆ Cy_SD_Host_GetResponse()

cy_en_sd_host_status_t Cy_SD_Host_GetResponse ( SDHC_Type const *  base,
uint32_t *  responsePtr,
bool  largeResponse 
)

This function reads the response register from the last completed command.

Parameters
*baseThe SD host registers structure pointer.
*responsePtrThe pointer to response data.
largeResponseIf true, the response is 136 bits, false - 32 bits.
Returns
cy_en_sd_host_status_t

◆ Cy_SD_Host_SendCommand()

cy_en_sd_host_status_t Cy_SD_Host_SendCommand ( SDHC_Type *  base,
cy_stc_sd_host_cmd_config_t const *  config 
)

Starts sending a command on the SD bus.

If the command uses the data lines Cy_SD_Host_InitDataTransfer() must be call first. This function returns before the command completes. To determine if the command is done, read the Normal Interrupt Status register and check the CMD_COMPLETE flag. To determine if the entire transfer is done check the XFER_COMPLETE flag. Also the interrupt is used and flags are set on these events in an ISR.

Note
It is the user's responsibility to clear the CY_SD_HOST_CMD_COMPLETE flag after calling this function.
Parameters
*baseThe SD host registers structure pointer.
*configThe configuration structure for the command.
Returns
cy_en_sd_host_status_t

◆ Cy_SD_Host_InitDataTransfer()

cy_en_sd_host_status_t Cy_SD_Host_InitDataTransfer ( SDHC_Type *  base,
cy_stc_sd_host_data_config_t const *  dataConfig 
)

Initializes the SD block for a data transfer.

It does not start a transfer. To start a transfer call Cy_SD_Host_SendCommand() after calling this function. If DMA is not used for data transfer, the buffer needs to be filled with data first if this is a write.

Parameters
*baseThe SD host registers structure pointer.
dataConfigThe pointer to the data transfer configuration structure.
Returns
cy_en_sd_host_status_t

◆ Cy_SD_Host_BufferRead()

__STATIC_INLINE uint32_t Cy_SD_Host_BufferRead ( SDHC_Type const *  base)

Reads 32-bits of data from the read buffer.

Only use this function if not using SD block DMA to transfer data from buffer.

Parameters
*baseThe SD host registers structure pointer.
Returns
uint32_t Data that is being read.

◆ Cy_SD_Host_BufferWrite()

__STATIC_INLINE cy_en_sd_host_status_t Cy_SD_Host_BufferWrite ( SDHC_Type *  base,
uint32_t  data 
)

Writes 32-bits of data into the write buffer.

Only use this function if not using SD block DMA to transfer data to buffer.

Parameters
*baseThe SD host registers structure pointer.
dataData to be written.
Returns
cy_en_sd_host_status_t

◆ Cy_SD_Host_ChangeIoVoltage()

void Cy_SD_Host_ChangeIoVoltage ( SDHC_Type *  base,
cy_en_sd_host_io_voltage_t  ioVoltage 
)

Changes the logic level on the sd_io_volt_sel line.

It assumes that this line is used to control a regulator connected to the VDDIO of the PSoC. This regulator allows for switching between the 3.3V and 1.8V signaling.

Note
The dedicated io_volt_sel pin is used to change the regulator supplying voltage to the VDDIO of the SD block in order to operate at 1.8V. To configure the custom IO pin in order to control (using the GPIO driver) the regulator supplying voltage, the user must implement weak Cy_SD_Host_ChangeIoVoltage(). Also, this function must set the SIGNALING_EN bit of the SDHC_CORE_HOST_CTRL2_R register when ioVoltage = CY_SD_HOST_IO_VOLT_1_8V.
Parameters
*baseThe SD host registers structure pointer.
ioVoltageThe voltage for IO.

◆ Cy_SD_Host_StopAtBlockGap()

__STATIC_INLINE void Cy_SD_Host_StopAtBlockGap ( SDHC_Type *  base)

Commands SD host to stop transmitting at the next block gap.

Parameters
*baseThe SD host registers structure pointer.

◆ Cy_SD_Host_ContinueFromBlockGap()

__STATIC_INLINE void Cy_SD_Host_ContinueFromBlockGap ( SDHC_Type *  base)

Commands SD host to continue transmitting after stopping at the block gap.

Parameters
*baseThe SD host registers structure pointer.

◆ Cy_SD_Host_GetAutoCmdErrStatus()

__STATIC_INLINE uint32_t Cy_SD_Host_GetAutoCmdErrStatus ( SDHC_Type const *  base)

Gets the SD host error status of the auto command.

Parameters
*baseThe SD host registers structure pointer.
Returns
uint32_t The bit mask of the Auto Command status.

◆ Cy_SD_Host_EnableAutoCmd23()

__STATIC_INLINE cy_en_sd_host_status_t Cy_SD_Host_EnableAutoCmd23 ( SDHC_Type *  base)

If the card supports AutoCmd23 call this function to enable it in the host.

Parameters
*baseThe SD host registers structure pointer.
Returns
cy_en_sd_host_status_t.

◆ Cy_SD_Host_DisableAutoCmd23()

__STATIC_INLINE void Cy_SD_Host_DisableAutoCmd23 ( SDHC_Type *  base)

Removes support for AutoCmd23 if it was previously set.

Parameters
*baseThe SD host registers structure pointer.

◆ Cy_SD_Host_EnableAsyncInterrupt()

__STATIC_INLINE cy_en_sd_host_status_t Cy_SD_Host_EnableAsyncInterrupt ( SDHC_Type *  base)

Enables the Asynchronous Interrupt for SDIO cards.

Set this only if the card supports this feature.

Parameters
*baseThe SD host registers structure pointer.
Returns
cy_en_sd_host_status_t

◆ Cy_SD_Host_DisableAsyncInterrupt()

__STATIC_INLINE void Cy_SD_Host_DisableAsyncInterrupt ( SDHC_Type *  base)

Removes the support for the Asynchronous Interrupt if it was previously set.

Parameters
*baseThe SD host registers structure pointer.

◆ Cy_SD_Host_GetAdmaErrorStatus()

__STATIC_INLINE uint32_t Cy_SD_Host_GetAdmaErrorStatus ( SDHC_Type const *  base)

Returns the ADMA Error Status register.

Parameters
*baseThe SD host registers structure pointer.
Returns
uint32_t The bit mask of ADMA Error Status.

◆ Cy_SD_Host_EMMC_Reset()

__STATIC_INLINE void Cy_SD_Host_EMMC_Reset ( SDHC_Type *  base)

Resets the eMMC card.

Parameters
*baseThe SD host registers structure pointer.

◆ Cy_SD_Host_AbortTransfer()

cy_en_sd_host_status_t Cy_SD_Host_AbortTransfer ( SDHC_Type *  base,
cy_stc_sd_host_context_t const *  context 
)

Calling this function causes abortion of the currently executing command with data.

It doesn't issue a reset, that is the users responsibility.

Parameters
*baseThe SD host registers structure pointer.
contextThe pointer to the context structure cy_stc_sd_host_context_t allocated by the user. The structure is used during the SD host operation for internal configuration and data retention. The user must not modify anything in this structure. If only the SD host functions which do not require context will be used, pass NULL as the pointer to the context.
Returns
cy_en_sd_host_status_t

◆ Cy_SD_Host_WriteProtect()

cy_en_sd_host_status_t Cy_SD_Host_WriteProtect ( SDHC_Type *  base,
cy_en_sd_host_write_protect_t  writeProtect,
cy_stc_sd_host_context_t context 
)

Write protects the blocks of data from the SD card.

This function should only be called after Cy_SD_Host_SDCard_Init()/eMMC_Init().

Parameters
*baseThe SD host registers structure pointer.
writeProtectcy_en_sd_host_write_protect_t.
contextThe pointer to the context structure cy_stc_sd_host_context_t allocated by the user. The structure is used during the SD host operation for internal configuration and data retention. The user must not modify anything in this structure. If only the SD host functions which do not require context will be used, pass NULL as the pointer to the context.
Returns
cy_en_sd_host_status_t

◆ Cy_SD_Host_GetCardStatus()

uint32_t Cy_SD_Host_GetCardStatus ( SDHC_Type *  base,
cy_stc_sd_host_context_t const *  context 
)

Returns the card status.

Parameters
*baseThe SD host registers structure pointer.
contextThe pointer to the context structure cy_stc_sd_host_context_t allocated by the user. The structure is used during the SD host operation for internal configuration and data retention. The user must not modify anything in this structure. If only the SD host functions which do not require context will be used, pass NULL as the pointer to the context.
Returns
uint32_t The card status (the result of the CMD13 command).

◆ Cy_SD_Host_GetSdStatus()

cy_en_sd_host_status_t Cy_SD_Host_GetSdStatus ( SDHC_Type *  base,
uint32_t *  sdStatus,
cy_stc_sd_host_context_t const *  context 
)

Returns the SD status from the card.

Parameters
*baseThe SD host registers structure pointer.
*sdStatusThe pointer to where to store the SD status array.
contextThe pointer to the context structure cy_stc_sd_host_context_t allocated by the user. The structure is used during the SD host operation for internal configuration and data retention. The user must not modify anything in this structure. If only the SD host functions which do not require context will be used, pass NULL as the pointer to the context.
Returns
cy_en_sd_host_status_t

◆ Cy_SD_Host_GetOcr()

uint32_t Cy_SD_Host_GetOcr ( SDHC_Type *  base,
cy_stc_sd_host_context_t const *  context 
)

Reads the Operating Condition Register (OCR) register from the card.

Note
This function can be used only if the card is in the Idle state.
Parameters
*baseThe SD host registers structure pointer.
contextThe pointer to the context structure cy_stc_sd_host_context_t allocated by the user. The structure is used during the SD host operation for internal configuration and data retention. The user must not modify anything in this structure. If only the SD host functions which do not require context will be used, pass NULL as the pointer to the context.
Returns
uint32_t The OCR register.
Note
For combo cards, the function returns the OCR register for the IO portion only.

◆ Cy_SD_Host_GetCid()

cy_en_sd_host_status_t Cy_SD_Host_GetCid ( SDHC_Type *  base,
uint32_t *  cid 
)

Returns the Card Identification Register (CID) contents.

Note
This function can be used only if the card is in the Ready state.
Parameters
*baseThe SD host registers structure pointer.
cidThe pointer to where to store the CID register.
Returns
cy_en_sd_host_status_t

◆ Cy_SD_Host_GetCsd()

cy_en_sd_host_status_t Cy_SD_Host_GetCsd ( SDHC_Type *  base,
uint32_t *  csd,
cy_stc_sd_host_context_t context 
)

Returns the Card Specific Data (CSD) register contents.

Note
This function can be used only if the card is in the Stand-by state.
Parameters
*baseThe SD host registers structure pointer.
*csdThe pointer to where to store the CSD register.
contextThe pointer to the context structure cy_stc_sd_host_context_t allocated by the user. The structure is used during the SD host operation for internal configuration and data retention. The user must not modify anything in this structure. If only the SD host functions which do not require context will be used, pass NULL as the pointer to the context.
Returns
cy_en_sd_host_status_t

◆ Cy_SD_Host_GetExtCsd()

cy_en_sd_host_status_t Cy_SD_Host_GetExtCsd ( SDHC_Type *  base,
uint32_t *  extCsd,
cy_stc_sd_host_context_t context 
)

Returns the EXTCSD Register contents.

This is only for EMMC cards. There are 512 bytes of data being read.

Parameters
*baseThe SD host registers structure pointer.
*extCsdThe pointer to where to store the EXTCSD register.
contextThe pointer to the context structure cy_stc_sd_host_context_t allocated by the user. The structure is used during the SD host operation for internal configuration and data retention. The user must not modify anything in this structure. If only the SD host functions which do not require context will be used, pass NULL as the pointer to the context.
Returns
cy_en_sd_host_status_t

◆ Cy_SD_Host_GetRca()

uint32_t Cy_SD_Host_GetRca ( SDHC_Type *  base)

Reads the Relative Card Address (RCA) register from the card.

Note
This function can be used only if the card is in the Identification or Stand-by state.
Parameters
*baseThe SD host registers structure pointer.
Returns
uint32_t The RCA register.

◆ Cy_SD_Host_GetScr()

cy_en_sd_host_status_t Cy_SD_Host_GetScr ( SDHC_Type *  base,
uint32_t *  scr,
cy_stc_sd_host_context_t const *  context 
)

Returns the SD Card Configuration Register (SCR) Register contents.

Note
This function can be used only if the card is in the Transition state.
Parameters
*baseThe SD host registers structure pointer.
*scrThe pointer to where to store the SCR register.
contextThe pointer to the context structure cy_stc_sd_host_context_t allocated by the user. The structure is used during the SD host operation for internal configuration and data retention. The user must not modify anything in this structure. If only the SD host functions which do not require context will be used, pass NULL as the pointer to the context.
Returns
cy_en_sd_host_status_t

◆ Cy_SD_Host_GetPresentState()

uint32_t Cy_SD_Host_GetPresentState ( SDHC_Type const *  base)

Returns the values of the present state register.

Parameters
*baseThe SD host registers structure pointer.
Returns
The value of the present state register.

◆ Cy_SD_Host_IsCardConnected()

bool Cy_SD_Host_IsCardConnected ( SDHC_Type const *  base)

Checks to see if a card is currently connected.

Note
You can use any GPIO custom pin for Card Detect. Add the SD Host driver Cy_SD_Host_IsCardConnected() function with the __WEAK type to your code. This function could read the value from any GPIO pin and return true when the card is connected.
Parameters
*baseThe SD host registers structure pointer.
Returns
bool true - the card is connected, false - the card is removed (not connected).

◆ Cy_SD_Host_SoftwareReset()

void Cy_SD_Host_SoftwareReset ( SDHC_Type *  base,
cy_en_sd_host_reset_t  reset 
)

Issues the software reset command to the SD card.

Parameters
*baseThe SD host registers structure pointer.
resetThe reset type.

◆ Cy_SD_Host_DeepSleepCallback()

cy_en_syspm_status_t Cy_SD_Host_DeepSleepCallback ( cy_stc_syspm_callback_params_t callbackParams,
cy_en_syspm_callback_mode_t  mode 
)

This function handles the transition of the SD Host into and out of Deep Sleep mode.

It disables SD CLK before going to Deep Sleep mode and enables SD CLK after wake up from Deep Sleep mode. If the DAT line is active, or a read (write) transfer is being executed on the bus, the device cannot enter Deep Sleep mode.

This function must be called during execution of Cy_SysPm_CpuEnterDeepSleep. To do it, register this function as a callback before calling Cy_SysPm_CpuEnterDeepSleep : specify CY_SYSPM_DEEPSLEEP as the callback type and call Cy_SysPm_RegisterCallback.

Note
When waking up from Deep Sleep, the SD Host driver requires up to 1 us for clock stabilization. By default the SD Host driver will wait this length of time on power up. The waiting loop is implemented in this function. If the application is time sensitive this delay can be overridden by the application by defining CY_SD_HOST_CLK_RAMP_UP_TIME_US_WAKEUP. This allows the application to perform other operations while the clock is stabilizing in the background. However, the application must still make sure that the SD Host clock has had time to stabilize before attempting to use the SD card. The recommended way to override the value is to specify this as a custom define on the compiler command line. This can be done by appending the entry to the DEFINES variable in the application Makefile. Eg: DEFINES+=CY_SD_HOST_CLK_RAMP_UP_TIME_US_WAKEUP=40.
Parameters
callbackParamsThe pointer to the callback parameters structure cy_stc_syspm_callback_params_t.
modeCallback mode, see cy_en_syspm_callback_mode_t
Returns
cy_en_syspm_status_t