efm32_opamp.h 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538
  1. /**************************************************************************//**
  2. * @file
  3. * @brief Operational Amplifier (OPAMP) peripheral API for EFM32.
  4. * @author Energy Micro AS
  5. * @version 2.0.0
  6. ******************************************************************************
  7. * @section License
  8. * <b>(C) Copyright 2011 Energy Micro AS, http://www.energymicro.com</b>
  9. ******************************************************************************
  10. *
  11. * This source code is the property of Energy Micro AS. The source and compiled
  12. * code may only be used on Energy Micro "EFM32" microcontrollers.
  13. *
  14. * This copyright notice may not be removed from the source code nor changed.
  15. *
  16. * DISCLAIMER OF WARRANTY/LIMITATION OF REMEDIES: Energy Micro AS has no
  17. * obligation to support this Software. Energy Micro AS is providing the
  18. * Software "AS IS", with no express or implied warranties of any kind,
  19. * including, but not limited to, any implied warranties of merchantability
  20. * or fitness for any particular purpose or warranties against infringement
  21. * of any proprietary rights of a third party.
  22. *
  23. * Energy Micro AS will not be liable for any consequential, incidental, or
  24. * special damages, or any other relief, or for any claim by any third party,
  25. * arising from your use of this Software.
  26. *
  27. *****************************************************************************/
  28. #ifndef __EFM32_OPAMP_H
  29. #define __EFM32_OPAMP_H
  30. #include "efm32.h"
  31. #if defined(OPAMP_PRESENT) && (OPAMP_COUNT == 1)
  32. #ifdef __cplusplus
  33. extern "C" {
  34. #endif
  35. #include <stdint.h>
  36. #include <stdbool.h>
  37. #include "efm32_dac.h"
  38. /***************************************************************************//**
  39. * @addtogroup EFM32_Library
  40. * @{
  41. ******************************************************************************/
  42. /***************************************************************************//**
  43. * @addtogroup OPAMP
  44. * @{
  45. ******************************************************************************/
  46. /** @cond DO_NOT_INCLUDE_WITH_DOXYGEN */
  47. /** Validation of DAC OPA number for assert statements. */
  48. #define DAC_OPA_VALID(opa) ((opa) <= OPA2)
  49. /** @endcond */
  50. /*******************************************************************************
  51. ******************************** ENUMS ************************************
  52. ******************************************************************************/
  53. /** OPAMP selector values. */
  54. typedef enum
  55. {
  56. OPA0 = 0, /**< Select OPA0. */
  57. OPA1 = 1, /**< Select OPA1. */
  58. OPA2 = 2 /**< Select OPA2. */
  59. } OPAMP_TypeDef;
  60. /** OPAMP negative terminal input selection values. */
  61. typedef enum
  62. {
  63. opaNegSelDisable = DAC_OPA0MUX_NEGSEL_DISABLE, /**< Input disabled. */
  64. opaNegSelUnityGain = DAC_OPA0MUX_NEGSEL_UG, /**< Unity gain feedback path. */
  65. opaNegSelResTap = DAC_OPA0MUX_NEGSEL_OPATAP, /**< Feedback resistor ladder tap. */
  66. opaNegSelNegPad = DAC_OPA0MUX_NEGSEL_NEGPAD /**< Negative pad as input. */
  67. } OPAMP_NegSel_TypeDef;
  68. /** OPAMP positive terminal input selection values. */
  69. typedef enum
  70. {
  71. opaPosSelDisable = DAC_OPA0MUX_POSSEL_DISABLE, /**< Input disabled. */
  72. opaPosSelDac = DAC_OPA0MUX_POSSEL_DAC, /**< DAC as input (not OPA2). */
  73. opaPosSelPosPad = DAC_OPA0MUX_POSSEL_POSPAD, /**< Positive pad as input. */
  74. opaPosSelOpaIn = DAC_OPA0MUX_POSSEL_OPA1IN, /**< Input from OPAx. */
  75. opaPosSelResTapOpa0 = DAC_OPA0MUX_POSSEL_OPATAP /**< Feedback resistor ladder tap from OPA0. */
  76. } OPAMP_PosSel_TypeDef;
  77. /** OPAMP output terminal selection values. */
  78. typedef enum
  79. {
  80. opaOutModeDisable = DAC_OPA0MUX_OUTMODE_DISABLE, /**< OPA output disabled. */
  81. opaOutModeMain = DAC_OPA0MUX_OUTMODE_MAIN, /**< Main output to pin enabled. */
  82. opaOutModeAlt = DAC_OPA0MUX_OUTMODE_ALT, /**< Alternate output(s) enabled (not OPA2). */
  83. opaOutModeAll = DAC_OPA0MUX_OUTMODE_ALL /**< Both main and alternate enabled (not OPA2). */
  84. } OPAMP_OutMode_TypeDef;
  85. /** OPAMP gain values. */
  86. typedef enum
  87. {
  88. opaResSelDefault = DAC_OPA0MUX_RESSEL_DEFAULT, /**< Default value when resistor ladder is unused. */
  89. opaResSelR2eq0_33R1 = DAC_OPA0MUX_RESSEL_RES0, /**< R2 = 0.33 * R1 */
  90. opaResSelR2eqR1 = DAC_OPA0MUX_RESSEL_RES1, /**< R2 = R1 */
  91. opaResSelR1eq1_67R1 = DAC_OPA0MUX_RESSEL_RES2, /**< R2 = 1.67 R1 */
  92. opaResSelR2eq2R1 = DAC_OPA0MUX_RESSEL_RES3, /**< R2 = 2 * R1 */
  93. opaResSelR2eq3R1 = DAC_OPA0MUX_RESSEL_RES4, /**< R2 = 3 * R1 */
  94. opaResSelR2eq4_33R1 = DAC_OPA0MUX_RESSEL_RES5, /**< R2 = 4.33 * R1 */
  95. opaResSelR2eq7R1 = DAC_OPA0MUX_RESSEL_RES6, /**< R2 = 7 * R1 */
  96. opaResSelR2eq15R1 = DAC_OPA0MUX_RESSEL_RES7 /**< R2 = 15 * R1 */
  97. } OPAMP_ResSel_TypeDef;
  98. /** OPAMP resistor ladder input selector values. */
  99. typedef enum
  100. {
  101. opaResInMuxDisable = DAC_OPA0MUX_RESINMUX_DISABLE, /**< Resistor ladder disabled. */
  102. opaResInMuxOpaIn = DAC_OPA0MUX_RESINMUX_OPA2INP, /**< Input from OPAx. */
  103. opaResInMuxNegPad = DAC_OPA0MUX_RESINMUX_NEGPAD, /**< Input from negative pad. */
  104. opaResInMuxPosPad = DAC_OPA0MUX_RESINMUX_POSPAD, /**< Input from positive pad. */
  105. opaResInMuxVss = DAC_OPA0MUX_RESINMUX_VSS /**< Input connected to Vss. */
  106. } OPAMP_ResInMux_TypeDef;
  107. /*******************************************************************************
  108. ******************************* STRUCTS ***********************************
  109. ******************************************************************************/
  110. /** OPAMP init structure. */
  111. typedef struct
  112. {
  113. OPAMP_NegSel_TypeDef negSel; /**< Select input source for negative terminal. */
  114. OPAMP_PosSel_TypeDef posSel; /**< Select input source for positive terminal. */
  115. OPAMP_OutMode_TypeDef outMode; /**< Output terminal connection. */
  116. OPAMP_ResSel_TypeDef resSel; /**< Select R2/R1 resistor ratio. */
  117. OPAMP_ResInMux_TypeDef resInMux; /**< Select input source for resistor ladder. */
  118. uint32_t outPen; /**< Select alternate output terminal connections. */
  119. uint32_t bias; /**< Set OPAMP bias current. */
  120. bool halfBias; /**< Divide OPAMP bias current by 2. */
  121. bool lpfPosPadDisable; /**< Disable low pass filter on positive pad. */
  122. bool lpfNegPadDisable; /**< Disable low pass filter on negative pad. */
  123. bool nextOut; /**< Enable NEXTOUT signal source. */
  124. bool npEn; /**< Enable positive pad. */
  125. bool ppEn; /**< Enable negative pad. */
  126. bool shortInputs; /**< Short OPAMP input terminals. */
  127. bool hcmDisable; /**< Disable input rail-to-rail capability. */
  128. bool defaultOffset; /**< Use factory calibrated opamp offset value. */
  129. uint32_t offset; /**< Opamp offset value when @ref defaultOffset is false.*/
  130. } OPAMP_Init_TypeDef;
  131. /** Configuration of OPA0/1 in unity gain voltage follower mode. */
  132. #define OPA_INIT_UNITY_GAIN \
  133. { \
  134. opaNegSelUnityGain, /* Unity gain. */ \
  135. opaPosSelPosPad, /* Pos input from pad. */ \
  136. opaOutModeMain, /* Main output enabled. */ \
  137. opaResSelDefault, /* Resistor ladder is not used. */ \
  138. opaResInMuxDisable, /* Resistor ladder disabled. */ \
  139. 0, /* No alternate outputs enabled. */ \
  140. _DAC_BIASPROG_BIASPROG_DEFAULT, /* Default bias setting. */ \
  141. _DAC_BIASPROG_HALFBIAS_DEFAULT, /* Default half-bias setting. */ \
  142. false, /* No low pass filter on pos pad. */ \
  143. false, /* No low pass filter on neg pad. */ \
  144. false, /* No nextout output enabled. */ \
  145. false, /* Neg pad disabled. */ \
  146. true, /* Pos pad enabled, used as signal input. */ \
  147. false, /* No shorting of inputs. */ \
  148. false, /* Rail-to-rail input enabled. */ \
  149. true, /* Use factory calibrated opamp offset. */ \
  150. 0 /* Opamp offset value (not used). */ \
  151. }
  152. /** Configuration of OPA2 in unity gain voltage follower mode. */
  153. #define OPA_INIT_UNITY_GAIN_OPA2 \
  154. { \
  155. opaNegSelUnityGain, /* Unity gain. */ \
  156. opaPosSelPosPad, /* Pos input from pad. */ \
  157. opaOutModeMain, /* Main output enabled. */ \
  158. opaResSelDefault, /* Resistor ladder is not used. */ \
  159. opaResInMuxDisable, /* Resistor ladder disabled. */ \
  160. DAC_OPA0MUX_OUTPEN_OUT0, /* Alternate output 0 enabled. */ \
  161. _DAC_BIASPROG_BIASPROG_DEFAULT, /* Default bias setting. */ \
  162. _DAC_BIASPROG_HALFBIAS_DEFAULT, /* Default half-bias setting. */ \
  163. false, /* No low pass filter on pos pad. */ \
  164. false, /* No low pass filter on neg pad. */ \
  165. false, /* No nextout output enabled. */ \
  166. false, /* Neg pad disabled. */ \
  167. true, /* Pos pad enabled, used as signal input. */ \
  168. false, /* No shorting of inputs. */ \
  169. false, /* Rail-to-rail input enabled. */ \
  170. true, /* Use factory calibrated opamp offset. */ \
  171. 0 /* Opamp offset value (not used). */ \
  172. }
  173. /** Configuration of OPA0/1 in non-inverting amplifier mode. */
  174. #define OPA_INIT_NON_INVERTING \
  175. { \
  176. opaNegSelResTap, /* Neg input from resistor ladder tap. */ \
  177. opaPosSelPosPad, /* Pos input from pad. */ \
  178. opaOutModeMain, /* Main output enabled. */ \
  179. opaResSelR2eq0_33R1, /* R2 = 1/3 R1 */ \
  180. opaResInMuxNegPad, /* Resistor ladder input from neg pad. */ \
  181. 0, /* No alternate outputs enabled. */ \
  182. _DAC_BIASPROG_BIASPROG_DEFAULT, /* Default bias setting. */ \
  183. _DAC_BIASPROG_HALFBIAS_DEFAULT, /* Default half-bias setting. */ \
  184. false, /* No low pass filter on pos pad. */ \
  185. false, /* No low pass filter on neg pad. */ \
  186. false, /* No nextout output enabled. */ \
  187. true, /* Neg pad enabled, used as signal ground. */ \
  188. true, /* Pos pad enabled, used as signal input. */ \
  189. false, /* No shorting of inputs. */ \
  190. false, /* Rail-to-rail input enabled. */ \
  191. true, /* Use factory calibrated opamp offset. */ \
  192. 0 /* Opamp offset value (not used). */ \
  193. }
  194. /** Configuration of OPA2 in non-inverting amplifier mode. */
  195. #define OPA_INIT_NON_INVERTING_OPA2 \
  196. { \
  197. opaNegSelResTap, /* Neg input from resistor ladder tap. */ \
  198. opaPosSelPosPad, /* Pos input from pad. */ \
  199. opaOutModeMain, /* Main output enabled. */ \
  200. opaResSelR2eq0_33R1, /* R2 = 1/3 R1 */ \
  201. opaResInMuxNegPad, /* Resistor ladder input from neg pad. */ \
  202. DAC_OPA0MUX_OUTPEN_OUT0, /* Alternate output 0 enabled. */ \
  203. _DAC_BIASPROG_BIASPROG_DEFAULT, /* Default bias setting. */ \
  204. _DAC_BIASPROG_HALFBIAS_DEFAULT, /* Default half-bias setting. */ \
  205. false, /* No low pass filter on pos pad. */ \
  206. false, /* No low pass filter on neg pad. */ \
  207. false, /* No nextout output enabled. */ \
  208. true, /* Neg pad enabled, used as signal ground. */ \
  209. true, /* Pos pad enabled, used as signal input. */ \
  210. false, /* No shorting of inputs. */ \
  211. false, /* Rail-to-rail input enabled. */ \
  212. true, /* Use factory calibrated opamp offset. */ \
  213. 0 /* Opamp offset value (not used). */ \
  214. }
  215. /** Configuration of OPA0/1 in inverting amplifier mode. */
  216. #define OPA_INIT_INVERTING \
  217. { \
  218. opaNegSelResTap, /* Neg input from resistor ladder tap. */ \
  219. opaPosSelPosPad, /* Pos input from pad. */ \
  220. opaOutModeMain, /* Main output enabled. */ \
  221. opaResSelR2eqR1, /* R2 = R1 */ \
  222. opaResInMuxNegPad, /* Resistor ladder input from neg pad. */ \
  223. 0, /* No alternate outputs enabled. */ \
  224. _DAC_BIASPROG_BIASPROG_DEFAULT, /* Default bias setting. */ \
  225. _DAC_BIASPROG_HALFBIAS_DEFAULT, /* Default half-bias setting. */ \
  226. false, /* No low pass filter on pos pad. */ \
  227. false, /* No low pass filter on neg pad. */ \
  228. false, /* No nextout output enabled. */ \
  229. true, /* Neg pad enabled, used as signal input. */ \
  230. true, /* Pos pad enabled, used as signal ground. */ \
  231. false, /* No shorting of inputs. */ \
  232. false, /* Rail-to-rail input enabled. */ \
  233. true, /* Use factory calibrated opamp offset. */ \
  234. 0 /* Opamp offset value (not used). */ \
  235. }
  236. /** Configuration of OPA2 in inverting amplifier mode. */
  237. #define OPA_INIT_INVERTING_OPA2 \
  238. { \
  239. opaNegSelResTap, /* Neg input from resistor ladder tap. */ \
  240. opaPosSelPosPad, /* Pos input from pad. */ \
  241. opaOutModeMain, /* Main output enabled. */ \
  242. opaResSelR2eqR1, /* R2 = R1 */ \
  243. opaResInMuxNegPad, /* Resistor ladder input from neg pad. */ \
  244. DAC_OPA0MUX_OUTPEN_OUT0, /* Alternate output 0 enabled. */ \
  245. _DAC_BIASPROG_BIASPROG_DEFAULT, /* Default bias setting. */ \
  246. _DAC_BIASPROG_HALFBIAS_DEFAULT, /* Default half-bias setting. */ \
  247. false, /* No low pass filter on pos pad. */ \
  248. false, /* No low pass filter on neg pad. */ \
  249. false, /* No nextout output enabled. */ \
  250. true, /* Neg pad enabled, used as signal input. */ \
  251. true, /* Pos pad enabled, used as signal ground. */ \
  252. false, /* No shorting of inputs. */ \
  253. false, /* Rail-to-rail input enabled. */ \
  254. true, /* Use factory calibrated opamp offset. */ \
  255. 0 /* Opamp offset value (not used). */ \
  256. }
  257. /** Configuration of OPA0 in cascaded non-inverting amplifier mode. */
  258. #define OPA_INIT_CASCADED_NON_INVERTING_OPA0 \
  259. { \
  260. opaNegSelResTap, /* Neg input from resistor ladder tap. */ \
  261. opaPosSelPosPad, /* Pos input from pad. */ \
  262. opaOutModeAll, /* Both main and alternate outputs. */ \
  263. opaResSelR2eq0_33R1, /* R2 = 1/3 R1 */ \
  264. opaResInMuxNegPad, /* Resistor ladder input from neg pad. */ \
  265. 0, /* No alternate outputs enabled. */ \
  266. _DAC_BIASPROG_BIASPROG_DEFAULT, /* Default bias setting. */ \
  267. _DAC_BIASPROG_HALFBIAS_DEFAULT, /* Default half-bias setting. */ \
  268. false, /* No low pass filter on pos pad. */ \
  269. false, /* No low pass filter on neg pad. */ \
  270. true, /* Pass output to next stage (OPA1). */ \
  271. true, /* Neg pad enabled, used as signal ground. */ \
  272. true, /* Pos pad enabled, used as signal input. */ \
  273. false, /* No shorting of inputs. */ \
  274. false, /* Rail-to-rail input enabled. */ \
  275. true, /* Use factory calibrated opamp offset. */ \
  276. 0 /* Opamp offset value (not used). */ \
  277. }
  278. /** Configuration of OPA1 in cascaded non-inverting amplifier mode. */
  279. #define OPA_INIT_CASCADED_NON_INVERTING_OPA1 \
  280. { \
  281. opaNegSelResTap, /* Neg input from resistor ladder tap. */ \
  282. opaPosSelOpaIn, /* Pos input from OPA0 output. */ \
  283. opaOutModeAll, /* Both main and alternate outputs. */ \
  284. opaResSelR2eq0_33R1, /* R2 = 1/3 R1 */ \
  285. opaResInMuxNegPad, /* Resistor ladder input from neg pad. */ \
  286. 0, /* No alternate outputs enabled. */ \
  287. _DAC_BIASPROG_BIASPROG_DEFAULT, /* Default bias setting. */ \
  288. _DAC_BIASPROG_HALFBIAS_DEFAULT, /* Default half-bias setting. */ \
  289. false, /* No low pass filter on pos pad. */ \
  290. false, /* No low pass filter on neg pad. */ \
  291. true, /* Pass output to next stage (OPA2). */ \
  292. true, /* Neg pad enabled, used as signal ground. */ \
  293. false, /* Pos pad disabled. */ \
  294. false, /* No shorting of inputs. */ \
  295. false, /* Rail-to-rail input enabled. */ \
  296. true, /* Use factory calibrated opamp offset. */ \
  297. 0 /* Opamp offset value (not used). */ \
  298. }
  299. /** Configuration of OPA2 in cascaded non-inverting amplifier mode. */
  300. #define OPA_INIT_CASCADED_NON_INVERTING_OPA2 \
  301. { \
  302. opaNegSelResTap, /* Neg input from resistor ladder tap. */ \
  303. opaPosSelOpaIn, /* Pos input from OPA1 output. */ \
  304. opaOutModeMain, /* Main output enabled. */ \
  305. opaResSelR2eq0_33R1, /* R2 = 1/3 R1 */ \
  306. opaResInMuxNegPad, /* Resistor ladder input from neg pad. */ \
  307. DAC_OPA0MUX_OUTPEN_OUT0, /* Alternate output 0 enabled. */ \
  308. _DAC_BIASPROG_BIASPROG_DEFAULT, /* Default bias setting. */ \
  309. _DAC_BIASPROG_HALFBIAS_DEFAULT, /* Default half-bias setting. */ \
  310. false, /* No low pass filter on pos pad. */ \
  311. false, /* No low pass filter on neg pad. */ \
  312. false, /* No nextout output enabled. */ \
  313. true, /* Neg pad enabled, used as signal ground. */ \
  314. false, /* Pos pad disabled. */ \
  315. false, /* No shorting of inputs. */ \
  316. false, /* Rail-to-rail input enabled. */ \
  317. true, /* Use factory calibrated opamp offset. */ \
  318. 0 /* Opamp offset value (not used). */ \
  319. }
  320. /** Configuration of OPA0 in cascaded inverting amplifier mode. */
  321. #define OPA_INIT_CASCADED_INVERTING_OPA0 \
  322. { \
  323. opaNegSelResTap, /* Neg input from resistor ladder tap. */ \
  324. opaPosSelPosPad, /* Pos input from pad. */ \
  325. opaOutModeAll, /* Both main and alternate outputs. */ \
  326. opaResSelR2eqR1, /* R2 = R1 */ \
  327. opaResInMuxNegPad, /* Resistor ladder input from neg pad. */ \
  328. 0, /* No alternate outputs enabled. */ \
  329. _DAC_BIASPROG_BIASPROG_DEFAULT, /* Default bias setting. */ \
  330. _DAC_BIASPROG_HALFBIAS_DEFAULT, /* Default half-bias setting. */ \
  331. false, /* No low pass filter on pos pad. */ \
  332. false, /* No low pass filter on neg pad. */ \
  333. true, /* Pass output to next stage (OPA1). */ \
  334. true, /* Neg pad enabled, used as signal input. */ \
  335. true, /* Pos pad enabled, used as signal ground. */ \
  336. false, /* No shorting of inputs. */ \
  337. false, /* Rail-to-rail input enabled. */ \
  338. true, /* Use factory calibrated opamp offset. */ \
  339. 0 /* Opamp offset value (not used). */ \
  340. }
  341. /** Configuration of OPA1 in cascaded inverting amplifier mode. */
  342. #define OPA_INIT_CASCADED_INVERTING_OPA1 \
  343. { \
  344. opaNegSelResTap, /* Neg input from resistor ladder tap. */ \
  345. opaPosSelPosPad, /* Pos input from pad. */ \
  346. opaOutModeAll, /* Both main and alternate outputs. */ \
  347. opaResSelR2eqR1, /* R2 = R1 */ \
  348. opaResInMuxOpaIn, /* Resistor ladder input from OPA0. */ \
  349. 0, /* No alternate outputs enabled. */ \
  350. _DAC_BIASPROG_BIASPROG_DEFAULT, /* Default bias setting. */ \
  351. _DAC_BIASPROG_HALFBIAS_DEFAULT, /* Default half-bias setting. */ \
  352. false, /* No low pass filter on pos pad. */ \
  353. false, /* No low pass filter on neg pad. */ \
  354. true, /* Pass output to next stage (OPA2). */ \
  355. false, /* Neg pad disabled. */ \
  356. true, /* Pos pad enabled, used as signal ground. */ \
  357. false, /* No shorting of inputs. */ \
  358. false, /* Rail-to-rail input enabled. */ \
  359. true, /* Use factory calibrated opamp offset. */ \
  360. 0 /* Opamp offset value (not used). */ \
  361. }
  362. /** Configuration of OPA2 in cascaded inverting amplifier mode. */
  363. #define OPA_INIT_CASCADED_INVERTING_OPA2 \
  364. { \
  365. opaNegSelResTap, /* Neg input from resistor ladder tap. */ \
  366. opaPosSelPosPad, /* Pos input from pad. */ \
  367. opaOutModeMain, /* Main output enabled. */ \
  368. opaResSelR2eqR1, /* R2 = R1 */ \
  369. opaResInMuxOpaIn, /* Resistor ladder input from OPA1. */ \
  370. DAC_OPA0MUX_OUTPEN_OUT0, /* Alternate output 0 enabled. */ \
  371. _DAC_BIASPROG_BIASPROG_DEFAULT, /* Default bias setting. */ \
  372. _DAC_BIASPROG_HALFBIAS_DEFAULT, /* Default half-bias setting. */ \
  373. false, /* No low pass filter on pos pad. */ \
  374. false, /* No low pass filter on neg pad. */ \
  375. false, /* No nextout output enabled. */ \
  376. false, /* Neg pad disabled. */ \
  377. true, /* Pos pad enabled, used as signal ground. */ \
  378. false, /* No shorting of inputs. */ \
  379. false, /* Rail-to-rail input enabled. */ \
  380. true, /* Use factory calibrated opamp offset. */ \
  381. 0 /* Opamp offset value (not used). */ \
  382. }
  383. /** Configuration of OPA0 in two-opamp differential driver mode. */
  384. #define OPA_INIT_DIFF_DRIVER_OPA0 \
  385. { \
  386. opaNegSelUnityGain, /* Unity gain. */ \
  387. opaPosSelPosPad, /* Pos input from pad. */ \
  388. opaOutModeAll, /* Both main and alternate outputs. */ \
  389. opaResSelDefault, /* Resistor ladder is not used. */ \
  390. opaResInMuxDisable, /* Resistor ladder disabled. */ \
  391. 0, /* No alternate outputs enabled. */ \
  392. _DAC_BIASPROG_BIASPROG_DEFAULT, /* Default bias setting. */ \
  393. _DAC_BIASPROG_HALFBIAS_DEFAULT, /* Default half-bias setting. */ \
  394. false, /* No low pass filter on pos pad. */ \
  395. false, /* No low pass filter on neg pad. */ \
  396. true, /* Pass output to next stage (OPA1). */ \
  397. false, /* Neg pad disabled. */ \
  398. true, /* Pos pad enabled, used as signal input. */ \
  399. false, /* No shorting of inputs. */ \
  400. false, /* Rail-to-rail input enabled. */ \
  401. true, /* Use factory calibrated opamp offset. */ \
  402. 0 /* Opamp offset value (not used). */ \
  403. }
  404. /** Configuration of OPA1 in two-opamp differential driver mode. */
  405. #define OPA_INIT_DIFF_DRIVER_OPA1 \
  406. { \
  407. opaNegSelResTap, /* Neg input from resistor ladder tap. */ \
  408. opaPosSelPosPad, /* Pos input from pad. */ \
  409. opaOutModeMain, /* Main output enabled. */ \
  410. opaResSelR2eqR1, /* R2 = R1 */ \
  411. opaResInMuxOpaIn, /* Resistor ladder input from OPA0. */ \
  412. 0, /* No alternate outputs enabled. */ \
  413. _DAC_BIASPROG_BIASPROG_DEFAULT, /* Default bias setting. */ \
  414. _DAC_BIASPROG_HALFBIAS_DEFAULT, /* Default half-bias setting. */ \
  415. false, /* No low pass filter on pos pad. */ \
  416. false, /* No low pass filter on neg pad. */ \
  417. false, /* No nextout output enabled. */ \
  418. false, /* Neg pad disabled. */ \
  419. true, /* Pos pad enabled, used as signal ground. */ \
  420. false, /* No shorting of inputs. */ \
  421. false, /* Rail-to-rail input enabled. */ \
  422. true, /* Use factory calibrated opamp offset. */ \
  423. 0 /* Opamp offset value (not used). */ \
  424. }
  425. /** Configuration of OPA0 in three-opamp differential receiver mode. */
  426. #define OPA_INIT_DIFF_RECEIVER_OPA0 \
  427. { \
  428. opaNegSelUnityGain, /* Unity gain. */ \
  429. opaPosSelPosPad, /* Pos input from pad. */ \
  430. opaOutModeAll, /* Both main and alternate outputs. */ \
  431. opaResSelR2eqR1, /* R2 = R1 */ \
  432. opaResInMuxNegPad, /* Resistor ladder input from neg pad. */ \
  433. 0, /* No alternate outputs enabled. */ \
  434. _DAC_BIASPROG_BIASPROG_DEFAULT, /* Default bias setting. */ \
  435. _DAC_BIASPROG_HALFBIAS_DEFAULT, /* Default half-bias setting. */ \
  436. false, /* No low pass filter on pos pad. */ \
  437. false, /* No low pass filter on neg pad. */ \
  438. true, /* Pass output to next stage (OPA2). */ \
  439. true, /* Neg pad enabled, used as signal ground. */ \
  440. true, /* Pos pad enabled, used as signal input. */ \
  441. false, /* No shorting of inputs. */ \
  442. false, /* Rail-to-rail input enabled. */ \
  443. true, /* Use factory calibrated opamp offset. */ \
  444. 0 /* Opamp offset value (not used). */ \
  445. }
  446. /** Configuration of OPA1 in three-opamp differential receiver mode. */
  447. #define OPA_INIT_DIFF_RECEIVER_OPA1 \
  448. { \
  449. opaNegSelUnityGain, /* Unity gain. */ \
  450. opaPosSelPosPad, /* Pos input from pad. */ \
  451. opaOutModeAll, /* Both main and alternate outputs. */ \
  452. opaResSelDefault, /* Resistor ladder is not used. */ \
  453. opaResInMuxDisable, /* Disable resistor ladder. */ \
  454. 0, /* No alternate outputs enabled. */ \
  455. _DAC_BIASPROG_BIASPROG_DEFAULT, /* Default bias setting. */ \
  456. _DAC_BIASPROG_HALFBIAS_DEFAULT, /* Default half-bias setting. */ \
  457. false, /* No low pass filter on pos pad. */ \
  458. false, /* No low pass filter on neg pad. */ \
  459. true, /* Pass output to next stage (OPA2). */ \
  460. false, /* Neg pad disabled. */ \
  461. true, /* Pos pad enabled, used as signal input. */ \
  462. false, /* No shorting of inputs. */ \
  463. false, /* Rail-to-rail input enabled. */ \
  464. true, /* Use factory calibrated opamp offset. */ \
  465. 0 /* Opamp offset value (not used). */ \
  466. }
  467. /** Configuration of OPA2 in three-opamp differential receiver mode. */
  468. #define OPA_INIT_DIFF_RECEIVER_OPA2 \
  469. { \
  470. opaNegSelResTap, /* Input from resistor ladder tap. */ \
  471. opaPosSelResTapOpa0, /* Input from OPA0 resistor ladder tap. */ \
  472. opaOutModeMain, /* Main output enabled. */ \
  473. opaResSelR2eqR1, /* R2 = R1 */ \
  474. opaResInMuxOpaIn, /* Resistor ladder input from OPA1. */ \
  475. DAC_OPA0MUX_OUTPEN_OUT0, /* Enable alternate output 0. */ \
  476. _DAC_BIASPROG_BIASPROG_DEFAULT, /* Default bias setting. */ \
  477. _DAC_BIASPROG_HALFBIAS_DEFAULT, /* Default half-bias setting. */ \
  478. false, /* No low pass filter on pos pad. */ \
  479. false, /* No low pass filter on neg pad. */ \
  480. false, /* No nextout output enabled. */ \
  481. false, /* Neg pad disabled. */ \
  482. false, /* Pos pad disabled. */ \
  483. false, /* No shorting of inputs. */ \
  484. false, /* Rail-to-rail input enabled. */ \
  485. true, /* Use factory calibrated opamp offset. */ \
  486. 0 /* Opamp offset value (not used). */ \
  487. }
  488. /*******************************************************************************
  489. ***************************** PROTOTYPES **********************************
  490. ******************************************************************************/
  491. void OPAMP_Disable(DAC_TypeDef *dac, OPAMP_TypeDef opa);
  492. void OPAMP_Enable(DAC_TypeDef *dac, OPAMP_TypeDef opa, OPAMP_Init_TypeDef *init);
  493. /** @} (end addtogroup OPAMP) */
  494. /** @} (end addtogroup EFM32_Library) */
  495. #ifdef __cplusplus
  496. }
  497. #endif
  498. #endif /* defined( OPAMP_PRESENT ) && ( OPAMP_COUNT == 1 ) */
  499. #endif /* __EFM32_DAC_H */