Skip to content

Commit d34981f

Browse files
CXSforHPURbb666
authored andcommitted
[bsp/renesas/vision_board] Fix the sdio mount
1 parent 9333ed7 commit d34981f

File tree

3 files changed

+43
-20
lines changed

3 files changed

+43
-20
lines changed

bsp/renesas/ra8d1-vision-board/board/SConscript

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@ list = os.listdir(cwd)
77
CPPPATH = [cwd]
88
src = Glob('*.c')
99

10-
if GetDepend(['BSP_USING_FS']):
11-
src += Glob('ports/mnt.c')
12-
1310
CPPDEFINES = ['BSP_CFG_RTOS = 2']
1411

1512
objs = DefineGroup('Drivers', src, depend = [''], CPPPATH = CPPPATH, CPPDEFINES=CPPDEFINES)

bsp/renesas/ra8d1-vision-board/board/ports/SConscript

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,13 @@ import os
22
from building import *
33

44
objs = []
5-
src = Glob('*.c')
5+
src = ["drv_sdram.c"]
66
cwd = GetCurrentDir()
77
CPPPATH = [cwd]
88

9+
if GetDepend(['BSP_USING_FS']):
10+
src += ['mnt.c']
11+
912
objs = DefineGroup('Drivers', src, depend = [''], CPPPATH = CPPPATH)
1013

1114
list = os.listdir(cwd)

bsp/renesas/ra8d1-vision-board/board/ports/mnt.c

Lines changed: 39 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,13 @@
99
#define DBG_LVL DBG_INFO
1010
#include <rtdbg.h>
1111

12+
#define SDHI_USING_CD
13+
#define RA_SDHI_CD_PIN "p503"
14+
15+
#ifdef BSP_USING_OPENMV
16+
#include "led.h"
17+
#endif /* BSP_USING_OPENMV */
18+
1219
#ifdef BSP_USING_ONCHIP_FS
1320
#include "fal.h"
1421
#define FS_PARTITION_NAME "disk"
@@ -47,10 +54,11 @@ static void sd_mount(void)
4754
#elif defined(BSP_USING_SDCARD_FS)
4855
#include <drv_sdhi.h>
4956

57+
#ifdef SDHI_USING_CD
5058
/* SD Card hot plug detection pin */
51-
#define SD_CHECK_PIN "p405"
52-
59+
#define SD_CHECK_PIN RA_SDHI_CD_PIN
5360
static rt_base_t sd_check_pin = 0;
61+
#endif
5462

5563
static void _sdcard_mount(void)
5664
{
@@ -92,39 +100,48 @@ static void _sdcard_unmount(void)
92100

93101
static void sd_auto_mount(void *parameter)
94102
{
95-
rt_uint8_t re_sd_check_pin = 1;
96-
rt_thread_mdelay(20);
103+
rt_uint8_t re_sd_check_pin = 0;
104+
rt_thread_mdelay(500);
97105

98-
if (!rt_pin_read(sd_check_pin))
106+
#ifdef SDHI_USING_CD
107+
if (re_sd_check_pin = rt_pin_read(sd_check_pin))
99108
{
100109
_sdcard_mount();
101110
}
102111

103112
while (1)
104113
{
105114
rt_thread_mdelay(200);
106-
107-
if (re_sd_check_pin && (re_sd_check_pin = rt_pin_read(sd_check_pin)) == 0)
115+
if (!re_sd_check_pin && (re_sd_check_pin = rt_pin_read(sd_check_pin)) != 0)
108116
{
117+
#ifdef BSP_USING_OPENMV
118+
led_state(LED_RED, 1);
119+
#endif /* BSP_USING_OPENMV */
109120
_sdcard_mount();
121+
#ifdef BSP_USING_OPENMV
122+
led_state(LED_RED, 0);
123+
#endif /* BSP_USING_OPENMV */
110124
}
111125

112-
if (!re_sd_check_pin && (re_sd_check_pin = rt_pin_read(sd_check_pin)) != 0)
126+
if (re_sd_check_pin && (re_sd_check_pin = rt_pin_read(sd_check_pin)) == 0)
113127
{
114128
_sdcard_unmount();
115129
}
116130
}
131+
#else
132+
_sdcard_mount();
133+
#endif /* SDHI_USING_CD */
117134
}
118135

119136
static void sd_mount(void)
120137
{
121138
rt_thread_t tid;
122-
139+
#ifdef SDHI_USING_CD
123140
sd_check_pin = rt_pin_get(SD_CHECK_PIN);
124141
rt_pin_mode(sd_check_pin, PIN_MODE_INPUT_PULLUP);
125-
142+
#endif /* SDHI_USING_CD */
126143
tid = rt_thread_create("sd_mount", sd_auto_mount, RT_NULL,
127-
2048, RT_THREAD_PRIORITY_MAX - 2, 20);
144+
2048, RT_THREAD_PRIORITY_MAX - 12, 20);
128145
if (tid != RT_NULL)
129146
{
130147
rt_thread_startup(tid);
@@ -137,12 +154,12 @@ static void sd_mount(void)
137154
}
138155

139156
#else
140-
#include <dev_spi_msd.h>
141-
#include "drv_sci.h"
157+
#include <spi_msd.h>
158+
#include "drv_sci_spi.h"
142159
int sd_mount(void)
143160
{
144161
uint32_t cs_pin = BSP_IO_PORT_10_PIN_05;
145-
rt_hw_sci_spi_device_attach("sci2s", "scpi20", cs_pin);
162+
rt_hw_sci_spi_device_attach("scpi2", "scpi20", cs_pin);
146163
msd_init("sd0", "scpi20");
147164
if (dfs_mount("sd0", "/", "elm", 0, 0) == 0)
148165
{
@@ -158,8 +175,14 @@ int sd_mount(void)
158175

159176
int mount_init(void)
160177
{
178+
mmcsd_wait_cd_changed(0);
179+
180+
sdcard_change();
181+
mmcsd_wait_cd_changed(RT_WAITING_FOREVER);
182+
183+
rt_thread_mdelay(200);
161184
sd_mount();
162185
return RT_EOK;
163186
}
164-
// INIT_ENV_EXPORT(mount_init);
165-
#endif
187+
INIT_ENV_EXPORT(mount_init);
188+
#endif

0 commit comments

Comments
 (0)