srv_sdcard_detect.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /* Copyright (C) 2019 RDA Technologies Limited and/or its affiliates("RDA").
  2. * All rights reserved.
  3. *
  4. * This software is supplied "AS IS" without any warranties.
  5. * RDA assumes no responsibility or liability for the use of the software,
  6. * conveys no license or title under any patent, copyright, or mask work
  7. * right to the product. RDA reserves the right to make changes in the
  8. * software without notification. RDA also make no representation or
  9. * warranty that such application will be suitable for the specified use
  10. * without further testing or modification.
  11. */
  12. #ifndef _SRV_SDCARD_DETECT_H_
  13. #define _SRV_SDCARD_DETECT_H_
  14. #include "osi_compiler.h"
  15. OSI_EXTERN_C_BEGIN
  16. #include <stdbool.h>
  17. #define CONFIG_SD_DETECT_DEBOUNCE_TIMEOUT (400) // ms
  18. #define CONFIG_SD_DETECT_DROPOUT_TIMEOUT (2000) // ms
  19. typedef enum
  20. {
  21. MSG_SDCARD_PLUGOUT = 0,
  22. MSG_SDCARD_PLUGIN = 1,
  23. MSG_SDCARD_MAX_COUNT ///< total count
  24. } srvSDCardStatus_t;
  25. /**
  26. * @brief function type to report sdcard plug in/out
  27. */
  28. typedef void (*sdDetectCB_t)(int id, bool connect);
  29. /**
  30. * @brief sdcard detect register callback
  31. *
  32. * @param id sdcard id (must be 1/2)
  33. * @param gpio_id gpio to detect sdcard hot plug
  34. * @param cb callback after sdcard plug in/out detect
  35. * @return
  36. * - true success
  37. * - false fail
  38. */
  39. bool srvSDCardDetectRegister(int id, int gpio_id, sdDetectCB_t cb);
  40. /**
  41. * @brief enable/disable sdcard detect
  42. *
  43. * @param id sdcard id (must be 1/2)
  44. * @param int_status enable or disable
  45. * @return
  46. * - true on success else fail
  47. */
  48. bool srvSDCardDetectSwitch(int id, bool int_status);
  49. /**
  50. * @brief sdcard connect status detect
  51. * @return
  52. * - true or false
  53. */
  54. bool srvSDCardStatus(void);
  55. OSI_EXTERN_C_END
  56. #endif