The clock control block provides different clock frequencies required for SD/MMC/CE-ATA cards. The clock control block has one clock divider, which is used to generate different card clock frequencies.
The clock divider is used to generate different clock frequencies required for the cards. The division factor for the clock divider can be set by calling the alt_sdmmc_card_clk_div_set() function. The clock divider is an 8-bit value that provides a clock division factor from 1 to 510; a value of 0 represents a clock-divider bypass, a value of 1 represents a divide by 2, a value of 2 represents a divide by 4, and so on.
struct ALT_SDMMC_CARD_MISC_s |
This type defines a structure for configuration of miscellaneous interface parameters for an attached card.
Data Fields |
uint32_t |
response_timeout |
Card response timeout period in sdmmc_cclk_out (SD/MMC card clock) ticks. |
uint32_t |
data_timeout |
Card data read timeout period in sdmmc_cclk_out (SD/MMC card clock) ticks. |
ALT_SDMMC_BUS_WIDTH_t |
card_width |
Indicates card interface width (1, 4, or 8 bits). |
uint32_t |
block_size |
The card block size in bytes. |
uint32_t |
debounce_count |
Number of host clock (l4_mp_clk) ticks used to debounce card interface signals. |
This type enumerates the SDMMC evailable bus width.
This type defines a structure for configuration of miscellaneous interface parameters for an attached card.
This type enumerates the SDMMC evailable bus width.
Get the current card interface configuration values for the miscellaneous set of parameters.
- Parameters
-
card_misc_cfg | [out] Pointer to a ALT_SDMMC_CARD_MISC_t structure to hold the returned card interface parameters. |
- Return values
-
ALT_E_SUCCESS | Successful status. |
ALT_E_ERROR | Details about error status code |
Set the specified card interface configuration for the miscellaneous set of parameters.
- Parameters
-
card_misc_cfg | Pointer to a ALT_SDMMC_CARD_MISC_t structure holding the card interface parameters to configure. |
- Return values
-
ALT_E_SUCCESS | Successful status. |
ALT_E_ERROR | Details about error status code |
Set the bus width appropriate supported by the card, send this parameter to the card.
- Parameters
-
card_info | A pointer to a ALT_SDMMC_CARD_INFO_t structure that holds identification and device property information for any detected card. |
width | Indicates card interface width. |
- Return values
-
ALT_E_SUCCESS | Successful status. |
ALT_E_ERROR | Details about error status code |
ALT_STATUS_CODE alt_sdmmc_card_block_size_set |
( |
const uint16_t |
block_size | ) |
|
Send block size to the card.
- Parameters
-
block_size | The card block size in bytes. |
- Return values
-
ALT_E_SUCCESS | Successful status. |
ALT_E_ERROR | Details about error status code |
Detects and identifies any connected card.
Detects any connected card (only one connected card is possible in this implementation) and returns the device identity and properties.
- Parameters
-
card_info | [out] A pointer to a ALT_SDMMC_CARD_INFO_t structure that holds identification and device property information for any detected card. |
- Return values
-
ALT_E_SUCCESS | Successful status. |
ALT_E_ERROR | Details about error status code |
uint32_t alt_sdmmc_card_clk_div_get |
( |
void |
| ) |
|
Gets the configured card clock divider value (sdmmc_cclk_out).
Returns the card clock divider value. Clock division is a 2 * n value. For example, a value of 0 means divide by 2 * 0 = 0 (no division, effectively a bypass), a value of 1 means divide by 2 * 1 = 2, value of 0xff means divide by 2
- 255 = 510. Valid range is 0 to 255.
- Returns
- The clock divider value.
ALT_STATUS_CODE alt_sdmmc_card_clk_div_set |
( |
const uint32_t |
clk_div | ) |
|
Sets the card clock divider configuration (sdmmc_cclk_out).
- Parameters
-
clk_div | Clock divider value. Clock division is 2 * n. For example, a value of 0 means divide by 2 * 0 = 0 (no division, effectively a bypass), a value of 1 means divide by 2 * 1 = 2, value of 0xff means divide by 2 * 255 = 510. Valid range is 0 to 255. |
- Return values
-
ALT_E_SUCCESS | The operation was successful. |
ALT_E_ERROR | The operation failed. |
uint32_t alt_sdmmc_card_speed_get |
( |
void |
| ) |
|
Gets the configured card data transfer rate in bit/s. The units is compatible with ALT_SDMMC_CARD_INFO_t::tran_speed.
- Returns
- The data transfer rate in bit/s.
Sets the card data transfer rate. The unit is compatible with ALT_SDMMC_CARD_INFO_t::tran_speed.
- Parameters
-
card_info | A pointer to a ALT_SDMMC_CARD_INFO_t structure that holds identification and device property information for any detected card. |
Desired | data transfer rate in bit/s. |
- Return values
-
ALT_E_SUCCESS | The operation was successful. |
ALT_E_ERROR | The operation failed. |
ALT_STATUS_CODE alt_sdmmc_card_clk_disable |
( |
void |
| ) |
|
Disables the card clock (sdmmc_cclk_out).
- Return values
-
ALT_E_SUCCESS | The operation was successful. |
ALT_E_ERROR | The operation failed. |
ALT_STATUS_CODE alt_sdmmc_card_clk_enable |
( |
const bool |
use_low_pwr_mode | ) |
|
Enables the card clock (sdmmc_cclk_out).
- Parameters
-
use_low_pwr_mode | If true then low-power mode is enabled to save card power, the sdmmc_cclk_out signal is disabled when the card is idle for at least eight card clock cycles. Low-power mode is enabled when a new command is loaded and the command path goes to a non-idle state. |
- Return values
-
ALT_E_SUCCESS | The operation was successful. |
ALT_E_ERROR | The operation failed. |
bool alt_sdmmc_card_clk_is_enabled |
( |
void |
| ) |
|
Returns true if the card clock (sdmmc_cclk_out) is enabled otherwise returns false.
- Return values
-
true | The card clock is enabled. |
false | The card clock is not enabled. |
bool alt_sdmmc_card_clk_low_power_is_enabled |
( |
void |
| ) |
|
Returns true if the card clk low power mode (sdmmc_cclk_low_power) is enabled otherwise returns false.
- Return values
-
true | The card clock low power mode is enabled. |
false | The card clock low power mode is not enabled. |
ALT_STATUS_CODE alt_sdmmc_card_reset |
( |
void |
| ) |
|
Reset the card device.
- Return values
-
ALT_E_SUCCESS | The operation was successful. |
ALT_E_ERROR | The operation failed. |
bool alt_sdmmc_card_is_detected |
( |
void |
| ) |
|
Returns true if a card presence is detected otherwise returns false.
- Return values
-
true | A card is present. |
false | A card is not present. |
bool alt_sdmmc_card_is_write_protected |
( |
void |
| ) |
|
Returns true if card write protection is enabled otherwise returns false.
- Return values
-
true | Card is write protected. |
false | Card is not write protected. |
bool alt_sdmmc_card_pwr_is_on |
( |
void |
| ) |
|
Returns true if power is on (enabled) to the card otherwise returns false.
- Return values
-
true | Card power is on (enabled). |
false | Card power is off (disabled). |
ALT_STATUS_CODE alt_sdmmc_card_pwr_on |
( |
void |
| ) |
|
Enable (turn on) power to the card device.
This function enables power to the card device allowing for power ramp-up time before returning.
- Return values
-
ALT_E_SUCCESS | Successful status. |
ALT_E_ERROR | Details about error status code |
ALT_STATUS_CODE alt_sdmmc_card_pwr_off |
( |
void |
| ) |
|
Disable (turn off) power to the card device.
This function disables power to the card device.
- Return values
-
ALT_E_SUCCESS | Successful status. |
ALT_E_ERROR | Details about error status code |