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 53 #ifndef __OPA_H__ 54 #define __OPA_H__ 55 56 /******************************************************************************* 57 * Include files 58 ******************************************************************************/ 59 #include "ddl.h" 60 #include "interrupts_hc32l136.h" 61 62 #ifdef __cplusplus 63 extern "C" 64 { 65 #endif 66 67 /** 68 ****************************************************************************** 69 ** \defgroup OPAGroup (OPA) 70 ** 71 ******************************************************************************/ 72 //@{ 73 74 /** 75 ******************************************************************************* 76 ** function prototypes. 77 ******************************************************************************/ 78 /** 79 ******************************************************************************* 80 ** \brief OPA通道选择 81 ** \note 82 ******************************************************************************/ 83 typedef enum en_opa_channel 84 { 85 OPA0 = 0u, ///<<OPA0 86 OPA1 = 1u, ///<<OPA1 87 OPA2 = 2u, ///<<OPA2 88 }en_opa_channel_t; 89 90 /** 91 ******************************************************************************* 92 ** \brief OPA反向增益选择 93 ** \note 94 ******************************************************************************/ 95 typedef enum en_opa_invert_pagagain 96 { 97 Gain15 = 0u, ///< 反向增益15倍 98 Gain07 = 1u, ///< 反向增益7倍 99 Gain13_3 = 2u, ///< 反向增益13/3倍 100 Gain03 = 3u, ///< 反向增益3倍 101 Gain05_3 = 4u, ///< 反向增益5/3倍 102 Gain01 = 5u, ///< 反向增益1倍 103 Gain01_3 = 6u, ///< 反向增益1/3倍 104 Gain11_5 = 7u, ///< 反向增益11/5倍 105 }en_opa_invert_pagagain_t; 106 107 /** 108 ******************************************************************************* 109 ** \brief OPA正向增益选择 110 ** \note 111 ******************************************************************************/ 112 typedef enum en_opa_noinvert_pagagain 113 { 114 Gain16 = 0u, ///< 正向增益16倍 115 Gain08 = 1u, ///< 正向增益8倍 116 Gain16_3 = 2u, ///< 正向增益16/3倍 117 Gain04 = 3u, ///< 正向增益4倍 118 Gain08_3 = 4u, ///< 正向增益8/3倍 119 Gain02 = 5u, ///< 正向增益2倍 120 Gain04_3 = 6u, ///< 正向增益4/3倍 121 Gain16_5 = 7u, ///< 正向增益16/5倍 122 }en_opa_noinvert_pagagain_t; 123 124 /** 125 ******************************************************************************* 126 ** \brief 仪表增益配置 127 ******************************************************************************/ 128 typedef enum opa_metergain 129 { 130 OpaMeterGain3 = 0u, 131 OpaMeterGain1_3 = 1u, 132 OpaMeterGain1 = 2u, 133 }en_opa_metergain_t; 134 135 136 /** 137 ******************************************************************************* 138 ** \brief opa 模式选择 139 ******************************************************************************/ 140 typedef enum opa_modesel 141 { 142 OpaUintMode = 0u, ///< PGA单位增益 143 OpaForWardMode = 1u, ///< 正向输入PGA 144 OpaOppositeMode = 2u, ///< 反向输入PGA 145 OpaThreeOppMode = 3u, ///< 3个OPA级联反向输入PGA 146 OpaThreeForMode = 4u, ///< 3个OPA级联正向输入PGA 147 OpaDiffMode = 5u, ///< 两运放差分输入PGA 148 OpaMeterMode = 6u, ///< 仪表放大器 149 OpaGpMode = 7u, ///< 通用运放 150 }en_opa_modesel_t; 151 152 /** 153 ******************************************************************************* 154 ** \brief opa 校正模式 155 ******************************************************************************/ 156 typedef enum opa_calsel 157 { 158 OpaSoftMode = 0u, ///< 软件控制 159 OpaSoftTriggerMode = 1u, ///< 软件触发 160 OpaADCTriggerMode = 2u, ///< ADC触发 161 }en_opa_calsel_t; 162 163 /** 164 ****************************************************************************** 165 ** \brief OPA增益配置 166 *****************************************************************************/ 167 typedef struct stc_opa_gain_config 168 { 169 en_opa_invert_pagagain_t enInGain; ///< 反向增益 170 en_opa_noinvert_pagagain_t enNoInGain; ///< 正向增益 171 }stc_opa_gain_config_t; 172 173 174 /****************************************************************************** 175 * Global variable declarations ('extern', definition in C source) 176 ******************************************************************************/ 177 178 /****************************************************************************** 179 * Global function prototypes (definition in C source) 180 ******************************************************************************/ 181 ///< OPA初始化 182 en_result_t OPA_Init(void); 183 ///< OPA去初始化 184 en_result_t OPA_DeInit(void); 185 ///< OPA基本功能设置 186 en_result_t OPA_Operate(en_opa_channel_t enchannel ,en_opa_modesel_t enMode,stc_opa_gain_config_t *pstrGain); 187 ///< OPA三级联设置 188 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); 189 ///< OPA 仪表模式 190 en_result_t OPA_MeterOperate(en_opa_metergain_t enGainMode); 191 ///< OPA校正模式 192 en_result_t OPA_Cal(en_opa_calsel_t enCalMode); 193 194 195 //@} // OPA Group 196 197 #ifdef __cplusplus 198 #endif 199 200 #endif /* __OPA_H__ */ 201 /******************************************************************************* 202 * EOF (not truncated) 203 ******************************************************************************/ 204 205 206