Altera HWLIB  16.0
The Altera HW Manager API Reference Manual
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Groups
Card Interface

Description

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.

Data Structures

struct  ALT_SDMMC_CARD_MISC_s
 

Typedefs

typedef enum ALT_SDMMC_BUS_WIDTH_e ALT_SDMMC_BUS_WIDTH_t
 
typedef struct
ALT_SDMMC_CARD_MISC_s 
ALT_SDMMC_CARD_MISC_t
 

ENUMS

enum  ALT_SDMMC_BUS_WIDTH_e
 

Functions

ALT_STATUS_CODE alt_sdmmc_card_misc_get (ALT_SDMMC_CARD_MISC_t *card_misc_cfg)
 
ALT_STATUS_CODE alt_sdmmc_card_misc_set (const ALT_SDMMC_CARD_MISC_t *card_misc_cfg)
 
ALT_STATUS_CODE alt_sdmmc_card_bus_width_set (ALT_SDMMC_CARD_INFO_t *card_info, const ALT_SDMMC_BUS_WIDTH_t width)
 
ALT_STATUS_CODE alt_sdmmc_card_block_size_set (const uint16_t block_size)
 
ALT_STATUS_CODE alt_sdmmc_card_identify (ALT_SDMMC_CARD_INFO_t *card_info)
 
uint32_t alt_sdmmc_card_clk_div_get (void)
 
ALT_STATUS_CODE alt_sdmmc_card_clk_div_set (const uint32_t clk_div)
 
uint32_t alt_sdmmc_card_speed_get (void)
 
ALT_STATUS_CODE alt_sdmmc_card_speed_set (ALT_SDMMC_CARD_INFO_t *card_info, uint32_t xfer_speed)
 
ALT_STATUS_CODE alt_sdmmc_card_clk_disable (void)
 
ALT_STATUS_CODE alt_sdmmc_card_clk_enable (const bool use_low_pwr_mode)
 
bool alt_sdmmc_card_clk_is_enabled (void)
 
bool alt_sdmmc_card_clk_low_power_is_enabled (void)
 
ALT_STATUS_CODE alt_sdmmc_card_reset (void)
 
bool alt_sdmmc_card_is_detected (void)
 
bool alt_sdmmc_card_is_write_protected (void)
 
bool alt_sdmmc_card_pwr_is_on (void)
 
ALT_STATUS_CODE alt_sdmmc_card_pwr_on (void)
 
ALT_STATUS_CODE alt_sdmmc_card_pwr_off (void)
 

Data Structure Documentation

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.

Typedef Documentation

This type enumerates the SDMMC evailable bus width.

This type defines a structure for configuration of miscellaneous interface parameters for an attached card.

Enumeration Type Documentation

This type enumerates the SDMMC evailable bus width.

Function Documentation

ALT_STATUS_CODE alt_sdmmc_card_misc_get ( ALT_SDMMC_CARD_MISC_t card_misc_cfg)

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_SUCCESSSuccessful status.
ALT_E_ERRORDetails about error status code
ALT_STATUS_CODE alt_sdmmc_card_misc_set ( const ALT_SDMMC_CARD_MISC_t card_misc_cfg)

Set the specified card interface configuration for the miscellaneous set of parameters.

Parameters
card_misc_cfgPointer to a ALT_SDMMC_CARD_MISC_t structure holding the card interface parameters to configure.
Return values
ALT_E_SUCCESSSuccessful status.
ALT_E_ERRORDetails about error status code
ALT_STATUS_CODE alt_sdmmc_card_bus_width_set ( ALT_SDMMC_CARD_INFO_t card_info,
const ALT_SDMMC_BUS_WIDTH_t  width 
)

Set the bus width appropriate supported by the card, send this parameter to the card.

Parameters
card_infoA pointer to a ALT_SDMMC_CARD_INFO_t structure that holds identification and device property information for any detected card.
widthIndicates card interface width.
Return values
ALT_E_SUCCESSSuccessful status.
ALT_E_ERRORDetails 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_sizeThe card block size in bytes.
Return values
ALT_E_SUCCESSSuccessful status.
ALT_E_ERRORDetails about error status code
ALT_STATUS_CODE alt_sdmmc_card_identify ( ALT_SDMMC_CARD_INFO_t card_info)

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_SUCCESSSuccessful status.
ALT_E_ERRORDetails 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_divClock 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_SUCCESSThe operation was successful.
ALT_E_ERRORThe 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.
ALT_STATUS_CODE alt_sdmmc_card_speed_set ( ALT_SDMMC_CARD_INFO_t card_info,
uint32_t  xfer_speed 
)

Sets the card data transfer rate. The unit is compatible with ALT_SDMMC_CARD_INFO_t::tran_speed.

Parameters
card_infoA pointer to a ALT_SDMMC_CARD_INFO_t structure that holds identification and device property information for any detected card.
Desireddata transfer rate in bit/s.
Return values
ALT_E_SUCCESSThe operation was successful.
ALT_E_ERRORThe operation failed.
ALT_STATUS_CODE alt_sdmmc_card_clk_disable ( void  )

Disables the card clock (sdmmc_cclk_out).

Return values
ALT_E_SUCCESSThe operation was successful.
ALT_E_ERRORThe 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_modeIf 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_SUCCESSThe operation was successful.
ALT_E_ERRORThe 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
trueThe card clock is enabled.
falseThe 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
trueThe card clock low power mode is enabled.
falseThe card clock low power mode is not enabled.
ALT_STATUS_CODE alt_sdmmc_card_reset ( void  )

Reset the card device.

Return values
ALT_E_SUCCESSThe operation was successful.
ALT_E_ERRORThe operation failed.
bool alt_sdmmc_card_is_detected ( void  )

Returns true if a card presence is detected otherwise returns false.

Return values
trueA card is present.
falseA 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
trueCard is write protected.
falseCard 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
trueCard power is on (enabled).
falseCard 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_SUCCESSSuccessful status.
ALT_E_ERRORDetails 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_SUCCESSSuccessful status.
ALT_E_ERRORDetails about error status code