High level interface for interacting with the Cypress SDIO interface.
The Secure Digital Input Output (SDIO) protocol is an extension of the SD interface for general I/O functions.
This driver allows commands to be sent over the SDIO bus; the supported commands can be found in cyhal_sdio_command_t. Bulk data transfer is also supported via cyhal_sdio_bulk_transfer().
|
| enum | cyhal_sdio_command_t {
CYHAL_SDIO_CMD_GO_IDLE_STATE = 0,
CYHAL_SDIO_CMD_SEND_RELATIVE_ADDR = 3,
CYHAL_SDIO_CMD_IO_SEND_OP_COND = 5,
CYHAL_SDIO_CMD_SELECT_CARD = 7,
CYHAL_SDIO_CMD_GO_INACTIVE_STATE = 15,
CYHAL_SDIO_CMD_IO_RW_DIRECT = 52,
CYHAL_SDIO_CMD_IO_RW_EXTENDED = 53
} |
| |
| enum | cyhal_transfer_t { CYHAL_READ,
CYHAL_WRITE
} |
| |
| enum | cyhal_sdio_event_t {
CYHAL_SDIO_CMD_COMPLETE = 0x00001,
CYHAL_SDIO_XFER_COMPLETE = 0x00002,
CYHAL_SDIO_BGAP_EVENT = 0x00004,
CYHAL_SDIO_DMA_INTERRUPT = 0x00008,
CYHAL_SDIO_BUF_WR_READY = 0x00010,
CYHAL_SDIO_BUF_RD_READY = 0x00020,
CYHAL_SDIO_CARD_INSERTION = 0x00040,
CYHAL_SDIO_CARD_REMOVAL = 0x00080,
CYHAL_SDIO_CARD_INTERRUPT = 0x00100,
CYHAL_SDIO_INT_A = 0x00200,
CYHAL_SDIO_INT_B = 0x00400,
CYHAL_SDIO_INT_C = 0x00800,
CYHAL_SDIO_RE_TUNE_EVENT = 0x01000,
CYHAL_SDIO_FX_EVENT = 0x02000,
CYHAL_SDIO_CQE_EVENT = 0x04000,
CYHAL_SDIO_ERR_INTERRUPT = 0x08000,
CYHAL_SDIO_GOING_DOWN = 0x10000,
CYHAL_SDIO_COMING_UP = 0x20000,
CYHAL_SDIO_ALL_INTERRUPTS = 0x0E1FF
} |
| |
|
| cy_rslt_t | cyhal_sdio_init (cyhal_sdio_t *obj, cyhal_gpio_t cmd, cyhal_gpio_t clk, cyhal_gpio_t data0, cyhal_gpio_t data1, cyhal_gpio_t data2, cyhal_gpio_t data3) |
| |
| void | cyhal_sdio_free (cyhal_sdio_t *obj) |
| |
| cy_rslt_t | cyhal_sdio_configure (cyhal_sdio_t *obj, const cyhal_sdio_cfg_t *config) |
| |
| cy_rslt_t | cyhal_sdio_send_cmd (const cyhal_sdio_t *obj, cyhal_transfer_t direction, cyhal_sdio_command_t command, uint32_t argument, uint32_t *response) |
| |
| cy_rslt_t | cyhal_sdio_bulk_transfer (cyhal_sdio_t *obj, cyhal_transfer_t direction, uint32_t argument, const uint32_t *data, uint16_t length, uint32_t *response) |
| |
| cy_rslt_t | cyhal_sdio_transfer_async (cyhal_sdio_t *obj, cyhal_transfer_t direction, uint32_t argument, const uint32_t *data, uint16_t length) |
| |
| bool | cyhal_sdio_is_busy (const cyhal_sdio_t *obj) |
| |
| cy_rslt_t | cyhal_sdio_abort_async (const cyhal_sdio_t *obj) |
| |
| void | cyhal_sdio_register_callback (cyhal_sdio_t *obj, cyhal_sdio_event_callback_t callback, void *callback_arg) |
| |
| void | cyhal_sdio_enable_event (cyhal_sdio_t *obj, cyhal_sdio_event_t event, uint8_t intrPriority, bool enable) |
| |
◆ cyhal_sdio_cfg_t
| Data Fields |
|
uint32_t |
frequencyhal_hz |
Clock frequency, in hertz. |
|
uint16_t |
block_size |
Block size. |
◆ CYHAL_SDIO_RET_NO_ERRORS
| #define CYHAL_SDIO_RET_NO_ERRORS (0x00) |
◆ CYHAL_SDIO_RET_NO_SP_ERRORS
| #define CYHAL_SDIO_RET_NO_SP_ERRORS (0x01) |
◆ CYHAL_SDIO_RET_CMD_CRC_ERROR
| #define CYHAL_SDIO_RET_CMD_CRC_ERROR (0x02) |
There was a CRC error on the Command/Response
◆ CYHAL_SDIO_RET_CMD_IDX_ERROR
| #define CYHAL_SDIO_RET_CMD_IDX_ERROR (0x04) |
The index for the command didn't match
◆ CYHAL_SDIO_RET_CMD_EB_ERROR
| #define CYHAL_SDIO_RET_CMD_EB_ERROR (0x08) |
There was an end bit error on the command
◆ CYHAL_SDIO_RET_DAT_CRC_ERROR
| #define CYHAL_SDIO_RET_DAT_CRC_ERROR (0x10) |
There was a data CRC Error
◆ CYHAL_SDIO_RET_CMD_TIMEOUT
| #define CYHAL_SDIO_RET_CMD_TIMEOUT (0x20) |
The command didn't finish before the timeout period was over
◆ CYHAL_SDIO_RET_DAT_TIMEOUT
| #define CYHAL_SDIO_RET_DAT_TIMEOUT (0x40) |
The data didn't finish before the timeout period was over
◆ CYHAL_SDIO_RET_RESP_FLAG_ERROR
| #define CYHAL_SDIO_RET_RESP_FLAG_ERROR (0x80) |
There was an error in the resposne flag for command 53
◆ CYHAL_SDIO_CLOCK_ERROR
| #define CYHAL_SDIO_CLOCK_ERROR (0x100) |
Failed to initial clock for SDIO
◆ CYHAL_SDIO_BAD_ARGUMENT
| #define CYHAL_SDIO_BAD_ARGUMENT (0x200) |
Bad argument passed for SDIO
◆ CYHAL_SDIO_SEMA_NOT_INITED
| #define CYHAL_SDIO_SEMA_NOT_INITED (0x400) |
Semaphore is not initiated
◆ CYHAL_SDIO_FUNC_NOT_SUPPORTED
| #define CYHAL_SDIO_FUNC_NOT_SUPPORTED (0x800) |
Function is not supported
◆ CYHAL_SDIO_CANCELED
| #define CYHAL_SDIO_CANCELED (0x1000) |
◆ CYHAL_SDIO_RSLT_ERR_BAD_PARAM
| #define CYHAL_SDIO_RSLT_ERR_BAD_PARAM |
Value:#define CYHAL_SDIO_BAD_ARGUMENT
Definition: cyhal_sdio.h:64
Module identifier for the SDIO module.
Definition: cyhal_modules.h:59
#define CY_RSLT_TYPE_ERROR
The result code is an error.
Definition: cy_result.h:143
#define CY_RSLT_CREATE(type, module, code)
Create a new cy_rslt_t value that encodes the specified type, module, and result code.
Definition: cy_result.h:126
Incorrect parameter value define
◆ CYHAL_SDIO_RSLT_ERR_CLOCK
| #define CYHAL_SDIO_RSLT_ERR_CLOCK |
Value:Module identifier for the SDIO module.
Definition: cyhal_modules.h:59
#define CY_RSLT_TYPE_ERROR
The result code is an error.
Definition: cy_result.h:143
#define CY_RSLT_CREATE(type, module, code)
Create a new cy_rslt_t value that encodes the specified type, module, and result code.
Definition: cy_result.h:126
#define CYHAL_SDIO_CLOCK_ERROR
Definition: cyhal_sdio.h:63
Clock initialization error define
◆ CYHAL_SDIO_RSLT_ERR_SEMA_NOT_INITED
| #define CYHAL_SDIO_RSLT_ERR_SEMA_NOT_INITED |
Value:Module identifier for the SDIO module.
Definition: cyhal_modules.h:59
#define CY_RSLT_TYPE_ERROR
The result code is an error.
Definition: cy_result.h:143
#define CYHAL_SDIO_SEMA_NOT_INITED
Definition: cyhal_sdio.h:65
#define CY_RSLT_CREATE(type, module, code)
Create a new cy_rslt_t value that encodes the specified type, module, and result code.
Definition: cy_result.h:126
Semaphore not initiated error define
◆ CYHAL_SDIO_RSLT_ERR_FUNC_RET
| #define CYHAL_SDIO_RSLT_ERR_FUNC_RET |
( |
|
retVal | ) |
|
Value:Module identifier for the SDIO module.
Definition: cyhal_modules.h:59
#define CY_RSLT_TYPE_ERROR
The result code is an error.
Definition: cy_result.h:143
#define CY_RSLT_CREATE(type, module, code)
Create a new cy_rslt_t value that encodes the specified type, module, and result code.
Definition: cy_result.h:126
Error define based on SDIO lower function return value
◆ CYHAL_SDIO_RSLT_CANCELED
| #define CYHAL_SDIO_RSLT_CANCELED |
Value:Module identifier for the SDIO module.
Definition: cyhal_modules.h:59
#define CY_RSLT_TYPE_ERROR
The result code is an error.
Definition: cy_result.h:143
#define CYHAL_SDIO_CANCELED
Definition: cyhal_sdio.h:67
#define CY_RSLT_CREATE(type, module, code)
Create a new cy_rslt_t value that encodes the specified type, module, and result code.
Definition: cy_result.h:126
Define to indicate canceled operation
◆ cyhal_sdio_event_callback_t
| typedef void(* cyhal_sdio_event_callback_t) (void *callback_arg, cyhal_sdio_event_t event) |
◆ cyhal_sdio_command_t
Commands that can be issued
| Enumerator |
|---|
| CYHAL_SDIO_CMD_SEND_RELATIVE_ADDR |
Go to idle state
|
| CYHAL_SDIO_CMD_IO_SEND_OP_COND |
Send a relative address
|
| CYHAL_SDIO_CMD_SELECT_CARD |
Send an OP IO
|
| CYHAL_SDIO_CMD_GO_INACTIVE_STATE |
Send a card select
|
| CYHAL_SDIO_CMD_IO_RW_DIRECT |
Go to inactive state
|
| CYHAL_SDIO_CMD_IO_RW_EXTENDED |
Perform a direct read/write
|
◆ cyhal_transfer_t
Types of transfer that can be performed
| Enumerator |
|---|
| CYHAL_WRITE |
Read from the card
Write to the card
|
◆ cyhal_sdio_event_t
Types of events that could be asserted by SDIO
| Enumerator |
|---|
| CYHAL_SDIO_XFER_COMPLETE |
Command Complete
|
| CYHAL_SDIO_BGAP_EVENT |
Host read/write transfer is complete
|
| CYHAL_SDIO_DMA_INTERRUPT |
This bit is set when both read/write transaction is stopped
|
| CYHAL_SDIO_BUF_WR_READY |
Host controller detects an SDMA Buffer Boundary during transfer
|
| CYHAL_SDIO_BUF_RD_READY |
This bit is set if the Buffer Write Enable changes from 0 to 1
|
| CYHAL_SDIO_CARD_INSERTION |
This bit is set if the Buffer Read Enable changes from 0 to 1
|
| CYHAL_SDIO_CARD_REMOVAL |
This bit is set if the Card Inserted in the Present State
|
| CYHAL_SDIO_CARD_INTERRUPT |
This bit is set if the Card Inserted in the Present State
|
| CYHAL_SDIO_INT_A |
The synchronized value of the DAT[1] interrupt input for SD mode
|
| CYHAL_SDIO_INT_B |
Reserved: set to 0
|
| CYHAL_SDIO_INT_C |
Reserved: set to 0
|
| CYHAL_SDIO_RE_TUNE_EVENT |
Reserved: set to 0
|
| CYHAL_SDIO_FX_EVENT |
Reserved: set to 0
|
| CYHAL_SDIO_CQE_EVENT |
This status is set when R[14] of response register is set to 1
|
| CYHAL_SDIO_ERR_INTERRUPT |
This status is set if Command Queuing/Crypto event has occurred
|
| CYHAL_SDIO_GOING_DOWN |
If any of the bits in the Error Interrupt Status register are set
|
| CYHAL_SDIO_COMING_UP |
The interface is going away (eg: powering down for some period of time)
|
| CYHAL_SDIO_ALL_INTERRUPTS |
The interface is back up (eg: came back from a low power state)
|
◆ cyhal_sdio_init()
| cy_rslt_t cyhal_sdio_init |
( |
cyhal_sdio_t * |
obj, |
|
|
cyhal_gpio_t |
cmd, |
|
|
cyhal_gpio_t |
clk, |
|
|
cyhal_gpio_t |
data0, |
|
|
cyhal_gpio_t |
data1, |
|
|
cyhal_gpio_t |
data2, |
|
|
cyhal_gpio_t |
data3 |
|
) |
| |
Initialize the SDIO peripheral
- Parameters
-
| [out] | obj | The SDIO 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 |
- Returns
- The status of the init request
◆ cyhal_sdio_free()
Release the SDIO peripheral, not currently invoked. It requires further resource management.
- Parameters
-
| [in,out] | obj | The SDIO object |
◆ cyhal_sdio_configure()
Configure the SDIO block.
- Parameters
-
| [in,out] | obj | The SDIO object |
| [in] | config | The SDIO configuration to apply |
- Returns
- The status of the configure request
◆ cyhal_sdio_send_cmd()
Sends a command to the SDIO block.
- Parameters
-
| [in,out] | obj | The SDIO object |
| [in] | direction | The direction of transfer (read/write) |
| [in] | command | The SDIO command to send |
| [in] | argument | The argument to the command |
| [out] | response | The response from the SDIO device |
- Returns
- The status of the configure request
◆ cyhal_sdio_bulk_transfer()
Performs a bulk data transfer (CMD=53) to the SDIO block.
- Parameters
-
| [in,out] | obj | The SDIO object |
| [in] | direction | The direction of transfer (read/write) |
| [in] | argument | The argument to the command |
| [in] | data | The data to send to the SDIO device. The data buffer should be aligned to the block size (64 bytes) if data size is greater that block size (64 bytes). |
| [in] | length | The number of bytes to send |
| [out] | response | The response from the SDIO device |
- Returns
- The status of the configure request
◆ cyhal_sdio_transfer_async()
Performs a bulk asynchronus data transfer (CMD=53) to the SDIO block.
- Parameters
-
| [in,out] | obj | The SDIO object |
| [in] | direction | The direction of transfer (read/write) |
| [in] | argument | The argument to the command |
| [in] | data | The data to send to the SDIO device |
| [in] | length | The number of bytes to send |
- Returns
- The status of the configure request
◆ cyhal_sdio_is_busy()
Checks if the specified SDIO is in use
- Parameters
-
| [in] | obj | The SDIO peripheral to check |
- Returns
- Indication of whether the SDIO is still transmitting
◆ cyhal_sdio_abort_async()
Abort an SDIO transfer
- Parameters
-
| [in] | obj | The SDIO peripheral to stop |
- Returns
- The status of the abort_async request
◆ cyhal_sdio_register_callback()
The SDIO event callback registration
- Parameters
-
| [in] | obj | The SDIO object |
| [in] | callback | The callback function which will be invoked when the event triggers |
| [in] | callback_arg | Generic argument that will be provided to the callback when executed |
◆ cyhal_sdio_enable_event()
Configure which SDIO events trigger callbacks.
- Parameters
-
| [in] | obj | The SDIO object |
| [in] | event | The SDIO event type |
| [in] | intrPriority | The priority for NVIC interrupt events |
| [in] | enable | Set to true to enable events, or false to disable them |