em_opamp.h 36 KB

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