Driver for the INTC_NMI peripheral on RZ MPUs. This module implements the External IRQ Interface.
Overview
The Interrupt Controller controls which event signals are linked to the NVIC module (CM33) or GIC module (CR8). The R_INTC_NMI software module only implements the External IRQ Interface.The interface is for configuring interrupts to fire when a trigger condition is detected on a NMI 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
- Supports configuring interrupts for NMI.
- Enabling and disabling interrupt generation.
- Configuring interrupt trigger on falling edge, or rising edge.
- Supports configuring a user callback function, which will be invoked by the HAL module when a NMI pin interrupt is generated.
Configuration
Build Time Configurations for r_intc_nmi
The following build time configurations are defined in fsp_cfg/r_intc_nmi_cfg.h:
Configuration | Options | Default | Description |
Parameter Checking |
-
Default (BSP)
-
Enabled
-
Disabled
| Default (BSP) | If selected code for parameter checking is included in the build. |
Configurations for Input > External IRQ Driver on r_intc_nmi
This module can be added to the Stacks tab via New Stack > Input > External IRQ Driver on r_intc_nmi.
Configuration | Options | Default | Description |
Name | Name must be a valid C symbol | g_external_irq0 | Module name. |
Trigger | MCU Specific Options | | Select the signal edge or state that triggers an interrupt. |
Callback | Name must be a valid C symbol | NULL | 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 Priority | Value must be an integer between 0 and 255 | 12 | Select the PIN interrupt priority(0-255). Note: If you specify the lowest priority (i.e.,255), no interrupt will occur. |
Clock Configuration
The INTC_NMI peripheral module doesn't require any specific clock settings.
Pin Configuration
The pin for the external interrupt channel must be configured as an input with NMI Input Enabled.
Limitation
Pin configuration does not show conflicts when same NMI is used by multiple pins.
Usage Notes
Examples
Basic Example
This is a basic example of minimal use of the INTC_NMI in an application.
{
(void) p_args;
g_external_irq_complete = 1;
}
void simple_example ()
{
{
.filter_enable = false,
.p_callback = external_irq_callback,
.p_context = 0,
.ipl = 12,
.irq = NMI_IRQn,
};
assert(FSP_SUCCESS == err);
assert(FSP_SUCCESS == err);
while (0 == g_external_irq_complete)
{
}
}
◆ intc_nmi_instance_ctrl_t
struct intc_nmi_instance_ctrl_t |
INTC_NMI private control block. DO NOT MODIFY. Initialization occurs when R_INTC_NMI_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.
|
|
void const * | p_context |
|
◆ p_context
void const* intc_nmi_instance_ctrl_t::p_context |
◆ R_INTC_NMI_ExternalIrqOpen()
Configure a NMI pin for use with the external interrupt interface. Implements external_irq_api_t::open.
The Open function is responsible for preparing a NMI pin for operation.
- Return values
-
FSP_SUCCESS | Open successful. |
FSP_ERR_ASSERTION | One of the following is invalid:
|
FSP_ERR_ALREADY_OPEN | The channel specified has already been opened. No configurations were changed. Call the associated Close function to reconfigure the channel. |
FSP_ERR_INVALID_ARGUMENT | p_cfg->trigger is invalid. |
- Note
- This function is reentrant for different channels. It is not reentrant for the same channel.
◆ R_INTC_NMI_ExternalIrqEnable()
Enable external interrupt for specified channel at NVIC. Implements external_irq_api_t::enable.
- Return values
-
FSP_SUCCESS | Interrupt Enabled successfully. |
FSP_ERR_ASSERTION | The p_ctrl parameter was null. |
FSP_ERR_NOT_OPEN | The channel is not opened. |
FSP_ERR_IRQ_BSP_DISABLED | Requested IRQ is not defined in this system. |
◆ R_INTC_NMI_ExternalIrqDisable()
Disable external interrupt for specified channel at NVIC. Implements external_irq_api_t::disable.
- Return values
-
FSP_SUCCESS | Interrupt disabled successfully. |
FSP_ERR_ASSERTION | The p_ctrl parameter was null. |
FSP_ERR_NOT_OPEN | The channel is not opened. |
FSP_ERR_IRQ_BSP_DISABLED | Requested IRQ is not defined in this system. |
◆ R_INTC_NMI_ExternalIrqCallbackSet()
Updates the user callback and has option of providing memory for callback structure. Implements external_irq_api_t::callbackSet.
- Return values
-
FSP_SUCCESS | Callback updated successfully. |
FSP_ERR_ASSERTION | A required pointer is NULL. |
FSP_ERR_NOT_OPEN | The control block has not been opened. |
FSP_ERR_NO_CALLBACK_MEMORY | p_callback is non-secure and p_callback_memory is either secure or NULL. |
◆ R_INTC_NMI_ExternalIrqClose()
Close the external interrupt channel. Implements external_irq_api_t::close.
- Return values
-
FSP_SUCCESS | Successfully closed. |
FSP_ERR_ASSERTION | The parameter p_ctrl is NULL. |
FSP_ERR_NOT_OPEN | The channel is not opened. |