opa.h 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. /*******************************************************************************
  2. * Copyright (C) 2018, Huada Semiconductor Co.,Ltd All rights reserved.
  3. *
  4. * This software is owned and published by:
  5. * Huada Semiconductor Co.,Ltd ("HDSC").
  6. *
  7. * BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND
  8. * BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT.
  9. *
  10. * This software contains source code for use with HDSC
  11. * components. This software is licensed by HDSC to be adapted only
  12. * for use in systems utilizing HDSC components. HDSC shall not be
  13. * responsible for misuse or illegal use of this software for devices not
  14. * supported herein. HDSC is providing this software "AS IS" and will
  15. * not be responsible for issues arising from incorrect user implementation
  16. * of the software.
  17. *
  18. * Disclaimer:
  19. * HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE,
  20. * REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS),
  21. * ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING,
  22. * WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED
  23. * WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED
  24. * WARRANTY OF NONINFRINGEMENT.
  25. * HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT,
  26. * NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT
  27. * LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION,
  28. * LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR
  29. * INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT,
  30. * INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA,
  31. * SAVINGS OR PROFITS,
  32. * EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
  33. * YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR
  34. * INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED
  35. * FROM, THE SOFTWARE.
  36. *
  37. * This software may be replicated in part or whole for the licensed use,
  38. * with the restriction that this Disclaimer and Copyright notice must be
  39. * included with each copy of this software, whether used in part or whole,
  40. * at all times.
  41. */
  42. /******************************************************************************/
  43. /** \file OPA.h
  44. **
  45. ** Headerfile for OPA functions
  46. ** @link OPA Group Some description @endlink
  47. **
  48. ** History:
  49. ** - 2018-04-15 Devi First Version
  50. **
  51. ******************************************************************************/
  52. #ifndef __OPA_H__
  53. #define __OPA_H__
  54. /*******************************************************************************
  55. * Include files
  56. ******************************************************************************/
  57. #include "ddl.h"
  58. #include "interrupts_hc32l136.h"
  59. #ifdef __cplusplus
  60. extern "C"
  61. {
  62. #endif
  63. /**
  64. ******************************************************************************
  65. ** \defgroup OPAGroup (OPA)
  66. **
  67. ******************************************************************************/
  68. //@{
  69. /**
  70. *******************************************************************************
  71. ** function prototypes.
  72. ******************************************************************************/
  73. /**
  74. *******************************************************************************
  75. ** \brief OPA通道选择
  76. ** \note
  77. ******************************************************************************/
  78. typedef enum en_opa_channel
  79. {
  80. OPA0 = 0u, ///<<OPA0
  81. OPA1 = 1u, ///<<OPA1
  82. OPA2 = 2u, ///<<OPA2
  83. }en_opa_channel_t;
  84. /**
  85. *******************************************************************************
  86. ** \brief OPA反向增益选择
  87. ** \note
  88. ******************************************************************************/
  89. typedef enum en_opa_invert_pagagain
  90. {
  91. Gain15 = 0u, ///< 反向增益15倍
  92. Gain07 = 1u, ///< 反向增益7倍
  93. Gain13_3 = 2u, ///< 反向增益13/3倍
  94. Gain03 = 3u, ///< 反向增益3倍
  95. Gain05_3 = 4u, ///< 反向增益5/3倍
  96. Gain01 = 5u, ///< 反向增益1倍
  97. Gain01_3 = 6u, ///< 反向增益1/3倍
  98. Gain11_5 = 7u, ///< 反向增益11/5倍
  99. }en_opa_invert_pagagain_t;
  100. /**
  101. *******************************************************************************
  102. ** \brief OPA正向增益选择
  103. ** \note
  104. ******************************************************************************/
  105. typedef enum en_opa_noinvert_pagagain
  106. {
  107. Gain16 = 0u, ///< 正向增益16倍
  108. Gain08 = 1u, ///< 正向增益8倍
  109. Gain16_3 = 2u, ///< 正向增益16/3倍
  110. Gain04 = 3u, ///< 正向增益4倍
  111. Gain08_3 = 4u, ///< 正向增益8/3倍
  112. Gain02 = 5u, ///< 正向增益2倍
  113. Gain04_3 = 6u, ///< 正向增益4/3倍
  114. Gain16_5 = 7u, ///< 正向增益16/5倍
  115. }en_opa_noinvert_pagagain_t;
  116. /**
  117. *******************************************************************************
  118. ** \brief 仪表增益配置
  119. ******************************************************************************/
  120. typedef enum opa_metergain
  121. {
  122. OpaMeterGain3 = 0u,
  123. OpaMeterGain1_3 = 1u,
  124. OpaMeterGain1 = 2u,
  125. }en_opa_metergain_t;
  126. /**
  127. *******************************************************************************
  128. ** \brief opa 模式选择
  129. ******************************************************************************/
  130. typedef enum opa_modesel
  131. {
  132. OpaUintMode = 0u, ///< PGA单位增益
  133. OpaForWardMode = 1u, ///< 正向输入PGA
  134. OpaOppositeMode = 2u, ///< 反向输入PGA
  135. OpaThreeOppMode = 3u, ///< 3个OPA级联反向输入PGA
  136. OpaThreeForMode = 4u, ///< 3个OPA级联正向输入PGA
  137. OpaDiffMode = 5u, ///< 两运放差分输入PGA
  138. OpaMeterMode = 6u, ///< 仪表放大器
  139. OpaGpMode = 7u, ///< 通用运放
  140. }en_opa_modesel_t;
  141. /**
  142. *******************************************************************************
  143. ** \brief opa 校正模式
  144. ******************************************************************************/
  145. typedef enum opa_calsel
  146. {
  147. OpaSoftMode = 0u, ///< 软件控制
  148. OpaSoftTriggerMode = 1u, ///< 软件触发
  149. OpaADCTriggerMode = 2u, ///< ADC触发
  150. }en_opa_calsel_t;
  151. /**
  152. ******************************************************************************
  153. ** \brief OPA增益配置
  154. *****************************************************************************/
  155. typedef struct stc_opa_gain_config
  156. {
  157. en_opa_invert_pagagain_t enInGain; ///< 反向增益
  158. en_opa_noinvert_pagagain_t enNoInGain; ///< 正向增益
  159. }stc_opa_gain_config_t;
  160. /******************************************************************************
  161. * Global variable declarations ('extern', definition in C source)
  162. ******************************************************************************/
  163. /******************************************************************************
  164. * Global function prototypes (definition in C source)
  165. ******************************************************************************/
  166. ///< OPA初始化
  167. en_result_t OPA_Init(void);
  168. ///< OPA去初始化
  169. en_result_t OPA_DeInit(void);
  170. ///< OPA基本功能设置
  171. en_result_t OPA_Operate(en_opa_channel_t enchannel ,en_opa_modesel_t enMode,stc_opa_gain_config_t *pstrGain);
  172. ///< OPA三级联设置
  173. en_result_t OPA_ThreeOperate(en_opa_modesel_t enMode,stc_opa_gain_config_t *pstrGain0,stc_opa_gain_config_t *pstrGain1,stc_opa_gain_config_t *pstrGain2);
  174. ///< OPA 仪表模式
  175. en_result_t OPA_MeterOperate(en_opa_metergain_t enGainMode);
  176. ///< OPA校正模式
  177. en_result_t OPA_Cal(en_opa_calsel_t enCalMode);
  178. //@} // OPA Group
  179. #ifdef __cplusplus
  180. #endif
  181. #endif /* __OPA_H__ */
  182. /*******************************************************************************
  183. * EOF (not truncated)
  184. ******************************************************************************/