sdcard_port.c 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /*
  2. * Copyright (c) 2006-2018, 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. #include <rtthread.h>
  11. #ifdef BSP_USING_SDCARD
  12. #include <dfs_elm.h>
  13. #include <dfs_fs.h>
  14. #include <dfs_posix.h>
  15. #include "drv_gpio.h"
  16. #define DBG_TAG "app.card"
  17. #define DBG_LVL DBG_INFO
  18. #include <rtdbg.h>
  19. #define WIFI_RESET_PIN GET_PIN(G, 9)
  20. int ewm1062_disable(void)
  21. {
  22. rt_pin_mode(WIFI_RESET_PIN, PIN_MODE_OUTPUT);
  23. rt_pin_write(WIFI_RESET_PIN,PIN_LOW);
  24. return RT_EOK;
  25. }
  26. INIT_BOARD_EXPORT(ewm1062_disable);
  27. void sd_mount(void *parameter)
  28. {
  29. while (1)
  30. {
  31. rt_thread_mdelay(500);
  32. if(rt_device_find("sd0") != RT_NULL)
  33. {
  34. if (dfs_mount("sd0", "/", "elm", 0, 0) == RT_EOK)
  35. {
  36. LOG_I("sd card mount to '/'");
  37. break;
  38. }
  39. else
  40. {
  41. LOG_W("sd card mount to '/' failed!");
  42. }
  43. }
  44. }
  45. }
  46. int stm32_sdcard_mount(void)
  47. {
  48. rt_thread_t tid;
  49. tid = rt_thread_create("sd_mount", sd_mount, RT_NULL,
  50. 1024, RT_THREAD_PRIORITY_MAX - 2, 20);
  51. if (tid != RT_NULL)
  52. {
  53. rt_thread_startup(tid);
  54. }
  55. else
  56. {
  57. LOG_E("create sd_mount thread err!");
  58. }
  59. return RT_EOK;
  60. }
  61. INIT_APP_EXPORT(stm32_sdcard_mount);
  62. #endif /* BSP_USING_SDCARD */