PSOC E8XXGP Device Support Library

| PSOC E8XXGP Device Support Library

Functions
High-Level
PDL API Reference » SD Host (SD Host Controller) » Functions

## General Description

## Functions
cy_en_sd_host_status_t | Cy_SD_Host_InitCard (SDHC_Type *base, cy_stc_sd_host_sd_card_config_t *config, cy_stc_sd_host_context_t *context)
| Initializes a card if it is connected. More...
cy_en_sd_host_status_t | Cy_SD_Host_Read (SDHC_Type *base, cy_stc_sd_host_write_read_config_t *config, cy_stc_sd_host_context_t const *context)
| Reads single- or multiple-block data from the SD card / eMMC. More...
cy_en_sd_host_status_t | Cy_SD_Host_Write (SDHC_Type *base, cy_stc_sd_host_write_read_config_t *config, cy_stc_sd_host_context_t const *context)
| Writes single- or multiple-block data to the SD card / eMMC. More...
cy_en_sd_host_status_t | Cy_SD_Host_Erase (SDHC_Type *base, uint32_t startAddr, uint32_t endAddr, cy_en_sd_host_erase_type_t eraseType, cy_stc_sd_host_context_t const *context)
| Erases the number block data of the SD card / eMMC. More...

## Function Documentation

## ◆ Cy_SD_Host_InitCard()

cy_en_sd_host_status_t Cy_SD_Host_InitCard | ( | SDHC_Type * | base,
|  | cy_stc_sd_host_sd_card_config_t * | config,
|  | cy_stc_sd_host_context_t * | context
| ) |  |

Initializes a card if it is connected.

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

Parameters

  *base | The SD host registers structure pointer.
  *config | The pointer to the SD card configuration structure.
  context | The 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
  When lowVoltageSignaling is True, this function negotiates with the card to change the bus signaling level to 1.8V. 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.
  After calling this function, the SD Host is configured in highest supported bus speed mode (for the SD card, irrespective of the value of lowVoltageSignaling), or eMMC legacy (for the eMMC card) with SD clock = 25 MHz. The Power Limit and Driver Strength functions of the CMD6 command are set into the default state (0.72 W and Type B). It is the user's responsibility to set Power Limit and Driver Strength depending on the capacitance load of the host system. To change Speed mode, the user must call the Cy_SD_Host_SetBusSpeedMode() and Cy_SD_Host_SdCardChangeClock() functions. Additionally, SD SDR25, SD SDR50, eMMC High Speed SDR modes require settings CLOCK_OUT_DLY and CLOCK_IN_DLY bit-fields of the GP_OUT_R register. For more information about Speed modes, refer to Part 1 Physical Layer SD Specification.

## ◆ Cy_SD_Host_Read()

cy_en_sd_host_status_t Cy_SD_Host_Read | ( | SDHC_Type * | base,
|  | cy_stc_sd_host_write_read_config_t * | config,
|  | cy_stc_sd_host_context_t const * | context
| ) |  |

Reads single- or multiple-block data from the SD card / eMMC.

If DMA is not used this function blocks until all data is read. If DMA is used all data is read when the Transfer complete event is set. It is the user responsibility to check and reset the transfer complete event (using Cy_SD_Host_GetNormalInterruptStatus and Cy_SD_Host_ClearNormalInterruptStatus functions).

Parameters

  *base | The SD host registers structure pointer.
  *config | The pointer to the SD card read-write structure.
  context | The 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_Write()

cy_en_sd_host_status_t Cy_SD_Host_Write | ( | SDHC_Type * | base,
|  | cy_stc_sd_host_write_read_config_t * | config,
|  | cy_stc_sd_host_context_t const * | context
| ) |  |

Writes single- or multiple-block data to the SD card / eMMC.

If DMA is not used this function blocks until all data is written. If DMA is used all data is written when the Transfer complete event is set. It is the user responsibility to check and reset the transfer complete event (using Cy_SD_Host_GetNormalInterruptStatus and Cy_SD_Host_ClearNormalInterruptStatus functions).

Parameters

  *base | The SD host registers structure pointer.
  *config | The pointer to the SD card read-write structure.
  context | The 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_Erase()

cy_en_sd_host_status_t Cy_SD_Host_Erase | ( | SDHC_Type * | base,
|  | uint32_t | startAddr,
|  | uint32_t | endAddr,
|  | cy_en_sd_host_erase_type_t | eraseType,
|  | cy_stc_sd_host_context_t const * | context
| ) |  |

Erases the number block data of the SD card / eMMC.

Note
  This function starts the erase operation end exits. It is the user's responsibility to check when the erase operation completes. The erase operation completes when Cy_SD_Host_GetCardStatus returns the status value where both ready-for-data (CY_SD_HOST_CMD13_READY_FOR_DATA) and card-transition (CY_SD_HOST_CARD_TRAN) bits are set. Also it is the user's responsibility to clear the CY_SD_HOST_CMD_COMPLETE flag after calling this function.

Parameters

  *base | The SD host registers structure pointer.
  startAddr | The address to start erasing from.
  endAddr | The address to stop erasing.
  eraseType | Specifies the erase type (FULE, DISCARD).
  context | The 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