RAFW Flexible Software Package Documentation  Release v2.0.1

 
External IRQ (r_ext_irq_w)

Functions

fsp_err_t R_EXT_IRQ_W_ExternalIrqOpen (external_irq_ctrl_t *const p_api_ctrl, external_irq_cfg_t const *const p_cfg)
 
fsp_err_t R_EXT_IRQ_W_ExternalIrqEnable (external_irq_ctrl_t *const p_api_ctrl)
 
fsp_err_t R_EXT_IRQ_W_ExternalIrqDisable (external_irq_ctrl_t *const p_api_ctrl)
 
fsp_err_t R_EXT_IRQ_W_ExternalIrqCallbackSet (external_irq_ctrl_t *const p_api_ctrl, void(*p_callback)(external_irq_callback_args_t *), void *const p_context, external_irq_callback_args_t *const p_callback_memory)
 
fsp_err_t R_EXT_IRQ_W_ExternalIrqClose (external_irq_ctrl_t *const p_api_ctrl)
 

Detailed Description

Driver for the External IRQ on RA6W1/RA6W2 MCUs. This module implements the External IRQ Interface.

Overview

The R_EXT_IRQ_W software module only implements the External IRQ Interface. The external_irq interface is for configuring interrupts to fire when a trigger condition is detected on an external IRQ pin.

Note
Multiple instances are used when more than one external interrupt is needed. Configure each instance with different channels and properties as needed for the specific interrupt.

Features

Configuration

Build Time Configurations for r_ext_irq_w

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

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

Configurations for Input > External IRQ (r_ext_irq_w)

This module can be added to the Stacks tab via New Stack > Input > External IRQ (r_ext_irq_w).

ConfigurationOptionsDefaultDescription
NameName must be a valid C symbolg_external_irq0 Module name.
ChannelValue must be an integer between 0 and 300 Specify the hardware channel.
TriggerMCU Specific OptionsSelect the signal edge or state that triggers an interrupt.
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
Pin Interrupt PriorityMCU Specific OptionsSelect the PIN interrupt priority.

Clock Configuration

No specific clock settings are required.

Pin Configuration

The pin for the external interrupt channel must be configured as an input with IRQ Input Enabled.

Limitation

Pin configuration does not show conflicts when same IRQ is used by multiple pins.

Usage Notes

Wake Up

When the following pins are used as IRQs and the trigger is set to rising or falling, the pins will be used as wake up pin.

Examples

Basic Example

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

#define EXT_IRQ_W_IRQN_PIN BSP_IO_PORT_01_PIN_12
#define EXT_IRQ_W_TRIGGER_PIN BSP_IO_PORT_00_PIN_10
#define EXT_IRQ_W_IRQN 0
/* Called from ext_irq_w_irq_isr */
void external_irq_callback (external_irq_callback_args_t * p_args)
{
(void) p_args;
g_external_irq_complete = 1;
}
void simple_example (void)
{
/* Example Configuration */
{
.channel = EXT_IRQ_W_IRQN,
.p_callback = external_irq_callback,
.p_context = 0,
.ipl = 2,
.p_extend = (bsp_io_port_pin_t *) EXT_IRQ_W_IRQN_PIN,
};
/* Configure the external interrupt. */
fsp_err_t err = R_EXT_IRQ_W_ExternalIrqOpen(&g_ext_irq_ctrl, &icu_cfg);
assert(FSP_SUCCESS == err);
/* Enable the external interrupt. */
/* Enable not required when used with ELC or DMAC. */
err = R_EXT_IRQ_W_ExternalIrqEnable(&g_ext_irq_ctrl);
assert(FSP_SUCCESS == err);
while (0 == g_external_irq_complete)
{
/* Wait for interrupt. */
}
}

Data Structures

struct  ext_irq_w_extended_cfg_t
 
struct  ext_irq_w_instance_ctrl_t
 

Data Structure Documentation

◆ ext_irq_w_extended_cfg_t

struct ext_irq_w_extended_cfg_t

Extended EXT_IRQ interface configuration

Data Fields
bsp_io_port_pin_t irq_pin IRQ pin.

◆ ext_irq_w_instance_ctrl_t

struct ext_irq_w_instance_ctrl_t

EXT_IRQ private control block. DO NOT MODIFY. Initialization occurs when R_EXT_IRQ_W_ExternalIrqOpen is called.

Data Fields

uint32_t open
 Used to determine if channel control block is in use.
 
IRQn_Type irq
 NVIC interrupt number.
 
uint8_t channel
 Channel.
 
bsp_io_port_pin_t irq_pin
 IRQ pin.
 
void * p_context
 

Field Documentation

◆ p_context

void* ext_irq_w_instance_ctrl_t::p_context

Placeholder for user data. Passed to the user callback in external_irq_callback_args_t.

Function Documentation

◆ R_EXT_IRQ_W_ExternalIrqOpen()

fsp_err_t R_EXT_IRQ_W_ExternalIrqOpen ( external_irq_ctrl_t *const  p_api_ctrl,
external_irq_cfg_t const *const  p_cfg 
)

Configure an IRQ input pin for use with the external interrupt interface. Implements external_irq_api_t::open.

The Open function is responsible for preparing an external IRQ pin for operation.

Return values
FSP_SUCCESSOpen successful.
FSP_ERR_ASSERTIONOne of the following is invalid:
  • p_ctrl or p_cfg is NULL
FSP_ERR_ALREADY_OPENThe channel specified has already been opened. No configurations were changed. Call the associated Close function to reconfigure the channel.
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_INVALID_ARGUMENTp_cfg->p_callback is not NULL, but ISR is not enabled. ISR must be enabled to use callback function.
FSP_ERR_UNSUPPORTEDAn input argument is not supported by selected mode.
Note
This function is reentrant for different channels. It is not reentrant for the same channel.

◆ R_EXT_IRQ_W_ExternalIrqEnable()

fsp_err_t R_EXT_IRQ_W_ExternalIrqEnable ( external_irq_ctrl_t *const  p_api_ctrl)

Enable external interrupt for specified channel at NVIC. Implements external_irq_api_t::enable.

Return values
FSP_SUCCESSInterrupt Enabled successfully.
FSP_ERR_ASSERTIONThe p_ctrl parameter was null.
FSP_ERR_NOT_OPENThe channel is not opened.

◆ R_EXT_IRQ_W_ExternalIrqDisable()

fsp_err_t R_EXT_IRQ_W_ExternalIrqDisable ( external_irq_ctrl_t *const  p_api_ctrl)

Disable external interrupt for specified channel at NVIC. Implements external_irq_api_t::disable.

Return values
FSP_SUCCESSInterrupt disabled successfully.
FSP_ERR_ASSERTIONThe p_ctrl parameter was null.
FSP_ERR_NOT_OPENThe channel is not opened.

◆ R_EXT_IRQ_W_ExternalIrqCallbackSet()

fsp_err_t R_EXT_IRQ_W_ExternalIrqCallbackSet ( external_irq_ctrl_t *const  p_api_ctrl,
void(*)(external_irq_callback_args_t *)  p_callback,
void *const  p_context,
external_irq_callback_args_t *const  p_callback_memory 
)

Updates the user callback and has option of providing memory for callback structure. Implements external_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.
FSP_ERR_NO_CALLBACK_MEMORYp_callback is non-secure and p_callback_memory is either secure or NULL.

◆ R_EXT_IRQ_W_ExternalIrqClose()

fsp_err_t R_EXT_IRQ_W_ExternalIrqClose ( external_irq_ctrl_t *const  p_api_ctrl)

Close the external interrupt channel. Implements external_irq_api_t::close.

Return values
FSP_SUCCESSSuccessfully closed.
FSP_ERR_ASSERTIONThe parameter p_ctrl is NULL.
FSP_ERR_NOT_OPENThe channel is not opened.