Reverted one of the previous changes in SDMMCv2, added slowdown setting.

git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@16134 27425a3e-05d8-49a3-a47f-9c15f0e5edd8
This commit is contained in:
Giovanni Di Sirio 2023-03-06 08:54:42 +00:00
parent 1905b25683
commit 2b5d72890d
4 changed files with 23 additions and 20 deletions

View File

@ -159,13 +159,13 @@
<storageModule moduleId="org.eclipse.cdt.make.core.buildtargets"/>
<storageModule moduleId="scannerConfiguration">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
<scannerConfigBuildInfo instanceId="0.365230168.523175374.1281863608">
<scannerConfigBuildInfo instanceId="0.365230168">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile"/>
</scannerConfigBuildInfo>
<scannerConfigBuildInfo instanceId="0.365230168.523175374.18049993">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile"/>
</scannerConfigBuildInfo>
<scannerConfigBuildInfo instanceId="0.365230168">
<scannerConfigBuildInfo instanceId="0.365230168.523175374.1281863608">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile"/>
</scannerConfigBuildInfo>
<scannerConfigBuildInfo instanceId="0.365230168.523175374">

View File

@ -792,7 +792,7 @@ bool sdc_lld_read_aligned(SDCDriver *sdcp, uint32_t startblk,
if (_sdc_wait_for_transfer_state(sdcp))
return HAL_FAILED;
/* Prepares the DMA channel for writing.*/
/* Prepares the DMA channel for reading.*/
dmaStreamSetMemory0(sdcp->dma, buf);
dmaStreamSetTransactionSize(sdcp->dma,
(blocks * MMCSD_BLOCK_SIZE) / sizeof (uint32_t));

View File

@ -67,7 +67,8 @@ SDCDriver SDCD2;
* @brief SDIO default configuration.
*/
static const SDCConfig sdc_default_cfg = {
SDC_MODE_4BIT
SDC_MODE_4BIT,
0U
};
#if STM32_SDC_USE_SDMMC1 || defined(__DOXYGEN__)
@ -102,10 +103,10 @@ static uint32_t sdc_lld_clkdiv(SDCDriver *sdcp, uint32_t f) {
#endif
if (f >= sdcp->clkfreq) {
return 0;
return sdcp->config->slowdown;
}
return (sdcp->clkfreq + (f * 2) - 1) / (f * 2);
return sdcp->config->slowdown + ((sdcp->clkfreq + (f * 2) - 1) / (f * 2));
}
/**
@ -247,17 +248,13 @@ static bool sdc_lld_prepare_write(SDCDriver *sdcp, uint32_t startblk,
static bool sdc_lld_wait_transaction_end(SDCDriver *sdcp, uint32_t n,
uint32_t *resp) {
// /* Note the mask is checked before going to sleep because the interrupt
// may have occurred before reaching the critical zone.*/
/* Note the mask is checked before going to sleep because the interrupt
may have occurred before reaching the critical zone.*/
osalSysLock();
/* Starting the DMA operation.*/
sdcp->sdmmc->IDMACTRL = SDMMC_IDMA_IDMAEN;
sdcp->sdmmc->DCTRL |= SDMMC_DCTRL_DTEN;
// if (sdcp->sdmmc->MASK != 0U) {
(void) osalThreadSuspendS(&sdcp->thread);
// }
if (sdcp->sdmmc->MASK != 0U) {
(void) osalThreadSuspendS(&sdcp->thread);
}
/* Stopping operations.*/
sdcp->sdmmc->IDMACTRL = 0U;
@ -270,7 +267,7 @@ static bool sdc_lld_wait_transaction_end(SDCDriver *sdcp, uint32_t n,
}
/* Clearing status.*/
sdcp->sdmmc->ICR = SDMMC_ICR_ALL_FLAGS;
sdcp->sdmmc->ICR = SDMMC_ICR_ALL_FLAGS;
osalSysUnlock();
@ -323,7 +320,7 @@ static void sdc_lld_collect_errors(SDCDriver *sdcp, uint32_t sta) {
static void sdc_lld_error_cleanup(SDCDriver *sdcp,
uint32_t n,
uint32_t *resp) {
uint32_t sta; // sdcp->sdmmc->STA; Double read, race condition.
uint32_t sta;
/* Clearing status.*/
sta = sdcp->sdmmc->STA;
@ -730,7 +727,7 @@ bool sdc_lld_read_aligned(SDCDriver *sdcp, uint32_t startblk,
/* Prepares IDMA.*/
sdcp->sdmmc->IDMABASE0 = (uint32_t)buf;
// sdcp->sdmmc->IDMACTRL = SDMMC_IDMA_IDMAEN;
sdcp->sdmmc->IDMACTRL = SDMMC_IDMA_IDMAEN;
if (sdc_lld_prepare_read(sdcp, startblk, blocks, sdcp->resp) == true)
goto error;
@ -785,7 +782,7 @@ bool sdc_lld_write_aligned(SDCDriver *sdcp, uint32_t startblk,
/* Prepares IDMA.*/
sdcp->sdmmc->IDMABASE0 = (uint32_t)buf;
// sdcp->sdmmc->IDMACTRL = SDMMC_IDMA_IDMAEN;
sdcp->sdmmc->IDMACTRL = SDMMC_IDMA_IDMAEN;
if (sdc_lld_prepare_write(sdcp, startblk, blocks, sdcp->resp) == true)
goto error;

View File

@ -185,6 +185,12 @@ typedef struct {
*/
sdcbusmode_t bus_width;
/* End of the mandatory fields.*/
/**
* @brief Bus slowdown.
* @note This values is added to the prescaler register in order to
* arbitrarily reduce clock speed.
*/
uint32_t slowdown;
} SDCConfig;
/**