1 /*
2 * Copyright (c) 2006-2021, RT-Thread Development Team
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 *
6 * Change Logs:
7 * Date Author Notes
8 * 2018-12-13 balanceTWK add sdcard port file
9 */
10
11 #include <rtthread.h>
12
13 #ifdef BSP_USING_SDCARD
14
15 #include <dfs_elm.h>
16 #include <dfs_fs.h>
17 #include <dfs_file.h>
18 #include <unistd.h>
19 #include <stdio.h>
20 #include <sys/stat.h>
21 #include <sys/statfs.h>
22 #include "drv_gpio.h"
23
24 #define DBG_TAG "app.card"
25 #define DBG_LVL DBG_INFO
26 #include <rtdbg.h>
27
28 #define WIFI_RESET_PIN GET_PIN(G, 9)
29
ewm1062_disable(void)30 int ewm1062_disable(void)
31 {
32 rt_pin_mode(WIFI_RESET_PIN, PIN_MODE_OUTPUT);
33 rt_pin_write(WIFI_RESET_PIN,PIN_LOW);
34 return RT_EOK;
35 }
36 INIT_BOARD_EXPORT(ewm1062_disable);
37
sd_mount(void * parameter)38 void sd_mount(void *parameter)
39 {
40 while (1)
41 {
42 rt_thread_mdelay(500);
43 if(rt_device_find("sd0") != RT_NULL)
44 {
45 if (dfs_mount("sd0", "/", "elm", 0, 0) == RT_EOK)
46 {
47 LOG_I("sd card mount to '/'");
48 break;
49 }
50 else
51 {
52 LOG_W("sd card mount to '/' failed!");
53 }
54 }
55 }
56 }
57
stm32_sdcard_mount(void)58 int stm32_sdcard_mount(void)
59 {
60 rt_thread_t tid;
61
62 tid = rt_thread_create("sd_mount", sd_mount, RT_NULL,
63 1024, RT_THREAD_PRIORITY_MAX - 2, 20);
64 if (tid != RT_NULL)
65 {
66 rt_thread_startup(tid);
67 }
68 else
69 {
70 LOG_E("create sd_mount thread err!");
71 }
72 return RT_EOK;
73 }
74 INIT_ENV_EXPORT(stm32_sdcard_mount);
75
76 #endif /* BSP_USING_SDCARD */
77
78