MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / FsdCtrl_Init

Function FsdCtrl_Init

bsp/ft2004/libraries/bsp/ft_sd/ft_sdctrl.c:66–103  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

64}
65
66ft_error_t FsdCtrl_Init(FT_INOUT FtsdCtrl_t *pFtsdCtrl)
67{
68 FSdCtrl_Config_t *pConfig;
69 Ft_assertNonvoid(FT_NULL != pFtsdCtrl);
70 pConfig = &pFtsdCtrl->config;
71
72 /* Disable card detection */
73 Ft_out32(pConfig->baseAddress + SD_SEN_REG_OFFSET, 0);
74
75 /* Disable all interrupts */
76 Ft_out32(pConfig->baseAddress + NORMAL_INT_EN_REG_OFFSET, 0);
77 Ft_out32(pConfig->baseAddress + ERROR_INT_EN_REG_OFFSET, 0);
78 Ft_out32(pConfig->baseAddress + BD_ISR_EN_REG_OFFSET, 0);
79 // Ft_out32(pConfig->baseAddress + NORMAL_INT_EN_REG_OFFSET, NORMAL_INT_EN_ECCRCE);
80
81 /* Clear status register */
82 Ft_out32(pConfig->baseAddress + NORMAL_INT_STATUS_REG, 0);
83 Ft_out32(pConfig->baseAddress + ERROR_INT_STATUS_REG, 0);
84 Ft_out32(pConfig->baseAddress + BD_ISR_REG, 0);
85
86 /* Set default ctrl register */
87 Ft_out32(pConfig->baseAddress + CONTROLL_SETTING_REG_OFFSET, 0x0f00);
88
89 /* Set default drive and sampling register */
90 Ft_out32(pConfig->baseAddress + SD_DRV_REG_OFFSET, 0);
91 Ft_out32(pConfig->baseAddress + SD_SAMP_REG_OFFSET, 0);
92
93 /* Configure to default cmd data timeout */
94 Ft_out32(pConfig->baseAddress + TIMEOUT_CMD_REG_OFFSET, 0xFFFFFFFF);
95 //FSdCtrl_ClkFreqSetup(pFtsdCtrl, 1);
96
97 Ft_out32(pConfig->baseAddress + CLOCK_DIV_REG_OFFSET, SD_FRRQ_DIV_DEFAULT);
98 Ft_out32(pConfig->baseAddress + SD_SAMP_REG_OFFSET, SD_SAMP_DEFAULT);
99
100 pFtsdCtrl->isReady = FT_COMPONENT_IS_READLY;
101
102 return FTSDC_SUCCESS;
103}
104
105bool_t FSdCtrl_CardDetect(FT_INOUT FtsdCtrl_t *pFtsdCtrl)
106{

Callers 2

rthw_sdctrl_initFunction · 0.85
ft2004_sdctrl_resetFunction · 0.85

Calls 1

Ft_out32Function · 0.85

Tested by

no test coverage detected