sdcard_port.c 1.5 KB

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