drv_gpo.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /* Copyright (C) 2018 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 _DRV_GPO_H_
  13. #define _DRV_GPO_H_
  14. #include <stdint.h>
  15. #include <stdbool.h>
  16. #include <stddef.h>
  17. #ifdef __cplusplus
  18. extern "C" {
  19. #endif
  20. typedef enum
  21. {
  22. GPO_LEVEL_INVALID = -1,
  23. GPO_LEVEL_LOW,
  24. GPO_LEVEL_HIGH
  25. } drvGpoLevel;
  26. struct drvGpo;
  27. /**
  28. * opaque data struct for GPO instance
  29. */
  30. typedef struct drvGpo drvGpo_t;
  31. /**
  32. * @brief open a GPO
  33. *
  34. * IOMUX will be set to GPO mode at open.
  35. *
  36. * Each GPO sould be opened only once. When it is already opened, this
  37. * API will return NULL.
  38. *
  39. * The returned instance is dynamic allocated, caller should free it after
  40. * \a drvGpoClose is called.
  41. *
  42. * @param id GPO id. The range may be different among chips.
  43. * @return
  44. * - GPO instance pointer
  45. * - NULL if parameter is invalid
  46. */
  47. drvGpo_t *drvGpoOpen(uint32_t id);
  48. /**
  49. * @brief close a GPO
  50. *
  51. * IOMUX will be kept, and the GPO will be set to default.
  52. *
  53. * @param d GPO instance
  54. */
  55. void drvGpoClose(drvGpo_t *d);
  56. /**
  57. * @brief read the level of GPO
  58. *
  59. * It can be called for GPO output,
  60. * it is the level set by software.
  61. *
  62. * @param d GPO instance
  63. * @return
  64. * - GPO_LEVEL_INVALID means error
  65. * - GPO_LEVEL_HIGH for level high
  66. * - GPO_LEVEL_LOW for level low
  67. */
  68. drvGpoLevel drvGpoRead(drvGpo_t *d);
  69. /**
  70. * @brief write level for GPO
  71. *
  72. * When it is called, set the output level.
  73. *
  74. * @param d GPO instance
  75. * @param level GPO level to be set,
  76. * - GPO_LEVEL_HIGH for level high
  77. * - GPO_LEVEL_LOW for level low
  78. */
  79. void drvGpoWrite(drvGpo_t *d, drvGpoLevel level);
  80. #ifdef __cplusplus
  81. }
  82. #endif
  83. #endif