RA Flexible Software Package Documentation
Release v5.5.0
|
|
Functions | |
fsp_err_t | R_OPAMP_Open (opamp_ctrl_t *const p_api_ctrl, opamp_cfg_t const *const p_cfg) |
fsp_err_t | R_OPAMP_InfoGet (opamp_ctrl_t *const p_api_ctrl, opamp_info_t *const p_info) |
fsp_err_t | R_OPAMP_Start (opamp_ctrl_t *const p_api_ctrl, uint32_t const channel_mask) |
fsp_err_t | R_OPAMP_Stop (opamp_ctrl_t *const p_api_ctrl, uint32_t const channel_mask) |
fsp_err_t | R_OPAMP_StatusGet (opamp_ctrl_t *const p_api_ctrl, opamp_status_t *const p_status) |
fsp_err_t | R_OPAMP_Trim (opamp_ctrl_t *const p_api_ctrl, opamp_trim_cmd_t const cmd, opamp_trim_args_t const *const p_args) |
fsp_err_t | R_OPAMP_Close (opamp_ctrl_t *const p_api_ctrl) |
Driver for the OPAMP peripheral on RA MCUs. This module implements the OPAMP Interface.
The OPAMP HAL module provides a high level API for signal amplification applications and supports the OPAMP peripheral available on RA MCUs.
Configuration | Options | Default | Description |
---|---|---|---|
Parameter Checking |
| Default (BSP) | If selected code for parameter checking is included in the build. |
Configuration | Options | Default | Description |
---|---|---|---|
Name | Name must be a valid C symbol | g_opamp0 | Module name. |
AGT Start Trigger Configuration (N/A unless AGT Start Trigger is Selected for the Channel) |
| AGT1 Compare Match Starts all OPAMPs configured for AGT Start | Configure which AGT channel event triggers which op-amp channel. The AGT compare match event only starts the op-amp channel if the AGT Start trigger is selected in the Trigger configuration for the channel. |
Power Mode | MCU Specific Options | Configure the op-amp based on power or speed requirements. This setting affects the minimum required stabilization time. Middle speed is not available for all MCUs. | |
Trigger Channel 0 | MCU Specific Options | Select the event triggers to start or stop op-amp channel 0. If the event trigger is selected for start, the start() API enables the event trigger for this channel. If the event trigger is selected for stop, the stop() API disables the event trigger for this channel. | |
Trigger Channel 1 | MCU Specific Options | Select the event triggers to start or stop op-amp channel 1. If the event trigger is selected for start, the start() API enables the event trigger for this channel. If the event trigger is selected for stop, the stop() API disables the event trigger for this channel. | |
Trigger Channel 2 |
| Software Start Software Stop | Select the event triggers to start or stop op-amp channel 2. If the event trigger is selected for start, the start() API enables the event trigger for this channel. If the event trigger is selected for stop, the stop() API disables the event trigger for this channel. |
Trigger Channel 3 | MCU Specific Options | Select the event triggers to start or stop op-amp channel 3. If the event trigger is selected for start, the start() API enables the event trigger for this channel. If the event trigger is selected for stop, the stop() API disables the event trigger for this channel. | |
OPAMP AMP0OS | MCU Specific Options | Select output to connect to AMP0O pin | |
OPAMP AMP0PS | MCU Specific Options | Select input to connect to AMP0+ pin | |
OPAMP AMP0MS | MCU Specific Options | Select input to connect to AMP0- pin | |
OPAMP AMP1PS | MCU Specific Options | Select input to connect to AMP1+ pin | |
OPAMP AMP1MS | MCU Specific Options | Select input to connect to AMP1- pin | |
OPAMP AMP2PS | MCU Specific Options | Select input to connect to AMP2+ pin | |
OPAMP AMP2MS | MCU Specific Options | Select input to connect to AMP2- pin |
The OPAMP runs on PCLKB.
To use the OPAMP HAL module, the port pins for the channels receiving the analog input must be set as inputs on the Pins tab of the RA Configuration editor.
Refer to the most recent FSP Release Notes for any additional operational limitations for this module.
This is a basic example of minimal use of the R_OPAMP in an application. The example demonstrates configuring OPAMP channel 0 for high speed mode, starting the OPAMP and reading the status of the OPAMP channel running. It also verifies that the stabilization wait time is the expected time for selected power mode
This example demonstrates the typical trimming procedure for opamp channel 0 using R_OPAMP_Trim() API.
Data Structures | |
struct | opamp_extended_cfg_t |
struct | opamp_instance_ctrl_t |
Macros | |
#define | OPAMP_MASK_CHANNEL_0 |
Enumerations | |
enum | opamp_trigger_t |
enum | opamp_agt_link_t |
enum | opamp_mode_t |
enum | opamp_plus_input_t |
enum | opamp_minus_input_t |
enum | opamp_output_t |
Variables | |
const opamp_api_t | g_opamp_on_opamp |
struct opamp_extended_cfg_t |
OPAMP configuration extension. This extension is required and must be provided in opamp_cfg_t::p_extend.
Data Fields | ||
---|---|---|
opamp_agt_link_t | agt_link |
Configure which AGT links are paired to which channel. Only applies to channels if OPAMP_TRIGGER_AGT_START_SOFTWARE_STOP or OPAMP_TRIGGER_AGT_START_ADC_STOP is selected for the channel. |
opamp_mode_t | mode | Low power, middle speed, or high speed mode. |
opamp_trigger_t | trigger_channel_0 | Start and stop triggers for channel 0. |
opamp_trigger_t | trigger_channel_1 | Start and stop triggers for channel 1. |
opamp_trigger_t | trigger_channel_2 | Start and stop triggers for channel 2. |
opamp_trigger_t | trigger_channel_3 | Start and stop triggers for channel 3. |
opamp_plus_input_t | plus_input_select_opamp0 | OPAMP0+ connection. |
opamp_minus_input_t | minus_input_select_opamp0 | OPAMP0- connection. |
opamp_output_t | output_select_opamp0 | OPAMP0O connection. |
opamp_plus_input_t | plus_input_select_opamp1 | OPAMP1+ connection. |
opamp_minus_input_t | minus_input_select_opamp1 | OPAMP1- connection. |
opamp_plus_input_t | plus_input_select_opamp2 | OPAMP2+ connection. |
opamp_minus_input_t | minus_input_select_opamp2 | OPAMP2- connection. |
struct opamp_instance_ctrl_t |
OPAMP instance control block. DO NOT INITIALIZE. Initialized in opamp_api_t::open().
#define OPAMP_MASK_CHANNEL_0 |
Version of code that implements the API defined in this file
enum opamp_trigger_t |
enum opamp_agt_link_t |
Which AGT timer starts the op-amp. Only applies to channels if OPAMP_TRIGGER_AGT_START_SOFTWARE_STOP or OPAMP_TRIGGER_AGT_START_ADC_STOP is selected for the channel. If OPAMP_TRIGGER_SOFTWARE_START_SOFTWARE_STOP is selected for a channel, then no AGT compare match event will start that op-amp channel.
enum opamp_mode_t |
enum opamp_plus_input_t |
Options to connect AMPnPS pins.
enum opamp_minus_input_t |
Options to connect AMPnMS pins.
enum opamp_output_t |
Options to connect AMP0OS pin.
fsp_err_t R_OPAMP_Open | ( | opamp_ctrl_t *const | p_api_ctrl, |
opamp_cfg_t const *const | p_cfg | ||
) |
Applies power to the OPAMP and initializes the hardware based on the user configuration. Implements opamp_api_t::open.
The op-amp is not operational until the opamp_api_t::start is called. If the op-amp is configured to start after AGT compare match, the op-amp is not operational until opamp_api_t::start and the associated AGT compare match event occurs.
Some MCUs have switches that must be set before starting the op-amp. These switches must be set in the application code after opamp_api_t::open and before opamp_api_t::start.
Example:
FSP_SUCCESS | Configuration successful. |
FSP_ERR_ASSERTION | An input pointer is NULL. |
FSP_ERR_ALREADY_OPEN | Control block is already opened. |
FSP_ERR_INVALID_ARGUMENT | An attempt to configure OPAMP in middle speed mode on MCU that does not support middle speed mode. |
fsp_err_t R_OPAMP_InfoGet | ( | opamp_ctrl_t *const | p_api_ctrl, |
opamp_info_t *const | p_info | ||
) |
Provides the minimum stabilization wait time in microseconds. Implements opamp_api_t::infoGet.
FSP_SUCCESS | information on opamp_power_mode stored in p_info. |
FSP_ERR_ASSERTION | An input pointer was NULL. |
FSP_ERR_NOT_OPEN | Instance control block is not open. |
fsp_err_t R_OPAMP_Start | ( | opamp_ctrl_t *const | p_api_ctrl, |
uint32_t const | channel_mask | ||
) |
If the OPAMP is configured for hardware triggers, enables hardware triggers. Otherwise, starts the op-amp. Implements opamp_api_t::start.
Some MCUs have switches that must be set before starting the op-amp. These switches must be set in the application code after opamp_api_t::open and before opamp_api_t::start.
Example:
FSP_SUCCESS | Op-amp started or hardware triggers enabled successfully. |
FSP_ERR_ASSERTION | An input pointer was NULL. |
FSP_ERR_NOT_OPEN | Instance control block is not open. |
FSP_ERR_INVALID_ARGUMENT | channel_mask includes a channel that does not exist on this MCU. |
fsp_err_t R_OPAMP_Stop | ( | opamp_ctrl_t *const | p_api_ctrl, |
uint32_t const | channel_mask | ||
) |
Stops the op-amp. If the OPAMP is configured for hardware triggers, disables hardware triggers. Implements opamp_api_t::stop.
FSP_SUCCESS | Op-amp stopped or hardware triggers disabled successfully. |
FSP_ERR_ASSERTION | An input pointer was NULL. |
FSP_ERR_NOT_OPEN | Instance control block is not open. |
FSP_ERR_INVALID_ARGUMENT | channel_mask includes a channel that does not exist on this MCU. |
fsp_err_t R_OPAMP_StatusGet | ( | opamp_ctrl_t *const | p_api_ctrl, |
opamp_status_t *const | p_status | ||
) |
Provides the operating status for each op-amp in a bitmask. This bit is set when operation begins, before the stabilization wait time has elapsed. Implements opamp_api_t::statusGet.
FSP_SUCCESS | Operating status of each op-amp provided in p_status. |
FSP_ERR_ASSERTION | An input pointer was NULL. |
FSP_ERR_NOT_OPEN | Instance control block is not open. |
fsp_err_t R_OPAMP_Trim | ( | opamp_ctrl_t *const | p_api_ctrl, |
opamp_trim_cmd_t const | cmd, | ||
opamp_trim_args_t const *const | p_args | ||
) |
On MCUs that support trimming, the op-amp trim register is set to the factory default after open(). This function allows the application to trim the operational amplifier to a user setting, which overwrites the factory default factory trim values.
Not supported on all MCUs. See hardware manual for details. Not supported if configured for low power mode (OPAMP_MODE_LOW_POWER).
This function is not reentrant. Only one side of one op-amp can be trimmed at a time. Complete the procedure for one side of one channel before calling trim() with command OPAMP_TRIM_CMD_START again.
Implements opamp_api_t::trim.
Reference: Section 37.9 "User Offset Trimming" RA2A1 hardware manual R01UM0008EU0130. The trim procedure works as follows:
FSP_SUCCESS | Conversion result in p_data. |
FSP_ERR_UNSUPPORTED | Trimming is not supported on this MCU. |
FSP_ERR_INVALID_STATE | The command is not valid in the current state of the trim state machine. |
FSP_ERR_INVALID_ARGUMENT | The requested channel is not operating or the trim procedure is not in progress for this channel/input combination. |
FSP_ERR_INVALID_MODE | Trim is not allowed in low power mode. |
FSP_ERR_ASSERTION | An input pointer was NULL. |
FSP_ERR_NOT_OPEN | Instance control block is not open. |
fsp_err_t R_OPAMP_Close | ( | opamp_ctrl_t *const | p_api_ctrl | ) |
Stops the op-amps. Implements opamp_api_t::close.
FSP_SUCCESS | Instance control block closed successfully. |
FSP_ERR_ASSERTION | An input pointer was NULL. |
FSP_ERR_NOT_OPEN | Instance control block is not open. |
const opamp_api_t g_opamp_on_opamp |
OPAMP Implementation of OPAMP interface.