RA Flexible Software Package Documentation  Release v5.7.0

 
ADC (r_adc_d)

Functions

fsp_err_t R_ADC_D_Open (adc_ctrl_t *p_ctrl, adc_cfg_t const *const p_cfg)
 
fsp_err_t R_ADC_D_ScanCfg (adc_ctrl_t *p_ctrl, void const *const p_channel_cfg)
 
fsp_err_t R_ADC_D_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)
 
fsp_err_t R_ADC_D_ScanStart (adc_ctrl_t *p_ctrl)
 
fsp_err_t R_ADC_D_ScanGroupStart (adc_ctrl_t *p_ctrl, adc_group_mask_t group_id)
 
fsp_err_t R_ADC_D_ScanStop (adc_ctrl_t *p_ctrl)
 
fsp_err_t R_ADC_D_StatusGet (adc_ctrl_t *p_ctrl, adc_status_t *p_status)
 
fsp_err_t R_ADC_D_Read (adc_ctrl_t *p_ctrl, adc_channel_t const reg_id, uint16_t *const p_data)
 
fsp_err_t R_ADC_D_Read32 (adc_ctrl_t *p_ctrl, adc_channel_t const reg_id, uint32_t *const p_data)
 
fsp_err_t R_ADC_D_InfoGet (adc_ctrl_t *p_ctrl, adc_info_t *p_adc_info)
 
fsp_err_t R_ADC_D_Close (adc_ctrl_t *p_ctrl)
 
fsp_err_t R_ADC_D_Calibrate (adc_ctrl_t *const p_ctrl, void const *p_extend)
 
fsp_err_t R_ADC_D_OffsetSet (adc_ctrl_t *const p_ctrl, adc_channel_t const reg_id, int32_t offset)
 
fsp_err_t R_ADC_D_SnoozeModePrepare (adc_ctrl_t *const p_ctrl)
 
fsp_err_t R_ADC_D_SnoozeModeExit (adc_ctrl_t *const p_ctrl)
 

Detailed Description

Driver for ADC_D version of the ADC12 peripheral on RA MCUs. This module implements the ADC Interface.

Overview

Features

The ADC module supports the following features:

Configuration

Build Time Configurations for r_adc_d

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

ConfigurationOptionsDefaultDescription
Parameter Checking
  • Default (BSP)
  • Enabled
  • Disabled
Default (BSP) If selected code for parameter checking is included in the build.
Internal Reference Voltage Support
  • Enabled
  • Disabled
Disabled Enable Internal Reference Voltage support for the ADC module.
Snooze Mode Support
  • Enabled
  • Disabled
Disabled Enable Snooze Mode Support.
Interrupt Support
  • Enabled
  • Disabled
Enabled Enable Scan End Interrupt support for the ADC module.

Configurations for Analog > ADC (r_adc_d)

This module can be added to the Stacks tab via New Stack > Analog > ADC (r_adc_d).

ConfigurationOptionsDefaultDescription
General
NameName must be a valid C symbolg_adc0 Module name
Resolution
  • 12-Bit
  • 10-Bit
  • 8-Bit
12-Bit Specifies the conversion resolution for this unit.
Conversion operation
  • One-shot
  • Sequential
One-shot Specifies the conversion operation mode.
Operation trigger
  • Wait
  • No-wait
Wait Specifies the operation trigger mode.
Operation voltage
  • Normal 1
  • Normal 2
  • Low voltage 1
  • Low voltage 2
Normal 1 Specifies operation voltage mode.
Conversion Clock (fAD)
  • PCLK
  • PCLK/2
  • PCLK/4
  • PCLK/8
  • PCLK/16
  • PCLK/32
PCLK Specifies divider for conversion clock (fAD).
Input
Channel Selection Mode
  • Select
  • Scan
Select Specifies the channel selection mode.
A/D Input channelMCU Specific OptionsSpecifies the input channels.
Negative Side Reference Voltage
  • VSS
  • VREFL0
VSS Selection of the Negative Side Reference Voltage.
Positive Side Reference Voltage
  • VCC
  • VREFH0
  • Internal Reference Voltage
VCC Selection of the Positive Side Reference Voltage.
Interrupts
Interrupts > Conversion Result upper/lower bound value setting
Generates an interrupt request (INTAD)
  • The interrupt signal is output when the ADLL register <= the ADCRn register <= the ADUL register
  • The interrupt signal is output when the ADCRn register < the ADLL register or the ADUL register < the ADCRn register
The interrupt signal is output when the ADLL register <= the ADCRn register <= the ADUL register Specify condition generates an interrupt(INTAD) after each time the ADC scan completes.
Upper bound (ADUL) valueMust be a valid integer255 Specify the upper limit conversion value that corresponds to the condition to generate an interrupt request (INTAD).
Lower bound (ADLL) valueMust be a valid integer0 Specify the lower limit conversion value that corresponds to the condition to generate an interrupt request (INTAD).
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.
Scan End Interrupt PriorityMCU Specific OptionsSelect scan end interrupt priority.
Start trigger sourceMCU Specific OptionsSpecifies the trigger type to be used for this unit.

Clock Configuration

The ADC_D conversion clock source may be configured to use ICLK with a selectable division ratio.

The ADC_D clock must be at least 1 MHz when the ADC is used.

Pin Configuration

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

Usage Notes

ADC_D Operational Conversion

The driver supports two operation conversion mode: One-shot scan and Sequential scan modes. For each time conversion, ADC peripheral only converts for each a pin or group of pins depending on channels selection mode, it can be changed to another pin or group of other pins by calling R_ADC_D_ScanCfg().

Oneshot-scan Mode

In One-shot scan mode, one or group specified channels are scanned once per trigger.

Sequential-scan Mode

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

When Interrupt Is Not Enabled

If interrupts are not enabled, the R_ADC_D_StatusGet API can be used to poll the ADC to determine when the scan has completed. The read API function is used to access the converted ADC result.

When Interrupt Is Enabled

An interrupt is generated depend on setting condition of converted ADC result is in range or out of range of Upper Bound Value (ADUL) and Low Bound Value (ADLL). Please refer to "Figure ADRCK Bit Interrupt Signal Generation Range" in RA0E1 User's Manual (R01UH1040EJ0100).

Selecting Reference Voltage

The ADC_D positive and negative side reference voltages may be configured for selected MCU's. Please refer to the RA Configuration editor in e2 studio for further details.

Note
When the internal reference voltage is selected as the positive side reference voltage. Please refer condition as below
  • Select operation voltage is low-voltage mode 1 or 2.
  • The conversion clock (fAD) must be range 1 to 2 MHZ.
  • Do not setting select internal reference voltage or temperature sensor channel as an A/D conversion channel.

Selecting Internal Reference Voltage or Temperature Sensor channel

When the internal reference voltage or temperature sensor output voltage is selected as the target for A/D conversion, please setting operation voltage is normal mode 2 or low-voltage mode 2.

Note
when using operation voltage is low-voltage mode 2, setting a conversion clock (fAD) is less than or equal 16 MHz.

Selecting Conversion Clock

Range for frequency of Conversion Clock (fAD) depends on frequency of ICK. Please refer table as below.

Frequency of ICLK Frequency of Conversion Clock (fAD)
4 MHz < ICLK <= 32 MHzICLK to ICLK/32
1 MHz <= fCLK <= 4 MHzICLK to ICLK/4

Selecting Operation Voltage

The operation voltage is selectable depending on the analog input channel, VREFH0 voltage, operation mode, and ICLK. For detail, refer table A/D Conversion Time Selection in Section A/D Converter (ADC) in RA0E1 User's Manual (R01UH1040EJ0100).

Note
When operation voltage is low-voltage modes 1 or 2 in the Electrical Characteristics section in RA0E1 User's Manual (R01UH1040EJ0100), setting frequency of ICLK should be used with a frequency less than or equal 24 MHz.

ADC_D conversion in Test Mode

The conversion target for testing can be selected by using the Input > A/D Input channel property in the module configuration.

Note
For more details on the method of checking, refer to section 25.8 "Testing of the A/D Converter" in RA0E1 User's Manual (R01UH1040EJ0100).

Using the Temperature Sensor with the ADC_D

The ADC_D HAL module supports reading the data from the on-chip temperature sensor. The value returned from the sensor can be converted into degrees Celsius or Fahrenheit in the application program using the following formula, T = (Vs - V1)/slope + T1, where:

Note
The slope value can be obtained for each in the Electrical Characteristics Chapter - TSN Characteristics Table, Temperature slope entry.

For the setting flow, see section 25.6.5. "Example of Using the ADC12 when Selecting the Temperature Sensor Output Voltage or Internal Reference Voltage, and Software Trigger No-wait Mode and One-shot Conversion Mode" in RA0E1 User's Manual (R01UH1040EJ0100).

Examples

Basic Example

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

/* A channel configuration is generated by the RA Configuration editor based on the options selected. If additional
* configurations are desired additional adc_d_channel_cfg_t elements can be defined and passed to R_ADC_D_ScanCfg. */
adc_d_channel_cfg_t g_adc_d0_channel_cfg =
{
.channel_input = ADC_CHANNEL_1,
};
void adc_d_callback (adc_callback_args_t * p_args)
{
}
void adc_d_basic_example (void)
{
fsp_err_t err = FSP_SUCCESS;
/* Initializes the module. */
err = R_ADC_D_Open(&g_adc_d0_ctrl, &g_adc_d0_cfg);
/* Handle any errors. This function should be defined by the user. */
assert(FSP_SUCCESS == err);
/* Enable channels. */
err = R_ADC_D_ScanCfg(&g_adc_d0_ctrl, &g_adc_d0_channel_cfg);
assert(FSP_SUCCESS == err);
/* In software trigger mode, start a scan by calling R_ADC_D_ScanStart(). In other modes, enable hardware
* triggers by calling R_ADC_D_ScanStart(). */
(void) R_ADC_D_ScanStart(&g_adc_d0_ctrl);
/* Wait for conversion to complete. */
adc_status_t status;
{
(void) R_ADC_D_StatusGet(&g_adc_d0_ctrl, &status);
}
/* Read converted data. */
uint16_t channel1_conversion_result;
err = R_ADC_D_Read(&g_adc_d0_ctrl, ADC_CHANNEL_1, &channel1_conversion_result);
assert(FSP_SUCCESS == err);
}

Temperature Sensor Example

This example shows how to calculate the MCU temperature using the ADC_D and the temperature sensor.

#define ADC_D_EXAMPLE_TEMPERATURE_VOLTAGE_V1 (1050000)
#define ADC_D_EXAMPLE_VCC_MICROVOLT (3300000)
#define ADC_D_EXAMPLE_TEMPERATURE_RESOLUTION (4096)
#define ADC_D_EXAMPLE_ADC_TEST_TEMPERATURE_CELSIUS_T1 (25)
#define ADC_PRV_COEFFICIENT (0.5)
void adc_d_temperature_example (void)
{
/* The following example calculates the temperature using the data provided in the section
* "Temperature Sensor (TSN)" in RA0E1 User's Manual (R01UH1040EJ0100). */
fsp_err_t err = FSP_SUCCESS;
/* Using normal mode 2 when configure temperature channel */
g_adc_d0_cfg_extend.operation_voltage = ADC_D_VOLTAGE_MODE_NORMAL_2;
g_adc_d0_cfg_extend.operation_trigger = ADC_D_TRIGGER_MODE_NO_WAIT;
/* Initializes the module. */
err = R_ADC_D_Open(&g_adc_d0_ctrl, &g_adc_d0_cfg);
/* Handle any errors. This function should be defined by the user. */
assert(FSP_SUCCESS == err);
/* Configure temperature channel */
g_adc_d0_channel_cfg.channel_input = ADC_CHANNEL_TEMPERATURE;
/* Enable temperature sensor. */
err = R_ADC_D_ScanCfg(&g_adc_d0_ctrl, &g_adc_d0_channel_cfg);
assert(FSP_SUCCESS == err);
/* Start of A/D conversion */
(void) R_ADC_D_ScanStart(&g_adc_d0_ctrl);
/* Wait for conversion to complete. */
adc_status_t status;
{
(void) R_ADC_D_StatusGet(&g_adc_d0_ctrl, &status);
}
/* The 1st conversion result cannot be used. See Table 25.18 "Setup when temperature sensor output voltage and
* internal reference voltage is selected" in RA0E1 User's Manual (R01UH1040EJ0100). */
/* Start of A/D conversion */
(void) R_ADC_D_ScanStart(&g_adc_d0_ctrl);
/* Wait for conversion to complete. */
{
(void) R_ADC_D_StatusGet(&g_adc_d0_ctrl, &status);
}
/* Read converted data. */
uint16_t temperature_conversion_result;
err = R_ADC_D_Read(&g_adc_d0_ctrl, ADC_CHANNEL_TEMPERATURE, &temperature_conversion_result);
assert(FSP_SUCCESS == err);
/* If the MCU does not provide calibration data, use the value in the hardware manual or determine it
* experimentally. */
/* Get Calibration data from the MCU if available. */
adc_info_t adc_info;
(void) R_ADC_D_InfoGet(&g_adc_d0_ctrl, &adc_info);
/* NOTE: The slope of the temperature sensor varies from sensor to sensor. Renesas recommends calculating
* the slope of the temperature sensor experimentally.
*
* This example uses the typical slope provided in Table "TSN characteristics" in the user manual */
int32_t slope_uv_per_c = BSP_FEATURE_ADC_TSN_SLOPE;
/* Formula for calculating temperature copied from section "Temperature Sensor (TSN)"
* of the user manual:
*
* Using this, the measured temperature can be calculated according to the following formula.
*
* T = (Vs - V1) / Slope + T1 [C]
* T: Measured temperature (C)
* Vs: Voltage output by the temperature sensor when the temperature is measured (V)
* V1: Voltage output by T1(25 C) is 1.05 V. Refer table "TSN characteristics" in the user manual
* Slope: Temperature slope given in table "TSN characteristics" -3.3 mV/C
* T1: Temperature of T1 is 25 C.Refer table "TSN characteristics" in the user manual
*/
int32_t v1_uv = ADC_D_EXAMPLE_TEMPERATURE_VOLTAGE_V1;
/* Refer to chapter "Input Voltage and Conversion Results" in the user manual */
int32_t vs_uv =
(int32_t) (((temperature_conversion_result - ADC_PRV_COEFFICIENT) * ADC_D_EXAMPLE_VCC_MICROVOLT) /
ADC_D_EXAMPLE_TEMPERATURE_RESOLUTION);
int32_t temperature_c =
(int32_t) ((vs_uv - v1_uv) / slope_uv_per_c + ADC_D_EXAMPLE_ADC_TEST_TEMPERATURE_CELSIUS_T1);
/* Expect room temperature, break if temperature is outside the range of 20 C to 25 C. */
if ((temperature_c < 20) || (temperature_c > 25))
{
__BKPT(0);
}
}

Requesting Snooze mode using ADC_D Hardware Trigger

ADC_D can request snooze mode via a hardware trigger and perform an ADC conversion in the following modes:

In order to enable this functionality, the application must call R_ADC_D_SnoozeModePrepare() immediately before entering software standby mode, and call R_ADC_D_SnoozeModeExit() immediately after returning from software standby mode.

void adc_d_snooze_request_example (void)
{
fsp_err_t err = FSP_SUCCESS;
/* Configure ADC_D with the following settings:
* - adc_d_extended_cfg_t::trigger_source = [ADC_D_TRIGGER_SOURCE_TAU0_TMI01,
* ADC_D_TRIGGER_SOURCE_RTC_ALARM_OR_PERIOD,
* ADC_D_TRIGGER_SOURCE_TML0_ITL0,
* ADC_D_TRIGGER_SOURCE_ELC] (Hardware trigger)
* - adc_d_extended_cfg_t::operation_trigger = ADC_D_TRIGGER_MODE_WAIT (Wait mode)
* - adc_d_extended_cfg_t::conversion_operation = ADC_D_CONVERSION_MODE_ONESHOT (One shot conversion mode)
* - ICLK must be operating off of HOCO or MOCO
*/
err = R_ADC_D_Open(&g_adc_d0_ctrl, &g_adc_d0_cfg);
assert(FSP_SUCCESS == err);
err = R_ADC_D_ScanCfg(&g_adc_d0_ctrl, &g_adc_d0_channel_cfg);
assert(FSP_SUCCESS == err);
err = R_ADC_D_ScanStart(&g_adc_d0_ctrl);
assert(FSP_SUCCESS == err);
/* Configure a hardware trigger for ADC_D (Ie. RTC Periodic IRQ). */
err = R_RTC_C_Open(&g_rtc_ctrl, &g_rtc_cfg);
assert(FSP_SUCCESS == err);
err = R_RTC_C_CalendarTimeSet(&g_rtc_ctrl, &g_rtc_current_time);
assert(FSP_SUCCESS == err);
assert(FSP_SUCCESS == err);
/* Configure LPM in snooze mode. */
err = R_LPM_Open(&g_lpm_ctrl, &g_lpm_snooze_cfg);
assert(FSP_SUCCESS == err);
/* Prepare ADC_D to operate in snooze mode. This must be called immediately before entering software standby mode. */
err = R_ADC_D_SnoozeModePrepare(&g_adc_d0_ctrl);
assert(FSP_SUCCESS == err);
/* Enter low power mode:
*
* When RTC_C Periodic IRQ occurs, ICLK source will be started. ADC_D will wait for the oscillator to stabilize,
* then start an ADC conversion.
*/
err = R_LPM_LowPowerModeEnter(&g_lpm_ctrl);
assert(FSP_SUCCESS == err);
/* After exiting snooze mode, return ADC operation to normal mode. */
err = R_ADC_D_SnoozeModeExit(&g_adc_d0_ctrl);
assert(FSP_SUCCESS == err);
}

Data Structures

struct  adc_d_channel_cfg_t
 
struct  adc_d_extended_cfg_t
 
struct  adc_d_instance_ctrl_t
 

Enumerations

enum  adc_d_channel_mode_t
 
enum  adc_d_voltage_mode_t
 
enum  adc_d_clock_div_t
 
enum  adc_d_trigger_source_t
 
enum  adc_d_trigger_mode_t
 
enum  adc_d_conversion_mode_t
 
enum  adc_d_boundary_t
 
enum  adc_d_negative_vref_t
 
enum  adc_d_positive_vref_t
 

Data Structure Documentation

◆ adc_d_channel_cfg_t

struct adc_d_channel_cfg_t

ADC_D channel(s) configuration

◆ adc_d_extended_cfg_t

struct adc_d_extended_cfg_t

Extended configuration structure for ADC.

Data Fields
adc_d_channel_mode_t channel_mode ADC_D channels mode setting.
adc_d_voltage_mode_t operation_voltage Voltage mode setting.
adc_d_clock_div_t conversion_clockdiv Divider for conversion clock (fAD) setting.
adc_d_trigger_source_t trigger_source Trigger source hardware and software setting.
adc_d_trigger_mode_t operation_trigger Operation mode wait/no wait setting.
adc_d_conversion_mode_t conversion_operation Sequential/one-shot conversion setting.
adc_d_boundary_t upper_lower_bound Upper limit and lower limit conversion setting.
adc_d_negative_vref_t negative_vref Negative side reference voltage setting.
adc_d_positive_vref_t positive_vref Positive side reference voltage setting.
uint8_t upper_bound_limit Setting upper limit conversion value.
uint8_t lower_bound_limit Setting lower limit conversion value.

◆ adc_d_instance_ctrl_t

struct adc_d_instance_ctrl_t

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

Enumeration Type Documentation

◆ adc_d_channel_mode_t

ADC_D channels mode selection

Enumerator
ADC_D_CHANNEL_MODE_SELECT 

Select mode.

ADC_D_CHANNEL_MODE_SCAN 

Scan mode.

◆ adc_d_voltage_mode_t

Operation voltage mode selection

Enumerator
ADC_D_VOLTAGE_MODE_NORMAL_1 

Normal 1.

ADC_D_VOLTAGE_MODE_NORMAL_2 

Normal 2.

ADC_D_VOLTAGE_MODE_LOW_1 

Low voltage 1.

ADC_D_VOLTAGE_MODE_LOW_2 

Low voltage 2.

◆ adc_d_clock_div_t

Divider for Conversion Clock (fAD)

Enumerator
ADC_D_CLOCK_DIV_32 

ADC_D clock division ICLK/32.

ADC_D_CLOCK_DIV_16 

ADC_D clock division ICLK/16.

ADC_D_CLOCK_DIV_8 

ADC_D clock division ICLK/8.

ADC_D_CLOCK_DIV_4 

ADC_D clock division ICLK/4.

ADC_D_CLOCK_DIV_2 

ADC_D clock division ICLK/2.

ADC_D_CLOCK_DIV_1 

ADC_D clock division ICLK/1.

◆ adc_d_trigger_source_t

Selection trigger signal

Enumerator
ADC_D_TRIGGER_SOURCE_TAU0_TMI01 

Timer channel 01 count or capture end interrupt signal.

ADC_D_TRIGGER_SOURCE_RTC_ALARM_OR_PERIOD 

Realtime clock interrupt signal.

ADC_D_TRIGGER_SOURCE_TML0_ITL0 

32-bit interval timer interrupt signal

ADC_D_TRIGGER_SOURCE_ELC 

Event input from ELC.

ADC_D_TRIGGER_SOURCE_SOFTWARE 

Software trigger, this option is controlled by bit ADCS, ADCE.

◆ adc_d_trigger_mode_t

Select trigger mode

Enumerator
ADC_D_TRIGGER_MODE_NO_WAIT 

Trigger no-wait mode.

ADC_D_TRIGGER_MODE_WAIT 

Trigger wait mode.

◆ adc_d_conversion_mode_t

Select conversion operation mode

Enumerator
ADC_D_CONVERSION_MODE_SEQUENTIAL 

Continuous conversion mode.

ADC_D_CONVERSION_MODE_ONESHOT 

Single conversion mode.

◆ adc_d_boundary_t

Select the upper limit and lower limit conversion result values

Enumerator
ADC_D_BOUNDARY_IN_RANGE 

The interrupt signal (INTAD) is output in range ADLL and AULL.

ADC_D_BOUNDARY_OUT_OF_RANGE 

The interrupt signal (INTAD) is output out of range ADLL and AULL.

◆ adc_d_negative_vref_t

The negative side reference voltage selection

Enumerator
ADC_D_NEGATIVE_VREF_VSS 

Supplied from VSS.

ADC_D_NEGATIVE_VREF_VREFL0 

Supplied from VREFL0.

◆ adc_d_positive_vref_t

The positive side reference voltage selection

Enumerator
ADC_D_POSITIVE_VREF_VCC 

Supplied from VSS.

ADC_D_POSITIVE_VREF_VREFH0 

Supplied from VREFH0.

ADC_D_POSITIVE_VREF_IVREF 

Supplied from the internal reference voltage.

Function Documentation

◆ R_ADC_D_Open()

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

Initialize the ADC_D peripheral. If interrupt is enabled, the function registers a callback function for notifying the user when a scan has completed. Implements adc_api_t::open.

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_INVALID_HW_CONDITIONInvalid configuration corresponds to condition HardWare UM.

◆ R_ADC_D_ScanCfg()

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

Configures the ADC_D scan parameters. Channel specific settings are set in this function. Pass a pointer to adc_d_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.
FSP_ERR_INVALID_HW_CONDITIONInvalid configuration corresponds to condition HardWare UM.
FSP_ERR_INVALID_STATEInvalid Scan Configuration.
FSP_ERR_INVALID_CHANNELChannel is invalid.

◆ R_ADC_D_CallbackSet()

fsp_err_t R_ADC_D_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_NOT_OPENUnit is not open.
FSP_ERR_ASSERTIONA required pointer is NULL.

◆ R_ADC_D_ScanStart()

fsp_err_t R_ADC_D_ScanStart ( adc_ctrl_t p_ctrl)

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

Precondition
Call R_ADC_D_ScanCfg after R_ADC_D_Open before starting a scan.
Return values
FSP_SUCCESSScan started (software trigger) or hardware trigger mode enabled.
FSP_ERR_ASSERTIONAn input argument is invalid.
FSP_ERR_NOT_OPENADC_D is not open.
FSP_ERR_NOT_INITIALIZEDADC_D is not initialized.

◆ R_ADC_D_ScanGroupStart()

fsp_err_t R_ADC_D_ScanGroupStart ( adc_ctrl_t p_ctrl,
adc_group_mask_t  group_id 
)

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

Return values
FSP_ERR_UNSUPPORTEDFunction not supported in this implementation.

◆ R_ADC_D_ScanStop()

fsp_err_t R_ADC_D_ScanStop ( adc_ctrl_t p_ctrl)

Disables the hardware trigger for a scan or select mode and immediately stops converters. This function will abort conversions.

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_D_StatusGet()

fsp_err_t R_ADC_D_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 interrupts triggers.

Note
In Hardware no-wait mode, ADCS retains the value 1 after conversion end.
Return values
FSP_SUCCESSModule status stored in the provided pointer p_status.
FSP_ERR_ASSERTIONAn input argument is invalid.
FSP_ERR_NOT_OPENADC_D is not open.

◆ R_ADC_D_Read()

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

Reads conversion results from a 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.
FSP_ERR_INVALID_MODEInvalid configuration for channel_mode.

◆ R_ADC_D_Read32()

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

Reads conversion results from a select/scan 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_OPENADC_D is not open.
FSP_ERR_NOT_INITIALIZEDADC_D is not initialized.
FSP_ERR_INVALID_MODEInvalid configuration for channel_mode.

◆ R_ADC_D_InfoGet()

fsp_err_t R_ADC_D_InfoGet ( adc_ctrl_t p_ctrl,
adc_info_t p_adc_info 
)

Get information of address ADCR to reading the data, determine the size of data that must be read, size data of each transfer, name of the ELC event for the peripheral, name of the peripheral in the ELC list

Return values
FSP_SUCCESSInformation stored in p_adc_info.
FSP_ERR_ASSERTIONAn input argument is invalid.
FSP_ERR_NOT_OPENADC_D is not open.
FSP_ERR_NOT_INITIALIZEDADC_D is not initialized.

◆ R_ADC_D_Close()

fsp_err_t R_ADC_D_Close ( adc_ctrl_t p_ctrl)

This function ends any scan or select mode 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_OPENADC_D is not open.

◆ R_ADC_D_Calibrate()

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

adc_api_t::calibrate is not supported on the ADC_D.

Return values
FSP_ERR_UNSUPPORTEDFunction not supported in this implementation.

◆ R_ADC_D_OffsetSet()

fsp_err_t R_ADC_D_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_D.

Return values
FSP_ERR_UNSUPPORTEDFunction not supported in this implementation.

◆ R_ADC_D_SnoozeModePrepare()

fsp_err_t R_ADC_D_SnoozeModePrepare ( adc_ctrl_t *const  p_ctrl)

Prepare ADC_D to enter snooze mode via a hardware trigger. This function must be called immediately before entering software standby mode in order to allow the configured hardware trigger to transition the MCU from software standby mode to snooze mode and perform an ADC conversion.

Supported modes for requesting snooze mode via hardware trigger:

  • channel_mode = ADC_D_CHANNEL_MODE_SELECT, conversion_operation = ADC_D_CONVERSION_MODE_ONESHOT
  • channel_mode = ADC_D_CHANNEL_MODE_SCAN, conversion_operation = ADC_D_CONVERSION_MODE_ONESHOT
Parameters
[in]p_ctrlPointer to the ADC control block
Precondition
The R_ADC_D_ScanStart must be called in advance.
Return values
FSP_SUCCESSADC is configured to request Snooze mode.
FSP_ERR_ASSERTIONAn input argument is invalid.
FSP_ERR_NOT_OPENADC_D is not open.
FSP_ERR_INVALID_MODEADC is in an invalid mode for requesting Snooze mode.

◆ R_ADC_D_SnoozeModeExit()

fsp_err_t R_ADC_D_SnoozeModeExit ( adc_ctrl_t *const  p_ctrl)

After exiting snooze mode, if the ADC_D module was in snooze mode, then this function must be called in order to restore ADC operation to normal mode.

Parameters
[in]p_ctrlPointer to the ADC control block
Return values
FSP_SUCCESSADC is configured to request Snooze mode.
FSP_ERR_INVALID_MODEADC is in an invalid mode for requesting Snooze mode.