This driver for Atmel® | SMART ARM®-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:
The following devices can use this module:
The outline of this documentation is as follows:
There are no prerequisites for this module.
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.
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.
There are no special considerations for this module.
For extra information, see Extra Information for OPAMP Driver. This includes:
For a list of examples related to this driver, see Examples for OPAMP Driver.
Modules | |
Quick Start Guide(s) | |
In this section you can find a list of all Quick Start guides related to the SAM Operational Amplifier Controller (OPAMP) Driver. | |
Data Structures | |
struct | opamp0_config |
OPAMP 0 configuration structure. More... | |
struct | opamp1_config |
OPAMP 1 configuration structure. More... | |
struct | opamp2_config |
OPAMP 2 configuration structure. More... | |
struct | opamp_config_common |
OPAMP 0 to 2 common configuration structure. More... | |
Enumerations | |
enum | opamp0_neg_mux { OPAMP0_NEG_MUX_PIN0 = OPAMP_OPAMPCTRL_MUXNEG(0), OPAMP0_NEG_MUX_TAP0 = OPAMP_OPAMPCTRL_MUXNEG(1), OPAMP0_NEG_MUX_OUT0 = OPAMP_OPAMPCTRL_MUXNEG(2), OPAMP0_NEG_MUX_DAC = OPAMP_OPAMPCTRL_MUXNEG(3) } |
Negative input MUX selection configuration enum. More... | |
enum | opamp0_pos_mux { OPAMP0_POS_MUX_PIN0 = OPAMP_OPAMPCTRL_MUXPOS(0), OPAMP0_POS_MUX_TAP0 = OPAMP_OPAMPCTRL_MUXPOS(1), OPAMP0_POS_MUX_DAC = OPAMP_OPAMPCTRL_MUXPOS(2), OPAMP0_POS_MUX_GND = OPAMP_OPAMPCTRL_MUXPOS(3) } |
Positive input MUX selection configuration enum. More... | |
enum | opamp0_res1_mux { OPAMP0_RES1_MUX_POS_PIN0 = OPAMP_OPAMPCTRL_RES1MUX(0), OPAMP0_RES1_MUX_NEG_PIN0 = OPAMP_OPAMPCTRL_RES1MUX(1), OPAMP0_RES1_MUX_DAC = OPAMP_OPAMPCTRL_RES1MUX(2), OPAMP0_RES1_MUX_GND = OPAMP_OPAMPCTRL_RES1MUX(3) } |
Resistor 1 MUX selection configuration enum. More... | |
enum | opamp1_neg_mux { OPAMP1_NEG_MUX_PIN1 = OPAMP_OPAMPCTRL_MUXNEG(0), OPAMP1_NEG_MUX_TAP1 = OPAMP_OPAMPCTRL_MUXNEG(1), OPAMP1_NEG_MUX_OUT1 = OPAMP_OPAMPCTRL_MUXNEG(2), OPAMP1_NEG_MUX_DAC = OPAMP_OPAMPCTRL_MUXNEG(3) } |
Negative input MUX selection configuration enum. More... | |
enum | opamp1_pos_mux { OPAMP1_POS_MUX_PIN1 = OPAMP_OPAMPCTRL_MUXPOS(0), OPAMP1_POS_MUX_TAP1 = OPAMP_OPAMPCTRL_MUXPOS(1), OPAMP1_POS_MUX_OUT0 = OPAMP_OPAMPCTRL_MUXPOS(2), OPAMP1_POS_MUX_GND = OPAMP_OPAMPCTRL_MUXPOS(3) } |
Positive input MUX selection configuration enum. More... | |
enum | opamp1_res1_mux { OPAMP1_RES1_MUX_POS_PIN0 = OPAMP_OPAMPCTRL_RES1MUX(0), OPAMP1_RES1_MUX_NEG_PIN0 = OPAMP_OPAMPCTRL_RES1MUX(1), OPAMP1_RES1_MUX_OUT0 = OPAMP_OPAMPCTRL_RES1MUX(2), OPAMP1_RES1_MUX_GND = OPAMP_OPAMPCTRL_RES1MUX(3) } |
Resistor 1 MUX selection configuration enum. More... | |
enum | opamp2_neg_mux { OPAMP2_NEG_MUX_PIN2 = OPAMP_OPAMPCTRL_MUXNEG(0), OPAMP2_NEG_MUX_TAP2 = OPAMP_OPAMPCTRL_MUXNEG(1), OPAMP2_NEG_MUX_OUT2 = OPAMP_OPAMPCTRL_MUXNEG(2), OPAMP2_NEG_MUX_PIN0 = OPAMP_OPAMPCTRL_MUXNEG(3), OPAMP2_NEG_MUX_PIN1 = OPAMP_OPAMPCTRL_MUXNEG(4), OPAMP2_NEG_MUX_DAC = OPAMP_OPAMPCTRL_MUXNEG(5) } |
Negative input MUX selection configuration enum. More... | |
enum | opamp2_pos_mux { OPAMP2_POS_MUX_PIN2 = OPAMP_OPAMPCTRL_MUXPOS(0), OPAMP2_POS_MUX_TAP2 = OPAMP_OPAMPCTRL_MUXPOS(1), OPAMP2_POS_MUX_OUT1 = OPAMP_OPAMPCTRL_MUXPOS(2), OPAMP2_POS_MUX_GND = OPAMP_OPAMPCTRL_MUXPOS(3), OPAMP2_POS_MUX_PIN0 = OPAMP_OPAMPCTRL_MUXPOS(4), OPAMP2_POS_MUX_PIN1 = OPAMP_OPAMPCTRL_MUXPOS(5), OPAMP2_POS_MUX_TAP0 = OPAMP_OPAMPCTRL_MUXPOS(6) } |
Positive input MUX selection configuration enum. More... | |
enum | opamp2_res1_mux { OPAMP2_RES1_MUX_POS_PIN0 = OPAMP_OPAMPCTRL_RES1MUX(0), OPAMP2_RES1_MUX_NEG_PIN0 = OPAMP_OPAMPCTRL_RES1MUX(1), OPAMP2_RES1_MUX_OUT1 = OPAMP_OPAMPCTRL_RES1MUX(2), OPAMP2_RES1_MUX_GND = OPAMP_OPAMPCTRL_RES1MUX(3) } |
Resistor 1 MUX selection configuration enum. More... | |
enum | opamp_bias_selection { OPAMP_BIAS_MODE_0 = OPAMP_OPAMPCTRL_BIAS(0), OPAMP_BIAS_MODE_1 = OPAMP_OPAMPCTRL_BIAS(1), OPAMP_BIAS_MODE_2 = OPAMP_OPAMPCTRL_BIAS(2), OPAMP_BIAS_MODE_3 = OPAMP_OPAMPCTRL_BIAS(3) } |
Bias mode selection MUX configuration enum. More... | |
enum | opamp_id { OPAMP_0 = 0, OPAMP_1 = 1, OPAMP_2 = 2, OPAMP_NUM } |
OPAMP ID number enum. More... | |
enum | opamp_pot_mux { OPAMP_POT_MUX_14R_2R = OPAMP_OPAMPCTRL_POTMUX(0), OPAMP_POT_MUX_12R_4R = OPAMP_OPAMPCTRL_POTMUX(1), OPAMP_POT_MUX_8R_8R = OPAMP_OPAMPCTRL_POTMUX(2), OPAMP_POT_MUX_6R_10R = OPAMP_OPAMPCTRL_POTMUX(3), OPAMP_POT_MUX_4R_12R = OPAMP_OPAMPCTRL_POTMUX(4), OPAMP_POT_MUX_3R_13R = OPAMP_OPAMPCTRL_POTMUX(5), OPAMP_POT_MUX_2R_14R = OPAMP_OPAMPCTRL_POTMUX(6), OPAMP_POT_MUX_R_15R = OPAMP_OPAMPCTRL_POTMUX(7) } |
Potentiometer selection MUX configuration enum. More... | |
Functions | |
void | opamp0_get_config_defaults (struct opamp0_config *const config) |
Initializes all members of OPAMP0 configuration structure to safe defaults. More... | |
void | opamp0_set_config (struct opamp0_config *const config) |
Writes OPAMP0 configuration to the hardware module. More... | |
void | opamp1_get_config_defaults (struct opamp1_config *const config) |
Initializes all members of OPAMP1 configuration structure to safe defaults. More... | |
void | opamp1_set_config (struct opamp1_config *const config) |
Writes OPAMP1 configuration to the hardware module. More... | |
void | opamp2_get_config_defaults (struct opamp2_config *const config) |
Initializes all members of OPAMP2 configuration structure to safe defaults. More... | |
void | opamp2_set_config (struct opamp2_config *const config) |
Writes OPAMP2 configuration to the hardware module. More... | |
void | opamp_disable (const enum opamp_id number) |
Disables an OPAMP that was previously enabled. More... | |
void | opamp_enable (const enum opamp_id number) |
Enables an OPAMP that was previously configured. More... | |
bool | opamp_is_ready (const enum opamp_id number) |
Checks an OPAMP output ready status. More... | |
static void | opamp_module_disable (void) |
Disables OPAMP module. More... | |
static void | opamp_module_enable (void) |
Enables OPAMP module. More... | |
void | opamp_module_init (void) |
Initializes OPAMP module. More... | |
static void | opamp_module_reset (void) |
Resets OPAMP module. More... | |
static void | opamp_voltage_doubler_disable (void) |
Disables OPAMP voltage doubler. More... | |
static void | opamp_voltage_doubler_enable (void) |
Enables OPAMP voltage doubler. More... | |
enum opamp0_neg_mux |
enum opamp0_pos_mux |
enum opamp0_res1_mux |
enum opamp1_neg_mux |
enum opamp1_pos_mux |
enum opamp1_res1_mux |
enum opamp2_neg_mux |
Negative input MUX selection configuration enum.
Enum for the negative input of OPAMP2.
enum opamp2_pos_mux |
Positive input MUX selection configuration enum.
Enum for the positive input of OPAMP2.
enum opamp2_res1_mux |
enum opamp_bias_selection |
Bias mode selection MUX configuration enum.
Enum for the Bias mode selection of OPAMP 0 to 2.
enum opamp_id |
enum opamp_pot_mux |
Potentiometer selection MUX configuration enum.
Enum for the potentiometer selection of OPAMP 0 to 2.
void opamp0_get_config_defaults | ( | struct opamp0_config *const | config | ) |
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.
[out] | config | OPAMP0 configuration structure to initialize to default values |
References _opamp_get_config_common_defaults(), Assert, opamp0_config::config_common, opamp0_config::negative_input, OPAMP0_NEG_MUX_OUT0, OPAMP0_POS_MUX_PIN0, OPAMP0_RES1_MUX_GND, opamp0_config::positive_input, and opamp0_config::r1_connection.
Referenced by configure_non_inverting_pga_opamp0().
void opamp0_set_config | ( | struct opamp0_config *const | config | ) |
Writes OPAMP0 configuration to the hardware module.
Writes a given OPAMP0 configuration to the hardware module.
[in] | config | Pointer to the OPAMP0 configuration struct |
References opamp_config_common::analog_out, opamp_config_common::bias_value, opamp0_config::config_common, opamp0_config::negative_input, opamp_config_common::on_demand, opamp0_config::positive_input, opamp_config_common::potentiometer_selection, opamp0_config::r1_connection, opamp_config_common::r1_enable, opamp_config_common::r2_out, opamp_config_common::r2_vcc, and opamp_config_common::run_in_standby.
Referenced by configure_non_inverting_pga_opamp0().
void opamp1_get_config_defaults | ( | struct opamp1_config *const | config | ) |
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.
[out] | config | OPAMP1 configuration structure to initialize to default values |
References _opamp_get_config_common_defaults(), Assert, opamp1_config::config_common, opamp1_config::negative_input, OPAMP1_NEG_MUX_OUT1, OPAMP1_POS_MUX_PIN1, OPAMP1_RES1_MUX_GND, opamp1_config::positive_input, and opamp1_config::r1_connection.
void opamp1_set_config | ( | struct opamp1_config *const | config | ) |
Writes OPAMP1 configuration to the hardware module.
Writes a given OPAMP1 configuration to the hardware module.
[in] | config | Pointer to the OPAMP1 configuration struct |
References opamp_config_common::analog_out, opamp_config_common::bias_value, opamp1_config::config_common, opamp1_config::negative_input, opamp_config_common::on_demand, opamp1_config::positive_input, opamp_config_common::potentiometer_selection, opamp1_config::r1_connection, opamp_config_common::r1_enable, opamp_config_common::r2_out, opamp_config_common::r2_vcc, and opamp_config_common::run_in_standby.
void opamp2_get_config_defaults | ( | struct opamp2_config *const | config | ) |
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.
[out] | config | OPAMP2 configuration structure to initialize to default values |
References _opamp_get_config_common_defaults(), Assert, opamp2_config::config_common, opamp2_config::negative_input, OPAMP2_NEG_MUX_OUT2, OPAMP2_POS_MUX_PIN2, OPAMP2_RES1_MUX_GND, opamp2_config::positive_input, and opamp2_config::r1_connection.
Referenced by configure_opamp2().
void opamp2_set_config | ( | struct opamp2_config *const | config | ) |
Writes OPAMP2 configuration to the hardware module.
Writes a given OPAMP2 configuration to the hardware module.
[in] | config | Pointer to the OPAMP2 configuration struct |
References opamp_config_common::analog_out, opamp_config_common::bias_value, opamp2_config::config_common, opamp2_config::negative_input, opamp_config_common::on_demand, opamp2_config::positive_input, opamp_config_common::potentiometer_selection, opamp2_config::r1_connection, opamp_config_common::r1_enable, opamp_config_common::r2_out, opamp_config_common::r2_vcc, and opamp_config_common::run_in_standby.
Referenced by configure_opamp2().
void opamp_disable | ( | const enum opamp_id | number | ) |
Disables an OPAMP that was previously enabled.
Disables an OPAMP that was previously enabled via a call to opamp_enable().
[in] | number | OPAMP number to disable |
void opamp_enable | ( | const enum opamp_id | number | ) |
Enables an OPAMP that was previously configured.
Enables an OPAMP that was previously configured via a call to the set configuration function.
[in] | number | OPAMP number to enable |
References Assert, OPAMP_0, OPAMP_1, and OPAMP_2.
Referenced by configure_non_inverting_pga_opamp0(), and configure_opamp2().
Checks an OPAMP output ready status.
Checks if an OPAMP output is ready.
[in] | number | OPAMP number to check |
false | If the select OPAMP output is not ready |
ture | If the select OPAMP output is ready |
References Assert, OPAMP_0, OPAMP_1, and OPAMP_2.
Referenced by configure_non_inverting_pga_opamp0(), and configure_opamp2().
|
inlinestatic |
Disables OPAMP module.
Disables the peripheral.
|
inlinestatic |
Enables OPAMP module.
Enable the peripheral. Each OPAMP must also be enabled individually by the Enable bit in the corresponding OPAMP Control register.
Referenced by opamp_module_init().
void opamp_module_init | ( | void | ) |
Initializes OPAMP module.
Resets all registers in the MODULE to their initial state, and then enable the module.
References opamp_module_enable(), opamp_module_reset(), system_apb_clock_set_mask(), SYSTEM_CLOCK_APB_APBD, system_clock_source_osculp32k_get_config_defaults(), and system_clock_source_osculp32k_set_config().
Referenced by configure_non_inverting_pga_opamp0(), and configure_opamp2().
|
inlinestatic |
Resets OPAMP module.
Resets all registers in the MODULE to their initial state, and the OPAMP will be disabled.
Referenced by opamp_module_init().
|
inlinestatic |
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).
|
inlinestatic |
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).
References system_clock_source_osculp32k_get_config_defaults(), and system_clock_source_osculp32k_set_config().