[BSP][RT1050] improve sdio stability and speed. | 优化SDIO接口稳定性和速度.

1.格式化代码.
2.优化SDIO接口稳定性和速度: 将SDIO时钟树中分频数增大, 提高内部时钟的稳定性, 同时SDIO速度提高到30M. 并且通过USB拷贝12M MP3文件测试, 多次拷贝数据稳定.
This commit is contained in:
liu2guang 2018-05-10 07:36:59 +08:00
parent 236fd82e5d
commit 51f638ad63
1 changed files with 150 additions and 148 deletions

View File

@ -76,7 +76,8 @@ static int enable_log = 1;
ALIGN(USDHC_ADMA2_ADDR_ALIGN) uint32_t g_usdhcAdma2Table[USDHC_ADMA_TABLE_WORDS] SECTION("NonCacheable");
struct imxrt_mmcsd {
struct imxrt_mmcsd
{
struct rt_mmcsd_host *host;
struct rt_mmcsd_req *req;
struct rt_mmcsd_cmd *cmd;
@ -93,7 +94,7 @@ struct imxrt_mmcsd {
uint32_t *usdhc_adma2_table;
};
static void _mmcsd_gpio_init(struct imxrt_mmcsd * mmcsd)
static void _mmcsd_gpio_init(struct imxrt_mmcsd *mmcsd)
{
gpio_pin_config_t sw_config;
@ -199,7 +200,7 @@ static void SDMMCHOST_ErrorRecovery(USDHC_Type *base)
}
}
static void _mmcsd_host_init(struct imxrt_mmcsd * mmcsd)
static void _mmcsd_host_init(struct imxrt_mmcsd *mmcsd)
{
usdhc_host_t *usdhc_host = &mmcsd->usdhc_host;
@ -214,28 +215,28 @@ static void _mmcsd_host_init(struct imxrt_mmcsd * mmcsd)
USDHC_Init(usdhc_host->base, &(usdhc_host->config));
}
static void _mmcsd_clk_init(struct imxrt_mmcsd * mmcsd)
static void _mmcsd_clk_init(struct imxrt_mmcsd *mmcsd)
{
CLOCK_EnableClock(mmcsd->ip_clock);
CLOCK_SetDiv(mmcsd->usdhc_div, 0U);
CLOCK_SetDiv(mmcsd->usdhc_div, 5U);
}
static void _mmcsd_isr_init(struct imxrt_mmcsd * mmcsd)
static void _mmcsd_isr_init(struct imxrt_mmcsd *mmcsd)
{
//NVIC_SetPriority(USDHC1_IRQn, 5U);
}
static void _mmc_request(struct rt_mmcsd_host *host, struct rt_mmcsd_req *req)
{
struct imxrt_mmcsd * mmcsd;
struct rt_mmcsd_cmd * cmd;
struct rt_mmcsd_data * data;
struct imxrt_mmcsd *mmcsd;
struct rt_mmcsd_cmd *cmd;
struct rt_mmcsd_data *data;
status_t error;
usdhc_adma_config_t dmaConfig;
usdhc_transfer_t fsl_content = {0};
usdhc_command_t fsl_command = {0};
usdhc_data_t fsl_data = {0};
rt_uint32_t * buf = NULL;
rt_uint32_t *buf = NULL;
RT_ASSERT(host != RT_NULL);
RT_ASSERT(req != RT_NULL);
@ -430,7 +431,7 @@ static void _mmc_request(struct rt_mmcsd_host *host, struct rt_mmcsd_req *req)
static void _mmc_set_iocfg(struct rt_mmcsd_host *host, struct rt_mmcsd_io_cfg *io_cfg)
{
struct imxrt_mmcsd * mmcsd;
struct imxrt_mmcsd *mmcsd;
unsigned int usdhc_clk;
unsigned int bus_width;
uint32_t src_clk;
@ -443,7 +444,7 @@ static void _mmc_set_iocfg(struct rt_mmcsd_host *host, struct rt_mmcsd_io_cfg *i
usdhc_clk = io_cfg->clock;
bus_width = io_cfg->bus_width;
if(usdhc_clk > IMXRT_MAX_FREQ)
if (usdhc_clk > IMXRT_MAX_FREQ)
usdhc_clk = IMXRT_MAX_FREQ;
src_clk = (CLOCK_GetSysPfdFreq(kCLOCK_Pfd2) / (CLOCK_GetDiv(mmcsd->usdhc_div) + 1U));
@ -492,7 +493,8 @@ FINSH_FUNCTION_EXPORT(log_toggle, toglle log dumple);
//
//}
static const struct rt_mmcsd_host_ops ops = {
static const struct rt_mmcsd_host_ops ops =
{
_mmc_request,
_mmc_set_iocfg,
RT_NULL,//_mmc_get_card_status,