cy_sd_host_8h

This file provides constants and parameter values for the SD Host Controller driver.

Version

1.80

Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0
Copyright

Copyright 2018-2021 Cypress Semiconductor Corporation SPDX-License-Identifier: Apache-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Defines

CY_SD_HOST_DRV_VERSION_MAJOR

Driver major version.

CY_SD_HOST_DRV_VERSION_MINOR

Driver minor version.

CY_SD_HOST_ID

SD_HOST PDL ID.

CY_SD_HOST_BLOCK_SIZE

The SD memory card block size.

CY_SD_HOST_SDSC_ADDR_SHIFT

This constant is used to get the address for the SDSC card using the shift operation instead of multiply to 512.

CY_SD_HOST_CLK_25M

Clk = 20 MHz.

CY_SD_HOST_CLK_50M

Clk = 50 MHz.

CY_SD_HOST_CLK_100M

Clk = 100 MHz.

CY_SD_HOST_CLK_RAMP_UP_TIME_MS

The host power ramp up time.

CY_SD_HOST_CLK_RAMP_UP_TIME_US_WAKEUP

The default host power ramp up time during wake up from deep sleep.

CY_SD_HOST_ADMA_NOP

Does not execute the current line and go to next line.

CY_SD_HOST_ADMA_RSV

Reserved.

CY_SD_HOST_ADMA_TRAN

Transfers data of one descriptor line.

The link to another descriptor.

CY_SD_HOST_ADMA3_CMD

The Command descriptor.

CY_SD_HOST_ADMA3_INTERGRATED

The Integrated descriptor.

CY_SD_HOST_ADMA2_DESCR_SIZE

The ADMA2 descriptor size.

CY_SD_HOST_ADMA_ATTR_VALID_POS

The ADMA Attr Valid position.

CY_SD_HOST_ADMA_ATTR_END_POS

The ADMA Attr End position.

CY_SD_HOST_ADMA_ATTR_INT_POS

The ADMA Attr Int position.

CY_SD_HOST_ADMA_ACT_POS

The ADMA Act position.

CY_SD_HOST_ADMA_RESERVED2_POS

The ADMA Reserved2 position.

CY_SD_HOST_ADMA_LEN_POS

The ADMA Len position.

CY_SD_HOST_CARD_IDLE

The card idle state.

CY_SD_HOST_CARD_READY

The card ready state.

CY_SD_HOST_CARD_IDENT

The card identification state.

CY_SD_HOST_CARD_STBY

The card stand-by state.

CY_SD_HOST_CARD_TRAN

The card transition state.

CY_SD_HOST_CARD_DATA

The card sending-data state.

CY_SD_HOST_CARD_RCV

The card receive-data state.

CY_SD_HOST_CARD_PRG

The card programming state.

CY_SD_HOST_CARD_DIS

The card disconnect state.

CY_SD_HOST_CMD13_OUT_OF_RANGE

The command’s argument is out of range.

CY_SD_HOST_CMD13_ADDRESS_ERROR

The address does not match the block length.

CY_SD_HOST_CMD13_BLOCK_LEN_ERROR

The block length is not allowed for this card.

CY_SD_HOST_CMD13_ERASE_SEQ_ERROR

An error in the sequence of erase commands occurred.

CY_SD_HOST_CMD13_ERASE_PARAM

An invalid selection of write blocks for erase occurred.

CY_SD_HOST_CMD13_WP_VIOLATION

The host attempts to write to a protected block or to the permanent write-protected card.

CY_SD_HOST_CMD13_CARD_IS_LOCKED

The card is locked by the host.

CY_SD_HOST_CMD13_LOCK_ULOCK_FAILED

A sequence or password error occurred has been detected in the lock/unlock card command.

CY_SD_HOST_CMD13_COM_CRC_ERROR

The CRC of the previous command failed.

CY_SD_HOST_CMD13_ILLEGAL_COMMAND

The command is not legal for the card state.

CY_SD_HOST_CMD13_CARD_ECC_FAILED

The card internal ECC failed.

CY_SD_HOST_CMD13_CC_ERROR

An internal card-controller error.

CY_SD_HOST_CMD13_ERROR

A general or unknown error occurred.

CY_SD_HOST_CMD13_CSD_OVERWRITE

Can be either one of the following errors:

  • The read only section of the CSD does not match the card content.

  • An attempt to reverse the copy (set as original) or permanent WP (unprotected) bits was made.

CY_SD_HOST_CMD13_WP_ERASE_SKIP

Set when only partial address space was erased due to existing write protected blocks or a temporary or permanent write protected card was erased.

CY_SD_HOST_CMD13_CARD_ECC_DISABLED

The command has been executed without using the internal ECC.

CY_SD_HOST_CMD13_CURRENT_STATE

The state of the card.

CY_SD_HOST_CMD13_READY_FOR_DATA

The buffer is empty on the bus.

CY_SD_HOST_CMD13_APP_CMD

The card will expect ACMD, or an indication that the command has been interpreted as ACMD.

CY_SD_HOST_CMD13_AKE_SEQ_ERROR

Error in the sequence of the authentication process.

CY_SD_HOST_CMD13_CURRENT_STATE_MSK

The current state mask of the card.

CY_SD_HOST_SCR_SCR_STRUCTURE

Version number of the related SCR structure in the SD Memory Card Physical Layer Specification.

CY_SD_HOST_SCR_SD_SPEC

Describes the SD Memory Card Physical Layer Specification version supported by this card.

CY_SD_HOST_SCR_DATA_STAT_AFTER_ERASE

Defines the data status after erase, whether it is ‘0’ or ‘1’ (the status is card vendor dependent).

CY_SD_HOST_SCR_SD_SECURITY

Describes the security algorithm supported by the card.

CY_SD_HOST_SCR_SD_BUS_WIDTHS

Describes all the DAT bus widths that are supported by this card.

CY_SD_HOST_SCR_CID_MDT

The manufacturing date is composed of two hexadecimal digits (contained in cid[0]), one is 8 bits representing the year(y) and the other is 4 bits representing the month (m).

The “m” field [11:8] is the month code. 1 = January. The “y” field [19:12] is the year code. 0 = 2000. As an example, the binary value of the Date field for production date “April 2018” will be: 00010010 0100.

CY_SD_HOST_SCR_CID_PSN_LSB

The mask for LSB part of the Serial Number (contained in cid[0]).

The Serial Number is 32 bits of binary number.

CY_SD_HOST_SCR_CID_PSN_MSB

The mask for MSB part of the Serial Number (contained in cid[1]).

The Serial Number is 32 bits of binary number.

CY_SD_HOST_SCR_CID_PRV

The product revision is composed of two Binary Coded Decimal (BCD) digits (contained in cid[1]), four bits each, representing an “n.m” revision number.

The “n” is the most significant nibble and “m” is the least significant nibble. As an example, the PRV binary value field for product revision “6.2” will be: 0110 0010b.

CY_SD_HOST_SCR_CID_PNM_LSB

The mask for LSB part (the first 8 bits) of the product name (contained in cid[1]).

The product name is a string, 5-character ASCII string. As an example, the PNM hex value field for product name “EB1QT” will be: 0x4542315154.

CY_SD_HOST_SCR_CID_PNM_MSB

The mask for MSB part (the last 32 bits) of the product name (contained in cid[2]).

The product name is a string, 5-character ASCII string. As an example, the PNM hex value field for product name “EB1QT” will be: 0x4542315154.

CY_SD_HOST_SCR_CID_OID

The mask for the OID (contained in cid[3]).

The OID is a 2-character ASCII string that identifies the card OEM and/or the card contents (when used as a distribution media either on ROM or FLASH cards). The OID number is controlled, defined, and allocated to a SD Memory Card manufacturer by the SD-3C, LLC. This procedure is established to ensure uniqueness of the CID register. As an example, the OID hex value field for the card OEM “SM” will be: 0x534D.

CY_SD_HOST_SCR_CID_MID

The mask for the MID (contained in cid[3]).

MID is a 8-bit binary number that identifies the card manufacturer. The MID number is controlled, defined, and allocated to a SD Memory Card manufacturer by the SD-3C, LLC. This procedure is established to ensure uniqueness of the CID register.

CY_SD_HOST_CSD_V2_CSD_STRUCTURE

CSD structure (contained in csd[3])

CY_SD_HOST_CSD_V2_TAAC

The data read access-time (contained in csd[3]).

This field is fixed to 0Eh, which indicates 1 ms.

CY_SD_HOST_CSD_V2_NSAC

The data read access-time in CLK cycles (NSAC*100) (contained in csd[3]).

This field is fixed to 00h. NSAC should not be used to calculate time-out values for CSD Version 2.0.

CY_SD_HOST_CSD_V2_TRAN_SPEED

The max.

data transfer rate (contained in csd[2]). Equals to 0x32 (25 MHz) or 0x5A (50 MHz).

CY_SD_HOST_CSD_V2_CCC

The card command classes (contained in csd[2]).

The card command class register CCC defines which command classes are supported by this card. A value of 1 in a CCC bit means that the corresponding command class is supported.

CY_SD_HOST_CSD_V2_READ_BL_LEN

The max.

read data block length (contained in csd[2]). This field is fixed to 9h, which indicates READ_BL_LEN=512 Byte.

CY_SD_HOST_CSD_V2_READ_BL_PARTIAL

The partial blocks for read allowed (contained in csd[2]).

This field is fixed to 0, which indicates partial block read is inhibited and only unit of block access is allowed.

CY_SD_HOST_CSD_V2_WRITE_BLK_MISALIGN

The write block misalignment (contained in csd[2]).

This field is fixed to 0, which indicates write access crossing physical block boundaries is always disabled in High Capacity SD Memory Card.

CY_SD_HOST_CSD_V2_READ_BLK_MISALIGN

The read block misalignment (contained in csd[2]).

This field is fixed to 0, which indicates read access crossing physical block boundaries is always disabled in High Capacity SD Memory Card.

CY_SD_HOST_CSD_V2_DSR_IMP

The DSR implemented (contained in csd[2]).

Defines if the configurable driver stage is integrated on the card.

CY_SD_HOST_CSD_V2_C_SIZE_MASK

The device size (contained in csd[1]).

This parameter is used to calculate the user data area capacity in the SD memory card (not include the protected area). The user data area capacity is calculated from C_SIZE as follows: memory capacity = (C_SIZE+1) * 512K byte.

CY_SD_HOST_CSD_V2_ERASE_BLK_EN

The erase single block enable (contained in csd[1]).

This field is fixed to 1, which means the host can erase one or multiple units of 512 bytes.

CY_SD_HOST_CSD_V2_SECTOR_SIZE_MSB

The MSB of erase sector size (6 MSB bits contained in csd[1]).

SECTOR_SIZE is fixed to 7Fh, which indicates 64 KBytes. This value does not relate to erase operation. Version 2.00 cards indicates memory boundary by AU size and this field should not be used.

CY_SD_HOST_CSD_V2_SECTOR_SIZE_LSB

The LSB of erase sector size (1 LSB bit of SECTOR_SIZE contained in csd[0]).

CY_SD_HOST_CSD_V2_WP_GRP_SIZE

The write protect group size (contained in csd[0]).

This field is fixed to 00h. The High Capacity SD Memory Card does not support write protected groups.

CY_SD_HOST_CSD_V2_WP_GRP_ENABLE

The write protect group enable (contained in csd[0]).

This field is fixed to 0. The High Capacity SD Memory Card does not support write protected groups.

CY_SD_HOST_CSD_V2_R2W_FACTOR

The write speed factor (contained in csd[0]).

This field is fixed to 2h, which indicates 4 multiples.

CY_SD_HOST_CSD_V2_WRITE_BL_LEN

The max.

write data block length (contained in csd[0]). This field is fixed to 9h, which indicates WRITE_BL_LEN=512 Byte.

CY_SD_HOST_CSD_V2_WRITE_BL_PARTIAL

The partial blocks for write allowed (contained in csd[0]).

This field is fixed to 0, which indicates partial block read is inhibited and only unit of block access is allowed.

CY_SD_HOST_CSD_V2_FILE_FORMAT_GRP

The File format group (contained in csd[0]).

This field is set to 0. Host should not use this field.

CY_SD_HOST_CSD_V2_COPY

The copy flag (OTP) (contained in csd[0]).

Defines if the contents is original (=0) or has been copied (=1). The COPY bit for OTP and MTP devices, sold to end consumers, is set to 1, which identifies the card contents as a copy. The COPY bit is a one time programmable bit.

CY_SD_HOST_CSD_V2_PERM_WRITE_PROTECT

The permanent write protection (contained in csd[0]).

Permanently protects the entire card content against overwriting or erasing (all write and erase commands for this card are permanently disabled). The default value is 0, i.e. not permanently write protected.

CY_SD_HOST_CSD_V2_TMP_WRITE_PROTECT

The temporary write protection (contained in csd[0]).

Temporarily protects the entire card content from being overwritten or erased (all write and erase commands for this card are temporarily disabled). This bit can be set and reset. The default value is 0, i.e. not write protected.

CY_SD_HOST_CSD_V2_FILE_FORMAT

The File format (contained in csd[0]).

This field is set to 0. Host should not use this field.

CY_SD_HOST_CMD_COMPLETE

Command complete.

In SD/eMMC mode, this event is set after detecting the end bit of a response except for Auto CMD12 and Auto CMD23. This event is not generated when the Response Interrupt is disabled.

CY_SD_HOST_XFER_COMPLETE

Transfer complete.

This event is set when a read/write transfer and a command with the Busy Status are completed.

CY_SD_HOST_BGAP

Block gap.

This event is set when both read/write transactions are stopped at the block gap due to a Stop-at-Block-Gap Request.

CY_SD_HOST_DMA_INTERRUPT

DMA Interrupt.

This event is set if the Host Controller detects a SDMA Buffer Boundary during a transfer. For ADMA, the Host controller generates this interrupt by setting the Int field in the descriptor table. This interrupt is not generated after a Transfer Complete.

CY_SD_HOST_BUF_WR_READY

The Buffer Write is ready.

This event is set if the Buffer Write Enable changes from 0 to 1.

CY_SD_HOST_BUF_RD_READY

The Buffer Read is ready.

This event is set if the Buffer Read Enable changes from 0 to 1.

CY_SD_HOST_CARD_INSERTION

Card insertion.

This event is set if the Card Inserted in the Present State register changes from 0 to 1.

CY_SD_HOST_CARD_REMOVAL

Card removal.

This event is set if the Card Inserted in the Present State register changes from 1 to 0.

CY_SD_HOST_CARD_INTERRUPT

The Card interrupt.

This event reflects the synchronized value of DAT[1] Interrupt Input for SD Mode

CY_SD_HOST_FX_EVENT

FX event.

This status is set when R[14] of the response register is set to 1 and Response Type R1/R5 is set to 0 in the Transfer Mode register. This interrupt is used with the response check function.

CY_SD_HOST_CQE_EVENT

Command Queuing event.

This status is set if a Command Queuing/Crypto related event has occurred in eMMC/SD mode.

CY_SD_HOST_ERR_INTERRUPT

Error Interrupt.

If any of the bits in the Error Interrupt Status register are set, then this bit is set.

CY_SD_HOST_CMD_TOUT_ERR

Command timeout error.

In SD/eMMC Mode, this event is set only if no response is returned within 64 SD clock cycles from the end bit of the command. If the Host Controller detects a CMD line conflict, along with Command CRC Error bit, this event is set to 1, without waiting for 64 SD/eMMC card clock cycles.

CY_SD_HOST_CMD_CRC_ERR

Command CRC error.

A Command CRC Error is generated in SD/eMMC mode when:

  1. A response is returned and the Command Timeout Error is set to 0 (indicating no timeout), this bit is set to 1 when detecting a CRC error in the command response.

  2. The Host Controller detects a CMD line conflict by monitoring the CMD line when a command is issued. If the Host Controller drives the CMD line to level 1, but detects level 0 on the CMD line at the next SD clock edge, then the Host Controller aborts the command (stop driving CMD line) and sets this bit to 1. The Command Timeout Error is also set to 1 to distinguish a CMD line conflict.

CY_SD_HOST_CMD_END_BIT_ERR

Command End Bit error.

This bit is set after detecting that the end bit of a command response is 0 in SD/eMMC mode.

CY_SD_HOST_CMD_IDX_ERR

Command Index error.

This bit is set if a Command Index error occurs in the command response in SD/eMMC mode.

CY_SD_HOST_DATA_TOUT_ERR

Data Timeout error.

This bit is set in SD/eMMC mode when detecting one of the following timeout conditions:

  • Busy timeout for R1b, R5b type

  • Busy timeout after Write CRC status

  • Write CRC Status timeout

  • Read Data timeout.

CY_SD_HOST_DATA_CRC_ERR

Data CRC error.

This error occurs in SD/eMMC mode after detecting a CRC error while transferring read data that uses the DAT line, after detecting the Write CRC status having a value other than 010 or when writing a CRC status timeout.

CY_SD_HOST_DATA_END_BIT_ERR

Data End Bit error.

This error occurs in SD/eMMC mode either when detecting 0 at the end bit position of read data that uses the DAT line or at the end bit position of the CRC status.

CY_SD_HOST_CUR_LMT_ERR

Current Limit error.

The SD Host driver does not support this function, this bit is always set to 0.

CY_SD_HOST_AUTO_CMD_ERR

Auto CMD error.

This error status is used by Auto CMD12 and Auto CMD23 in SD/eMMC mode. This bit is set after detecting that any of the bits D00 to D05 in the Auto CMD Error Status register has changed from 0 to 1. D07 is effective in case for Auto CMD12. The Auto CMD Error Status register is valid while this bit is set to 1 and may be cleared by clearing this bit.

CY_SD_HOST_ADMA_ERR

ADMA error.

This bit is set when the Host Controller detects an error during an ADMA-based data transfer. The possible reasons for an error:

  • An error response is received from the System bus;

  • ADMA3, ADMA2 Descriptors are invalid;

  • CQE Task or Transfer descriptors are invalid. When an error occurs, the state of the ADMA is saved in the ADMA Error Status register.

CY_SD_HOST_TUNING_ERR

Tuning error.

The SD Host driver does not support this function.

CY_SD_HOST_RESP_ERR

Response error.

Host Controller Version 4.00 supports the response error check function to avoid overhead of the response error check by Host Driver during DMA execution. If the Response Error Check Enable is set to 1 in the Transfer Mode register, the Host Controller checks R1 or R5 response. If an error is detected in a response, this bit is set to 1. This is applicable in SD/eMMC mode.

CY_SD_HOST_BOOT_ACK_ERR

Boot Acknowledgement error.

This bit is set when there is a timeout for boot acknowledgement or after detecting the boot ACK status having a value other than 010. This is applicable only when boot acknowledgement is expected in eMMC mode.

CY_SD_HOST_CMD_INHIBIT

Command Inhibit (CMD).

This bit indicates the following:

  • SD/eMMC mode: If this bit is set to 0, it indicates that the CMD line is not in use and the Host controller can issue an SD/eMMC command using the CMD line. This bit is set when the command register is written. This bit is cleared when the command response is received. This bit is not cleared by the response of auto CMD12/23 but cleared by the response of the Read/Write command.

CY_SD_HOST_CMD_CMD_INHIBIT_DAT

Command Inhibit (DAT).

This bit is applicable for SD/eMMC mode and is generated if either the DAT line active or Read transfer active is set to 1. If this bit is set to 0, it indicates that the Host Controller can issue subsequent SD/eMMC commands.

CY_SD_HOST_DAT_LINE_ACTIVE

DAT Line Active (SD/eMMC Mode only).

This bit indicates whether one of the DAT lines on the SD/eMMC bus is in use. For Read transactions, this bit indicates whether a read transfer is executing on the SD/eMMC bus. For Write transactions, this bit indicates whether a write transfer is executing on the SD/eMMC bus. For a command with the Busy status, this status indicates whether the command executing busy is executing on an SD or eMMC bus.

CY_SD_HOST_DAT_7_4

DAT[7:4] Line Signal Level.

These bits are used to check the DAT line level to recover from errors and for debugging. These bits reflect the value of the sd_dat_in (upper nibble) signal.

CY_SD_HOST_WR_XFER_ACTIVE

Write Transfer Active This status indicates whether the Write transfer is active for SD/eMMC mode.

CY_SD_HOST_RD_XFER_ACTIVE

Read Transfer Active.

This bit indicates whether the Read transfer is active for SD/eMMC mode.

CY_SD_HOST_BUF_WR_ENABLE

Buffer Write Enable.

This bit is used for non-DMA transfers. This bit is set if space is available for writing data.

CY_SD_HOST_BUF_RD_ENABLE

Buffer Read Enable.

This bit is used for non-DMA transfers. This bit is set if valid data exists in the Host buffer.

CY_SD_HOST_CARD_INSERTED

Card Inserted.

This bit indicates whether a card has been inserted. The Host Controller debounces this signal so that the Host Driver does not need to wait for the signal to stabilize.

CY_SD_HOST_CARD_STABLE

Card Stable.

This bit indicates the stability of the Card Detect Pin Level. A card is not detected if this bit is set to 1 and the value of the CARD_INSERTED bit is 0.

CY_SD_HOST_CARD_DETECT_PIN_LEVEL

Card Detect Pin Level.

This bit reflects the inverse synchronized value of the card_detect_n signal.

CY_SD_HOST_WR_PROTECT_SW_LVL

Write Protect Switch Pin Level.

This bit is supported only for memory and combo cards. This bit reflects the synchronized value of the card_write_prot signal.

CY_SD_HOST_DAT_3_0

DAT[3:0] Line Signal Level.

This bit is used to check the DAT line level to recover from errors and for debugging. These bits reflect the value of the sd_dat_in (lower nibble) signal.

CY_SD_HOST_CMD_LINE_LVL

Command-Line Signal Level.

This bit is used to check the CMD line level to recover from errors and for debugging. These bits reflect the value of the sd_cmd_in signal.

CY_SD_HOST_HOST_REG_VOL

Host Regulator Voltage Stable.

This bit is used to check whether the host regulator voltage is stable for switching the voltage of UHS-I mode. This bit reflects the synchronized value of the host_reg_vol_stable signal.

CY_SD_HOST_CMD_ISSU_ERR

Command Not Issued by Error.

This bit is set if a command cannot be issued after setting the command register due to an error except an Auto CMD12 error.

CY_SD_HOST_SUB_CMD_STAT

Sub Command Status.

This bit is used to distinguish between a main command and a sub command status.

CY_SD_HOST_IN_DORMANT_ST

In Dormant Status.

This bit indicates whether UHS-II lanes enter the Dormant state in the UHS-II mode. For SD/eMMC mode, this bit always returns 0.

CY_SD_HOST_LANE_SYNC

Lane Synchronization.

This bit indicates whether a lane is synchronized in UHSII mode. For SD/eMMC mode, this bit always returns 0.

CY_SD_HOST_UHS2_IF_DETECT

UHS-II Interface Detection.

This bit indicates whether a card supports the UHS-II interface. For SD/eMMC mode, this bit always returns 0.

Enums

enum cy_en_sd_host_cmd_type_t

cy_en_sd_host_cmd_type_t: SD command types.

Values:

enumerator CY_SD_HOST_CMD_NORMAL

Other commands.

enumerator CY_SD_HOST_CMD_SUSPEND

CMD52 for writing “Bus Suspend” in CCCR.

enumerator CY_SD_HOST_CMD_RESUME

CMD52 for writing “Function Select” in CCCR.

enumerator CY_SD_HOST_CMD_ABORT

CMD12, CMD52 for writing “I/O Abort” in CCCR.

enum cy_en_sd_host_auto_cmd_t

cy_en_sd_host_auto_cmd_t: SD Host auto command enable selection.

Values:

enumerator CY_SD_HOST_AUTO_CMD_NONE

Auto command disable.

enumerator CY_SD_HOST_AUTO_CMD_12

Auto command 12 enable.

enumerator CY_SD_HOST_AUTO_CMD_23

Auto command 23 enable.

enumerator CY_SD_HOST_AUTO_CMD_AUTO

Auto command Auto enable.

enum cy_en_sd_host_reset_t

cy_en_sd_host_reset_t: SD Host reset types.

Values:

enumerator CY_SD_HOST_RESET_DATALINE

Reset the data circuit only.

enumerator CY_SD_HOST_RESET_CMD_LINE

Reset the command circuit only.

enumerator CY_SD_HOST_RESET_ALL

Reset the whole SD Host controller.

enum cy_en_sd_host_adma_error_t

cy_en_sd_host_adma_error_t: SD Host error interrupt types.

Values:

enumerator CY_SD_HOST_ADMA_ST_STOP

Stop DMA - The SYS_ADR register points to a location next to the error descriptor.

enumerator CY_SD_HOST_ADMA_ST_FDS

Fetch Descriptor - The SYS_ADR register points to the error descriptor.

enumerator CY_SD_HOST_ADMA_ST_TFR

Transfer Data - SYS_ADR register points to a location next to the error descriptor.

enumerator CY_SD_HOST_ADMA_LEN_ERR

The ADMA Length Mismatch error.

enum cy_en_sd_host_auto_cmd_status_t

cy_en_sd_host_auto_cmd_status_t: Auto CMD Status error codes.

Values:

enumerator CY_SD_HOST_AUTO_CMD12_NOT_EXEC

Auto CMD12 Not Executed.

enumerator CY_SD_HOST_AUTO_CMD_TOUT_ERR

Auto CMD Timeout Error.

enumerator CY_SD_HOST_AUTO_CMD_CRC_ERR

Auto CMD CRC Error.

enumerator CY_SD_HOST_AUTO_CMD_EBIT_ERR

Auto CMD End Bit Error.

enumerator CY_SD_HOST_AUTO_CMD_IDX_ERR

Auto CMD Index Error.

enumerator CY_SD_HOST_AUTO_CMD_RESP_ERR

Auto CMD Response Error.

enumerator CY_SD_HOST_CMD_NOT_ISSUED_AUTO_CMD12

Command Not Issued By Auto CMD12 Error.

enum cy_en_sd_host_status_t

cy_en_sd_host_status_t: SD host error codes.

Values:

enumerator CY_SD_HOST_SUCCESS

Successful.

enumerator CY_SD_HOST_ERROR

Non-specific error code.

enumerator CY_SD_HOST_ERROR_INVALID_PARAMETER

The provided parameter is not valid.

enumerator CY_SD_HOST_ERROR_OPERATION_IN_PROGRESS

A conflicting or requested operation is still in progress.

enumerator CY_SD_HOST_ERROR_UNINITIALIZED

The module (or part of it) was not initialized properly.

enumerator CY_SD_HOST_ERROR_TIMEOUT

A Time Out error occurred.

enumerator CY_SD_HOST_OPERATION_INPROGRESS

The indicator for operation in progress.

enumerator CY_SD_HOST_ERROR_UNUSABLE_CARD

The card is unusable.

enumerator CY_SD_HOST_ERROR_DISCONNECTED

The card is disconnected.

enum cy_en_sd_host_bus_width_t

cy_en_sd_host_bus_width_t: The widths of the data bus.

Values:

enumerator CY_SD_HOST_BUS_WIDTH_1_BIT

The 1-bit mode data transfer width.

enumerator CY_SD_HOST_BUS_WIDTH_4_BIT

The 4-bit mode data transfer width.

enumerator CY_SD_HOST_BUS_WIDTH_8_BIT

The 8-bit mode data transfer width.

enum cy_en_sd_host_bus_speed_mode_t

cy_en_sd_host_bus_speed_mode_t: The bus speed modes.

Values:

enumerator CY_SD_HOST_BUS_SPEED_DEFAULT

Default Speed mode: 3.3V signaling at 25 MHz SDClk.

enumerator CY_SD_HOST_BUS_SPEED_HIGHSPEED

High Speed mode: 3.3V signaling at 50 MHz SDClk.

enumerator CY_SD_HOST_BUS_SPEED_SDR12_5

SDR12: UHS-I (1.8V signaling) at 25 MHz SDClk (12.5 MB/sec).

enumerator CY_SD_HOST_BUS_SPEED_SDR25

SDR25: UHS-I (1.8V signaling) at 50 MHz SDClk (25 MB/sec).

enumerator CY_SD_HOST_BUS_SPEED_SDR50

SDR50: UHS-I (1.8V signaling) at 100 MHz SDClk (50 MB/sec).

enumerator CY_SD_HOST_BUS_SPEED_EMMC_LEGACY

Backwards Compatibility with legacy MMC card (26MB/sec max).

enumerator CY_SD_HOST_BUS_SPEED_EMMC_HIGHSPEED_SDR

eMMC High speed SDR (52MB/sec max)

enum cy_en_sd_host_io_voltage_t

cy_en_sd_host_io_voltage_t: The SD bus voltage select.

Values:

enumerator CY_SD_HOST_IO_VOLT_3_3V

3.3V.

enumerator CY_SD_HOST_IO_VOLT_1_8V

1.8V.

enum cy_en_sd_host_erase_type_t

cy_en_sd_host_erase_type_t: Erase type.

Values:

enumerator CY_SD_HOST_ERASE_ERASE

The ERASE operation.

enumerator CY_SD_HOST_ERASE_DISCARD

The DISCARD operation.

enumerator CY_SD_HOST_ERASE_FULE

The Full User Area Logical Erase (FULE) operation.

enumerator CY_SD_HOST_ERASE_SECURE

The secure purge according to Secure Removal Type in EXT_CSD on the erase groups identified by the startAddr&endAddr parameters and any copies of those erase groups.

enumerator CY_SD_HOST_ERASE_SECURE_TRIM_STEP_2

The secure purge operation on the write blocks according to Secure Removal Type in EXT_CSD and copies of those write blocks that were previously identified using Cy_SD_Host_Erase with CY_SD_HOST_ERASE_SECURE_TRIM_STEP_1.

enumerator CY_SD_HOST_ERASE_SECURE_TRIM_STEP_1

Mark the write blocks, indicated by the startAddr&endAddr parameters, for secure erase.

enumerator CY_SD_HOST_ERASE_TRIM

Trim the write blocks identified by the startAddr&endAddr parameters.

The controller can perform the actual erase at convenient time.

enum cy_en_sd_host_card_type_t

cy_en_sd_host_card_type_t: Card type.

Values:

enumerator CY_SD_HOST_SD

The Secure Digital card (SD).

enumerator CY_SD_HOST_SDIO

The CD Input Output card (SDIO).

enumerator CY_SD_HOST_EMMC

The Embedded Multimedia card (eMMC).

enumerator CY_SD_HOST_COMBO

The Combo card (SD + SDIO).

enumerator CY_SD_HOST_UNUSABLE

The unusable or not supported.

enumerator CY_SD_HOST_NOT_EMMC

The card is not eMMC.

enum cy_en_sd_host_card_capacity_t

cy_en_sd_host_card_capacity_t: The card capacity type.

Values:

enumerator CY_SD_HOST_SDSC

SDSC - Secure Digital Standard Capacity (up to 2 GB).

enumerator CY_SD_HOST_SDHC

SDHC - Secure Digital High Capacity (up to 32 GB).

enumerator CY_SD_HOST_EMMC_LESS_2G

The eMMC block addressing for less than 2GB.

enumerator CY_SD_HOST_EMMC_GREATER_2G

The eMMC block addressing for greater than 2GB.

enumerator CY_SD_HOST_SDXC

SDXC - Secure Digital Extended Capacity (up to 2 TB).

enumerator CY_SD_HOST_UNSUPPORTED

Not supported.

enum cy_en_sd_host_response_type_t

cy_en_sd_host_response_type_t: SDHC response types.

Values:

enumerator CY_SD_HOST_RESPONSE_NONE

No Response.

enumerator CY_SD_HOST_RESPONSE_LEN_136

Response Length 136.

enumerator CY_SD_HOST_RESPONSE_LEN_48

Response Length 48.

enumerator CY_SD_HOST_RESPONSE_LEN_48B

Response Length 48.

Check Busy after response.

enum cy_en_sd_host_dma_type_t

cy_en_sd_host_dma_type_t: The DMA type enum.

Values:

enumerator CY_SD_HOST_DMA_SDMA

SDMA mode.

enumerator CY_SD_HOST_DMA_ADMA2

ADMA2 mode.

enumerator CY_SD_HOST_DMA_ADMA2_ADMA3

ADMA2-ADMA3 mode.

enum cy_en_sd_host_write_protect_t

cy_en_sd_host_write_protect_t: Write Protect type enum.

Values:

enumerator CY_SD_HOST_PERMANENT

The permanent write protect.

enumerator CY_SD_HOST_ENABLE_TEMPORARY

The temporary write protect.

enumerator CY_SD_HOST_DISABLE_TEMPORARY

Clear the temporary write protect.

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.

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

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.

note

After calling this function, the SD Host is configured in Default Speed mode (for the SD card), or SDR12 Speed mode (when lowVoltageSignaling is true), 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.

Return

cy_en_sd_host_status_t

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.

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).

Return

cy_en_sd_host_status_t

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.

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).

Return

cy_en_sd_host_status_t

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.

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 ref\ 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.

Return

cy_en_sd_host_status_t

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.

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.

Return

cy_en_sd_host_status_t

Parameters
  • *base: The SD host registers structure pointer.

  • config: The SD host module configuration.

  • 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.

void Cy_SD_Host_DeInit(SDHC_Type *base)

Restores the SD Host block registers back to default.

Parameters
  • *base: The SD host registers structure pointer.

void Cy_SD_Host_Enable(SDHC_Type *base)

Enables the SD host block.

Parameters
  • *base: The SD host registers structure pointer.

void Cy_SD_Host_Disable(SDHC_Type *base)

Disables the SD host block.

Parameters
  • *base: The SD host registers structure pointer.

__STATIC_INLINE void Cy_SD_Host_EnableSdClk (SDHC_Type *base)

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

Parameters
  • *base: The SD host registers structure pointer.

__STATIC_INLINE void Cy_SD_Host_DisableSdClk (SDHC_Type *base)

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

Parameters
  • *base: The SD host registers structure pointer.

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.

Return

cy_en_sd_host_status_t

Parameters
  • *base: The SD host registers structure pointer.

  • clkDiv: The clock divider for the SD clock.

bool Cy_SD_Host_IsWpSet(SDHC_Type const *base)

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

Return

bool true - the write protect is set, false - the write protect is not set.

Parameters
  • *base: The SD host registers structure pointer.

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().

Return

cy_en_sd_host_status_t

Parameters
  • *base: The SD host registers structure pointer.

  • width: The width of the data bus.

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.

Return

cy_en_sd_host_status_t

Parameters
  • *base: The SD host registers structure pointer.

  • width: The width of the data bus.

  • 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.

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.

Return

cy_en_sd_host_status_t

Parameters
  • *base: The SD host registers structure pointer.

  • speedMode: Bus Speed mode.

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.

Return

cy_en_sd_host_status_t

Parameters
  • *base: The SD host registers structure pointer.

  • speedMode: Bus speed mode.

  • 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.

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.

note

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.

note

This function is applicable for SD cards only.

note

The SD card power supply should be disabled and initialized again when this function returns CY_SD_HOST_ERROR_UNUSABLE_CARD.

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.

Return

cy_en_sd_host_status_t

Parameters
  • *base: The SD host registers structure pointer.

  • enable18VSignal: If true, use the 1.8V signaling, false - use the 3.3V signaling.

  • 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.

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
  • *base: The SD host registers structure pointer.

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
  • *base: The SD host registers structure pointer.

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.

Return

cy_en_sd_host_status_t

Parameters
  • *base: The SD host registers structure pointer.

  • *responsePtr: The pointer to response data.

  • largeResponse: If true, the response is 136 bits, false - 32 bits.

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.

Return

cy_en_sd_host_status_t

Parameters
  • *base: The SD host registers structure pointer.

  • *config: The configuration structure for the command.

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.

Return

cy_en_sd_host_status_t

Parameters
  • *base: The SD host registers structure pointer.

  • dataConfig: The pointer to the data transfer configuration structure.

__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.

Return

uint32_t Data that is being read.

Parameters
  • *base: The SD host registers structure pointer.

__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.

Return

cy_en_sd_host_status_t

Parameters
  • *base: The SD host registers structure pointer.

  • data: Data to be written.

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
  • *base: The SD host registers structure pointer.

  • ioVoltage: The voltage for IO.

__STATIC_INLINE void Cy_SD_Host_StopAtBlockGap (SDHC_Type *base)

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

Parameters
  • *base: The SD host registers structure pointer.

__STATIC_INLINE void Cy_SD_Host_ContinueFromBlockGap (SDHC_Type *base)

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

Parameters
  • *base: The SD host registers structure pointer.

__STATIC_INLINE uint32_t Cy_SD_Host_GetAutoCmdErrStatus (SDHC_Type const *base)

Gets the SD host error status of the auto command.

Return

uint32_t The bit mask of the Auto Command status.

Parameters
  • *base: The SD host registers structure pointer.

__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.

Return

cy_en_sd_host_status_t.

Parameters
  • *base: The SD host registers structure pointer.

__STATIC_INLINE void Cy_SD_Host_DisableAutoCmd23 (SDHC_Type *base)

Removes support for AutoCmd23 if it was previously set.

Parameters
  • *base: The SD host registers structure pointer.

__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.

Return

cy_en_sd_host_status_t

Parameters
  • *base: The SD host registers structure pointer.

__STATIC_INLINE void Cy_SD_Host_DisableAsyncInterrupt (SDHC_Type *base)

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

Parameters
  • *base: The SD host registers structure pointer.

__STATIC_INLINE uint32_t Cy_SD_Host_GetAdmaErrorStatus (SDHC_Type const *base)

Returns the ADMA Error Status register.

Return

uint32_t The bit mask of ADMA Error Status.

Parameters
  • *base: The SD host registers structure pointer.

__STATIC_INLINE void Cy_SD_Host_EMMC_Reset (SDHC_Type *base)

Resets the eMMC card.

Parameters
  • *base: The SD host registers structure pointer.

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.

Return

cy_en_sd_host_status_t

Parameters
  • *base: The SD host registers structure pointer.

  • 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.

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().

Return

cy_en_sd_host_status_t

Parameters
  • *base: The SD host registers structure pointer.

  • writeProtect: cy_en_sd_host_write_protect_t.

  • 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.

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

Returns the card status.

Return

uint32_t The card status (the result of the CMD13 command).

Parameters
  • *base: The SD host registers structure pointer.

  • 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.

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.

Return

cy_en_sd_host_status_t

Parameters
  • *base: The SD host registers structure pointer.

  • *sdStatus: The pointer to where to store the SD status array.

  • 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.

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.

note

For combo cards, the function returns the OCR register for the IO portion only.

Return

uint32_t The OCR register.

Parameters
  • *base: The SD host registers structure pointer.

  • 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.

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.

Return

cy_en_sd_host_status_t

Parameters
  • *base: The SD host registers structure pointer.

  • cid: The pointer to where to store the CID register.

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.

Return

cy_en_sd_host_status_t

Parameters
  • *base: The SD host registers structure pointer.

  • *csd: The pointer to where to store the CSD register.

  • 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.

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.

Return

cy_en_sd_host_status_t

Parameters
  • *base: The SD host registers structure pointer.

  • *extCsd: The pointer to where to store the EXTCSD register.

  • 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.

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.

Return

uint32_t The RCA register.

Parameters
  • *base: The SD host registers structure pointer.

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.

Return

cy_en_sd_host_status_t

Parameters
  • *base: The SD host registers structure pointer.

  • *scr: The pointer to where to store the SCR register.

  • 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.

uint32_t Cy_SD_Host_GetPresentState(SDHC_Type const *base)

Returns the values of the present state register.

Return

The value of the present state register.

Parameters
  • *base: The SD host registers structure pointer.

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.

Return

bool true - the card is connected, false - the card is removed (not connected).

Parameters
  • *base: The SD host registers structure pointer.

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
  • *base: The SD host registers structure pointer.

  • reset: The reset type.

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.

Return

cy_en_syspm_status_t

Parameters

cy_en_sd_host_status_t Cy_SD_Host_GetBlockCount(SDHC_Type *base, uint32_t *block_count, cy_stc_sd_host_context_t *context)

Returns the Block count in SD/eMMC Card.

Return

cy_en_sd_host_status_t

Parameters
  • *base: The SD host registers structure pointer.

  • *block_count: The pointer to store the block_count.

  • 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.

__STATIC_INLINE uint32_t Cy_SD_Host_GetNormalInterruptStatus (SDHC_Type const *base)

Returns the normal Int Status register.

Return

uint32_t The Bit mask of the normal Int Status.

Parameters
  • *base: The SD host registers structure pointer.

__STATIC_INLINE void Cy_SD_Host_ClearNormalInterruptStatus (SDHC_Type *base, uint32_t status)

Clears the selected SD host normal status.

Parameters
  • *base: The SD host registers structure pointer.

  • status: The bitmask of statuses to clear.

__STATIC_INLINE void Cy_SD_Host_SetNormalInterruptEnable (SDHC_Type *base, uint32_t interrupt)

Sets the bit to be active in the Int status register.

Parameters
  • *base: The SD host registers structure pointer.

  • interrupt: The Bit field of which normal interrupt status to enable.

__STATIC_INLINE uint32_t Cy_SD_Host_GetNormalInterruptEnable (SDHC_Type const *base)

Returns which normal interrupts are enabled.

Return

uint32_t The Bit field of which normal interrupt statuses are enabled.

Parameters
  • *base: The SD host registers structure pointer.

__STATIC_INLINE void Cy_SD_Host_SetNormalInterruptMask (SDHC_Type *base, uint32_t interruptMask)

Setting a bit in this register allows the enabled status to cause an interrupt.

Parameters
  • *base: The SD host registers structure pointer.

  • interruptMask: The Bit field of which normal interrupts can cause an interrupt.

__STATIC_INLINE uint32_t Cy_SD_Host_GetNormalInterruptMask (SDHC_Type const *base)

Returns which normal interrupts are masked to cause an interrupt.

Return

uint32_t The Bit field of which normal interrupts are masked to cause an interrupt.

Parameters
  • *base: The SD host registers structure pointer.

__STATIC_INLINE uint32_t Cy_SD_Host_GetErrorInterruptStatus (SDHC_Type const *base)

Returns the error Int Status register.

Return

uint32_t The bit mask of the error Int status.

Parameters
  • *base: The SD host registers structure pointer.

__STATIC_INLINE void Cy_SD_Host_ClearErrorInterruptStatus (SDHC_Type *base, uint32_t status)

Clears the error interrupt status.

Parameters
  • *base: The SD host registers structure pointer.

  • status: The bitmask of statuses to clear.

__STATIC_INLINE void Cy_SD_Host_SetErrorInterruptEnable (SDHC_Type *base, uint32_t interrupt)

Setting a bit in this register allows for the bit to be active in the Int status register.

Parameters
  • *base: The SD host registers structure pointer.

  • interrupt: The Bit field of which error interrupt status to enable.

__STATIC_INLINE uint32_t Cy_SD_Host_GetErrorInterruptEnable (SDHC_Type const *base)

Returns which error interrupts are enabled.

Return

uint32_t The Bit field of which error interrupt statuses are enabled.

Parameters
  • *base: The SD host registers structure pointer.

__STATIC_INLINE void Cy_SD_Host_SetErrorInterruptMask (SDHC_Type *base, uint32_t interruptMask)

Setting a bit in this register allows the enabled status to cause an interrupt.

Parameters
  • *base: The SD host registers structure pointer.

  • interruptMask: The Bit filed of which error interrupts can cause an interrupt.

__STATIC_INLINE uint32_t Cy_SD_Host_GetErrorInterruptMask (SDHC_Type const *base)

Returns which error interrupts are masked to cause an interrupt.

Return

uint32_t The Bit field of which error interrupts are masked to cause an interrupt.

Parameters
  • *base: The SD host registers structure pointer.

struct cy_stc_sd_host_init_config_t
#include <cy_sd_host.h>

SD Host initialization configuration structure.

Public Members

bool emmc

Set to true of eMMC otherwise false.

cy_en_sd_host_dma_type_t dmaType

Selects the DMA type to be used.

bool enableLedControl

If true the SD clock controls one IO used to indicate when the card is being accessed.

struct cy_stc_sd_host_sd_card_config_t
#include <cy_sd_host.h>

SD/eMMC card configuration structure.

Public Members

bool lowVoltageSignaling

If true, the host supports the 1.8V signaling.

cy_en_sd_host_bus_width_t busWidth

The desired bus width.

cy_en_sd_host_card_type_t *cardType

The card type.

uint32_t *rca

The pointer to where to store the cards relative card address.

cy_en_sd_host_card_capacity_t *cardCapacity

Stores the card capacity.

struct cy_stc_sd_host_cmd_config_t
#include <cy_sd_host.h>

SD Host command configuration structure.

Public Members

uint32_t commandIndex

The index of the command.

uint32_t commandArgument

The argument for the command.

bool enableCrcCheck

Enables the CRC check on the response.

bool enableAutoResponseErrorCheck

If true the hardware checks the response for errors.

cy_en_sd_host_response_type_t respType

The response type.

bool enableIdxCheck

Checks the index of the response.

bool dataPresent

true: Data is present to be transferred using the DAT line, false: Commands use the CMD line only.

cy_en_sd_host_cmd_type_t cmdType

The command type.

struct cy_stc_sd_host_data_config_t
#include <cy_sd_host.h>

The SD Host data transfer configuration structure.

Public Members

uint32_t blockSize

The size of the data block.

uint32_t numberOfBlock

The number of blocks to send.

bool enableDma

Enables DMA for the transaction.

cy_en_sd_host_auto_cmd_t autoCommand

Selects which auto commands are used if any.

bool read

true = Read from the card, false = Write to the card.

uint32_t *data

The pointer to data to send/receive or the pointer to the DMA descriptor.

uint32_t dataTimeout

The timeout value for the transfer.

bool enableIntAtBlockGap

Enables the interrupt generation at the block gap.

bool enReliableWrite

For EMMC enables the reliable write.

struct cy_stc_sd_host_write_read_config_t
#include <cy_sd_host.h>

SD Host Write/Read structure.

Public Members

uint32_t *data

The pointer to data.

uint32_t address

The address to Write/Read data on the card or eMMC.

uint32_t numberOfBlocks

The number of blocks to Write/Read.

cy_en_sd_host_auto_cmd_t autoCommand

Selects which auto commands are used if any.

uint32_t dataTimeout

The timeout value for the transfer.

bool enReliableWrite

For EMMC cards, enables the reliable write.

bool enableDma

Enables DMA for the transaction.

struct cy_stc_sd_host_context_t
#include <cy_sd_host.h>

Context structure.

Public Members

cy_en_sd_host_dma_type_t dmaType

Defines the DMA type to be used.

cy_en_sd_host_card_capacity_t cardCapacity

The standard card or the card with the high capacity.

uint32_t maxSectorNum

The SD card maximum number of the sectors.

uint32_t RCA

The relative card address.

cy_en_sd_host_card_type_t cardType

The card type.

uint32_t csd[4]

The Card-Specific Data register.