sdcard_port.c 1.5 KB

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