forked from xuos/xiuos
Ubiquitous/RT-Thread_Fusion_XiUOS/: sd(tf) card driver supported by sdio
This commit is contained in:
parent
f42d049cb0
commit
42416d58ef
|
@ -949,6 +949,104 @@ void imxrt_enet_pins_init(void)
|
|||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef RT_USING_SDIO
|
||||
void imxrt_sdio_pins_init(void)
|
||||
{
|
||||
IOMUXC_SetPinMux(
|
||||
IOMUXC_GPIO_B1_14_USDHC1_VSELECT, /* GPIO_B1_14 is configured as USDHC1_VSELECT */
|
||||
0U); /* Software Input On Field: Input Path is determined by functionality */
|
||||
IOMUXC_SetPinMux(
|
||||
IOMUXC_GPIO_SD_B0_00_USDHC1_CMD, /* GPIO_SD_B0_00 is configured as USDHC1_CMD */
|
||||
0U); /* Software Input On Field: Input Path is determined by functionality */
|
||||
IOMUXC_SetPinMux(
|
||||
IOMUXC_GPIO_SD_B0_01_USDHC1_CLK, /* GPIO_SD_B0_01 is configured as USDHC1_CLK */
|
||||
0U); /* Software Input On Field: Input Path is determined by functionality */
|
||||
IOMUXC_SetPinMux(
|
||||
IOMUXC_GPIO_SD_B0_02_USDHC1_DATA0, /* GPIO_SD_B0_02 is configured as USDHC1_DATA0 */
|
||||
0U); /* Software Input On Field: Input Path is determined by functionality */
|
||||
IOMUXC_SetPinMux(
|
||||
IOMUXC_GPIO_SD_B0_03_USDHC1_DATA1, /* GPIO_SD_B0_03 is configured as USDHC1_DATA1 */
|
||||
0U); /* Software Input On Field: Input Path is determined by functionality */
|
||||
IOMUXC_SetPinMux(
|
||||
IOMUXC_GPIO_SD_B0_04_USDHC1_DATA2, /* GPIO_SD_B0_04 is configured as USDHC1_DATA2 */
|
||||
0U); /* Software Input On Field: Input Path is determined by functionality */
|
||||
IOMUXC_SetPinMux(
|
||||
IOMUXC_GPIO_SD_B0_05_USDHC1_DATA3, /* GPIO_SD_B0_05 is configured as USDHC1_DATA3 */
|
||||
0U); /* Software Input On Field: Input Path is determined by functionality */
|
||||
IOMUXC_SetPinConfig(
|
||||
IOMUXC_GPIO_B1_14_USDHC1_VSELECT, /* GPIO_B1_14 PAD functional properties : */
|
||||
0x0170A1u); /* Slew Rate Field: Fast Slew Rate
|
||||
Drive Strength Field: R0/4
|
||||
Speed Field: medium(100MHz)
|
||||
Open Drain Enable Field: Open Drain Disabled
|
||||
Pull / Keep Enable Field: Pull/Keeper Enabled
|
||||
Pull / Keep Select Field: Pull
|
||||
Pull Up / Down Config. Field: 47K Ohm Pull Up
|
||||
Hyst. Enable Field: Hysteresis Enabled */
|
||||
IOMUXC_SetPinConfig(
|
||||
IOMUXC_GPIO_SD_B0_00_USDHC1_CMD, /* GPIO_SD_B0_00 PAD functional properties : */
|
||||
0x017089u); /* Slew Rate Field: Fast Slew Rate
|
||||
Drive Strength Field: R0(150 Ohm @ 3.3V, 260 Ohm@1.8V)
|
||||
Speed Field: medium(100MHz)
|
||||
Open Drain Enable Field: Open Drain Disabled
|
||||
Pull / Keep Enable Field: Pull/Keeper Enabled
|
||||
Pull / Keep Select Field: Pull
|
||||
Pull Up / Down Config. Field: 47K Ohm Pull Up
|
||||
Hyst. Enable Field: Hysteresis Enabled */
|
||||
IOMUXC_SetPinConfig(
|
||||
IOMUXC_GPIO_SD_B0_01_USDHC1_CLK, /* GPIO_SD_B0_01 PAD functional properties : */
|
||||
0x014089u); /* Slew Rate Field: Fast Slew Rate
|
||||
Drive Strength Field: R0(150 Ohm @ 3.3V, 260 Ohm@1.8V)
|
||||
Speed Field: medium(100MHz)
|
||||
Open Drain Enable Field: Open Drain Disabled
|
||||
Pull / Keep Enable Field: Pull/Keeper Disabled
|
||||
Pull / Keep Select Field: Keeper
|
||||
Pull Up / Down Config. Field: 47K Ohm Pull Up
|
||||
Hyst. Enable Field: Hysteresis Enabled */
|
||||
IOMUXC_SetPinConfig(
|
||||
IOMUXC_GPIO_SD_B0_02_USDHC1_DATA0, /* GPIO_SD_B0_02 PAD functional properties : */
|
||||
0x017089u); /* Slew Rate Field: Fast Slew Rate
|
||||
Drive Strength Field: R0(150 Ohm @ 3.3V, 260 Ohm@1.8V)
|
||||
Speed Field: medium(100MHz)
|
||||
Open Drain Enable Field: Open Drain Disabled
|
||||
Pull / Keep Enable Field: Pull/Keeper Enabled
|
||||
Pull / Keep Select Field: Pull
|
||||
Pull Up / Down Config. Field: 47K Ohm Pull Up
|
||||
Hyst. Enable Field: Hysteresis Enabled */
|
||||
IOMUXC_SetPinConfig(
|
||||
IOMUXC_GPIO_SD_B0_03_USDHC1_DATA1, /* GPIO_SD_B0_03 PAD functional properties : */
|
||||
0x017089u); /* Slew Rate Field: Fast Slew Rate
|
||||
Drive Strength Field: R0(150 Ohm @ 3.3V, 260 Ohm@1.8V)
|
||||
Speed Field: medium(100MHz)
|
||||
Open Drain Enable Field: Open Drain Disabled
|
||||
Pull / Keep Enable Field: Pull/Keeper Enabled
|
||||
Pull / Keep Select Field: Pull
|
||||
Pull Up / Down Config. Field: 47K Ohm Pull Up
|
||||
Hyst. Enable Field: Hysteresis Enabled */
|
||||
IOMUXC_SetPinConfig(
|
||||
IOMUXC_GPIO_SD_B0_04_USDHC1_DATA2, /* GPIO_SD_B0_04 PAD functional properties : */
|
||||
0x017089u); /* Slew Rate Field: Fast Slew Rate
|
||||
Drive Strength Field: R0(150 Ohm @ 3.3V, 260 Ohm@1.8V)
|
||||
Speed Field: medium(100MHz)
|
||||
Open Drain Enable Field: Open Drain Disabled
|
||||
Pull / Keep Enable Field: Pull/Keeper Enabled
|
||||
Pull / Keep Select Field: Pull
|
||||
Pull Up / Down Config. Field: 47K Ohm Pull Up
|
||||
Hyst. Enable Field: Hysteresis Enabled */
|
||||
IOMUXC_SetPinConfig(
|
||||
IOMUXC_GPIO_SD_B0_05_USDHC1_DATA3, /* GPIO_SD_B0_05 PAD functional properties : */
|
||||
0x017089u); /* Slew Rate Field: Fast Slew Rate
|
||||
Drive Strength Field: R0(150 Ohm @ 3.3V, 260 Ohm@1.8V)
|
||||
Speed Field: medium(100MHz)
|
||||
Open Drain Enable Field: Open Drain Disabled
|
||||
Pull / Keep Enable Field: Pull/Keeper Enabled
|
||||
Pull / Keep Select Field: Pull
|
||||
Pull Up / Down Config. Field: 47K Ohm Pull Up
|
||||
Hyst. Enable Field: Hysteresis Enabled */
|
||||
|
||||
}
|
||||
#endif
|
||||
void rt_hw_board_init()
|
||||
{
|
||||
|
@ -974,6 +1072,10 @@ void rt_hw_board_init()
|
|||
imxrt_dma_init();
|
||||
#endif
|
||||
|
||||
#ifdef RT_USING_SDIO
|
||||
imxrt_sdio_pins_init();
|
||||
#endif
|
||||
|
||||
#ifdef RT_USING_HEAP
|
||||
rt_system_heap_init((void *)HEAP_BEGIN, (void *)HEAP_END);
|
||||
#endif
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
|
||||
#include <rtdevice.h>
|
||||
#include <rtthread.h>
|
||||
#include "drv_gpio.h"
|
||||
#include <board.h>
|
||||
#include <dfs_elm.h>
|
||||
#include <dfs_posix.h>
|
||||
#define DBG_TAG "sdcard"
|
||||
#define DBG_LVL DBG_INFO
|
||||
#include <rtdbg.h>
|
||||
int sd_mount()
|
||||
{
|
||||
rt_uint32_t result;
|
||||
result = mmcsd_wait_cd_changed(RT_TICK_PER_SECOND);
|
||||
if (result == MMCSD_HOST_PLUGED)
|
||||
{
|
||||
/* mount sd card fat partition 1 as root directory */
|
||||
if (dfs_mount("sd0", "/", "elm", 0, 0) == 0)
|
||||
{
|
||||
LOG_I("File System initialized!\n");
|
||||
return RT_EOK;
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG_E("File System init failed!\n");
|
||||
return -RT_ERROR;
|
||||
}
|
||||
|
||||
}
|
||||
LOG_E("msd_init fail !!!");
|
||||
return -RT_ERROR;
|
||||
}
|
||||
INIT_APP_EXPORT(sd_mount);
|
Loading…
Reference in New Issue