High level interface for interacting with the Cypress SDHC.
The SD Host Controller allows data to be read from and written to several types of memory cards, including SD and eMMC (see cyhal_sdhc_card_type_t for a full list).
|
| enum | cyhal_sdhc_card_type_t {
CYHAL_SDHC_SD,
CYHAL_SDHC_SDIO,
CYHAL_SDHC_EMMC,
CYHAL_SDHC_COMBO,
CYHAL_SDHC_UNUSABLE,
CYHAL_SDHC_NOT_EMMC
} |
| |
| enum | cyhal_sdhc_event_t {
CYHAL_SDHC_CMD_COMPLETE = 0x0001,
CYHAL_SDHC_XFER_COMPLETE = 0x0002,
CYHAL_SDHC_BGAP_EVENT = 0x0004,
CYHAL_SDHC_DMA_INTERRUPT = 0x0008,
CYHAL_SDHC_BUF_WR_READY = 0x0010,
CYHAL_SDHC_BUF_RD_READY = 0x0020,
CYHAL_SDHC_CARD_INSERTION = 0x0040,
CYHAL_SDHC_CARD_REMOVAL = 0x0080,
CYHAL_SDHC_CARD_INTERRUPT = 0x0100,
CYHAL_SDHC_INT_A = 0x0200,
CYHAL_SDHC_INT_B = 0x0400,
CYHAL_SDHC_INT_C = 0x0800,
CYHAL_SDHC_RE_TUNE_EVENT = 0x1000,
CYHAL_SDHC_FX_EVENT = 0x2000,
CYHAL_SDHC_CQE_EVENT = 0x4000,
CYHAL_SDHC_ERR_INTERRUPT = 0x8000,
CYHAL_SDHC_ALL_INTERRUPTS = 0xFFFF
} |
| |
|
| cy_rslt_t | cyhal_sdhc_init (cyhal_sdhc_t *obj, const cyhal_sdhc_config_t *config, cyhal_gpio_t cmd, cyhal_gpio_t clk, cyhal_gpio_t data0, cyhal_gpio_t data1, cyhal_gpio_t data2, cyhal_gpio_t data3, cyhal_gpio_t data4, cyhal_gpio_t data5, cyhal_gpio_t data6, cyhal_gpio_t data7, cyhal_gpio_t cardDetect, cyhal_gpio_t ioVoltSel, cyhal_gpio_t cardIfPwrEn, cyhal_gpio_t cardMechWriteProt, cyhal_gpio_t ledCtrl, cyhal_gpio_t cardEmmcReset) |
| |
| void | cyhal_sdhc_free (cyhal_sdhc_t *obj) |
| |
| cy_rslt_t | cyhal_sdhc_read (const cyhal_sdhc_t *obj, uint32_t address, uint8_t *data, size_t *length) |
| |
| cy_rslt_t | cyhal_sdhc_write (const cyhal_sdhc_t *obj, uint32_t address, const uint8_t *data, size_t *length) |
| |
| cy_rslt_t | cyhal_sdhc_erase (const cyhal_sdhc_t *obj, uint32_t startAddr, size_t length) |
| |
| cy_rslt_t | cyhal_sdhc_read_async (const cyhal_sdhc_t *obj, uint32_t address, uint8_t *data, size_t *length) |
| |
| cy_rslt_t | cyhal_sdhc_write_async (const cyhal_sdhc_t *obj, uint32_t address, const uint8_t *data, size_t *length) |
| |
| bool | cyhal_sdhc_is_busy (const cyhal_sdhc_t *obj) |
| |
| cy_rslt_t | cyhal_sdhc_abort_async (const cyhal_sdhc_t *obj) |
| |
| void | cyhal_sdhc_register_callback (cyhal_sdhc_t *obj, cyhal_sdhc_event_callback_t callback, void *callback_arg) |
| |
| void | cyhal_sdhc_enable_event (cyhal_sdhc_t *obj, cyhal_sdhc_event_t event, uint8_t intrPriority, bool enable) |
| |
◆ cyhal_sdhc_config_t
| struct cyhal_sdhc_config_t |
| Data Fields |
|
bool |
enableLedControl |
Drive one IO to indicate when the card is being accessed. |
|
bool |
lowVoltageSignaling |
Whether 1.8V signaling is supported. |
|
bool |
isEmmc |
true if eMMC card, otherwise false |
|
uint8_t |
busWidth |
The desired bus width. |
◆ CYHAL_SDHC_RSLT_ERR_PIN [1/2]
◆ CYHAL_SDHC_RSLT_ERR_PIN [2/2]
◆ cyhal_sdhc_event_callback_t
| typedef void(* cyhal_sdhc_event_callback_t) (void *callback_arg, cyhal_sdhc_event_t event) |
Handler for SDHC interrupts
◆ cyhal_sdhc_card_type_t
Card types
| Enumerator |
|---|
| CYHAL_SDHC_SD | Secure Digital card.
|
| CYHAL_SDHC_SDIO | SD Input Output card.
|
| CYHAL_SDHC_EMMC | Embedded Multimedia card.
|
| CYHAL_SDHC_COMBO | Combo Card (SD + SDIO)
|
| CYHAL_SDHC_UNUSABLE | Unusable card or unsupported type.
|
| CYHAL_SDHC_NOT_EMMC | Not an eMMC card.
|
◆ cyhal_sdhc_event_t
SDHC interrupt triggers
| Enumerator |
|---|
| CYHAL_SDHC_XFER_COMPLETE |
Command Complete
|
| CYHAL_SDHC_BGAP_EVENT |
Host read/write transfer is complete
|
| CYHAL_SDHC_DMA_INTERRUPT |
This bit is set when both read/write transaction is stopped at the block gap
|
| CYHAL_SDHC_BUF_WR_READY |
Host controller detects an SDMA Buffer Boundary during transfer
|
| CYHAL_SDHC_BUF_RD_READY |
This bit is set if the Buffer Write Enable changes from 0 to 1
|
| CYHAL_SDHC_CARD_INSERTION |
This bit is set if the Buffer Read Enable changes from 0 to 1
|
| CYHAL_SDHC_CARD_REMOVAL |
This bit is set if the Card Inserted in the Present State register changes from 0 to 1.
|
| CYHAL_SDHC_CARD_INTERRUPT |
This bit is set if the Card Inserted in the Present State register changes from 1 to 0.
|
| CYHAL_SDHC_INT_A |
The synchronized value of the DAT[1] interrupt input for SD mode
|
| CYHAL_SDHC_FX_EVENT |
This bit is set if the Re-Tuning Request changes from 0 to 1
|
| CYHAL_SDHC_CQE_EVENT |
This status is set when R[14] of response register is set to 1
|
| CYHAL_SDHC_ERR_INTERRUPT |
This status is set if Command Queuing/Crypto event has occurred
|
| CYHAL_SDHC_ALL_INTERRUPTS |
If any of the bits in the Error Interrupt Status register are set
|
◆ cyhal_sdhc_init()
| cy_rslt_t cyhal_sdhc_init |
( |
cyhal_sdhc_t * |
obj, |
|
|
const cyhal_sdhc_config_t * |
config, |
|
|
cyhal_gpio_t |
cmd, |
|
|
cyhal_gpio_t |
clk, |
|
|
cyhal_gpio_t |
data0, |
|
|
cyhal_gpio_t |
data1, |
|
|
cyhal_gpio_t |
data2, |
|
|
cyhal_gpio_t |
data3, |
|
|
cyhal_gpio_t |
data4, |
|
|
cyhal_gpio_t |
data5, |
|
|
cyhal_gpio_t |
data6, |
|
|
cyhal_gpio_t |
data7, |
|
|
cyhal_gpio_t |
cardDetect, |
|
|
cyhal_gpio_t |
ioVoltSel, |
|
|
cyhal_gpio_t |
cardIfPwrEn, |
|
|
cyhal_gpio_t |
cardMechWriteProt, |
|
|
cyhal_gpio_t |
ledCtrl, |
|
|
cyhal_gpio_t |
cardEmmcReset |
|
) |
| |
Initialize the SDHC peripheral
- Parameters
-
| [out] | obj | The SDHC object |
| [in] | config | The card configuration object |
| [out] | clk | The pin connected to the clk signal |
| [in] | cmd | The pin connected to the command signal |
| [in] | data0 | The pin connected to the data0 signal |
| [in] | data1 | The pin connected to the data1 signal |
| [in] | data2 | The pin connected to the data2 signal |
| [in] | data3 | The pin connected to the data3 signal |
| [in] | data4 | The pin connected to the data4 signal |
| [in] | data5 | The pin connected to the data5 signal |
| [in] | data6 | The pin connected to the data6 signal |
| [in] | data7 | The pin connected to the data7 signal |
| [in] | cardDetect | The pin connected to the cardDetect signal |
| [out] | ioVoltSel | The pin connected to the ioVoltSel signal |
| [out] | cardIfPwrEn | The pin connected to the cardIfPwrEn signal |
| [in] | cardMechWriteProt | The pin connected to the cardMechWriteProt signal |
| [in] | ledCtrl | The pin connected to the ledCtrl signal |
| [in] | cardEmmcReset | The pin connected to the cardEmmcReset signal |
- Returns
- The status of the init request
◆ cyhal_sdhc_free()
Release the SDHC peripheral, not currently invoked. It requires further resource management.
- Parameters
-
| [in,out] | obj | The SDHC object |
◆ cyhal_sdhc_read()
| cy_rslt_t cyhal_sdhc_read |
( |
const cyhal_sdhc_t * |
obj, |
|
|
uint32_t |
address, |
|
|
uint8_t * |
data, |
|
|
size_t * |
length |
|
) |
| |
Attempts to read data over the SDHC peripheral.
- Parameters
-
| [in] | obj | The SDHC object |
| [in] | address | The address to read data from |
| [out] | data | Pointer to the byte-array of data to read from the device |
| [in,out] | length | Number of 512 byte blocks to read, updated with the number actually read |
- Returns
- The status of the read request
◆ cyhal_sdhc_write()
| cy_rslt_t cyhal_sdhc_write |
( |
const cyhal_sdhc_t * |
obj, |
|
|
uint32_t |
address, |
|
|
const uint8_t * |
data, |
|
|
size_t * |
length |
|
) |
| |
Attempts to write data over SDHC peripheral
- Parameters
-
| [in] | obj | The SDHC object |
| [in] | address | The address to write data to |
| [in] | data | Pointer to the byte-array of data to write to the device |
| [in,out] | length | Number of 512 byte blocks to write, updated with the number actually written |
- Returns
- The status of the write request
◆ cyhal_sdhc_erase()
Attempts to erase a block of data over the SDHC peripheral
- Parameters
-
| [in] | obj | The SDHC object |
| [in] | startAddr | Is the address of the first byte to erase |
| [in] | length | Number of 512 byte blocks (starting at startAddr) to erase |
- Returns
- The status of the erase request
◆ cyhal_sdhc_read_async()
| cy_rslt_t cyhal_sdhc_read_async |
( |
const cyhal_sdhc_t * |
obj, |
|
|
uint32_t |
address, |
|
|
uint8_t * |
data, |
|
|
size_t * |
length |
|
) |
| |
Begin the SDHC read
- Parameters
-
| [in] | obj | The SDHC object that holds the transfer information |
| [in] | address | The address to read data from |
| [out] | data | The receive buffer |
| [in,out] | length | Number of 512 byte blocks to read, updated with the number actually read |
- Returns
- The status of the read_async request
◆ cyhal_sdhc_write_async()
| cy_rslt_t cyhal_sdhc_write_async |
( |
const cyhal_sdhc_t * |
obj, |
|
|
uint32_t |
address, |
|
|
const uint8_t * |
data, |
|
|
size_t * |
length |
|
) |
| |
Begin the SDHC write
- Parameters
-
| [in] | obj | The SDHC object that holds the transfer information |
| [in] | address | The address to write data to |
| [in] | data | The transmit buffer |
| [in,out] | length | The number of 512 byte blocks to write, updated with the number actually written |
- Returns
- The status of the write_async request
◆ cyhal_sdhc_is_busy()
Checks if the specified SDHC peripheral is in use
- Parameters
-
| [in] | obj | The SDHC peripheral to check |
- Returns
- Indication of whether the SDHC is still transmitting
◆ cyhal_sdhc_abort_async()
Abort an SDHC transfer
- Parameters
-
| [in] | obj | The SDHC peripheral to stop |
- Returns
- The status of the abort_async request
◆ cyhal_sdhc_register_callback()
The SDHC callback handler registration
- Parameters
-
| [in] | obj | The SDHC object |
| [in] | callback | The callback handler which will be invoked when the interrupt fires |
| [in] | callback_arg | Generic argument that will be provided to the callback when called |
◆ cyhal_sdhc_enable_event()
Configure SDHC event enablement.
- Parameters
-
| [in] | obj | The SDHC object |
| [in] | event | The SDHC event type |
| [in] | intrPriority | The priority for NVIC interrupt events |
| [in] | enable | True to turn on interrupts, False to turn off |