gd_adc.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. /*!
  2. *******************************************************************************
  3. **
  4. ** \file gd_adc.h
  5. **
  6. ** \brief ADC.
  7. **
  8. ** Copyright: 2012 - 2013 (C) GoKe Microelectronics ShangHai Branch
  9. **
  10. ** \attention THIS SAMPLE CODE IS PROVIDED AS IS. GOKE MICROELECTRONICS
  11. ** ACCEPTS NO RESPONSIBILITY OR LIABILITY FOR ANY ERRORS OR
  12. ** OMMISSIONS.
  13. **
  14. ** \note Do not modify this file as it is generated automatically.
  15. **
  16. ******************************************************************************/
  17. #ifndef _GD_ADC_H_
  18. #define _GD_ADC_H_
  19. #include "gmodids.h"
  20. //*****************************************************************************
  21. //*****************************************************************************
  22. //** Defines and Macros
  23. //*****************************************************************************
  24. //*****************************************************************************
  25. #define GD_ADC_ERR_BASE (GD_ADC_MODULE_ID << 16)
  26. #define GD_ADC_AUX_ATOP_INITIALIZE 0x0255
  27. #define GD_ADC_CONTROL_INITIALIZE 0x000A
  28. //*****************************************************************************
  29. //*****************************************************************************
  30. //** Enumerated types
  31. //*****************************************************************************
  32. //*****************************************************************************
  33. /*!
  34. *******************************************************************************
  35. **
  36. ** \brief ADC driver error codes.
  37. **
  38. *******************************************************************************
  39. */
  40. enum
  41. {
  42. GD_ERR_ADC_TYPE_NOT_SUPPORTED = GD_ADC_ERR_BASE, //!< Device not supported.
  43. };
  44. /*---------------------------------------------------------------------------*/
  45. /* types, enums and structures */
  46. /*---------------------------------------------------------------------------*/
  47. /*!
  48. *******************************************************************************
  49. **
  50. ** \brief ADC channel number.
  51. **
  52. ** \sa GD_ADC_OPEN_PARAMS_S
  53. **
  54. ******************************************************************************/
  55. typedef enum
  56. {
  57. GD_ADC_ENABLE_DISABLE = 0,
  58. GD_ADC_ENABLE_ENABLE,
  59. GD_ADC_ENABLE_COUNT,
  60. }GD_ADC_ENABLE_E;
  61. typedef enum
  62. {
  63. GD_ADC_CONTROL_CHANNEL_ONE = 0x5, //!< ADC pad_sar_key1.
  64. GD_ADC_CONTROL_CHANNEL_TWO = 0x6, //!< ADC pad_sar_key2.
  65. GD_ADC_CONTROL_CHANNEL_COUNT,
  66. }GD_ADC_CONTROL_CHANNEL_E;
  67. typedef enum
  68. {
  69. GD_ADC_CHANNEL_ONE = 0, //!< ADC channel 1.
  70. GD_ADC_CHANNEL_TWO, //!< ADC channel 2.
  71. GD_ADC_CHANNEL_COUNT,
  72. }GD_ADC_CHANNEL_E;
  73. enum
  74. {
  75. GD_ADC_REQ_CHANNEL_ONE = 1, //!< ADC req channel 1.
  76. GD_ADC_REQ_CHANNEL_TWO, //!< ADC req channel 2.
  77. };
  78. //*****************************************************************************
  79. //*****************************************************************************
  80. //** Data Structures
  81. //*****************************************************************************
  82. //*****************************************************************************
  83. /*!
  84. *******************************************************************************
  85. **
  86. ** \brief Init parameters.
  87. **
  88. ** \sa GD_ADC_Open() <BR>
  89. **
  90. ******************************************************************************/
  91. typedef struct
  92. {
  93. U32 val_lo : 10;
  94. U32 : 5;
  95. U32 val_hi : 10;
  96. U32 : 5;
  97. U32 en_lo : 1;
  98. U32 en_hi : 1;
  99. } GD_ADC_CONTROL_S;
  100. typedef union
  101. {
  102. U32 data;
  103. GD_ADC_CONTROL_S control;
  104. }GD_ADC_CRYPTO_DATA_T;
  105. typedef struct
  106. {
  107. GD_ADC_CHANNEL_E channel;
  108. GD_ADC_CRYPTO_DATA_T control;
  109. } GD_ADC_OPEN_PARAMS_S;
  110. //*****************************************************************************
  111. //*****************************************************************************
  112. //** Global Data
  113. //*****************************************************************************
  114. //*****************************************************************************
  115. //*****************************************************************************
  116. //*****************************************************************************
  117. //** API Functions
  118. //*****************************************************************************
  119. //*****************************************************************************
  120. #ifdef __cplusplus
  121. extern "C" {
  122. #endif
  123. GERR GD_ADC_Init(void);
  124. GERR GD_ADC_Exit(void);
  125. GERR GD_ADC_Open(GD_ADC_OPEN_PARAMS_S * openParamsP, GD_HANDLE* pHandle );
  126. GERR GD_ADC_Close(GD_HANDLE * pHandle);
  127. GERR GD_ADC_Read(GD_HANDLE *pHandle, U32* data);
  128. #ifdef __cplusplus
  129. }
  130. #endif
  131. #endif /* _GD_ADC_H_ */
  132. /*----------------------------------------------------------------------------*/
  133. /* end of file */
  134. /*----------------------------------------------------------------------------*/