RZT Flexible Software Package Documentation  Release v2.3.0

 
Inter-CPU IRQ on ICU (r_icu_inter_cpu_irq)

Functions

fsp_err_t R_ICU_INTER_CPU_IRQ_Open (icu_inter_cpu_irq_ctrl_t *const p_ctrl, icu_inter_cpu_irq_cfg_t const *const p_cfg)
 
fsp_err_t R_ICU_INTER_CPU_IRQ_Generate (icu_inter_cpu_irq_ctrl_t *const p_ctrl)
 
fsp_err_t R_ICU_INTER_CPU_IRQ_CallbackSet (icu_inter_cpu_irq_ctrl_t *const p_ctrl, void(*p_callback)(icu_inter_cpu_irq_callback_args_t *), void const *const p_context, icu_inter_cpu_irq_callback_args_t *const p_callback_memory)
 
fsp_err_t R_ICU_INTER_CPU_IRQ_Close (icu_inter_cpu_irq_ctrl_t *const p_ctrl)
 

Detailed Description

Driver for the ICU peripheral on RZ microprocessor. This module implements the Inter CPU IRQ Interface.

Overview

The Inter-CPU IRQ on ICU driver implements an interface for inter-CPU interrupt.

It is possible to generate not only the interrupt inter-CPUs but also the software interrupt to its own CPU.

Note
When using inter-CPUs interrupts, it is necessary to use this instance on each CPU side.

Features

Configuration

Build Time Configurations for r_icu_inter_cpu_irq

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

ConfigurationOptionsDefaultDescription
Parameter Checking
  • Default (BSP)
  • Enabled
  • Disabled
Default (BSP) If selected code for parameter checking is included in the build.
Multiplex Interrupt
  • Enabled
  • Disabled
Disabled Enable multiplex interrupt for a single driver.

Configurations for System > Inter-CPU IRQ (r_icu_inter_cpu_irq)

This module can be added to the Stacks tab via New Stack > System > Inter-CPU IRQ (r_icu_inter_cpu_irq).

ConfigurationOptionsDefaultDescription
NameName must be a valid C symbolg_icu_inter_cpu_irq0 Module name.
ChannelValue must be an integer greater than or equal to 00 Specify the hardware channel.
Software Interrupt PriorityMCU Specific OptionsSelect the Software interrupt priority.
CallbackName must be a valid C symbolNULL A user callback function can be provided here. If this callback function is provided, it is called from the interrupt service routine (ISR) each time the IRQn triggers

Clock Configuration

The ICU peripheral module doesn't require any specific clock settings.

Pin Configuration

This module does not use I/O pins.

Usage Notes

Use case 1) Software interrupt Single core usage

Software interrupts can be generated to CPU0 itself using INTCPU.

Example of stack configuration

stack config CPU0
0 Name g_icu_inter_cpu_irq0
Channel 0
Software Interrupt Priority 12
Callback cpu0_ic0_callback

Image of single core software interrupt operation

r_icu_inter_cpu_irq_Single_core_usage.svg
ICU INTER CPU IRQ Single core usage

Use case 2) Software interrupt Dual core usage (2 channels)

Software interrupts can be generated between CPU0 and CPU1 using INTCPU.

If the parameter check is Enable and "Callback" is "NULL", the R_ICU_INTER_CPU_IRQ_Open() function returns FSP_ERR_ASSERTION, so set any callback function.

Example of stack configuration

stack config CPU0 CPU1
0 Name g_icu_inter_cpu_irq0 g_icu_inter_cpu_irq0
Channel 1 1
Software Interrupt Priority Disabled 12
Callback NULL cpu1_ic1_callback
1 Name g_icu_inter_cpu_irq1 g_icu_inter_cpu_irq1
Channel 2 2
Software Interrupt Priority 12 Disabled
Callback cpu0_ic2_callback NULL

Image of dual core software interrupt operation

r_icu_inter_cpu_irq_Dual_core_usage_2channels.svg
ICU INTER CPU IRQ Dual core usage 2channels

Use case 3) Software interrupt Dual core usage (1 channel)

Software interrupts can be generated between CPU0 and CPU1 using same INTCPU.

Property setting example

stack config CPU0 CPU1
0 Name g_icu_inter_cpu_irq0 g_icu_inter_cpu_irq0
Channel 3 3
Software Interrupt Priority 12 12
Callback cpu0_ic3_callback cpu1_ic3_callback

Image of dual core software interrupt operation

r_icu_inter_cpu_irq_Dual_core_usage_1channel.svg
ICU INTER CPU IRQ Dual core usage 1channel

Examples

Basic Example

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

volatile bool g_icu_inter_cpu_irq_notification_receive_flag = false;
void r_icu_inter_cpu_irq_basic_example (void)
{
fsp_err_t err;
/* Open the driver. */
err = R_ICU_INTER_CPU_IRQ_Open(&g_icu_inter_cpu_irq_ctrl, &g_icu_inter_cpu_irq_cfg);
handle_error(err);
/* Generate INTCPU0. */
err = R_ICU_INTER_CPU_IRQ_Generate(&g_icu_inter_cpu_irq_ctrl);
handle_error(err);
while (!g_icu_inter_cpu_irq_notification_receive_flag)
{
/* Wait until an interrupt notification is received */
}
}
void example_callback (icu_inter_cpu_irq_callback_args_t * p_args)
{
g_icu_inter_cpu_irq_notification_receive_flag = true;
}

Function Documentation

◆ R_ICU_INTER_CPU_IRQ_Open()

fsp_err_t R_ICU_INTER_CPU_IRQ_Open ( icu_inter_cpu_irq_ctrl_t *const  p_ctrl,
icu_inter_cpu_irq_cfg_t const *const  p_cfg 
)

Opens the icu_inter_cpu_irq driver. Implements icu_inter_cpu_irq_api_t::open().

Return values
FSP_SUCCESSopened successfully.
FSP_ERR_IP_CHANNEL_NOT_PRESENTThe channel requested in p_cfg is not available on the device selected in r_bsp_cfg.h.
FSP_ERR_ALREADY_OPENModule is already open.
FSP_ERR_ASSERTIONParameter check failure due to one or more reasons below:
  1. p_ctrl or p_cfg is NULL.
  2. Callback parameter is NULL.

◆ R_ICU_INTER_CPU_IRQ_Generate()

fsp_err_t R_ICU_INTER_CPU_IRQ_Generate ( icu_inter_cpu_irq_ctrl_t *const  p_ctrl)

Generate software interrupt. Implements icu_inter_cpu_irq_api_t::generate().

Return values
FSP_SUCCESSFunction executed without issue.
FSP_ERR_ASSERTIONp_ctrl or p_src is NULL.
FSP_ERR_NOT_OPENDevice is not open.

◆ R_ICU_INTER_CPU_IRQ_CallbackSet()

fsp_err_t R_ICU_INTER_CPU_IRQ_CallbackSet ( icu_inter_cpu_irq_ctrl_t *const  p_ctrl,
void(*)(icu_inter_cpu_irq_callback_args_t *)  p_callback,
void const *const  p_context,
icu_inter_cpu_irq_callback_args_t *const  p_callback_memory 
)

Updates the user callback with the option to provide memory for the callback argument structure. Implements icu_inter_cpu_irq_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.

◆ R_ICU_INTER_CPU_IRQ_Close()

fsp_err_t R_ICU_INTER_CPU_IRQ_Close ( icu_inter_cpu_irq_ctrl_t *const  p_ctrl)

Closes the icu_inter_cpu_irq. Implements icu_inter_cpu_irq_api_t::close().

Return values
FSP_SUCCESSDevice closed successfully.
FSP_ERR_NOT_OPENDevice not opened.
FSP_ERR_ASSERTIONp_ctrl is NULL.