summaryrefslogtreecommitdiff
path: root/bsp/samd21/sam_d2x_asflib/sam0/drivers/opamp/opamp.h
blob: 7178ff7525bbeae312868c72bb4b56d4cd603301 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
/**
 * \file
 *
 * \brief SAM Operational Amplifier Controller (OPAMP) Driver
 *
 * Copyright (C) 2014-2015 Atmel Corporation. All rights reserved.
 *
 * \asf_license_start
 *
 * \page License
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 * 1. Redistributions of source code must retain the above copyright notice,
 *    this list of conditions and the following disclaimer.
 *
 * 2. Redistributions in binary form must reproduce the above copyright notice,
 *    this list of conditions and the following disclaimer in the documentation
 *    and/or other materials provided with the distribution.
 *
 * 3. The name of Atmel may not be used to endorse or promote products derived
 *    from this software without specific prior written permission.
 *
 * 4. This software may only be redistributed and used in connection with an
 *    Atmel microcontroller product.
 *
 * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
 * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 *
 * \asf_license_stop
 *
 */
/*
 * Support and FAQ: visit <a href="http://www.atmel.com/design-support/">Atmel Support</a>
 */

#ifndef OPAMP_H_INCLUDED
#define OPAMP_H_INCLUDED

/**
 * \defgroup asfdoc_sam0_opamp_group SAM Operational Amplifier Controller (OPAMP) Driver
 *
 * This driver for Atmel&reg; | SMART ARM&reg;-based microcontrollers provides an interface for the configuration
 * and management of the device's Operational Amplifier Controller functionality.
 *
 * The following peripheral is used by this module:
 *  - OPAMP (Operational Amplifier Controller)
 *
 * The following devices can use this module:
 *  - Atmel | SMART SAM L21
 *
 * The outline of this documentation is as follows:
 *  - \ref asfdoc_sam0_opamp_prerequisites
 *  - \ref asfdoc_sam0_opamp_module_overview
 *  - \ref asfdoc_sam0_opamp_special_considerations
 *  - \ref asfdoc_sam0_opamp_extra_info
 *  - \ref asfdoc_sam0_opamp_examples
 *  - \ref asfdoc_sam0_opamp_api_overview
 *
 *
 * \section asfdoc_sam0_opamp_prerequisites Prerequisites
 *
 * There are no prerequisites for this module.
 *
 *
 * \section asfdoc_sam0_opamp_module_overview Module Overview
 *
 * The OPAMP is an individually configurable low power, general purpose operational
 * amplifier offering a high degree of flexibility and rail-to-rail inputs.
 *
 * Each operational amplifier can be configured in standalone operational amplifier
 * and operational amplifier with built-in feedback. All OPAMPs can be cascaded
 * to support circuits such as differential amplifiers.
 * \note For more detail configuration reference, refer to the "Built-in Modes"
 * section in the device datasheet.
 *
 * Each OPAMP has one positive and one negative input which can be flexible chosen
 * from analog input pins including the output of another OPAMP, internal inputs
 * such as the DAC or the resistor ladder, and the ground.
 *
 * Each OPAMP output can be selected as input for AC or ADC, also available
 * on I/O pins.
 *
 * Four modes are available to select the trade-off between speed and power
 * consumption to best fit the application requirements and optimize the power
 * consumption.
 *
 * \section asfdoc_sam0_opamp_special_considerations Special Considerations
 *
 * There are no special considerations for this module.
 *
 *
 * \section asfdoc_sam0_opamp_extra_info Extra Information
 *
 * For extra information, see \ref asfdoc_sam0_opamp_extra. This includes:
 *  - \ref asfdoc_sam0_opamp_extra_acronyms
 *  - \ref asfdoc_sam0_opamp_extra_dependencies
 *  - \ref asfdoc_sam0_opamp_extra_errata
 *  - \ref asfdoc_sam0_opamp_extra_history
 *
 *
 * \section asfdoc_sam0_opamp_examples Examples
 *
 * For a list of examples related to this driver, see
 * \ref asfdoc_sam0_opamp_exqsg.
 *
 *
 * \section asfdoc_sam0_opamp_api_overview API Overview
 * @{
 */

#include <compiler.h>
#include <system.h>

#ifdef __cplusplus
extern "C" {
#endif

/**
 * \brief OPAMP ID number enum.
 */
enum opamp_id {
	/** OPAMP 0  */
	OPAMP_0 = 0,
	/** OPAMP 1  */
	OPAMP_1 = 1,
	/** OPAMP 2  */
	OPAMP_2 = 2,
	/** OPAMP number  */
	OPAMP_NUM,
};

/**
 * \brief Negative input MUX selection configuration enum.
 *
 * Enum for the negative input of OPAMP0.
 */
enum opamp0_neg_mux {
	/** Negative I/O pin 0 */
	OPAMP0_NEG_MUX_PIN0 = OPAMP_OPAMPCTRL_MUXNEG(0),
	/** Resistor ladder 0 taps */
	OPAMP0_NEG_MUX_TAP0 = OPAMP_OPAMPCTRL_MUXNEG(1),
	/** OPAMP output */
	OPAMP0_NEG_MUX_OUT0 = OPAMP_OPAMPCTRL_MUXNEG(2),
	/** DAC output */
	OPAMP0_NEG_MUX_DAC = OPAMP_OPAMPCTRL_MUXNEG(3),
};

/**
 * \brief Negative input MUX selection configuration enum.
 *
 * Enum for the negative input of OPAMP1.
 */
enum opamp1_neg_mux {
	/** Negative I/O pin 1 */
	OPAMP1_NEG_MUX_PIN1 = OPAMP_OPAMPCTRL_MUXNEG(0),
	/** Resistor ladder 1 taps */
	OPAMP1_NEG_MUX_TAP1 = OPAMP_OPAMPCTRL_MUXNEG(1),
	/** OPAMP output */
	OPAMP1_NEG_MUX_OUT1 = OPAMP_OPAMPCTRL_MUXNEG(2),
	/** DAC output */
	OPAMP1_NEG_MUX_DAC = OPAMP_OPAMPCTRL_MUXNEG(3),
};

/**
 * \brief Negative input MUX selection configuration enum.
 *
 * Enum for the negative input of OPAMP2.
 */
enum opamp2_neg_mux {
	/** Negative I/O pin 2 */
	OPAMP2_NEG_MUX_PIN2 = OPAMP_OPAMPCTRL_MUXNEG(0),
	/** Resistor ladder 2 taps */
	OPAMP2_NEG_MUX_TAP2 = OPAMP_OPAMPCTRL_MUXNEG(1),
	/** OPAMP output */
	OPAMP2_NEG_MUX_OUT2 = OPAMP_OPAMPCTRL_MUXNEG(2),
	/** Negative I/O pin 0 */
	OPAMP2_NEG_MUX_PIN0 = OPAMP_OPAMPCTRL_MUXNEG(3),
	/** Negative I/O pin 1 */
	OPAMP2_NEG_MUX_PIN1 = OPAMP_OPAMPCTRL_MUXNEG(4),
	/** DAC output */
	OPAMP2_NEG_MUX_DAC = OPAMP_OPAMPCTRL_MUXNEG(5),
};

/**
 * \brief Positive input MUX selection configuration enum.
 *
 * Enum for the positive input of OPAMP0.
 */
enum opamp0_pos_mux {
	/** Positive I/O pin 0 */
	OPAMP0_POS_MUX_PIN0 = OPAMP_OPAMPCTRL_MUXPOS(0),
	/** Resistor ladder 0 taps */
	OPAMP0_POS_MUX_TAP0 = OPAMP_OPAMPCTRL_MUXPOS(1),
	/** DAC output */
	OPAMP0_POS_MUX_DAC = OPAMP_OPAMPCTRL_MUXPOS(2),
	/** Ground */
	OPAMP0_POS_MUX_GND = OPAMP_OPAMPCTRL_MUXPOS(3),
};

/**
 * \brief Positive input MUX selection configuration enum.
 *
 * Enum for the positive input of OPAMP1.
 */
enum opamp1_pos_mux {
	/** Positive I/O pin 1 */
	OPAMP1_POS_MUX_PIN1 = OPAMP_OPAMPCTRL_MUXPOS(0),
	/** Resistor ladder 1 taps */
	OPAMP1_POS_MUX_TAP1 = OPAMP_OPAMPCTRL_MUXPOS(1),
	/** OPAMP0 output */
	OPAMP1_POS_MUX_OUT0 = OPAMP_OPAMPCTRL_MUXPOS(2),
	/** Ground */
	OPAMP1_POS_MUX_GND = OPAMP_OPAMPCTRL_MUXPOS(3),
};

/**
 * \brief Positive input MUX selection configuration enum.
 *
 * Enum for the positive input of OPAMP2.
 */
enum opamp2_pos_mux {
	/** Positive I/O pin 2 */
	OPAMP2_POS_MUX_PIN2 = OPAMP_OPAMPCTRL_MUXPOS(0),
	/** Resistor ladder 2 taps */
	OPAMP2_POS_MUX_TAP2 = OPAMP_OPAMPCTRL_MUXPOS(1),
	/** OPAMP1 output */
	OPAMP2_POS_MUX_OUT1 = OPAMP_OPAMPCTRL_MUXPOS(2),
	/** Ground */
	OPAMP2_POS_MUX_GND = OPAMP_OPAMPCTRL_MUXPOS(3),
	/** Positive I/O pin 0 */
	OPAMP2_POS_MUX_PIN0 = OPAMP_OPAMPCTRL_MUXPOS(4),
	/** Positive I/O pin 1 */
	OPAMP2_POS_MUX_PIN1 = OPAMP_OPAMPCTRL_MUXPOS(5),
	/** Resistor ladder 0 taps */
	OPAMP2_POS_MUX_TAP0 = OPAMP_OPAMPCTRL_MUXPOS(6),
};

/**
 * \brief Potentiometer selection MUX configuration enum.
 *
 * Enum for the potentiometer selection of OPAMP 0 to 2.
 */
enum opamp_pot_mux {
	/** Gain = R2/R1 = 1/7 */
	OPAMP_POT_MUX_14R_2R = OPAMP_OPAMPCTRL_POTMUX(0),
	/** Gain = R2/R1 = 1/3 */
	OPAMP_POT_MUX_12R_4R = OPAMP_OPAMPCTRL_POTMUX(1),
	/** Gain = R2/R1 = 1 */
	OPAMP_POT_MUX_8R_8R = OPAMP_OPAMPCTRL_POTMUX(2),
	/** Gain = R2/R1 = 1 + 2/3 */
	OPAMP_POT_MUX_6R_10R = OPAMP_OPAMPCTRL_POTMUX(3),
	/** Gain = R2/R1 = 3 */
	OPAMP_POT_MUX_4R_12R = OPAMP_OPAMPCTRL_POTMUX(4),
	/** Gain = R2/R1 = 4 + 1/3 */
	OPAMP_POT_MUX_3R_13R = OPAMP_OPAMPCTRL_POTMUX(5),
	/** Gain = R2/R1 = 7 */
	OPAMP_POT_MUX_2R_14R = OPAMP_OPAMPCTRL_POTMUX(6),
	/** Gain = R2/R1 = 15 */
	OPAMP_POT_MUX_R_15R = OPAMP_OPAMPCTRL_POTMUX(7),
};

/**
 * \brief Resistor 1 MUX selection configuration enum.
 *
 * Enum for the Resistor 1 of OPAMP0.
 */
enum opamp0_res1_mux {
	/** Positive input of OPAMP0 */
	OPAMP0_RES1_MUX_POS_PIN0 = OPAMP_OPAMPCTRL_RES1MUX(0),
	/** Negative input of OPAMP0 */
	OPAMP0_RES1_MUX_NEG_PIN0 = OPAMP_OPAMPCTRL_RES1MUX(1),
	/** DAC output */
	OPAMP0_RES1_MUX_DAC = OPAMP_OPAMPCTRL_RES1MUX(2),
	/** Ground */
	OPAMP0_RES1_MUX_GND = OPAMP_OPAMPCTRL_RES1MUX(3),
};

/**
 * \brief Resistor 1 MUX selection configuration enum.
 *
 * Enum for the Resistor 1 of OPAMP1.
 */
enum opamp1_res1_mux {
	/** Positive input of OPAMP1 */
	OPAMP1_RES1_MUX_POS_PIN0 = OPAMP_OPAMPCTRL_RES1MUX(0),
	/** Negative input of OPAMP1 */
	OPAMP1_RES1_MUX_NEG_PIN0 = OPAMP_OPAMPCTRL_RES1MUX(1),
	/** OPAMP0 output */
	OPAMP1_RES1_MUX_OUT0 = OPAMP_OPAMPCTRL_RES1MUX(2),
	/** Ground */
	OPAMP1_RES1_MUX_GND = OPAMP_OPAMPCTRL_RES1MUX(3),
};

/**
 * \brief Resistor 1 MUX selection configuration enum.
 *
 * Enum for the Resistor 1 of OPAMP2.
 */
enum opamp2_res1_mux {
	/** Positive input of OPAMP2 */
	OPAMP2_RES1_MUX_POS_PIN0 = OPAMP_OPAMPCTRL_RES1MUX(0),
	/** Negative input of OPAMP2 */
	OPAMP2_RES1_MUX_NEG_PIN0 = OPAMP_OPAMPCTRL_RES1MUX(1),
	/** OPAMP1 output */
	OPAMP2_RES1_MUX_OUT1 = OPAMP_OPAMPCTRL_RES1MUX(2),
	/** Ground */
	OPAMP2_RES1_MUX_GND = OPAMP_OPAMPCTRL_RES1MUX(3),
};

/**
 * \brief Bias mode selection MUX configuration enum.
 *
 * Enum for the Bias mode selection of OPAMP 0 to 2.
 */
enum opamp_bias_selection {
	/** Minimum current consumption but the slowest mode */
	OPAMP_BIAS_MODE_0 = OPAMP_OPAMPCTRL_BIAS(0),
	/** Low current consumption, slow speed */
	OPAMP_BIAS_MODE_1 = OPAMP_OPAMPCTRL_BIAS(1),
	/** High current consumption, fast speed */
	OPAMP_BIAS_MODE_2 = OPAMP_OPAMPCTRL_BIAS(2),
	/** Maximum current consumption but the fastest mode */
	OPAMP_BIAS_MODE_3 = OPAMP_OPAMPCTRL_BIAS(3),
};

/**
 * \brief OPAMP 0 to 2 common configuration structure.
 *
 *  Common configuration structure for OPAMP 0 to 2.
 */
struct opamp_config_common {
	/**  Potentiometer selection */
	enum opamp_pot_mux potentiometer_selection;
	/** If \c true, R1 connected to RES1MUX */
	bool r1_enable;
	/** If \c true, resistor ladder to V<SUB>CC</SUB> */
	bool r2_vcc;
	/** If \c true, resistor ladder to output */
	bool r2_out;
	/** If \c true, the OPAMPx is enabled when a peripheral is requesting
	 * the OPAMPx to be used as an input. The OPAMPx is
        * disabled if no peripheral is requesting it as an input. */
	bool on_demand;
	/** If \c true, the OPAMPx is not stopped during sleep
	 *  mode when triggered */
	bool run_in_standby;
	/**  Bias mode selection */
	enum opamp_bias_selection bias_value;
	/** If \c true, OPAMP output is connected to the ADC or AC input */
	bool analog_out;
};

/**
 * \brief OPAMP 0 configuration structure.
 *
 *  Configuration structure for OPAMP 0.
 */
struct opamp0_config {
	/** Negative input MUX selection */
	enum opamp0_neg_mux negative_input;
	/** Positive input MUX selection */
	enum opamp0_pos_mux positive_input;
	/** Resistor 1 MUX selection */
	enum opamp0_res1_mux r1_connection;
	/** If \c true, the comparator will continue to sample during sleep
	 *  mode when triggered */
	struct opamp_config_common config_common;
};

/**
 * \brief OPAMP 1 configuration structure.
 *
 *  Configuration structure for OPAMP 1.
 */
struct opamp1_config {
	/** Negative input MUX selection */
	enum opamp1_neg_mux negative_input;
	/** Positive input MUX selection */
	enum opamp1_pos_mux positive_input;
	/** Resistor 1 MUX selection */
	enum opamp1_res1_mux r1_connection;
	/** If \c true, the comparator will continue to sample during sleep
	 *  mode when triggered */
	struct opamp_config_common config_common;
};

/**
 * \brief OPAMP 2 configuration structure.
 *
 *  Configuration structure for OPAMP 2.
 */
struct opamp2_config {
	/** Negative input MUX selection */
	enum opamp2_neg_mux negative_input;
	/** Positive input MUX selection */
	enum opamp2_pos_mux positive_input;
	/** Resistor 1 MUX selection */
	enum opamp2_res1_mux r1_connection;
	/** If \c true, the comparator will continue to sample during sleep
	 *  mode when triggered */
	struct opamp_config_common config_common;
};

/**
 * \brief Initializes OPAMP module.
 *
 * Resets all registers in the MODULE to their initial state,
 * and then enable the module.
 */
void opamp_module_init(void);

/**
 * \brief Resets OPAMP module.
 *
 * Resets all registers in the MODULE to their initial state,
 * and the OPAMP will be disabled.
 */
static inline void opamp_module_reset(void)
{
	/* Reset OPAMP. */
	OPAMP->CTRLA.reg |= OPAMP_CTRLA_SWRST;
}

/**
 * \brief Enables OPAMP module.
 *
 * Enable the peripheral. Each OPAMP must also be enabled individually
 * by the Enable bit in the corresponding OPAMP Control register.
 *
 */
static inline void opamp_module_enable(void)
{
	/* Enable OPAMP. */
	OPAMP->CTRLA.reg |= OPAMP_CTRLA_ENABLE;
}

/**
 * \brief Disables OPAMP module.
 *
 * Disables the peripheral.
 */
static inline void opamp_module_disable(void)
{
	/* Disable OPAMP. */
	OPAMP->CTRLA.reg &= ~OPAMP_CTRLA_ENABLE;
}

/**
 * \brief Enables OPAMP voltage doubler.
 *
 * The analog input MUXes have low resistance, but consume more
 * power at lower voltages (e.g., driven by the voltage doubler).
 *
 */
static inline void opamp_voltage_doubler_enable(void)
{
	struct system_clock_source_osculp32k_config config;

	/* Enable the OSCULP32K clock. */
	system_clock_source_osculp32k_get_config_defaults(&config);
	system_clock_source_osculp32k_set_config(&config);

	/* Enable Voltage Doubler. */
	OPAMP->CTRLA.reg &= ~ OPAMP_CTRLA_LPMUX;
}

/**
 * \brief Disables OPAMP voltage doubler.
 *
 * The analog input MUXes have high resistance, but consume less power
 * at lower voltages (e.g., the voltage doubler is disabled).
 */
static inline void opamp_voltage_doubler_disable(void)
{
	/* Disable Voltage Doubler. */
	OPAMP->CTRLA.reg |= OPAMP_CTRLA_LPMUX;
}

/**
 * \brief Initializes all members of OPAMP0 configuration
 * structure to safe defaults.
 *
 *  Initializes all members of OPAMP0 configuration
 *  structure to safe defaults. This function should be called on all new
 *  instances of these configuration structures before being modified by the
 *  user application.
 *
 *  The default configuration is setting OPAMP0 as "Voltage Follower", refer to
 *  the first mode of "Built-in Modes" in the device datasheet.
 *
 *  \param[out] config  OPAMP0 configuration structure to initialize to
 *                       default values
 */
void opamp0_get_config_defaults(struct opamp0_config *const config);

/**
 * \brief Initializes all members of OPAMP1 configuration
 * structure to safe defaults.
 *
 *  Initializes all members of OPAMP1 configuration
 *  structure to safe defaults. This function should be called on all new
 *  instances of these configuration structures before being modified by the
 *  user application.
 *
 *  The default configuration is setting OPAMP1 as "Voltage Follower", refer to
 *  the first mode of "Built-in Modes" in the device datasheet.
 *
 *  \param[out] config  OPAMP1 configuration structure to initialize to
 *                       default values
 */
void opamp1_get_config_defaults(struct opamp1_config *const config);

/**
 * \brief Initializes all members of OPAMP2 configuration
 * structure to safe defaults.
 *
 *  Initializes all members of OPAMP2 configuration
 *  structure to safe defaults. This function should be called on all new
 *  instances of these configuration structures before being modified by the
 *  user application.
 *
 *  The default configuration is setting OPAMP2 as "Voltage Follower", refer to
 *  the first mode of "Built-in Modes" in the device datasheet.
 *
 *  \param[out] config  OPAMP2 configuration structure to initialize to
 *                       default values
 */
void opamp2_get_config_defaults(struct opamp2_config *const config);

/** \brief Writes OPAMP0 configuration to the hardware module.
 *
 *  Writes a given OPAMP0 configuration to the hardware  module.
 *
 *  \param[in] config       Pointer to the OPAMP0 configuration struct
 */
void opamp0_set_config(struct opamp0_config *const config);

/** \brief Writes OPAMP1 configuration to the hardware module.
 *
 *  Writes a given OPAMP1 configuration to the hardware  module.
 *
 *  \param[in] config       Pointer to the OPAMP1 configuration struct
 */
void opamp1_set_config(struct opamp1_config *const config);

/** \brief Writes OPAMP2 configuration to the hardware module.
 *
 *  Writes a given OPAMP2 configuration to the hardware  module.
 *
 *  \param[in] config       Pointer to the OPAMP2 configuration struct
 */
void opamp2_set_config(struct opamp2_config *const config);

/**
 * \brief Enables an OPAMP that was previously configured.
 *
 *  Enables an OPAMP that was previously  configured via a call to
 *  the set configuration function.
 *
 *  \param[in] number      OPAMP number to enable
 */
void opamp_enable(const enum opamp_id number);

/**
 * \brief Disables an OPAMP that was previously enabled.
 *
 *  Disables an OPAMP that was previously enabled via a call to
 *  \ref opamp_enable().
 *
 *  \param[in] number      OPAMP number to disable
 */
void opamp_disable(const enum opamp_id number);

/**
 * \brief Checks an OPAMP output ready status.
 *
 *  Checks if an OPAMP output is ready.
 *
 *  \param[in] number      OPAMP number to check
 *
 * \return Ready status of the select OPAMP.
 *
 * \retval false If the select OPAMP output is not ready
 * \retval ture If the select OPAMP output is ready

 */
bool opamp_is_ready(const enum opamp_id number);


#ifdef __cplusplus
}
#endif

/** @} */

/**
 * \page asfdoc_sam0_opamp_extra Extra Information for OPAMP Driver
 *
 * \section asfdoc_sam0_opamp_extra_acronyms Acronyms
 * Below is a table listing the acronyms used in this module, along with their
 * intended meanings.
 *
 * <table>
 *	<tr>
 *		<th>Acronym</th>
 *		<th>Description</th>
 *	</tr>
 *  <tr>
 *		<td>OPAMP</td>
 *		<td>Operational Amplifier Controller</td>
 *	</tr>
 * </table>
 *
 *
 * \section asfdoc_sam0_opamp_extra_dependencies Dependencies
 * This driver has no dependencies.
 *
 *
 * \section asfdoc_sam0_opamp_extra_errata Errata
 * There are no errata related to this driver.
 *
 *
 * \section asfdoc_sam0_opamp_extra_history Module History
 * An overview of the module history is presented in the table below, with
 * details on the enhancements and fixes made to the module since its first
 * release. The current version of this corresponds to the newest version in
 * the table.
 *
 * <table>
 *	<tr>
 *		<th>Changelog</th>
 *	</tr>
  *	<tr>
 *		<td>Initial Release</td>
 *	</tr>
 * </table>
 */

/**
 * \page asfdoc_sam0_opamp_exqsg Examples for OPAMP Driver
 *
 * This is a list of the available Quick Start guides (QSGs) and example
 * applications for \ref asfdoc_sam0_opamp_group. QSGs are simple examples with
 * step-by-step instructions to configure and use this driver in a selection of
 * use cases. Note that a QSG can be compiled as a standalone application or be
 * added to the user application.
 *
 *  - \subpage asfdoc_sam0_opamp_basic_use_case
 *
 * \page asfdoc_sam0_opamp_document_revision_history Document Revision History
 *
 * <table>
 *	<tr>
 *		<th>Doc. Rev.</td>
 *		<th>Date</td>
 *		<th>Comments</td>
 *	</tr>
 *	<tr>
 *		<td>42446A</td>
 *		<td>07/2015</td>
 *		<td>Initial document release</td>
 *	</tr>
 * </table>
 */

#endif /* OPAMP_H_INCLUDED */