High level interface to the Secure Digital Host Controller (SDHC).
The SDHC driver allows data to be read from and written to an SD Card using the SDHC block. The data is transferred in blocks with a block size of 512 bytes.
Initialize SDHC by using cyhal_sdhc_init by selecting the pins according to the target device used. Specify the SDHC configuration using the configuration structure (const cyhal_sdhc_config_t * config).
See Snippet 1: SDHC Initialization and configuration
The following snippet is used to initialize the SDHC block. SDHC object - cyhal_sdhc_t, SDHC card configuration structure (const cyhal_sdhc_config_t * config). The pins connected to the SDHC block needs to be provided to the cyhal_sdhc_init function.
The following snippet reads a block of data from the SD Card.
The following snippet writes a block of data to the SD Card.
API Reference | |
SDHC HAL Results | |
SDHC specific return codes. | |
Data Structures | |
struct | cyhal_sdhc_config_t |
Defines configuration options for the SDHC block. More... | |
struct | cyhal_sdhc_data_config_t |
Defines data configuration. More... | |
struct | cyhal_sdhc_cmd_config_t |
Defines command configuration for cyhal_sdhc_send_cmd function. More... | |
Typedefs | |
typedef void(* | cyhal_sdhc_event_callback_t) (void *callback_arg, cyhal_sdhc_event_t event) |
Handler for SDHC interrupts. | |
Functions | |
cy_rslt_t | cyhal_sdhc_init_hw (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 card_detect, cyhal_gpio_t io_volt_sel, cyhal_gpio_t card_pwr_en, cyhal_gpio_t card_mech_write_prot, cyhal_gpio_t led_ctrl, cyhal_gpio_t emmc_reset, cyhal_clock_t *block_clk) |
Initialize SDHC driver and corresponding hardware. More... | |
cy_rslt_t | cyhal_sdhc_init_card (cyhal_sdhc_t *obj) |
Initialize the connected card. More... | |
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 card_detect, cyhal_gpio_t io_volt_sel, cyhal_gpio_t card_pwr_en, cyhal_gpio_t card_mech_write_prot, cyhal_gpio_t led_ctrl, cyhal_gpio_t emmc_reset, cyhal_clock_t *block_clk) |
Initialize the SDHC block and connected card. More... | |
void | cyhal_sdhc_free (cyhal_sdhc_t *obj) |
Release the SDHC peripheral, not currently invoked. More... | |
cy_rslt_t | cyhal_sdhc_read (cyhal_sdhc_t *obj, uint32_t address, uint8_t *data, size_t *length) |
Attempts to read data synchronously over the SDHC peripheral. More... | |
cy_rslt_t | cyhal_sdhc_write (cyhal_sdhc_t *obj, uint32_t address, const uint8_t *data, size_t *length) |
Attempts to write data synchronously over SDHC peripheral. More... | |
cy_rslt_t | cyhal_sdhc_erase (cyhal_sdhc_t *obj, uint32_t start_addr, size_t length, uint32_t timeout_ms) |
Erases a block of data over the SDHC peripheral. More... | |
cy_rslt_t | cyhal_sdhc_read_async (cyhal_sdhc_t *obj, uint32_t address, uint8_t *data, size_t *length) |
Start SDHC asynchronous read. More... | |
cy_rslt_t | cyhal_sdhc_write_async (cyhal_sdhc_t *obj, uint32_t address, const uint8_t *data, size_t *length) |
Start asynchronous SDHC write. More... | |
bool | cyhal_sdhc_is_busy (const cyhal_sdhc_t *obj) |
Checks if the specified SDHC peripheral is in use. More... | |
cy_rslt_t | cyhal_sdhc_abort_async (cyhal_sdhc_t *obj) |
Abort an SDHC transfer. More... | |
void | cyhal_sdhc_register_callback (cyhal_sdhc_t *obj, cyhal_sdhc_event_callback_t callback, void *callback_arg) |
Register an SDHC callback handler. More... | |
void | cyhal_sdhc_enable_event (cyhal_sdhc_t *obj, cyhal_sdhc_event_t event, uint8_t intr_priority, bool enable) |
Configure SDHC event enablement. More... | |
bool | cyhal_sdhc_is_card_inserted (const cyhal_sdhc_t *obj) |
Checks if SD card is inserted. More... | |
bool | cyhal_sdhc_is_card_mech_write_protected (const cyhal_sdhc_t *obj) |
Checks if the inserted SD card is mechanically write protected. More... | |
cy_rslt_t | cyhal_sdhc_get_block_count (cyhal_sdhc_t *obj, uint32_t *block_count) |
Get block count of inserted SD card / eMMC. More... | |
cy_rslt_t | cyhal_sdhc_set_frequency (cyhal_sdhc_t *obj, uint32_t hz, bool negotiate) |
Sets the SD bus frequency (frequency on which SD card / eMMC is accessed) More... | |
uint32_t | cyhal_sdhc_get_frequency (cyhal_sdhc_t *obj) |
Get the actual frequency that SD bus is configured for. More... | |
cy_rslt_t | cyhal_sdhc_set_data_read_timeout (cyhal_sdhc_t *obj, uint32_t timeout, bool auto_reconfigure) |
Sets the maximum time to wait for data from the card. More... | |
cy_rslt_t | cyhal_sdhc_config_data_transfer (cyhal_sdhc_t *obj, cyhal_sdhc_data_config_t *data_config) |
Initializes the SD block and DMA for a data transfer. More... | |
cy_rslt_t | cyhal_sdhc_send_cmd (cyhal_sdhc_t *obj, cyhal_sdhc_cmd_config_t *cmd_config) |
Sends a command to the card and wait until it is sent. More... | |
cy_rslt_t | cyhal_sdhc_get_response (cyhal_sdhc_t *obj, uint32_t *response, bool large_response) |
Returns a response of last issued by cyhal_sdhc_send_cmd function command. More... | |
cy_rslt_t | cyhal_sdhc_wait_transfer_complete (cyhal_sdhc_t *obj) |
Wait for asynchronous data transfer to complete. More... | |
cy_rslt_t | cyhal_sdhc_set_io_voltage (cyhal_sdhc_t *obj, cyhal_sdhc_io_voltage_t io_voltage, cyhal_sdhc_io_volt_action_type_t io_switch_type) |
Sets the voltage level of the I/O lines. More... | |
cyhal_sdhc_io_voltage_t | cyhal_sdhc_get_io_voltage (cyhal_sdhc_t *obj) |
Returns the current voltage level of the I/O lines. More... | |
cy_rslt_t | cyhal_sdhc_set_bus_width (cyhal_sdhc_t *obj, uint8_t bus_width, bool configure_card) |
Configures data bus width on host side and (optionally) informs the card about new width configuration. More... | |
uint8_t | cyhal_sdhc_get_bus_width (cyhal_sdhc_t *obj) |
Returns currently configured data bus width. More... | |
cyhal_sdhc_error_type_t | cyhal_sdhc_get_last_command_errors (cyhal_sdhc_t *obj) |
Returns last issued SD operation error states. More... | |
void | cyhal_sdhc_clear_errors (cyhal_sdhc_t *obj) |
Clears SDHC hardware error states. More... | |
void | cyhal_sdhc_software_reset (cyhal_sdhc_t *obj) |
Resets CMD and Data lines and corresponding circuits of SD Host. More... | |
cy_rslt_t | cyhal_sdhc_enable_card_power (cyhal_sdhc_t *obj, bool enable) |
Powers up / down the card based on provided parameter. More... | |
cy_rslt_t | cyhal_sdhc_init_cfg (cyhal_sdhc_t *obj, const cyhal_sdhc_configurator_t *cfg) |
Initialize the SDHC peripheral using a configurator generated configuration struct. More... | |
struct cyhal_sdhc_config_t |
struct cyhal_sdhc_data_config_t |
Data Fields | ||
---|---|---|
uint32_t * | data_ptr | The pointer to data for send/receive. Data will be transfered using DMA, which will be configured automaticaly by SDHC HAL driver. |
uint32_t | block_size | The size of the data block. |
uint32_t | number_of_blocks | The number of blocks with size block_size to send. |
cyhal_sdhc_auto_cmd_t | auto_command | Selects which auto commands are used if any. |
bool | is_read | true = Read from the card, false = Write to the card. |
struct cyhal_sdhc_cmd_config_t |
Data Fields | ||
---|---|---|
uint32_t | command_index | The index of the command. |
uint32_t | command_argument | The argument for the command. |
bool | enable_crc_check | Enables the CRC check on the response. |
cyhal_sdhc_cmd_response_type_t | response_type | The response type. |
bool | enable_idx_check | Checks the index of the response. |
cyhal_sdhc_cmd_type_t | command_type | The command type. |
cyhal_sdhc_data_config_t * | data_config | Data transfer configuration, defined in cyhal_sdhc_data_config_t. Should be NULL if data transfer is not expected for provided command. |
enum cyhal_sdhc_event_t |
SDHC interrupt triggers.
SDHC I/O voltage select principle.
SDHC command error states.
cy_rslt_t cyhal_sdhc_init_hw | ( | 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 | card_detect, | ||
cyhal_gpio_t | io_volt_sel, | ||
cyhal_gpio_t | card_pwr_en, | ||
cyhal_gpio_t | card_mech_write_prot, | ||
cyhal_gpio_t | led_ctrl, | ||
cyhal_gpio_t | emmc_reset, | ||
cyhal_clock_t * | block_clk | ||
) |
Initialize SDHC driver and corresponding hardware.
[out] | obj | Pointer to an SDHC object. The caller must allocate the memory for this object but the init function will initialize its contents. |
[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. This pin can be NC if bus width is 1-bit. |
[in] | data2 | The pin connected to the data2 signal. This pin can be NC if bus width is 1-bit. |
[in] | data3 | The pin connected to the data3 signal. This pin can be NC if bus width is 1-bit. |
[in] | data4 | The pin connected to the data4 signal. This pin can be NC if bus width is less than 8-bit. |
[in] | data5 | The pin connected to the data5 signal. This pin can be NC if bus width is less than 8-bit. |
[in] | data6 | The pin connected to the data6 signal. This pin can be NC if bus width is less than 8-bit. |
[in] | data7 | The pin connected to the data7 signal. This pin can be NC if bus width is less than 8-bit. |
[in] | card_detect | The pin connected to the card_detect signal Card is considered as inserted if card_detect pin in low state. This pin can be NC. |
[out] | io_volt_sel | The pin connected to the io_volt_sel signal. This pin 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 MCU. This regulator allows for switching between the 3.3V and 1.8V signaling. High level on the pin stands for 1.8V signaling, while low - for 3.3V. This pin can be NC. |
[out] | card_pwr_en | The pin connected to the card_pwr_en signal This pin can be used to enable a voltage regulator used to power the card. High level on the pin - card is powered. Low - card is not powered. This pin can be NC. |
[in] | card_mech_write_prot | The pin connected to the card_mech_write_prot signal This pin is used for card mechanical write protect checking. If pin in high state - card is mechanically write protected, if in low state - card is not mechanically write protected. cyhal_sdhc_is_card_mech_write_protected function can be used to check card write protection state. This pin can be NC. |
[in] | led_ctrl | The pin connected to the led_ctrl signal. This pin can be NC. |
[in] | emmc_reset | The pin connected to the emmc_reset signal. This pin can be NC. |
[in] | block_clk | The clock to use can be shared, if not provided a new clock will be allocated |
cy_rslt_t cyhal_sdhc_init_card | ( | cyhal_sdhc_t * | obj | ) |
Initialize the connected card.
[in,out] | obj | The SDHC object |
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 | card_detect, | ||
cyhal_gpio_t | io_volt_sel, | ||
cyhal_gpio_t | card_pwr_en, | ||
cyhal_gpio_t | card_mech_write_prot, | ||
cyhal_gpio_t | led_ctrl, | ||
cyhal_gpio_t | emmc_reset, | ||
cyhal_clock_t * | block_clk | ||
) |
Initialize the SDHC block and connected card.
This function is a combination of cyhal_sdhc_init_hw and cyhal_sdhc_init_card calls.
[out] | obj | Pointer to an SDHC object. The caller must allocate the memory for this object but the init function will initialize its contents. |
[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. This pin can be NC if bus width is 1-bit. |
[in] | data2 | The pin connected to the data2 signal. This pin can be NC if bus width is 1-bit. |
[in] | data3 | The pin connected to the data3 signal. This pin can be NC if bus width is 1-bit. |
[in] | data4 | The pin connected to the data4 signal. This pin can be NC if bus width is less than 8-bit. |
[in] | data5 | The pin connected to the data5 signal. This pin can be NC if bus width is less than 8-bit. |
[in] | data6 | The pin connected to the data6 signal. This pin can be NC if bus width is less than 8-bit. |
[in] | data7 | The pin connected to the data7 signal. This pin can be NC if bus width is less than 8-bit. |
[in] | card_detect | The pin connected to the card_detect signal |
[out] | io_volt_sel | The pin connected to the io_volt_sel signal |
[out] | card_pwr_en | The pin connected to the card_pwr_en signal |
[in] | card_mech_write_prot | The pin connected to the card_mech_write_prot signal |
[in] | led_ctrl | The pin connected to the led_ctrl signal |
[in] | emmc_reset | The pin connected to the emmc_reset signal |
[in] | block_clk | The clock to use can be shared, if not provided a new clock will be allocated |
void cyhal_sdhc_free | ( | cyhal_sdhc_t * | obj | ) |
Release the SDHC peripheral, not currently invoked.
It requires further resource management.
[in,out] | obj | The SDHC object |
cy_rslt_t cyhal_sdhc_read | ( | cyhal_sdhc_t * | obj, |
uint32_t | address, | ||
uint8_t * | data, | ||
size_t * | length | ||
) |
Attempts to read data synchronously over the SDHC peripheral.
This will read as many blocks as possible, up to length
blocks, into the buffer pointed to by data
, then return. The value pointed to by length
will be updated to reflect the number of words that were actually read.
See Snippet 2: Reading a block of data from an SD Card
[in] | obj | The SDHC object |
[in] | address | The address to read data from |
[out] | data | Pointer to the byte-array where data read from the device should be stored |
[in,out] | length | Number of 512 byte blocks to read, updated with the number actually read |
cy_rslt_t cyhal_sdhc_write | ( | cyhal_sdhc_t * | obj, |
uint32_t | address, | ||
const uint8_t * | data, | ||
size_t * | length | ||
) |
Attempts to write data synchronously over SDHC peripheral.
This will write as many blocks as possible, up to length
blocks, then return. The value pointed to by length
will be updated to reflect the number of words that were actually read.
See Snippet 3: Writing a block of data to an SD Card
[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 |
cy_rslt_t cyhal_sdhc_erase | ( | cyhal_sdhc_t * | obj, |
uint32_t | start_addr, | ||
size_t | length, | ||
uint32_t | timeout_ms | ||
) |
Erases a block of data over the SDHC peripheral.
[in] | obj | The SDHC object |
[in] | start_addr | Is the address of the first byte to erase |
[in] | length | Number of 512 byte blocks (starting at start_addr) to erase |
[in] | timeout_ms | Timeout value in ms for waiting/polling operations. If zero is provided for this parameter the default value will be used. See implementation specific documentation for timeout details. |
cy_rslt_t cyhal_sdhc_read_async | ( | cyhal_sdhc_t * | obj, |
uint32_t | address, | ||
uint8_t * | data, | ||
size_t * | length | ||
) |
Start SDHC asynchronous read.
This will transfer length
512 byte blocks into the buffer pointed to by data
in the background. When the requested quantity of data has been read, the CYHAL_SDHC_XFER_COMPLETE event will be raised. See cyhal_sdhc_register_callback and cyhal_sdhc_enable_event.
[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 |
cy_rslt_t cyhal_sdhc_write_async | ( | cyhal_sdhc_t * | obj, |
uint32_t | address, | ||
const uint8_t * | data, | ||
size_t * | length | ||
) |
Start asynchronous SDHC write.
This will transfer length
512 byte blocks from the buffer pointed to by data
in the background. When the requested quantity of data has been written, the CYHAL_SDHC_XFER_COMPLETE event will be raised. See cyhal_sdhc_register_callback and cyhal_sdhc_enable_event.
[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 |
bool cyhal_sdhc_is_busy | ( | const cyhal_sdhc_t * | obj | ) |
Checks if the specified SDHC peripheral is in use.
[in] | obj | The SDHC peripheral to check |
cy_rslt_t cyhal_sdhc_abort_async | ( | cyhal_sdhc_t * | obj | ) |
Abort an SDHC transfer.
[in] | obj | The SDHC peripheral to stop |
void cyhal_sdhc_register_callback | ( | cyhal_sdhc_t * | obj, |
cyhal_sdhc_event_callback_t | callback, | ||
void * | callback_arg | ||
) |
Register an SDHC callback handler.
This function will be called when one of the events enabled by cyhal_sdhc_enable_event occurs.
[in] | obj | The SDHC object |
[in] | callback | The callback handler which will be invoked when the event fires |
[in] | callback_arg | Generic argument that will be provided to the callback when called |
void cyhal_sdhc_enable_event | ( | cyhal_sdhc_t * | obj, |
cyhal_sdhc_event_t | event, | ||
uint8_t | intr_priority, | ||
bool | enable | ||
) |
Configure SDHC event enablement.
When an enabled event occurs, the function specified by cyhal_sdhc_register_callback will be called.
[in] | obj | The SDHC object |
[in] | event | The SDHC event type |
[in] | intr_priority | The priority for NVIC interrupt events |
[in] | enable | True to turn on interrupts, False to turn off |
bool cyhal_sdhc_is_card_inserted | ( | const cyhal_sdhc_t * | obj | ) |
Checks if SD card is inserted.
[in] | obj | The SDHC peripheral to check |
bool cyhal_sdhc_is_card_mech_write_protected | ( | const cyhal_sdhc_t * | obj | ) |
Checks if the inserted SD card is mechanically write protected.
[in] | obj | The SDHC peripheral to check |
cy_rslt_t cyhal_sdhc_get_block_count | ( | cyhal_sdhc_t * | obj, |
uint32_t * | block_count | ||
) |
Get block count of inserted SD card / eMMC.
[in] | obj | The SDHC object |
[in] | block_count | Pointer to variable where block count will be stored |
cy_rslt_t cyhal_sdhc_set_frequency | ( | cyhal_sdhc_t * | obj, |
uint32_t | hz, | ||
bool | negotiate | ||
) |
Sets the SD bus frequency (frequency on which SD card / eMMC is accessed)
[in] | obj | The SDHC object |
[in] | hz | Desired SD bus frequency in Hz |
[in] | negotiate | Whether new frequency value needs to be negotiated with card or not. true is recommended and it means that new frequency will be negotiated. |
uint32_t cyhal_sdhc_get_frequency | ( | cyhal_sdhc_t * | obj | ) |
Get the actual frequency that SD bus is configured for.
[in] | obj | The SDHC object |
cy_rslt_t cyhal_sdhc_set_data_read_timeout | ( | cyhal_sdhc_t * | obj, |
uint32_t | timeout, | ||
bool | auto_reconfigure | ||
) |
Sets the maximum time to wait for data from the card.
The time is specified in number of card clock cycles. With SD bus frequency changed by cyhal_sdhc_set_frequency, timeout can automaticaly be recalculated according to new clock frequency. This can be activated by 'auto_reconfigure' parameter.
[in] | obj | The SDHC object |
[in] | timeout | Time to wait for data from the card. |
[in] | auto_reconfigure | Timeout value will be automaticaly reconfigured upon clock change |
cy_rslt_t cyhal_sdhc_config_data_transfer | ( | cyhal_sdhc_t * | obj, |
cyhal_sdhc_data_config_t * | data_config | ||
) |
Initializes the SD block and DMA for a data transfer.
It does not start a transfer. cyhal_sdhc_send_cmd needs to be called after this function in order to start data transfer.
[in] | obj | The SDHC object |
[in] | data_config | Data transfer configuration |
cy_rslt_t cyhal_sdhc_send_cmd | ( | cyhal_sdhc_t * | obj, |
cyhal_sdhc_cmd_config_t * | cmd_config | ||
) |
Sends a command to the card and wait until it is sent.
If the command assumes data transfer via data lines, cyhal_sdhc_config_data_transfer function needs to be called prior to this one. The response of issued command can be retrieved by using cyhal_sdhc_get_response function.
[in] | obj | The SDHC object |
[in] | cmd_config | Command configuration |
cy_rslt_t cyhal_sdhc_get_response | ( | cyhal_sdhc_t * | obj, |
uint32_t * | response, | ||
bool | large_response | ||
) |
Returns a response of last issued by cyhal_sdhc_send_cmd function command.
[in] | obj | The SDHC object |
[in] | response | Pointer to array where response will be stored |
[in] | large_response | If true, the expected response is 136 bits, false - 48 bits, which corresponds to 120 and 32 bits of useful for application data respectively. So for large_response 4 uint32_t element array can be used while for not large_response 1 uint32_t value will be enough. |
cy_rslt_t cyhal_sdhc_wait_transfer_complete | ( | cyhal_sdhc_t * | obj | ) |
Wait for asynchronous data transfer to complete.
Such data transfer can be triggered by cyhal_sdhc_write_async, cyhal_sdhc_read_async or by cyhal_sdhc_config_data_transfer + cyhal_sdhc_send_cmd functions.
[in] | obj | The SDHC object |
cy_rslt_t cyhal_sdhc_set_io_voltage | ( | cyhal_sdhc_t * | obj, |
cyhal_sdhc_io_voltage_t | io_voltage, | ||
cyhal_sdhc_io_volt_action_type_t | io_switch_type | ||
) |
Sets the voltage level of the I/O lines.
[in] | obj | The SDHC object |
[in] | io_voltage | I/O voltage to be set on lines |
[in] | io_switch_type | Defines how I/O voltage will be switched |
cyhal_sdhc_io_voltage_t cyhal_sdhc_get_io_voltage | ( | cyhal_sdhc_t * | obj | ) |
Returns the current voltage level of the I/O lines.
[in] | obj | The SDHC object |
cy_rslt_t cyhal_sdhc_set_bus_width | ( | cyhal_sdhc_t * | obj, |
uint8_t | bus_width, | ||
bool | configure_card | ||
) |
Configures data bus width on host side and (optionally) informs the card about new width configuration.
[in] | obj | The SDHC object |
[in] | bus_width | The desired bus width, 1-bit, 4-bit, 8-bit |
[in] | configure_card | Whether card needs to be configured with new bus width. true is recommended. |
uint8_t cyhal_sdhc_get_bus_width | ( | cyhal_sdhc_t * | obj | ) |
Returns currently configured data bus width.
[in] | obj | The SDHC object |
cyhal_sdhc_error_type_t cyhal_sdhc_get_last_command_errors | ( | cyhal_sdhc_t * | obj | ) |
Returns last issued SD operation error states.
This function can be used for error checking after any of cmd / data transfer-related operations. For list of possible errors, that are being tracked, please refer to cyhal_sdhc_error_type_t.
[in] | obj | The SDHC object |
void cyhal_sdhc_clear_errors | ( | cyhal_sdhc_t * | obj | ) |
Clears SDHC hardware error states.
Error statuses are indicated by cyhal_sdhc_get_last_command_errors function.
[in] | obj | The SDHC object |
void cyhal_sdhc_software_reset | ( | cyhal_sdhc_t * | obj | ) |
Resets CMD and Data lines and corresponding circuits of SD Host.
[in] | obj | The SDHC object |
cy_rslt_t cyhal_sdhc_enable_card_power | ( | cyhal_sdhc_t * | obj, |
bool | enable | ||
) |
Powers up / down the card based on provided parameter.
This function uses card_pwr_en pin to change card power state. Please refer to cyhal_sdhc_init_hw for pin description.
[in] | obj | The SDHC peripheral to configure |
[in] | enable | Card is powered if true, not powered if false. |
cy_rslt_t cyhal_sdhc_init_cfg | ( | cyhal_sdhc_t * | obj, |
const cyhal_sdhc_configurator_t * | cfg | ||
) |
Initialize the SDHC peripheral using a configurator generated configuration struct.
[in] | obj | The SDHC peripheral to configure |
[in] | cfg | Configuration structure generated by a configurator. |