SDIO. Clock detection procedure for SDC now uses stack allocated buffer instead of provided in config.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@7701 35acf78f-673a-0410-8e92-d51de3d6d3f4
This commit is contained in:
parent
c3cfdc2746
commit
3f403d2288
|
@ -222,7 +222,7 @@ typedef struct {
|
||||||
* @brief Working area for memory consuming operations.
|
* @brief Working area for memory consuming operations.
|
||||||
* @note Buffer must be word aligned and big enough to store 512 bytes.
|
* @note Buffer must be word aligned and big enough to store 512 bytes.
|
||||||
* @note It is mandatory for detecting MMC cards bigger than 2GB else it
|
* @note It is mandatory for detecting MMC cards bigger than 2GB else it
|
||||||
* can be @p NULL.
|
* can be @p NULL. SD cards do NOT need it.
|
||||||
* @note Memory pointed by this buffer is only used by @p sdcConnect(),
|
* @note Memory pointed by this buffer is only used by @p sdcConnect(),
|
||||||
* afterward it can be reused for other purposes.
|
* afterward it can be reused for other purposes.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -303,24 +303,26 @@ static bool sdc_cmd6_check_status(sd_switch_function_t function,
|
||||||
* @notapi
|
* @notapi
|
||||||
*/
|
*/
|
||||||
static bool sdc_detect_bus_clk(SDCDriver *sdcp, sdcbusclk_t *clk) {
|
static bool sdc_detect_bus_clk(SDCDriver *sdcp, sdcbusclk_t *clk) {
|
||||||
uint32_t cmdarg = 0;
|
uint32_t cmdarg;
|
||||||
uint8_t *scratchpad = sdcp->config->scratchpad;
|
const size_t N = 64;
|
||||||
|
uint8_t tmp[N];
|
||||||
|
|
||||||
/* Safe default.*/
|
/* Safe default.*/
|
||||||
*clk = SDC_CLK_25MHz;
|
*clk = SDC_CLK_25MHz;
|
||||||
|
|
||||||
/* Use safe default when there is no space for data.*/
|
/* Read switch functions' register.*/
|
||||||
if (NULL == scratchpad)
|
if (sdc_lld_read_special(sdcp, tmp, N, MMCSD_CMD_SWITCH, 0))
|
||||||
return HAL_SUCCESS;
|
|
||||||
|
|
||||||
if (sdc_lld_read_special(sdcp, scratchpad, 64, MMCSD_CMD_SWITCH, cmdarg))
|
|
||||||
return HAL_FAILED;
|
return HAL_FAILED;
|
||||||
|
|
||||||
if ((sdc_cmd6_extract_info(SD_SWITCH_FUNCTION_SPEED, scratchpad) & 2) == 2) {
|
/* Check card capabilities parsing acquired data.*/
|
||||||
|
if ((sdc_cmd6_extract_info(SD_SWITCH_FUNCTION_SPEED, tmp) & 2) == 2) {
|
||||||
|
/* Construct command to set the bus speed.*/
|
||||||
cmdarg = sdc_cmd6_construct(SD_SWITCH_SET, SD_SWITCH_FUNCTION_SPEED, 1);
|
cmdarg = sdc_cmd6_construct(SD_SWITCH_SET, SD_SWITCH_FUNCTION_SPEED, 1);
|
||||||
if (sdc_lld_read_special(sdcp, scratchpad, 64, MMCSD_CMD_SWITCH, cmdarg))
|
/* Write constructed command and read operation status in single call.*/
|
||||||
|
if (sdc_lld_read_special(sdcp, tmp, N, MMCSD_CMD_SWITCH, cmdarg))
|
||||||
return HAL_FAILED;
|
return HAL_FAILED;
|
||||||
if (HAL_SUCCESS == sdc_cmd6_check_status(SD_SWITCH_FUNCTION_SPEED, scratchpad))
|
/* Check card answer for success status bits.*/
|
||||||
|
if (HAL_SUCCESS == sdc_cmd6_check_status(SD_SWITCH_FUNCTION_SPEED, tmp))
|
||||||
*clk = SDC_CLK_50MHz;
|
*clk = SDC_CLK_50MHz;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue