RZV Flexible Software Package Documentation  Release v3.0.0

 
Analog to Digital Converter (r_adc_e)

Functions

fsp_err_t R_ADC_E_Open (adc_ctrl_t *p_ctrl, adc_cfg_t const *const p_cfg)
 
fsp_err_t R_ADC_E_ScanCfg (adc_ctrl_t *p_ctrl, void const *const p_channel_cfg)
 
fsp_err_t R_ADC_E_InfoGet (adc_ctrl_t *p_ctrl, adc_info_t *p_adc_info)
 
fsp_err_t R_ADC_E_ScanStart (adc_ctrl_t *p_ctrl)
 
fsp_err_t R_ADC_E_ScanGroupStart (adc_ctrl_t *p_ctrl, adc_group_mask_t group_id)
 
fsp_err_t R_ADC_E_ScanStop (adc_ctrl_t *p_ctrl)
 
fsp_err_t R_ADC_E_StatusGet (adc_ctrl_t *p_ctrl, adc_status_t *p_status)
 
fsp_err_t R_ADC_E_Read (adc_ctrl_t *p_ctrl, adc_channel_t const reg_id, uint16_t *const p_data)
 
fsp_err_t R_ADC_E_Read32 (adc_ctrl_t *p_ctrl, adc_channel_t const reg_id, uint32_t *const p_data)
 
fsp_err_t R_ADC_E_Close (adc_ctrl_t *p_ctrl)
 
fsp_err_t R_ADC_E_OffsetSet (adc_ctrl_t *const p_ctrl, adc_channel_t const reg_id, int32_t offset)
 
fsp_err_t R_ADC_E_Calibrate (adc_ctrl_t *const p_ctrl, void const *p_extend)
 
fsp_err_t R_ADC_E_CallbackSet (adc_ctrl_t *const p_api_ctrl, void(*p_callback)(adc_callback_args_t *), void const *const p_context, adc_callback_args_t *const p_callback_memory)
 

Detailed Description

Driver for the and ADC12 peripherals on RZ MPUs. This module implements the ADC Interface.

Overview

Features

The ADC_E module supports the following features:

Configuration

Build Time Configurations for r_adc_e

The following build time configurations are defined in fsp_cfg/r_adc_e_cfg.h:

ConfigurationOptionsDefaultDescription
Parameter Checking
  • Default (BSP)
  • Enabled
  • Disabled
Default (BSP) If selected code for parameter checking is included in the build.

Configurations for Analog > ADC Driver on r_adc_e

This module can be added to the Stacks tab via New Stack > Analog > ADC Driver on r_adc_e.

ConfigurationOptionsDefaultDescription
General > NameName must be a valid C symbolg_adc0 Module name
General > UnitUnit must be a non-negative integer0 Specifies the ADC Unit to be used.
General > Resolution
  • 12-Bit
  • 8-Bit
12-Bit Specifies the conversion resolution for this unit.
General > Clear after read
  • Off
  • On
On Specifies if the result register will be automatically cleared after the conversion result is read.
General > Mode
  • Single Scan
  • Continuous Scan
  • Group Scan
Single Scan Specifies the mode that this ADC unit is used in.
General > Double-trigger
  • Disabled
  • Enabled
  • Enabled (extended mode)
Disabled When enabled, the scan-end interrupt for Group A is only thrown on every second scan. Extended double-trigger mode (single-scan only) triggers on both ELC events, allowing (for example) a scan on two different timer compare match values.

In group mode Group B is unaffected.

Input > Start Trigger > Group ARefer to the RZV Configuration tool for available options.software A/D Conversion Start Trigger Select for Group A.
Input > Start Trigger > Group BRefer to the RZV Configuration tool for available options.Disabled A/D Conversion Start Trigger Select for Group B.
Input > Start Trigger > Group C Enabled
  • Disabled
  • Enabled
Disabled Set to true to enable Group C, false to disable Group C.
Input > Start Trigger > Group CRefer to the RZV Configuration tool for available options.Disabled A/D Conversion Start Trigger Select for Group C.
Input > Start Trigger > ELC EventMCU Specific OptionsSelect ELC event.
Input > Window Compare > Window A > Enable
  • Disabled
  • Enabled
Disabled Enable or disable comparison with Window A.
Input > Window Compare > Window A > Channels to compare
  • Channel 0
  • Channel 1
  • Channel 2
  • Channel 3
  • Channel 4
  • Channel 5
  • Channel 6
  • Channel 7
Select channels to be compared to Window A.
Input > Window Compare > Window A > Channel comparison mode (channel availability varies by MCU and unit)
  • Channel 0
  • Channel 1
  • Channel 2
  • Channel 3
  • Channel 4
  • Channel 5
  • Channel 6
  • Channel 7
Checking a box sets the comparison mode for that channel to Greater Than or Inside Window depending on whether Window Mode is disabled or enabled (respectively). If left unchecked the comparison mode will likewise be Less Than or Outside Window (respectively).
Input > Window Compare > Window A > Lower ReferenceMust be a positive 16-bit integer.0 Set the lower comparison value.
Input > Window Compare > Window A > Upper ReferenceMust be a positive 16-bit integer.0 Set the upper comparison value.
Input > Window Compare > Window B > Enable
  • Disabled
  • Enabled
Disabled Enable or disable comparison with Window B.
Input > Window Compare > Window B > Channel to compare (channel availability varies by MCU and unit)
  • Not Selected
  • Channel 0
  • Channel 1
  • Channel 2
  • Channel 3
  • Channel 4
  • Channel 5
  • Channel 6
  • Channel 7
Channel 0 Select a channel to be compared to Window B.
Input > Window Compare > Window B > Comparison mode
  • Less Than or Outside Window
  • Greater Than or Inside Window
module.driver.adc_e.compare.window_b.mode Select the comparison mode for Window B. For each option, the first condition applies when Window Mode is disabled and the second option applies when Window Mode is enabled.
Input > Window Compare > Window B > Lower ReferenceMust be a positive 16-bit integer.0 Set the lower comparison value.
Input > Window Compare > Window B > Upper ReferenceMust be a positive 16-bit integer.0 Set the upper comparison value.
Input > Window Compare > Window Mode
  • Disabled
  • Enabled
Disabled When disabled, ADC values will be compared only with the lower reference on each comparator. When enabled, both the lower and upper reference values will be used to create a comparison window.
Input > Window Compare > Event Output
  • OR
  • XOR
  • AND
OR Select how comparison results should be composited for event output.
Input > Channel Scan Mask
  • Channel 0
  • Channel 1
  • Channel 2
  • Channel 3
  • Channel 4
  • Channel 5
  • Channel 6
  • Channel 7
In Normal mode of operation, this bitmask field specifies the channels that are enabled in that ADC unit. In group mode, this field specifies which channels belong to group A.
Input > Group B Scan Mask
  • Channel 0
  • Channel 1
  • Channel 2
  • Channel 3
  • Channel 4
  • Channel 5
  • Channel 6
  • Channel 7
In group mode, this field specifies which channels belong to group B.
Input > Group C Scan Mask
  • Channel 0
  • Channel 1
  • Channel 2
  • Channel 3
  • Channel 4
  • Channel 5
  • Channel 6
  • Channel 7
In group mode, this field specifies which channels belong to group C.
Input > Addition/Averaging Mask (channel availability varies by MCU and unit)
  • Channel 0
  • Channel 1
  • Channel 2
  • Channel 3
  • Channel 4
  • Channel 5
  • Channel 6
  • Channel 7
Select channels to include in the Addition/Averaging Mask
Input > Add/Average Count
  • Disabled
  • Add 2 samples
  • Add 3 samples
  • Add 4 samples
  • Add 16 samples
  • Average 2 samples
  • Average 4 samples
Disabled Specifies if addition or averaging needs to be done for any of the channels in this unit.
Input > Group Priority (Valid only in Group Scan Mode)
  • Group A ignored and does not interrupt Group B and Group C
  • Group B and Group C restart at next trigger
  • Group B and Group C restart immediately and scans from the head of the channel
  • Group B and Group C restart immediately and scans
  • Group B and Group C restart and scans continuously from the head of the channel
  • Group B and Group C restart immediately and scans continuously from the head of the channel
  • Group B and Group C restart immediately and scans continuously
Group A ignored and does not interrupt Group B and Group C Determines whether an ongoing group B scan can be interrupted by a group A trigger, whether it should abort on a group A trigger, or if it should pause to allow group A scan and restart immediately after group A scan is complete.
Interrupts > CallbackName must be a valid C symbolNULL A user callback function. If this callback function is provided, it is called from the interrupt service routine (ISR) each time the ADC scan completes.
Interrupts > Scan End Interrupt EnableMCU Specific OptionsEnable or disable Scan End interrupt.
Interrupts > Scan End Interrupt PriorityValue must be an integer between 0 and 25512 Select scan end interrupt priority.
Interrupts > Scan End Group B Interrupt EnableMCU Specific OptionsEnable or disable Scan End Group B interrupt.
Interrupts > Scan End Group B Interrupt PriorityValue must be an integer between 0 and 25512 Select group B scan end interrupt priority.
Interrupts > Scan End Group C Interrupt EnableMCU Specific OptionsEnable or disable Scan End Group C interrupt.
Interrupts > Scan End Group C Interrupt PriorityValue must be an integer between 0 and 25512 Select group C scan end interrupt priority.
Interrupts > Window Compare A Interrupt EnableMCU Specific OptionsEnable or disable Window Compare A interrupt.
Interrupts > Window Compare A Interrupt PriorityValue must be an integer between 0 and 25512 Select group C scan end interrupt priority.
Interrupts > Window Compare B Interrupt EnableMCU Specific OptionsEnable or disable Window Compare B interrupt.
Interrupts > Window Compare B Interrupt PriorityValue must be an integer between 0 and 25512 Select group C scan end interrupt priority.
ELC > Output Event Signal
  • Group A
  • Group B
  • Group A or B or C
  • Group C
Group A A/D Event Link Control.

Clock Configuration

A/D conversion clock ADC_0_ADCLK is 50MHz, 40MHz, 20MHz, 10MHz or 5MHz.

Pin Configuration

The ANxxx pins are analog input channels that can be used with the ADC.

Usage Notes

ADC Operational Modes

The driver supports three operation modes: single-scan, continuous-scan, and group-scan modes. In each mode, analog channels are converted in ascending order of channel number, followed by scans of the voltage sensor if they are included in the mask of channels to scan.

Single-scan Mode

In single scan mode, one or more specified channels are scanned once per trigger.

Continuous-scan Mode

In continuous scan mode, a single trigger is required to start the scan. Scans continue until R_ADC_E_ScanStop() is called.

Note
On RZ MPUs, the AD conversion sampling time is not long enough to meet the ADC interrupt processing time. Particularly in continuous scan mode, it is not possible to obtain the results of the ADC conversion at the time of each scan is complete, so it is advisable to configure the system considering that only the conversion results available at the time of the scan end callback can be retrieved. To maintain system responsiveness and effectiveness, avoiding high-frequency scan settings relative to core clocks is recommended to prevent excessive interrupts.

Group-scan Mode

Group-scan mode allows the application to allocate channels to one of two groups (A and B and C). Conversion begins when the specified ELC start trigger for that group is received.

The priority of group priority operations is group A > group B > group C. In group priority operation, if the scan start of group B is accepted during the scan of group C, the scan of group C is interrupted and the scan of group B is started. If the scan start of group A is accepted during the scan of group C, the scan of group A is started. The scan of Group C is interrupted and the scan of Group A is started. Similarly, if the scan start of Group A is accepted during the scan of Group B, the scan of Group B is interrupted and the scan of Group A is started.

Double-triggering

When double-triggering is enabled a single channel is selected to be scanned twice before an interrupt is thrown. The first scan result when using double-triggering is always saved to the selected channel's data register. The second result is saved to the data duplexing register (ADC_CHANNEL_DUPLEX).

Double-triggering uses Group A; only one channel can be selected when enabled. No other scanning is possible on Group A while double-trigger mode is selected.

When extended double-triggering is enabled both ADC input events are routed to Group A. The interrupt is still thrown after every two scans regardless of the triggering event(s). While the first and second scan are saved to the selected ADC data register and the ADC duplexing register as before, scans associated with event A and B are additionally copied into duplexing register A and B, respectively (ADC_CHANNEL_DUPLEX_A and ADC_CHANNEL_DUPLEX_B).

A/D conversion stop procedure

When using an external or internal trigger as the A/D conversion start condition, follow the section "A/D conversion stop procedure" in the user's manual. If it is configured the ADC scan end event to ELC, the example code in "Event Link Example" is useful.

Event Output Function

To use the event output of compare function, Set the mode of operation to Single Scan Mode. The compare function can be configured by enabling both Window A and Window B. Select the channel of Window A. Select Window B channel to NOT SELECTED. Set the upper and lower reference values for both Window A and Window B.

Examples

Basic Example

This is a basic example of minimal use of the ADC in an application.

/* A channel configuration is generated by the FSP Configuration editor based on the options selected. If additional
* configurations are desired additional adc_channel_cfg_t elements can be defined and passed to R_ADC_E_ScanCfg. */
const adc_e_channel_cfg_t g_adc0_channel_cfg =
{
.scan_mask_group_b = 0,
.priority_group_a = (adc_e_grpa_t) 0,
.add_mask = 0
};
void adc_e_basic_example (void)
{
fsp_err_t err = FSP_SUCCESS;
/* Initializes the module. */
err = R_ADC_E_Open(&g_adc0_ctrl, &g_adc0_cfg);
/* Handle any errors. This function should be defined by the user. */
handle_error(err);
/* Enable channels. */
err = R_ADC_E_ScanCfg(&g_adc0_ctrl, &g_adc0_channel_cfg);
handle_error(err);
/* In software trigger mode, start a scan by calling R_ADC_E_ScanStart(). In other modes, enable external
* triggers by calling R_ADC_E_ScanStart(). */
(void) R_ADC_E_ScanStart(&g_adc0_ctrl);
/* Wait for conversion to complete. */
adc_status_t status;
{
(void) R_ADC_E_StatusGet(&g_adc0_ctrl, &status);
}
/* Read converted data. */
uint16_t channel1_conversion_result;
err = R_ADC_E_Read(&g_adc0_ctrl, ADC_CHANNEL_1, &channel1_conversion_result);
handle_error(err);
}

Double-Trigger Example

This example demonstrates reading data from a double-trigger scan. A flag is used to wait for a callback event. Two scans must occur before the callback is called. These results are read via R_ADC_E_Read using the selected channel enum value as well as ADC_CHANNEL_DUPLEX.

volatile bool scan_complete_flag = false;
void adc_e_callback (adc_callback_args_t * p_args)
{
scan_complete_flag = true;
}
void adc_e_double_trigger_example (void)
{
fsp_err_t err = FSP_SUCCESS;
/* Initialize the module. */
err = R_ADC_E_Open(&g_adc0_ctrl, &g_adc0_cfg);
/* Handle any errors. This function should be defined by the user. */
handle_error(err);
/* Enable double-trigger channel. */
err = R_ADC_E_ScanCfg(&g_adc0_ctrl, &g_adc0_channel_cfg);
handle_error(err);
/* Enable scan triggering from ELC events. */
(void) R_ADC_E_ScanStart(&g_adc0_ctrl);
/* Wait for conversion to complete. Two scans must be triggered before a callback occurs. */
scan_complete_flag = false;
while (!scan_complete_flag)
{
/* Wait for callback to set flag. */
}
/* Read converted data from both scans. */
uint16_t channel1_conversion_result_0;
uint16_t channel1_conversion_result_1;
err = R_ADC_E_Read(&g_adc0_ctrl, ADC_CHANNEL_1, &channel1_conversion_result_0);
handle_error(err);
err = R_ADC_E_Read(&g_adc0_ctrl, ADC_CHANNEL_DUPLEX, &channel1_conversion_result_1);
handle_error(err);
}

Window Compare Example

This example shows how to configure the window compare function at runtime as well as how to handle events and obtain comparison results through a callback.

adc_e_window_cfg_t g_adc0_window_cfg =
{
/* Enable Window A and Window B; enable Window mode */
(adc_e_compare_cfg_t) (ADC_E_COMPARE_CFG_A_ENABLE | ADC_E_COMPARE_CFG_B_ENABLE | ADC_E_COMPARE_CFG_WINDOW_ENABLE),
/* Compare scan values from Channels 0 and 1 */
/* Set Channel 1 condition to be inside the window instead of outside */
.compare_mode_mask = ADC_E_MASK_CHANNEL_1,
/* Set reference voltage levels for Window A */
.compare_ref_low = ADC_SCAN_MAX / 3,
.compare_ref_high = ADC_SCAN_MAX * 2 / 3,
/* Configure Window B to compare Channel 2 (inside window) */
.compare_b_channel = ADC_E_WINDOW_B_CHANNEL_2,
.compare_b_mode = ADC_E_WINDOW_B_MODE_GREATER_THAN_OR_INSIDE,
/* Set reference voltage levels for Window B */
.compare_b_ref_low = ADC_SCAN_MAX / 4,
.compare_b_ref_high = ADC_SCAN_MAX * 3 / 4,
};
void adc_e_window_callback (adc_callback_args_t * p_args)
{
{
/* Get channel that met the comparison criteria */
adc_channel_t channel = p_args->channel;
/* Process event here */
}
else if (ADC_EVENT_WINDOW_COMPARE_B == p_args->event)
{
/* Process Window B events here */
}
else
{
/* ... */
}
}
void adc_e_window_compare_example (void)
{
fsp_err_t err = FSP_SUCCESS;
/* Open the ADC module */
err = R_ADC_E_Open(&g_adc0_ctrl, &g_adc0_cfg);
assert(FSP_SUCCESS == err);
/* Set the window compare configuration in the channel config */
g_adc0_channel_runtime_cfg.p_window_cfg = &g_adc0_window_cfg;
/* The window compare function is configured as part of the scan configuration */
err = R_ADC_E_ScanCfg(&g_adc0_ctrl, &g_adc0_channel_runtime_cfg);
assert(FSP_SUCCESS == err);
/* Main program loop - scan the ADC every second */
while (1)
{
/* Start a scan */
err = R_ADC_E_ScanStart(&g_adc0_ctrl);
assert(FSP_SUCCESS == err);
/* Delay; any compare events will be handled by the callback */
}
}

Event Link Example

This example shows how it works if you have set ELC to the ADC scan end event. When the ADC scan end event is set in the ELC, it should be cleared the link after stopping the ADC operation. Please refer to the section "A/D conversion stop procedure" in the user's manual.

/* ELC configuration is generated by the FSP Configuration editor based on the options selected.
* The following is the ELC configuration when the ADC_E scan end event is set to Single IOPORT. */
void adc_e_event_link_example (void)
{
fsp_err_t err = FSP_SUCCESS;
/* Initializes the module. */
err = R_ELC_Open(&g_elc_ctrl, &g_elc_cfg);
handle_error(err);
/* Create a link between a peripheral function and an event source. */
err = R_ELC_LinkSet(&g_elc_ctrl, ELC_PERIPHERAL_SINGLEPORT0, ELC_EVENT_ADC0_ADA_ADELCREQ);
handle_error(err);
/* Globally enable ELC events. */
err = R_ELC_Enable(&g_elc_ctrl);
handle_error(err);
/* Initializes the module. */
err = R_ADC_E_Open(&g_adc0_ctrl, &g_adc0_cfg);
/* Handle any errors. This function should be defined by the user. */
handle_error(err);
/* Enable channels. */
err = R_ADC_E_ScanCfg(&g_adc0_ctrl, &g_adc0_channel_cfg);
handle_error(err);
/* In software trigger mode, start a scan by calling R_ADC_E_ScanStart(). In other modes, enable external
* triggers by calling R_ADC_E_ScanStart(). */
(void) R_ADC_E_ScanStart(&g_adc0_ctrl);
/* Wait for conversion to complete. */
adc_status_t status;
{
(void) R_ADC_E_StatusGet(&g_adc0_ctrl, &status);
}
/* Stops the scan. */
err = R_ADC_E_ScanStop(&g_adc0_ctrl);
handle_error(err);
/* If the ADC scan end event is set in the ELC register of the event link controller,
* clear the link after stopping the ADC. */
err = R_ELC_LinkBreak(&g_elc_ctrl, ELC_PERIPHERAL_SINGLEPORT0);
handle_error(err);
}

Data Structures

struct  adc_e_extended_cfg_t
 
struct  adc_e_window_cfg_t
 
struct  adc_e_channel_cfg_t
 
struct  adc_e_instance_ctrl_t
 

Enumerations

enum  adc_e_mask_t
 
enum  adc_e_add_t
 
enum  adc_e_clear_t
 
enum  adc_e_grpa_t
 
enum  adc_e_active_trigger_t
 
enum  adc_e_double_trigger_t
 
enum  adc_e_compare_cfg_t
 
enum  adc_e_window_b_channel_t
 
enum  adc_e_window_b_mode_t
 
enum  adc_e_elc_t
 

Data Structure Documentation

◆ adc_e_extended_cfg_t

struct adc_e_extended_cfg_t

Extended configuration structure for ADC.

Data Fields
adc_e_add_t add_average_count Add or average samples.
adc_e_clear_t clearing Clear after read.
adc_trigger_t trigger_group_b Group B trigger source; valid only for group mode.
adc_e_double_trigger_t double_trigger_mode Double-trigger mode setting.
adc_e_active_trigger_t adc_start_trigger_a A/D Conversion Start Trigger Group A.
adc_e_active_trigger_t adc_start_trigger_b A/D Conversion Start Trigger Group B.
bool adc_start_trigger_c_enabled Set to true to enable Group C, false to disable Group C.
adc_e_active_trigger_t adc_start_trigger_c A/D Conversion Start Trigger Group C.
adc_e_elc_t adc_elc_ctrl A/D Event Link Control.
IRQn_Type window_a_irq IRQ number for Window Compare A interrupts.
IRQn_Type window_b_irq IRQ number for Window Compare B interrupts.
uint8_t window_a_ipl Priority for Window Compare A interrupts.
uint8_t window_b_ipl Priority for Window Compare B interrupts.

◆ adc_e_window_cfg_t

struct adc_e_window_cfg_t

ADC Window Compare configuration

Data Fields
uint32_t compare_mask Channel mask to compare with Window A.
uint32_t compare_mode_mask Per-channel condition mask for Window A.
adc_e_compare_cfg_t compare_cfg Window Compare configuration.
uint16_t compare_ref_low Window A lower reference value.
uint16_t compare_ref_high Window A upper reference value.
uint16_t compare_b_ref_low Window B lower reference value.
uint16_t compare_b_ref_high Window A upper reference value.
adc_e_window_b_channel_t compare_b_channel Window B channel.
adc_e_window_b_mode_t compare_b_mode Window B condition setting.

◆ adc_e_channel_cfg_t

struct adc_e_channel_cfg_t

ADC channel(s) configuration

Data Fields
uint32_t scan_mask Channels/bits: bit 0 is ch0; bit 15 is ch15.
uint32_t scan_mask_group_b Valid for group modes.
uint32_t scan_mask_group_c Valid for group modes.
uint32_t add_mask Valid if add enabled in Open().
adc_e_window_cfg_t * p_window_cfg Pointer to Window Compare configuration.
adc_e_grpa_t priority_group_a Valid for group modes.

◆ adc_e_instance_ctrl_t

struct adc_e_instance_ctrl_t

ADC instance control block. DO NOT INITIALIZE. Initialized in adc_api_t::open().

Enumeration Type Documentation

◆ adc_e_mask_t

For ADC Scan configuration adc_channel_cfg_t::scan_mask, adc_channel_cfg_t::scan_mask_group_b, adc_channel_cfg_t::add_mask and adc_channel_cfg_t::sample_hold_mask. Use bitwise OR to combine these masks for desired channels and sensors.

Enumerator
ADC_E_MASK_OFF 

No channels selected.

ADC_E_MASK_CHANNEL_0 

Channel 0 mask.

ADC_E_MASK_CHANNEL_1 

Channel 1 mask.

ADC_E_MASK_CHANNEL_2 

Channel 2 mask.

ADC_E_MASK_CHANNEL_3 

Channel 3 mask.

ADC_E_MASK_CHANNEL_4 

Channel 4 mask.

ADC_E_MASK_CHANNEL_5 

Channel 5 mask.

ADC_E_MASK_CHANNEL_6 

Channel 6 mask.

ADC_E_MASK_CHANNEL_7 

Channel 7 mask.

◆ adc_e_add_t

ADC data sample addition and averaging options

Enumerator
ADC_E_ADD_OFF 

Addition turned off for channels/sensors.

ADC_E_ADD_TWO 

Add two samples.

ADC_E_ADD_THREE 

Add three samples.

ADC_E_ADD_FOUR 

Add four samples.

ADC_E_ADD_SIXTEEN 

Add sixteen samples.

ADC_E_ADD_AVERAGE_TWO 

Average two samples.

ADC_E_ADD_AVERAGE_FOUR 

Average four samples.

◆ adc_e_clear_t

ADC clear after read definitions

Enumerator
ADC_E_CLEAR_AFTER_READ_OFF 

Clear after read off.

ADC_E_CLEAR_AFTER_READ_ON 

Clear after read on.

◆ adc_e_grpa_t

ADC action for group A interrupts group B scan. This enumeration is used to specify the priority between Group A and B in group mode.

Enumerator
ADC_E_GRPA_PRIORITY_OFF 

Group A ignored and does not interrupt Group B and Group C.

ADC_E_GRPA_GRPB_GRPC_WAIT_TRIG 

Group B and Group C restart at next trigger.

ADC_E_GRPA_GRPB_GRPC_TOP_RESTART_SCAN 

Group B and Group C restart immediately and scans from the head of the channel.

ADC_E_GRPA_GRPB_GRPC_RESTART_SCAN 

Group B and Group C restart immediately and scans.

ADC_E_GRPA_GRPB_GRPC_TOP_CONT_SCAN 

Group B and Group C restart and scans continuously from the head of the channel.

ADC_E_GRPA_GRPB_GRPC_RESTART_TOP_CONT_SCAN 

Group B and Group C restart immediately and scans continuously from the head of the channel.

ADC_E_GRPA_GRPB_GRPC_RESTART_CONT_SCAN 

Group B and Group C restart immediately and scans continuously.

◆ adc_e_active_trigger_t

Defines the registers settings for the ADC trigger.

Enumerator
ADC_E_ACTIVE_TRIGGER_EXTERNAL 

Input pin for the trigger.

ADC_E_ACTIVE_TRIGGER_GTADTRA0N 

Compare match with GPT00.GTADTRA.

ADC_E_ACTIVE_TRIGGER_GTADTRB0N 

Compare match with GPT00.GTADTRB.

ADC_E_ACTIVE_TRIGGER_GTADTRA1N 

Compare match with GPT01.GTADTRA.

ADC_E_ACTIVE_TRIGGER_GTADTRB1N 

Compare match with GPT01.GTADTRB.

ADC_E_ACTIVE_TRIGGER_GTADTRA2N 

Compare match with GPT02.GTADTRA.

ADC_E_ACTIVE_TRIGGER_GTADTRB2N 

Compare match with GPT02.GTADTRB.

ADC_E_ACTIVE_TRIGGER_GTADTRA3N 

Compare match with GPT03.GTADTRA.

ADC_E_ACTIVE_TRIGGER_GTADTRB3N 

Compare match with GPT03.GTADTRB.

ADC_E_ACTIVE_TRIGGER_GTADTRA4N 

Compare match with GPT04.GTADTRA.

ADC_E_ACTIVE_TRIGGER_GTADTRB4N 

Compare match with GPT04.GTADTRB.

ADC_E_ACTIVE_TRIGGER_GTADTRA5N 

Compare match with GPT05.GTADTRA.

ADC_E_ACTIVE_TRIGGER_GTADTRB5N 

Compare match with GPT05.GTADTRB.

ADC_E_ACTIVE_TRIGGER_GTADTRA6N 

Compare match with GPT06.GTADTRA.

ADC_E_ACTIVE_TRIGGER_GTADTRB6N 

Compare match with GPT06.GTADTRB.

ADC_E_ACTIVE_TRIGGER_GTADTRA7N 

Compare match with GPT07.GTADTRA.

ADC_E_ACTIVE_TRIGGER_GTADTRB7N 

Compare match with GPT07.GTADTRB.

ADC_E_ACTIVE_TRIGGER_GTADTRA8N 

Compare match with GPT08.GTADTRA.

ADC_E_ACTIVE_TRIGGER_GTADTRB8N 

Compare match with GPT08.GTADTRB.

ADC_E_ACTIVE_TRIGGER_GTADTRA9N 

Compare match with GPT09.GTADTRA.

ADC_E_ACTIVE_TRIGGER_GTADTRB9N 

Compare match with GPT09.GTADTRB.

ADC_E_ACTIVE_TRIGGER_GTADTRA10N 

Compare match with GPT10.GTADTRA.

ADC_E_ACTIVE_TRIGGER_GTADTRB10N 

Compare match with GPT10.GTADTRB.

ADC_E_ACTIVE_TRIGGER_GTADTRA11N 

Compare match with GPT11.GTADTRA.

ADC_E_ACTIVE_TRIGGER_GTADTRB11N 

Compare match with GPT11.GTADTRB.

ADC_E_ACTIVE_TRIGGER_GTADTRA12N 

Compare match with GPT12.GTADTRA.

ADC_E_ACTIVE_TRIGGER_GTADTRB12N 

Compare match with GPT12.GTADTRB.

ADC_E_ACTIVE_TRIGGER_GTADTRA13N 

Compare match with GPT13.GTADTRA.

ADC_E_ACTIVE_TRIGGER_GTADTRB13N 

Compare match with GPT13.GTADTRB.

ADC_E_ACTIVE_TRIGGER_GTADTRA14N 

Compare match with GPT14.GTADTRA.

ADC_E_ACTIVE_TRIGGER_GTADTRB14N 

Compare match with GPT14.GTADTRB.

ADC_E_ACTIVE_TRIGGER_GTADTRA15N 

Compare match with GPT15.GTADTRA.

ADC_E_ACTIVE_TRIGGER_GTADTRB15N 

Compare match with GPT15.GTADTRB.

ADC_E_ACTIVE_TRIGGER_GTADTRA0N_B0N 

Compare match with GPT00.GTADTRA or Compare match with GPT00.GTADTRB.

ADC_E_ACTIVE_TRIGGER_GTADTRA1N_B1N 

Compare match with GPT01.GTADTRA or Compare match with GPT01.GTADTRB.

ADC_E_ACTIVE_TRIGGER_GTADTRA2N_B2N 

Compare match with GPT02.GTADTRA or Compare match with GPT02.GTADTRB.

ADC_E_ACTIVE_TRIGGER_GTADTRA3N_B3N 

Compare match with GPT03.GTADTRA or Compare match with GPT03.GTADTRB.

ADC_E_ACTIVE_TRIGGER_GTADTRA4N_B4N 

Compare match with GPT04.GTADTRA or Compare match with GPT04.GTADTRB.

ADC_E_ACTIVE_TRIGGER_GTADTRA5N_B5N 

Compare match with GPT05.GTADTRA or Compare match with GPT05.GTADTRB.

ADC_E_ACTIVE_TRIGGER_GTADTRA6N_B6N 

Compare match with GPT06.GTADTRA or Compare match with GPT06.GTADTRB.

ADC_E_ACTIVE_TRIGGER_GTADTRA7N_B7N 

Compare match with GPT07.GTADTRA or Compare match with GPT07.GTADTRB.

ADC_E_ACTIVE_TRIGGER_GTADTRA8N_B8N 

Compare match with GPT08.GTADTRA or Compare match with GPT08.GTADTRB.

ADC_E_ACTIVE_TRIGGER_GTADTRA9N_B9N 

Compare match with GPT09.GTADTRA or Compare match with GPT09.GTADTRB.

ADC_E_ACTIVE_TRIGGER_GTADTRA10N_B10N 

Compare match with GPT10.GTADTRA or Compare match with GPT10.GTADTRB.

ADC_E_ACTIVE_TRIGGER_GTADTRA11N_B11N 

Compare match with GPT11.GTADTRA or Compare match with GPT11.GTADTRB.

ADC_E_ACTIVE_TRIGGER_GTADTRA12N_B12N 

Compare match with GPT12.GTADTRA or Compare match with GPT12.GTADTRB.

ADC_E_ACTIVE_TRIGGER_GTADTRA13N_B13N 

Compare match with GPT13.GTADTRA or Compare match with GPT13.GTADTRB.

ADC_E_ACTIVE_TRIGGER_GTADTRA14N_B14N 

Compare match with GPT14.GTADTRA or Compare match with GPT14.GTADTRB.

ADC_E_ACTIVE_TRIGGER_GTADTRA15N_B15N 

Compare match with GPT15.GTADTRA or Compare match with GPT15.GTADTRB.

ADC_E_ACTIVE_TRIGGER_ELCTRG0 

ELC trigger.

ADC_E_ACTIVE_TRIGGER_DISABLED 

Trigger source de-selection state.

◆ adc_e_double_trigger_t

ADC double-trigger mode definitions

Enumerator
ADC_E_DOUBLE_TRIGGER_DISABLED 

Double-triggering disabled.

ADC_E_DOUBLE_TRIGGER_ENABLED 

Double-triggering enabled.

ADC_E_DOUBLE_TRIGGER_ENABLED_EXTENDED 

Double-triggering enabled on both ADC ELC events.

◆ adc_e_compare_cfg_t

ADC comparison settings

◆ adc_e_window_b_channel_t

ADC Window B channel

◆ adc_e_window_b_mode_t

ADC Window B comparison mode

◆ adc_e_elc_t

AD event link control definitions.

Enumerator
ADC_E_ELC_GROUP_A_SCAN 

At the end of a group_a scan GCELC = 0b, ELCC[1:0] = 00b.

ADC_E_ELC_GROUP_B_SCAN 

At the end of a group_b scan GCELC = 0b, ELCC[1:0] = 01b.

ADC_E_ELC_GROUP_A_B_C_SCAN 

At the end of a group_abc scan GCELC = 0b, ELCC[1:0] = 1xb.

ADC_E_ELC_GROUP_C_SCAN 

At the end of a group_c scan GCELC = 1b, ELCC[1:0] = 00b.

Function Documentation

◆ R_ADC_E_Open()

fsp_err_t R_ADC_E_Open ( adc_ctrl_t p_ctrl,
adc_cfg_t const *const  p_cfg 
)

Sets the operational mode, trigger sources, interrupt priority, and configurations for the peripheral as a whole. If interrupt is enabled, the function registers a callback function pointer for notifying the user whenever a scan has completed.

Return values
FSP_SUCCESSModule is ready for use.
FSP_ERR_ASSERTIONAn input argument is invalid.
FSP_ERR_ALREADY_OPENThe instance control structure has already been opened.
FSP_ERR_IRQ_BSP_DISABLEDA callback is provided, but the interrupt is not enabled.
FSP_ERR_IP_CHANNEL_NOT_PRESENTThe requested unit does not exist on this MCU.
FSP_ERR_INVALID_HW_CONDITIONThe ADC clock must be at least 1 MHz

◆ R_ADC_E_ScanCfg()

fsp_err_t R_ADC_E_ScanCfg ( adc_ctrl_t p_ctrl,
void const *const  p_channel_cfg 
)

Configures the ADC scan parameters. Channel specific settings are set in this function. Pass a pointer to adc_e_channel_cfg_t to p_channel_cfg.

Return values
FSP_SUCCESSChannel specific settings applied.
FSP_ERR_ASSERTIONAn input argument is invalid.
FSP_ERR_NOT_OPENUnit is not open.

◆ R_ADC_E_InfoGet()

fsp_err_t R_ADC_E_InfoGet ( adc_ctrl_t p_ctrl,
adc_info_t p_adc_info 
)

Returns the address of the lowest number configured channel and the total number of bytes to be read in order to read the results of the configured channels. If no channels are configured, then a length of 0 is returned.

Note
In group mode, information is returned for group A only. Calculating information for group B is not currently supported.
Return values
FSP_SUCCESSInformation stored in p_adc_info.
FSP_ERR_ASSERTIONAn input argument is invalid.
FSP_ERR_NOT_OPENUnit is not open.

◆ R_ADC_E_ScanStart()

fsp_err_t R_ADC_E_ScanStart ( adc_ctrl_t p_ctrl)

Starts a software scan or enables the hardware trigger for a scan depending on how the triggers were configured in the R_ADC_E_Open call. If the unit was configured for ELC or external hardware triggering, then this function allows the trigger signal to get to the ADC unit. The function is not able to control the generation of the trigger itself. If the unit was configured for software triggering, then this function starts the software triggered scan.

Precondition
Call R_ADC_E_ScanCfg after R_ADC_E_Open before starting a scan.
Return values
FSP_SUCCESSScan started (software trigger) or hardware triggers enabled.
FSP_ERR_ASSERTIONAn input argument is invalid.
FSP_ERR_NOT_OPENADC_E is not open.
FSP_ERR_NOT_INITIALIZEDADC_E is not initialized.
FSP_ERR_IN_USEAnother scan is still in progress (software trigger).

◆ R_ADC_E_ScanGroupStart()

fsp_err_t R_ADC_E_ScanGroupStart ( adc_ctrl_t p_ctrl,
adc_group_mask_t  group_id 
)

adc_api_t::scanStart is not supported on the ADCH. Use scanStart instead.

Return values
FSP_ERR_UNSUPPORTEDFunction not supported in this implementation.

◆ R_ADC_E_ScanStop()

fsp_err_t R_ADC_E_ScanStop ( adc_ctrl_t p_ctrl)

Stops the software scan or disables the unit from being triggered by the hardware trigger (ELC or external) based on what type of trigger the unit was configured for in the R_ADC_E_Open function. Stopping a hardware triggered scan via this function does not abort an ongoing scan, but prevents the next scan from occurring. Stopping a software triggered scan aborts an ongoing scan.

Return values
FSP_SUCCESSScan stopped (software trigger) or hardware triggers disabled.
FSP_ERR_ASSERTIONAn input argument is invalid.
FSP_ERR_NOT_OPENUnit is not open.
FSP_ERR_NOT_INITIALIZEDUnit is not initialized.

◆ R_ADC_E_StatusGet()

fsp_err_t R_ADC_E_StatusGet ( adc_ctrl_t p_ctrl,
adc_status_t p_status 
)

Provides the status of any scan process that was started, including scans started by ELC or external triggers.

Return values
FSP_SUCCESSModule status stored in the provided pointer p_status
FSP_ERR_ASSERTIONAn input argument is invalid.
FSP_ERR_NOT_OPENUnit is not open.

◆ R_ADC_E_Read()

fsp_err_t R_ADC_E_Read ( adc_ctrl_t p_ctrl,
adc_channel_t const  reg_id,
uint16_t *const  p_data 
)

Reads conversion results from a single channel or sensor.

Return values
FSP_SUCCESSData read into provided p_data.
FSP_ERR_ASSERTIONAn input argument is invalid.
FSP_ERR_NOT_OPENUnit is not open.
FSP_ERR_NOT_INITIALIZEDUnit is not initialized.

◆ R_ADC_E_Read32()

fsp_err_t R_ADC_E_Read32 ( adc_ctrl_t p_ctrl,
adc_channel_t const  reg_id,
uint32_t *const  p_data 
)

Reads conversion results from a single channel or sensor register into a 32-bit result.

Return values
FSP_SUCCESSData read into provided p_data.
FSP_ERR_ASSERTIONAn input argument is invalid.
FSP_ERR_NOT_OPENUnit is not open.
FSP_ERR_NOT_INITIALIZEDUnit is not initialized.

◆ R_ADC_E_Close()

fsp_err_t R_ADC_E_Close ( adc_ctrl_t p_ctrl)

This function ends any scan in progress, disables interrupts, and removes power to the A/D peripheral.

Return values
FSP_SUCCESSModule closed.
FSP_ERR_ASSERTIONAn input argument is invalid.
FSP_ERR_NOT_OPENUnit is not open.

◆ R_ADC_E_OffsetSet()

fsp_err_t R_ADC_E_OffsetSet ( adc_ctrl_t *const  p_ctrl,
adc_channel_t const  reg_id,
int32_t  offset 
)

adc_api_t::offsetSet is not supported on the ADC.

Return values
FSP_ERR_UNSUPPORTEDFunction not supported in this implementation.

◆ R_ADC_E_Calibrate()

fsp_err_t R_ADC_E_Calibrate ( adc_ctrl_t *const  p_ctrl,
void const *  p_extend 
)

adc_api_t::calibrate is not supported on the ADC.

Return values
FSP_ERR_UNSUPPORTEDFunction not supported in this implementation.

◆ R_ADC_E_CallbackSet()

fsp_err_t R_ADC_E_CallbackSet ( adc_ctrl_t *const  p_api_ctrl,
void(*)(adc_callback_args_t *)  p_callback,
void const *const  p_context,
adc_callback_args_t *const  p_callback_memory 
)

Updates the user callback and has option of providing memory for callback structure. Implements adc_api_t::callbackSet

Return values
FSP_SUCCESSCallback updated successfully.
FSP_ERR_ASSERTIONA required pointer is NULL.
FSP_ERR_NOT_OPENThe control block has not been opened.