RA Flexible Software Package Documentation  Release v6.1.0

 
Delta-Sigma Modulator Interface (r_dsmif)

Functions

fsp_err_t R_DSMIF_Open (adc_ctrl_t *p_ctrl, adc_cfg_t const *const p_cfg)
 
fsp_err_t R_DSMIF_ScanCfg (adc_ctrl_t *p_ctrl, void const *const p_extend)
 
fsp_err_t R_DSMIF_ScanStart (adc_ctrl_t *p_ctrl)
 
fsp_err_t R_DSMIF_ScanGroupStart (adc_ctrl_t *p_ctrl, adc_group_mask_t group_mask)
 
fsp_err_t R_DSMIF_ScanStop (adc_ctrl_t *p_ctrl)
 
fsp_err_t R_DSMIF_ScanStatusGet (adc_ctrl_t *p_ctrl, adc_status_t *p_status)
 
fsp_err_t R_DSMIF_Read (adc_ctrl_t *p_ctrl, adc_channel_t const reg_id, uint16_t *const p_data)
 
fsp_err_t R_DSMIF_Read32 (adc_ctrl_t *p_ctrl, adc_channel_t const reg_id, uint32_t *const p_data)
 
fsp_err_t R_DSMIF_Calibrate (adc_ctrl_t *p_ctrl, void const *p_extend)
 
fsp_err_t R_DSMIF_OffsetSet (adc_ctrl_t *const p_ctrl, adc_channel_t const reg_id, int32_t const offset)
 
fsp_err_t R_DSMIF_CallbackSet (adc_ctrl_t *const p_ctrl, void(*p_callback)(adc_callback_args_t *), void *const p_context, adc_callback_args_t *const p_callback_memory)
 
fsp_err_t R_DSMIF_Close (adc_ctrl_t *p_ctrl)
 
fsp_err_t R_DSMIF_InfoGet (adc_ctrl_t *const p_ctrl, adc_info_t *const p_adc_info)
 
fsp_err_t R_DSMIF_ErrorDetectionEnable (adc_ctrl_t *p_ctrl)
 
fsp_err_t R_DSMIF_ErrorStatusGet (adc_ctrl_t *p_ctrl, dsmif_error_status_t *p_error_status)
 

Detailed Description

Driver for the DSMIF peripheral on RA MCUs. This module implements the ADC Interface.

Overview

The Delta-Sigma Modulator interface (DSMIF) functions similarly to a normal ADC, however, instead of sampling an analog signal directly, DSMIF samples a PDM signal that is generated by an externally connected 1-bit Delta-Sigma Modulator.

dsmif-overview-light.drawio.svg
DSMIF Overview

Every instance of the DSMIF peripheral has 3 separate channels that can sample independent PDM signals. Each channel has a pair of sinc filters. One sinc filter is used for normal measurements, and the other sinc filter is used for detecting error conditions. The sinc filter configuration will determine the sample resolution, and the final sample rate for each channel. There are three primary configuration settings for the sinc filters:

Features

The DSMIF module supports the following features:

Configuration

Build Time Configurations for r_dsmif

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

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

Configurations for Analog > DSMIF (r_dsmif)

This module can be added to the Stacks tab via New Stack > Analog > DSMIF (r_dsmif). Non-secure callable guard functions can be generated for this module by right clicking the module in the RA Configuration tool and checking the "Non-secure Callable" box.

ConfigurationOptionsDefaultDescription
General
NameName must be a valid C symbolg_dsmif0 Module name
Clock Selection
  • PCLKA
  • DSMIFCLK
  • GPTCLK
PCLKA Select the DSMIF Core Clock.
Unit
  • Unit 0
  • Unit 1
Unit 0 DSMIF unit number.
Alignment
  • Left Justified
  • Right Justified
Right Justified Select if the conversion result is aligned to the left or right of the channel data registers.
CallbackName must be a valid C symbolNULL Callback for handling DSMIF interrupts.
Overcurrent Sum Error
Overcurrent Sum Error > Upper Limit
Detection
  • Disabled
  • Enabled
Disabled Enable or disable overcurrent sum error upper limit detection.
ThresholdMust be an integer in the range [0,0x3FFFF].0 Overcurrent sum error detection upper limit.
Overcurrent Sum Error > Lower Limit
Detection
  • Disabled
  • Enabled
Disabled Enable or disable overcurrent sum error lower limit detection.
ThresholdMust be an integer in the range [0,0x3FFFF].0 Overcurrent sum error detection lower limit.
Channel Selection
  • Channels 0, 1 and 2
  • Channels 0 and 1
  • Channel 0
  • Channel 1
  • Channel 2
Channels 0, 1 and 2 Specify the channel(s) used for detecting overcurrent sum errors.
Interrupts
Channel Synchronization
  • Channels are not synchronized
  • Channels 0 and 1 are synchronized
  • Channels 0, 1 and 2 are synchronized
Channels are not synchronized Select the channel synchronization mode. Two or three channels that share the same configuration may optionaly configure a common interrupts instead of channel specific interrupts.
Common Data Update Interrupt Priority (CDUPD_COM)MCU Specific OptionsThe Common Data Update Interrupt occurs when a conversion is completed on all synchronized channels.
Common Capture A Data Update Interrupt Priority (CDACUPD_COM)MCU Specific OptionsThe Common Capture A Interrupt occurs when a Capture A conversion is completed on all synchronized channels.
Common Capture B Data Update Interrupt Priority (CDBCUPD_COM)MCU Specific OptionsThe Common Capture B Interrupt occurs when a Capture B conversion is completed on all synchronized channels.
Error Interrupt PriorityMCU Specific OptionsThe Error Interrupt occurs when a short-cicuit, overcurrent, overcurrent sum, or window notification error occurs on any channel.

Configurations for Analog > DSMIF Channel Configuration (r_dsmif)

ConfigurationOptionsDefaultDescription
General
NameName must be a valid C symbolg_dsmif_channel0 Module name
Clock
Clock Direction
  • Slave Mode
  • Master Mode
Slave Mode Select the conversion clock mode for the DSMIF channel. In master mode the clock is output from the DSMIF channel. In slave mode the clock is input to the DSMIF channel.
Clock Edge
  • Negative Edge
  • Positive Edge
Negative Edge Select the sampling edge of DSMCLKn for this channel.
CKDIV Setting (Master Mode Only)Must be an integer in the range [2,63].2 Set the A/D conversion clock division ratio. The clock division ratio is equal to 2 x (CKDIV + 1). This setting is only used in master mode.
DSMCLK Frequency (Slave Mode Only)Must be an integer in the range [0,25000000].25000000 If slave mode is selected, then manually enter the DSMCLK frequency. This setting is used to calculate the settling time of the DSMIF sinc filters.
Filter
Filter Order
  • First Order
  • Second Order
  • Third Order
Third Order Select 1st, 2nd, or 3rd order sinc filter for current data.
Decimation CountMust be an integer in the range [4,256].256 Decimation ratio of the current data sinc filter.
Trigger
Trigger > Filter Initialization
Trigger
  • No Trigger
  • Trigger 0 (ELC_DSMIFm_CNT0)
  • Trigger 1 (ELC_DSMIFm_CNT1)
  • Trigger 2 (ELC_DSMIFm_CNT2)
No Trigger Select filter initialization trigger. The filter initialization trigger resets the sinc filter's decimation clock via ELC event.
Edge
  • Negative
  • Positive
Positive Select either a positive or negative edge for the filter initialization trigger.
Capture Trigger A
  • No Trigger
  • Trigger 0 (ELC_DSMIFm_CAP0)
  • Trigger 1 (ELC_DSMIFm_CAP1)
  • Trigger 2 (ELC_DSMIFm_CAP2)
  • Trigger 3 (ELC_DSMIFm_CAP3)
  • Trigger 4 (ELC_DSMIFm_CAP4)
  • Trigger 5 (ELC_DSMIFm_CAP5)
No Trigger Current capture trigger A selection.
Capture Trigger B
  • No Trigger
  • Trigger 0 (ELC_DSMIFm_CAP0)
  • Trigger 1 (ELC_DSMIFm_CAP1)
  • Trigger 2 (ELC_DSMIFm_CAP2)
  • Trigger 3 (ELC_DSMIFm_CAP3)
  • Trigger 4 (ELC_DSMIFm_CAP4)
  • Trigger 5 (ELC_DSMIFm_CAP5)
No Trigger Current capture trigger B selection.
Error Detection
Error Detection > Filter
Filter Order
  • First Order
  • Second Order
  • Third Order
Third Order Select 1st, 2nd, or 3rd order sinc filter for overcurrent detection.
Decimation CountMust be an integer in the range [4,256].256 Decimation ratio of the overcurrent detection filter.
Error Detection > Overcurrent Detection 0
Error Detection > Overcurrent Detection 0 > Upper Limit
Detection
  • Disabled
  • Enabled
Disabled Enable or disable overcurrent 0 upper limit.
ThresholdMust be an integer in the range [0,65535].0xFFFF Configure the overcurrent 0 upper limit. Valid settings are in the range [0,65535].
Error Detection > Overcurrent Detection 0 > Lower Limit
Detection
  • Disabled
  • Enabled
Disabled Enable or disable overcurrent 0 lower limit.
ThresholdMust be an integer in the range [0,65535].0 Configure the overcurrent 0 lower limit. Valid settings are in the range [0,65535].
Error Detection > Overcurrent Detection 1
Error Detection > Overcurrent Detection 1 > Upper Limit
Detection
  • Disabled
  • Enabled
Disabled Enable or disable overcurrent 1 upper limit.
ThresholdMust be an integer in the range [0,65535].0xFFFF Configure the overcurrent 1 upper limit. Valid settings are in the range [0,65535].
Error Detection > Overcurrent Detection 1 > Lower Limit
Detection
  • Disabled
  • Enabled
Disabled Enable or disable overcurrent 1 lower limit.
ThresholdMust be an integer in the range [0,65535].0 Configure the overcurrent 1 lower limit. Valid settings are in the range [0,65535].
Error Detection > Overcurrent Detection 2
Error Detection > Overcurrent Detection 2 > Upper Limit
Detection
  • Disabled
  • Enabled
Disabled Enable or disable overcurrent 2 upper limit.
ThresholdMust be an integer in the range [0,65535].0xFFFF Configure the overcurrent 2 upper limit. Valid settings are in the range [0,65535].
Error Detection > Overcurrent Detection 2 > Lower Limit
Detection
  • Disabled
  • Enabled
Disabled Enable or disable overcurrent 2 lower limit.
ThresholdMust be an integer in the range [0,65535].0 Configure the overcurrent 2 lower limit. Valid settings are in the range [0,65535].
Error Detection > Overcurrent Window Notifcation 0
Notification
  • Disabled
  • Enabled
Disabled Enable or disable overcurrent window notification 0.
Mode
  • Overcurrent Data < Lower Limit 0 or Upper Limit 0 < Overcurrent Data
  • Lower Limit 0 <= Overcurrent Data <= Upper Limit 0
Overcurrent Data < Lower Limit 0 or Upper Limit 0 < Overcurrent Data Select overcurrent window notification 0 mode.
Error Detection > Overcurrent Window Notifcation 1
Notification
  • Disabled
  • Enabled
Disabled Enable or disable overcurrent window notification 1.
Mode
  • Overcurrent Data < Lower Limit 1 or Upper Limit 1 < Overcurrent Data
  • Lower Limit 1 <= Overcurrent Data <= Upper Limit 1
Overcurrent Data < Lower Limit 1 or Upper Limit 1 < Overcurrent Data Select overcurrent window notification 1 mode.
Error Detection > Overcurrent Window Notifcation 2
Notification
  • Disabled
  • Enabled
Disabled Enable or disable overcurrent window notification 2.
Mode
  • Overcurrent Data < Lower Limit 2 or Upper Limit 2 < Overcurrent Data
  • Lower Limit 2 <= Overcurrent Data <= Upper Limit 2
Overcurrent Data < Lower Limit 2 or Upper Limit 2 < Overcurrent Data Select overcurrent window notification 2 mode.
Error Detection > Overcurrent Window Notifcation 3
Notification
  • Disabled
  • Enabled
Disabled Enable or disable overcurrent window notification 3.
ModeRefer to the RA Configuration tool for available options.Window notification 0 Select overcurrent window notification 3 mode.
Error Detection > Short Circuit
Detection
  • Disabled
  • Enabled
Disabled Enable or disable short circuit detection.
Low CountMust be an integer in the range [0,8191].0 Short circuit detection low count.
High CountMust be an integer in the range [0,8191].0 Short circuit detection high count.
Interrupts
Current Data Update Interrupt Priority (CDUPD)MCU Specific OptionsThe Current Data Update Interrupt occurs when a conversion is completed.
Capture A Data Update Interrupt Priority (CDAUPD)MCU Specific OptionsThe Capture A Data Update Interrupt occurs when a capture A conversion is completed.
Capture B Data Update Interrupt Priority (CDBUPD)MCU Specific OptionsThe Capture B Data Update Interrupt occurs when a capture B conversion is completed.

Clock Configuration

The DSMIF conversion rate is determined by the DSMIF Core Clock, A/D Conversion Division Ratio (CKDIV), and the configured sinc filter's decimation count.

The DSMIF Core Clock is common to all channels and may be configured to the following settings:

The A/D Conversion Division Ratio (CKDIV) is a channel specific setting that further divides the core clock by the following formula:

A/D Conversion Division Ratio = (2 x (CKDIV + 1))
Note
1. CKDIV is set in the range [2,63].
2. CKDIV is only valid in master mode.

The decimation count is a channel specific sinc filter setting that will determine the final conversion rate of a DSMIF channel.

Note
1. The decimation count is set in the range [4,256].

DSMIF Recommended Clock Configuration:

DSMIF Core Clock (Mhz) CKDIV DSMCLKn (Mhz)
300 0x05 25
0x08 16.67
0x09 15
0x0E 10
0x1D 5
200 0x03 25
0x04 20
0x07 12.5
0x09 10
0x0F 6.25
0x13 5
Note
1. If settings other than the recommended are used, there is an additional clock constraint: DSMIF Core Clock/5 ≤ PCLKA

Pin Configuration

Each DSMIF channel has two pins:

Usage Notes

Channel Synchronization

Multiple channels may be optionally synchronized in order to generate common interrupts in response to the following events:

The following sets of channels may be synchronized:

When synchronizing channels, each channel must use the same 'Clock', 'Filter', and 'Trigger' configuration settings. For convenience, channel configurations can be reused between channels of a DSMIF instance instead of creating new channel configurations for each channel.

Note
1. Channel configurations cannot be reused between different DSMIF instances.
2. Channel configurations can only be reused between channels that are synchronized.

Filter Settling Time

The filter settling time is the time required for the filter results to be valid after the DSMIF channels have been started. The settling time is determined by the DSMCLK period, Decimation Ratio, Filter Order, DSMIF Core Clock period, and Peripheral Clock period.

The following macros are generated by the tooling in order to assist with determining the required settling time:

/* Calculated settling time required for DSMIF filters (See "Settling Time" section in the MCU user manual). */
#define DSMIF0_FILTER_SETTLING_TIME_SYNCHRONOUS_US (...)
#define DSMIF0_FILTER_SETTLING_TIME_ASYNCHRONOUS_US (...)
#define DSMIF0_FILTER_SETTLING_TIME_GPT_SYNCHRONOUS_US (...)
#define DSMIF0_FILTER_SETTLING_TIME_GPT_ASYNCHRONOUS_US (...)
Note
1. For more information on how to calculate the settling time refer to the MCU user manual.

Error Detection

There are four different types of error interrupts generated by the DSMIF peripheral:

In order to enable error detection, the application must call R_DSMIF_ErrorDetectionEnable after waiting for all DSMIF channel filters to stabilize. The amount of time required for a filter to stabilize is dependent on the filter parameters, and clock settings. Refer to the MCU user manual for determining the filter stabilization time.

Once error detection is enabled, R_DSMIF_ErrorStatusGet can be called to read the error status.

Note
1. Error detection is disabled when channel operation is stopped via R_DSMIF_ScanStop. When starting channel operation again, the same settling time is required before reenabling error detection.

Error Interrupt

If the error interrupt is enabled, the following configured error flags will generate an interrupt request:

Note
1. Since the error interrupt is a level interrupt, R_DSMIF_ErrorStatusGet must be called from the user callback in order to clear the associated error status flags.
2. Window Notification error detection does not generate an interrupt request.

Limitations

Developers should be aware of the following limitations when using DSMIF:

Examples

Basic Example

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

void dsmif_basic_example (void)
{
fsp_err_t err = R_DSMIF_Open(&g_dsmif_ctrl, &g_dsmif_cfg);
assert(FSP_SUCCESS == err);
err = R_DSMIF_ScanStart(&g_dsmif_ctrl);
assert(FSP_SUCCESS == err);
/* The application must wait for the configured filters to stabilize. */
app_wait_for_filter_stabilization(DSMIF0_FILTER_SETTLING_TIME_SYNCHRONOUS_US);
err = R_DSMIF_ErrorDetectionEnable(&g_dsmif_ctrl);
assert(FSP_SUCCESS == err);
}
void dsmif_callback (adc_callback_args_t * p_args)
{
switch (p_args->event)
{
{
uint32_t conversion;
fsp_err_t err = R_DSMIF_Read32(&g_dsmif_ctrl, p_args->channel, &conversion);
if (FSP_SUCCEESS == err)
{
/* Application process the converted data. */
app_dsmif_data_process(p_args->channel, conversion);
}
break;
}
{
uint32_t conversion;
fsp_err_t err = R_DSMIF_Read32(&g_dsmif_ctrl, p_args->channel, &conversion);
if (FSP_SUCCEESS == err)
{
/* Application process the converted capture a data. */
app_dsmif_capture_a_data_process(p_args->channel, conversion);
}
break;
}
{
uint32_t conversion;
fsp_err_t err = R_DSMIF_Read32(&g_dsmif_ctrl, p_args->channel, &conversion);
if (FSP_SUCCEESS == err)
{
/* Application process the converted capture b data. */
app_dsmif_capture_b_data_process(p_args->channel, conversion);
}
break;
}
{
dsmif_error_status_t error_status;
fsp_err_t err = R_DSMIF_ErrorStatusGet(&g_dsmif_ctrl, &error_status);
if (FSP_SUCCESS == err)
{
/* Application process the error status. */
app_dsmif_error_process(&error_status);
}
break;
}
default:
{
/* Invalid event. */
break;
}
}
}

Reading Current/Overcurrent/Capture data

This is a basic example of how to read the following types of data by OR'ing the appropriate channel mask:

void dsmif_channel_data_masks_example (void)
{
fsp_err_t err;
uint16_t conversion;
/* Read normal current data from channel 0. */
err = R_DSMIF_Read32(&g_dsmif_ctrl, ADC_CHANNEL_0, &conversion);
assert(FSP_SUCCESS == err);
/* Read capture current data from channel 0. */
err = R_DSMIF_Read32(&g_dsmif_ctrl, ADC_CHANNEL_0_CAPTURE_A, &conversion);
assert(FSP_SUCCESS == err);
/* Read overcurrent data from channel 0. */
err = R_DSMIF_Read32(&g_dsmif_ctrl, ADC_CHANNEL_0_OVERCURRENT, &conversion);
assert(FSP_SUCCESS == err);
/* Read overcurrent capture data 0 from channel 0. */
err = R_DSMIF_Read32(&g_dsmif_ctrl, ADC_CHANNEL_0_OVERCURRENT0_CAPTURE, &conversion);
assert(FSP_SUCCESS == err);
/* Read overcurrent sum capture data from channel 0. */
err = R_DSMIF_Read32(&g_dsmif_ctrl, ADC_CHANNEL_0_OVERCURRENT_SUM_CAPTURE, &conversion);
assert(FSP_SUCCESS == err);
}

Data Structures

struct  dsmif_clock_cfg_t
 
struct  dsmif_filter_cfg_t
 
struct  dsmif_trigger_cfg_t
 
struct  dsmif_interrupt_cfg_t
 
struct  dsmif_error_detection_cfg_t
 
struct  dsmif_error_status_t
 
struct  dsmif_channel_cfg_t
 
struct  dsmif_extended_cfg_t
 
struct  dsmif_instance_ctrl_t
 

Enumerations

enum  dsmif_clock_selection_t
 
enum  dsmif_overcurrent_sum_error_channel_t
 
enum  dsmif_channel_synchronization_mode_t
 
enum  dsmif_clock_direction_t
 
enum  dsmif_clock_edge_t
 
enum  dsmif_filter_order_t
 
enum  dsmif_data_shift_t
 
enum  dsmif_capture_trigger_t
 
enum  dsmif_filter_initialization_trigger_t
 
enum  dsmif_overcurrent_window_notification_mode_t
 
enum  dsmif_overcurrent_window_notification_mode3_t
 
enum  dsmif_overcurrent_status_t
 
enum  dsmif_short_circuit_status_t
 
enum  dsmif_overcurrent_sum_status_t
 
enum  dsmif_overcurrent_window_notification_status_t
 

Data Structure Documentation

◆ dsmif_clock_cfg_t

struct dsmif_clock_cfg_t

Channel clock configuration

Data Fields
dsmif_clock_direction_t direction A/D conversion clock master/slave switching.
dsmif_clock_edge_t edge Sampling edge selection.
uint8_t divider A/D conversion clock division ratio.

◆ dsmif_filter_cfg_t

struct dsmif_filter_cfg_t

Filter configuration

Data Fields
dsmif_filter_order_t filter_order Sinc filter order (1st, 2nd, or 3rd)
dsmif_data_shift_t data_shift Data shift setting.
uint8_t decimation_count Decimation count [0,255].

◆ dsmif_trigger_cfg_t

struct dsmif_trigger_cfg_t

Event trigger configuration.

Data Fields
dsmif_capture_trigger_t capture_trigger_a Current capture trigger A selection.
dsmif_capture_trigger_t capture_trigger_b Current capture trigger B selection.
dsmif_filter_initialization_trigger_t filter_initialization_trigger Current measurement filter initialization trigger selection.
dsmif_clock_edge_t filter_initialization_edge Current measurement filter initialization trigger edge selection.

◆ dsmif_interrupt_cfg_t

struct dsmif_interrupt_cfg_t

Channel interrupt configuration.

Data Fields
IRQn_Type current_data_update_irq Channel current data update interrupt request.
uint8_t current_data_update_ipl Channel current data update interrupt priority.
IRQn_Type capture_data_a_irq Channel capture data a interrupt request.
uint8_t capture_data_a_ipl Channel capture data a interrupt priority.
IRQn_Type capture_data_b_irq Channel capture data b interrupt request.
uint8_t capture_data_b_ipl Channel capture data b interrupt priority.

◆ dsmif_error_detection_cfg_t

struct dsmif_error_detection_cfg_t

Channel error configuration:

  • Overcurrent upper/lower limit error detection 0,1,2
  • Overcurrent window notification 0,1,2,3
  • Short circuit low/high detection
Data Fields
union dsmif_error_detection_cfg_t __unnamed__
union dsmif_error_detection_cfg_t __unnamed__
union dsmif_error_detection_cfg_t __unnamed__
bool short_circuit_detection_enable Enable short circuit detection.
uint32_t short_circuit_detection_low_count Short circuit low count.
uint32_t short_circuit_detection_high_count Short circuit high count.
uint32_t overcurrent_lower_limit[3] Overcurrent lower limit settings.
uint32_t overcurrent_upper_limit[3] Overcurrent upper limit settings.
dsmif_filter_cfg_t overcurrent_filter_cfg Sinc filter configuration for overcurrent detection.

◆ dsmif_error_status_t

struct dsmif_error_status_t

Error status.

Data Fields
dsmif_overcurrent_status_t channel_overcurrent_status Channel Overcurrent state.
dsmif_short_circuit_status_t channel_short_circuit_status Channel Short circuit state.
dsmif_overcurrent_sum_status_t overcurrent_sum_status Overcurrent Sum state.
dsmif_overcurrent_window_notification_status_t channel_overcurrent_window_status Channel Overcurrent Window State.

◆ dsmif_channel_cfg_t

struct dsmif_channel_cfg_t

Channel configuration.

Data Fields
dsmif_clock_cfg_t clock_cfg Channel clock configuration.
dsmif_filter_cfg_t filter_cfg Channel sinc filter configuration.
dsmif_trigger_cfg_t trigger_cfg Channel event trigger configuration.
dsmif_interrupt_cfg_t irq_cfg Channel interrupt configuration.

◆ dsmif_extended_cfg_t

struct dsmif_extended_cfg_t

DSMIF configuration extension. This extension is required and must be provided in dsmif_cfg_t::p_extend.

Data Fields
dsmif_clock_selection_t clock_selection DSMIF core clock selection.
uint32_t channel_mask Channel bitmask.
dsmif_channel_cfg_t const * p_channel_cfgs[DSMIF_MAX_NUM_CHANNELS] Configuration for each channel, set to NULL if unused.
dsmif_channel_synchronization_mode_t synchronization_mode Channel synchronization mode.
IRQn_Type common_current_data_irq Common current data interrupt request.
uint8_t common_current_data_ipl Common current data interrupt priority.
IRQn_Type common_capture_data_a_irq Channel capture data a interrupt request.
uint8_t common_capture_data_a_ipl Channel capture data a interrupt priority.
IRQn_Type common_capture_data_b_irq Channel capture data b interrupt request.
uint8_t common_capture_data_b_ipl Channel capture data b interrupt priority.

◆ dsmif_instance_ctrl_t

struct dsmif_instance_ctrl_t

DSMIF instance control block. DO NOT INITIALIZE.

Enumeration Type Documentation

◆ dsmif_clock_selection_t

DSMIF clock selection.

Enumerator
DSMIF_CLOCK_SELECTION_PCLKA 

Select PCLKA as the DSMIF clock.

DSMIF_CLOCK_SELECTION_DSMIFCLK 

Select DSMIFCLK as the DSMIF clock.

DSMIF_CLOCK_SELECTION_GPTCLK 

Select GPTCLK as the DSMIF clock.

◆ dsmif_overcurrent_sum_error_channel_t

Select the channel(s) for overcurrent sum error detection.

Enumerator
DSMIF_OVERCURRENT_SUM_ERROR_CHANNEL_0_2 

Detects error of sum value of overcurrent data of CH0, CH1, CH2.

DSMIF_OVERCURRENT_SUM_ERROR_CHANNEL_0_1 

Detects error of sum value of overcurrent data of CH0, CH1.

DSMIF_OVERCURRENT_SUM_ERROR_CHANNEL_0 

Detects error of overcurrent data of CH0.

DSMIF_OVERCURRENT_SUM_ERROR_CHANNEL_1 

Detects error of overcurrent data of CH1.

DSMIF_OVERCURRENT_SUM_ERROR_CHANNEL_2 

Detects error of overcurrent data of CH2.

◆ dsmif_channel_synchronization_mode_t

Select the channel(s) that are synchronized.

Enumerator
DSMIF_CHANNEL_SYNCHRONIZATION_MODE_DISABLED 

Channels are not synchronized.

DSMIF_CHANNEL_SYNCHRONIZATION_MODE_CHANNEL_0_2 

Channel 0 and Channel 1 and Channel 2 are synchronized.

DSMIF_CHANNEL_SYNCHRONIZATION_MODE_CHANNEL_0_1 

Channel 0 and Channel 1 are synchronized.

◆ dsmif_clock_direction_t

Enumerator
DSMIF_CLOCK_DIRECTION_SLAVE 

Clock signal is input (slave operation)

DSMIF_CLOCK_DIRECTION_MASTER 

Clock signal is output (master operation)

◆ dsmif_clock_edge_t

Select the clock edge for sampling DSMIF data.

Enumerator
DSMIF_CLOCK_EDGE_NEGATIVE 

Data is sampled on the negative edge of clock signal.

DSMIF_CLOCK_EDGE_POSITIVE 

Data is sampled on the positive edge of clock signal.

◆ dsmif_filter_order_t

Select the DSMIF filter order.

Enumerator
DSMIF_FILTER_ORDER_3RD 

Filter order setting 3rd order.

DSMIF_FILTER_ORDER_1ST 

Filter order setting 1st order.

DSMIF_FILTER_ORDER_2ND 

Filter order setting 2nd order.

◆ dsmif_data_shift_t

Select the [MSB,LSB] that are copied from the filter output into the data register.

Enumerator
DSMIF_DATA_SHIFT_23_8 

Data shift setting [23:8].

DSMIF_DATA_SHIFT_22_7 

Data shift setting [22:7].

DSMIF_DATA_SHIFT_21_6 

Data shift setting [21:6].

DSMIF_DATA_SHIFT_20_5 

Data shift setting [20:5].

DSMIF_DATA_SHIFT_19_4 

Data shift setting [19:4].

DSMIF_DATA_SHIFT_18_3 

Data shift setting [18:3].

DSMIF_DATA_SHIFT_17_2 

Data shift setting [17:2].

DSMIF_DATA_SHIFT_16_1 

Data shift setting [16:1].

DSMIF_DATA_SHIFT_15_0 

Data shift setting [15:0].

DSMIF_DATA_SHIFT_14_0 

Data shift setting [14:0].

DSMIF_DATA_SHIFT_13_0 

Data shift setting [13:0].

DSMIF_DATA_SHIFT_12_0 

Data shift setting [12:0].

DSMIF_DATA_SHIFT_11_0 

Data shift setting [11:0].

DSMIF_DATA_SHIFT_10_0 

Data shift setting [10:0].

DSMIF_DATA_SHIFT_9_0 

Data shift setting [9:0].

DSMIF_DATA_SHIFT_8_0 

Data shift setting [8:0].

DSMIF_DATA_SHIFT_7_0 

Data shift setting [7:0].

DSMIF_DATA_SHIFT_6_0 

Data shift setting [6:0].

DSMIF_DATA_SHIFT_5_0 

Data shift setting [5:0].

DSMIF_DATA_SHIFT_4_0 

Data shift setting [4:0].

◆ dsmif_capture_trigger_t

Enumerator
DSMIF_CAPTURE_TRIGGER_NONE 

Do not capture.

DSMIF_CAPTURE_TRIGGER_0 

Select current data capture trigger 0.

DSMIF_CAPTURE_TRIGGER_1 

Select current data capture trigger 1.

DSMIF_CAPTURE_TRIGGER_2 

Select current data capture trigger 2.

DSMIF_CAPTURE_TRIGGER_3 

Select current data capture trigger 3.

DSMIF_CAPTURE_TRIGGER_4 

Select current data capture trigger 4.

DSMIF_CAPTURE_TRIGGER_5 

Select current data capture trigger 5.

◆ dsmif_filter_initialization_trigger_t

Enumerator
DSMIF_FILTER_INITIALIZATION_TRIGGER_NONE 

Do not initialize.

DSMIF_FILTER_INITIALIZATION_TRIGGER_0 

Select decimation dividing counter initialization trigger 0.

DSMIF_FILTER_INITIALIZATION_TRIGGER_1 

Select decimation dividing counter initialization trigger 1.

DSMIF_FILTER_INITIALIZATION_TRIGGER_2 

Select decimation dividing counter initialization trigger 2.

◆ dsmif_overcurrent_window_notification_mode_t

Overcurrent window notification window mode setting [0,2].

Enumerator
DSMIF_OVERCURRENT_WINDOW_NOTIFICATION_MODE_OUTSIDE 

Overcurrent data <= lower limit, upper limit <= overcurrent data.

DSMIF_OVERCURRENT_WINDOW_NOTIFICATION_MODE_INSIDE 

lower limit < overcurrent data < upper limit.

◆ dsmif_overcurrent_window_notification_mode3_t

Overcurrent window detection window mode setting for window notification 3.

Enumerator
DSMIF_OVERCURRENT_WINDOW_NOTIFICATION_MODE3_0 

Overcurrent detection window notification 0.

DSMIF_OVERCURRENT_WINDOW_NOTIFICATION_MODE3_1 

Overcurrent detection window notification 1.

DSMIF_OVERCURRENT_WINDOW_NOTIFICATION_MODE3_2 

Overcurrent detection window notification 2.

DSMIF_OVERCURRENT_WINDOW_NOTIFICATION_MODE3_0_OR_1 

Overcurrent detection window notification 0 OR 1.

DSMIF_OVERCURRENT_WINDOW_NOTIFICATION_MODE3_0_AND_1 

Overcurrent detection window notification 0 AND 1.

DSMIF_OVERCURRENT_WINDOW_NOTIFICATION_MODE3_0_OR_2 

Overcurrent detection window notification 0 OR 2.

DSMIF_OVERCURRENT_WINDOW_NOTIFICATION_MODE3_0_AND_2 

Overcurrent detection window notification 0 AND 2.

DSMIF_OVERCURRENT_WINDOW_NOTIFICATION_MODE3_1_OR_2 

Overcurrent detection window notification 1 OR 2.

DSMIF_OVERCURRENT_WINDOW_NOTIFICATION_MODE3_1_AND_2 

Overcurrent detection window notification 1 AND 2.

DSMIF_OVERCURRENT_WINDOW_NOTIFICATION_MODE3_0_OR_1_OR_2 

Overcurrent detection window notification 0 OR 1 OR 2.

DSMIF_OVERCURRENT_WINDOW_NOTIFICATION_MODE3_0_AND_1_AND_2 

Overcurrent detection window notification 0 AND 1 AND 2.

◆ dsmif_overcurrent_status_t

DSMIF Channel Overcurrent detect status.

Enumerator
DSMIF_OVERCURRENT_STATUS_CH0_LOWER_LIMIT_0 

Channel 0 overcurrent lower limit detection 0 flag.

DSMIF_OVERCURRENT_STATUS_CH1_LOWER_LIMIT_0 

Channel 1 overcurrent lower limit detection 0 flag.

DSMIF_OVERCURRENT_STATUS_CH2_LOWER_LIMIT_0 

Channel 2 overcurrent lower limit detection 0 flag.

DSMIF_OVERCURRENT_STATUS_CH0_UPPER_LIMIT_0 

Channel 0 overcurrent upper limit exceeded 0 flag.

DSMIF_OVERCURRENT_STATUS_CH1_UPPER_LIMIT_0 

Channel 1 overcurrent upper limit exceeded 0 flag.

DSMIF_OVERCURRENT_STATUS_CH2_UPPER_LIMIT_0 

Channel 2 overcurrent upper limit exceeded 0 flag.

DSMIF_OVERCURRENT_STATUS_CH0_LOWER_LIMIT_1 

Channel 0 overcurrent lower limit detection 1 flag.

DSMIF_OVERCURRENT_STATUS_CH1_LOWER_LIMIT_1 

Channel 1 overcurrent lower limit detection 1 flag.

DSMIF_OVERCURRENT_STATUS_CH2_LOWER_LIMIT_1 

Channel 2 overcurrent lower limit detection 1 flag.

DSMIF_OVERCURRENT_STATUS_CH0_UPPER_LIMIT_1 

Channel 0 overcurrent upper limit exceeded 1 flag.

DSMIF_OVERCURRENT_STATUS_CH1_UPPER_LIMIT_1 

Channel 1 overcurrent upper limit exceeded 1 flag.

DSMIF_OVERCURRENT_STATUS_CH2_UPPER_LIMIT_1 

Channel 2 overcurrent upper limit exceeded 1 flag.

DSMIF_OVERCURRENT_STATUS_CH0_LOWER_LIMIT_2 

Channel 0 overcurrent lower limit detection 2 flag.

DSMIF_OVERCURRENT_STATUS_CH1_LOWER_LIMIT_2 

Channel 1 overcurrent lower limit detection 2 flag.

DSMIF_OVERCURRENT_STATUS_CH2_LOWER_LIMIT_2 

Channel 2 overcurrent lower limit detection 2 flag.

DSMIF_OVERCURRENT_STATUS_CH0_UPPER_LIMIT_2 

Channel 0 overcurrent upper limit exceeded 2 flag.

DSMIF_OVERCURRENT_STATUS_CH1_UPPER_LIMIT_2 

Channel 1 overcurrent upper limit exceeded 2 flag.

DSMIF_OVERCURRENT_STATUS_CH2_UPPER_LIMIT_2 

Channel 2 overcurrent upper limit exceeded 2 flag.

◆ dsmif_short_circuit_status_t

DSMIF Channel Short circuit detect status.

Enumerator
DSMIF_SHORT_CIRCUIT_STATUS_CH0 

Channel 0 short circuit detection flag.

DSMIF_SHORT_CIRCUIT_STATUS_CH1 

Channel 1 short circuit detection flag.

DSMIF_SHORT_CIRCUIT_STATUS_CH2 

Channel 2 short circuit detection flag.

◆ dsmif_overcurrent_sum_status_t

DSMIF Overcurrent Sum detect status.

Enumerator
DSMIF_OVERCURRENT_SUM_STATUS_LOWER_LIMIT 

Overcurrent sum error lower limit detection flag.

DSMIF_OVERCURRENT_SUM_STATUS_UPPER_LIMIT 

Overcurrent sum error upper limit detection flag.

◆ dsmif_overcurrent_window_notification_status_t

DSMIF Overcurrent Window detect status.

Enumerator
DSMIF_OVERCURRENT_WINDOW_NOTIFICATION_STATUS_CH0_0 

Channel 0 overcurrent detection window notification 0 flag.

DSMIF_OVERCURRENT_WINDOW_NOTIFICATION_STATUS_CH1_0 

Channel 1 overcurrent detection window notification 0 flag.

DSMIF_OVERCURRENT_WINDOW_NOTIFICATION_STATUS_CH2_0 

Channel 2 overcurrent detection window notification 0 flag.

DSMIF_OVERCURRENT_WINDOW_NOTIFICATION_STATUS_CH0_1 

Channel 0 overcurrent detection window notification 1 flag.

DSMIF_OVERCURRENT_WINDOW_NOTIFICATION_STATUS_CH1_1 

Channel 1 overcurrent detection window notification 1 flag.

DSMIF_OVERCURRENT_WINDOW_NOTIFICATION_STATUS_CH2_1 

Channel 2 overcurrent detection window notification 1 flag.

DSMIF_OVERCURRENT_WINDOW_NOTIFICATION_STATUS_CH0_2 

Channel 0 overcurrent detection window notification 2 flag.

DSMIF_OVERCURRENT_WINDOW_NOTIFICATION_STATUS_CH1_2 

Channel 1 overcurrent detection window notification 2 flag.

DSMIF_OVERCURRENT_WINDOW_NOTIFICATION_STATUS_CH2_2 

Channel 2 overcurrent detection window notification 2 flag.

DSMIF_OVERCURRENT_WINDOW_NOTIFICATION_STATUS_CH0_3 

Channel 0 overcurrent detection window notification 3 flag.

DSMIF_OVERCURRENT_WINDOW_NOTIFICATION_STATUS_CH1_3 

Channel 1 overcurrent detection window notification 3 flag.

DSMIF_OVERCURRENT_WINDOW_NOTIFICATION_STATUS_CH2_3 

Channel 2 overcurrent detection window notification 3 flag.

Function Documentation

◆ R_DSMIF_Open()

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

Applies power to the DSMIF and initializes the hardware based on the user configuration. As part of this initialization, set interrupts, set DSMIF error interrupt registers, etc.

Return values
FSP_SUCCESSConfiguration successful.
FSP_ERR_ASSERTIONAn input pointer is NULL or an input parameter is invalid.
FSP_ERR_ALREADY_OPENControl block is already open.
FSP_ERR_IRQ_BSP_DISABLEDA required interrupt is disabled
FSP_ERR_IP_UNIT_NOT_PRESENTThe Unit requested in the p_cfg parameter is not available on this device.

◆ R_DSMIF_ScanCfg()

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

adc_api_t::scanCfg is not supported on DSMIF.

Return values
FSP_ERR_UNSUPPORTEDThis function is not supported by the DSMIF instance.

◆ R_DSMIF_ScanStart()

fsp_err_t R_DSMIF_ScanStart ( adc_ctrl_t p_ctrl)

Starts all configured DSMIF channels

Note
After executing R_DSMIF_ScanStart, it is necessary to wait until the filter result is output stably.
Return values
FSP_SUCCESSScan started or hardware triggers enabled successfully.
FSP_ERR_ASSERTIONAn input pointer was NULL.
FSP_ERR_NOT_OPENInstance control block is not open.

◆ R_DSMIF_ScanGroupStart()

fsp_err_t R_DSMIF_ScanGroupStart ( adc_ctrl_t p_ctrl,
adc_group_mask_t  group_mask 
)

adc_api_t::scanGroupStart is not supported on DSMIF.

Return values
FSP_ERR_UNSUPPORTEDThis function is not supported by the DSMIF instance.

◆ R_DSMIF_ScanStop()

fsp_err_t R_DSMIF_ScanStop ( adc_ctrl_t p_ctrl)

Stops any in-progress scan started by software.

Return values
FSP_SUCCESSScan stopped or hardware triggers disabled successfully.
FSP_ERR_ASSERTIONAn input pointer was NULL.
FSP_ERR_NOT_OPENInstance control block is not open.
FSP_ERR_TIMEOUTTimeout error.

◆ R_DSMIF_ScanStatusGet()

fsp_err_t R_DSMIF_ScanStatusGet ( adc_ctrl_t p_ctrl,
adc_status_t p_status 
)

Returns the status of a scan started by software.

Return values
FSP_SUCCESSNo software scan is in progress.
FSP_ERR_ASSERTIONAn input pointer was NULL.
FSP_ERR_NOT_OPENInstance control block is not open.

◆ R_DSMIF_Read()

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

Reads the most recent result from a channel.

Return values
FSP_SUCCESSResult in p_data.
FSP_ERR_ASSERTIONAn input pointer was NULL or an input parameter was invalid.
FSP_ERR_NOT_OPENInstance control block is not open.

◆ R_DSMIF_Read32()

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

Reads the most recent conversion result from a single channel into a 32-bit result.

Return values
FSP_SUCCESSResult in p_data.
FSP_ERR_ASSERTIONAn input pointer was NULL or an input parameter was invalid.
FSP_ERR_NOT_OPENInstance control block is not open.

◆ R_DSMIF_Calibrate()

fsp_err_t R_DSMIF_Calibrate ( adc_ctrl_t p_ctrl,
void const *  p_extend 
)

adc_api_t::calibrate is not supported on DSMIF.

Return values
FSP_ERR_UNSUPPORTEDThis function is not supported by the DSMIF instance.

◆ R_DSMIF_OffsetSet()

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

adc_api_t::offsetSet is not supported on DSMIF.

Return values
FSP_ERR_UNSUPPORTEDThis function is not supported by the DSMIF instance.

◆ R_DSMIF_CallbackSet()

fsp_err_t R_DSMIF_CallbackSet ( adc_ctrl_t *const  p_ctrl,
void(*)(adc_callback_args_t *)  p_callback,
void *const  p_context,
adc_callback_args_t *const  p_callback_memory 
)

Updates the user callback with the option to provide memory for the callback argument structure.

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

◆ R_DSMIF_Close()

fsp_err_t R_DSMIF_Close ( adc_ctrl_t p_ctrl)

Stops any scan in progress, disables interrupts, and powers down the DSMIF peripheral.

Note
This function is delayed at least until the outage is complete, as required by the DSMIF outage procedure.
Return values
FSP_SUCCESSInstance control block closed successfully.
FSP_ERR_ASSERTIONAn input pointer was NULL.
FSP_ERR_NOT_OPENInstance control block is not open.

◆ R_DSMIF_InfoGet()

fsp_err_t R_DSMIF_InfoGet ( adc_ctrl_t *const  p_ctrl,
adc_info_t *const  p_adc_info 
)

adc_api_t::infoGet is not supported on DSMIF.

Return values
FSP_ERR_UNSUPPORTEDThis function is not supported by the DSMIF instance.

◆ R_DSMIF_ErrorDetectionEnable()

fsp_err_t R_DSMIF_ErrorDetectionEnable ( adc_ctrl_t p_ctrl)

Enable error detection.

Return values
FSP_SUCCESSConfiguration setting successfully.
FSP_ERR_ASSERTIONAn input pointer was NULL.
FSP_ERR_NOT_OPENInstance control block is not open.

◆ R_DSMIF_ErrorStatusGet()

fsp_err_t R_DSMIF_ErrorStatusGet ( adc_ctrl_t p_ctrl,
dsmif_error_status_t p_error_status 
)

Returns the error status of a scan started by software.

Return values
FSP_SUCCESSNo software scan is in progress.
FSP_ERR_ASSERTIONAn input pointer was NULL.
FSP_ERR_NOT_OPENInstance control block is not open.