PSoC 6 Peripheral Driver Library

General Description

Functions

cy_en_sysint_status_t Cy_SysInt_Init (const cy_stc_sysint_t *config, cy_israddress userIsr)
 Initializes the referenced interrupt by setting the priority and the interrupt vector. More...
 
cy_israddress Cy_SysInt_SetVector (IRQn_Type IRQn, cy_israddress userIsr)
 Changes the ISR vector for the interrupt. More...
 
cy_israddress Cy_SysInt_GetVector (IRQn_Type IRQn)
 Gets the address of the current ISR vector for the interrupt. More...
 
void Cy_SysInt_SetInterruptSource (IRQn_Type IRQn, cy_en_intr_t devIntrSrc)
 Configures the interrupt selection for the specified NVIC channel. More...
 
cy_en_intr_t Cy_SysInt_GetInterruptSource (IRQn_Type IRQn)
 Gets the interrupt source of the NVIC channel. More...
 
IRQn_Type Cy_SysInt_GetNvicConnection (cy_en_intr_t devIntrSrc)
 Gets the NVIC channel to which the interrupt source is connected. More...
 
cy_en_intr_t Cy_SysInt_GetInterruptActive (IRQn_Type IRQn)
 Gets the highest priority active interrupt for the selected NVIC channel. More...
 
void Cy_SysInt_DisconnectInterruptSource (IRQn_Type IRQn, cy_en_intr_t devIntrSrc)
 Disconnect the interrupt source from the specified NVIC channel. More...
 
__STATIC_INLINE void Cy_SysInt_SetNmiSource (cy_en_sysint_nmi_t nmiNum, IRQn_Type intrSrc)
 Sets the interrupt source of the CPU core NMI. More...
 
__STATIC_INLINE IRQn_Type Cy_SysInt_GetNmiSource (cy_en_sysint_nmi_t nmiNum)
 Gets the interrupt source of the CPU core NMI for the given NMI source number. More...
 
__STATIC_INLINE void Cy_SysInt_SoftwareTrig (IRQn_Type IRQn)
 Triggers an interrupt using software (Not applicable for CM0+). More...
 

Function Documentation

◆ Cy_SysInt_Init()

cy_en_sysint_status_t Cy_SysInt_Init ( const cy_stc_sysint_t config,
cy_israddress  userIsr 
)

Initializes the referenced interrupt by setting the priority and the interrupt vector.

Use the CMSIS core function NVIC_EnableIRQ(config.intrSrc) to enable the interrupt.

Parameters
configInterrupt configuration structure
userIsrAddress of the ISR
Returns
Initialization status
Note
The interrupt vector will be relocated only if the vector table was moved to __ramVectors in SRAM. Otherwise it is ignored.
Function Usage
/* Scenario: Vector table is relocated to RAM in __ramVectors[] */
/* Prototype of ISR function for port interrupt 0 */
void Interrupt_Handler_Port0 (void);
cy_stc_sysint_t intrCfg =
{
#if (CY_CPU_CORTEX_M0P)
/*.intrSrc =*/ NvicMux7_IRQn, /* CM0+ interrupt is NVIC #7 */
/*.cm0pSrc =*/ ioss_interrupts_gpio_0_IRQn, /* Source of NVIC #7 is GPIO port 0 interrupt */
/*.intrPriority =*/ 2UL /* Interrupt priority is 2 */
#else
/*.intrSrc =*/ ioss_interrupts_gpio_0_IRQn, /* Interrupt source is GPIO port 0 interrupt */
/*.intrPriority =*/ 4UL /* Interrupt priority is 4 */
#endif
};
/* Initialize the interrupt with vector at Interrupt_Handler_Port0() */
Cy_SysInt_Init(&intrCfg, &Interrupt_Handler_Port0);
/* Enable the interrupt */
NVIC_EnableIRQ(intrCfg.intrSrc);

◆ Cy_SysInt_SetVector()

cy_israddress Cy_SysInt_SetVector ( IRQn_Type  IRQn,
cy_israddress  userIsr 
)

Changes the ISR vector for the interrupt.

This function relies on the assumption that the vector table is relocated to __ramVectors[RAM_VECTORS_SIZE] in SRAM. Otherwise it will return the address of the default ISR location in the flash vector table.

Parameters
IRQnInterrupt source
userIsrAddress of the ISR to set in the interrupt vector table
Returns
Previous address of the ISR in the interrupt vector table
Note
For CM0+, this function sets the interrupt vector for the interrupt channel on the NVIC.
Function Usage
/* Scenario: Vector table is relocated to RAM in __ramVectors[]. The interrupt
was initialized with the "intrCfg" configuration struct. */
/* Prototype of ISR function for port interrupt 0 */
void Interrupt_Handler_Port0 (void);
if(&Interrupt_Handler_Port0 != Cy_SysInt_GetVector(intrCfg.intrSrc))
{
/* Set the port0 interrupt vector to be at Interrupt_Handler_Port0() */
(void)Cy_SysInt_SetVector(intrCfg.intrSrc, &Interrupt_Handler_Port0);
}

◆ Cy_SysInt_GetVector()

cy_israddress Cy_SysInt_GetVector ( IRQn_Type  IRQn)

Gets the address of the current ISR vector for the interrupt.

This function relies on the assumption that the vector table is relocated to __ramVectors[RAM_VECTORS_SIZE] in SRAM. Otherwise it will return the address of the default ISR location in the flash vector table.

Parameters
IRQnInterrupt source
Returns
Address of the ISR in the interrupt vector table
Note
For CM0+, this function returns the interrupt vector for the interrupt channel on the NVIC.
Function Usage
/* Scenario: Vector table is relocated to RAM in __ramVectors[]. The interrupt
was initialized with the "intrCfg" configuration struct. */
/* Prototype of ISR function for port interrupt 0 */
void Interrupt_Handler_Port0 (void);
if(&Interrupt_Handler_Port0 != Cy_SysInt_GetVector(intrCfg.intrSrc))
{
/* Set the port0 interrupt vector to be at Interrupt_Handler_Port0() */
(void)Cy_SysInt_SetVector(intrCfg.intrSrc, &Interrupt_Handler_Port0);
}

◆ Cy_SysInt_SetInterruptSource()

void Cy_SysInt_SetInterruptSource ( IRQn_Type  IRQn,
cy_en_intr_t  devIntrSrc 
)

Configures the interrupt selection for the specified NVIC channel.

To disconnect the interrupt source from the NVIC channel use the Cy_SysInt_DisconnectInterruptSource.

Parameters
IRQnNVIC channel number connected to the CPU core.
devIntrSrcDevice interrupt to be routed to the NVIC channel.
Note
This function is available for CM0+ core only.
Function Usage
/* Scenario: Reconfigure the interrupt source of the NVIC input on the CM0+
core at run-time. The interrupt was initialized with the
"intrCfg" configuration struct. */
#if (CY_IP_M4CPUSS_VERSION == 1)
if(disconnected_IRQn == Cy_SysInt_GetInterruptSource(intrCfg.intrSrc))
#else /* CY_IP_M4CPUSS_VERSION == 2 */
if(unconnected_IRQn == Cy_SysInt_GetNvicConnection(intrCfg.cm0pSrc))
#endif /* CY_IP_M4CPUSS_VERSION */
{
/* Set the interrupt source for intrCfg.intrSrc on CM0+ */
}

◆ Cy_SysInt_GetInterruptSource()

cy_en_intr_t Cy_SysInt_GetInterruptSource ( IRQn_Type  IRQn)

Gets the interrupt source of the NVIC channel.

Parameters
IRQnNVIC channel number connected to the CPU core
Returns
Device interrupt connected to the NVIC channel. A returned value of "disconnected_IRQn" indicates that the interrupt source is disconnected.
Note
This function is available for CM0+ core only.
This function supports only devices using CPUSS_ver1. For all other devices, use the Cy_SysInt_GetNvicConnection() function.
Function Usage
/* Scenario: Reconfigure the interrupt source of the NVIC input on the CM0+
core at run-time. The interrupt was initialized with the
"intrCfg" configuration struct. */
#if (CY_IP_M4CPUSS_VERSION == 1)
if(disconnected_IRQn == Cy_SysInt_GetInterruptSource(intrCfg.intrSrc))
#else /* CY_IP_M4CPUSS_VERSION == 2 */
if(unconnected_IRQn == Cy_SysInt_GetNvicConnection(intrCfg.cm0pSrc))
#endif /* CY_IP_M4CPUSS_VERSION */
{
/* Set the interrupt source for intrCfg.intrSrc on CM0+ */
}

◆ Cy_SysInt_GetNvicConnection()

IRQn_Type Cy_SysInt_GetNvicConnection ( cy_en_intr_t  devIntrSrc)

Gets the NVIC channel to which the interrupt source is connected.

Parameters
devIntrSrcDevice interrupt that is potentially connected to the NVIC channel.
Returns
NVIC channel number connected to the CPU core. A returned value of "unconnected_IRQn" indicates that the interrupt source is disabled.
Note
This function is available for CM0+ core only.
This function supports only devices using CPUSS_ver2 or higher.
Function Usage
/* Scenario: Reconfigure the interrupt source of the NVIC input on the CM0+
core at run-time. The interrupt was initialized with the
"intrCfg" configuration struct. */
#if (CY_IP_M4CPUSS_VERSION == 1)
if(disconnected_IRQn == Cy_SysInt_GetInterruptSource(intrCfg.intrSrc))
#else /* CY_IP_M4CPUSS_VERSION == 2 */
if(unconnected_IRQn == Cy_SysInt_GetNvicConnection(intrCfg.cm0pSrc))
#endif /* CY_IP_M4CPUSS_VERSION */
{
/* Set the interrupt source for intrCfg.intrSrc on CM0+ */
}

◆ Cy_SysInt_GetInterruptActive()

cy_en_intr_t Cy_SysInt_GetInterruptActive ( IRQn_Type  IRQn)

Gets the highest priority active interrupt for the selected NVIC channel.

The priority of the interrupt in a given channel is determined by the index value of the interrupt in the cy_en_intr_t enum. The lower the index, the higher the priority. E.g. Consider a case where an interrupt source with value 29 and an interrupt source with value 46 both source the same NVIC channel. If both are active (triggered) at the same time, calling Cy_SysInt_GetInterruptActive() will return 29 as the active interrupt.

Parameters
IRQnNVIC channel number connected to the CPU core
Returns
Device interrupt connected to the NVIC channel. A returned value of "disconnected_IRQn" indicates that there are no active (pending) interrupts on this NVIC channel.
Note
This function is available for CM0+ core only.
This function supports only devices using CPUSS_ver2 or higher.
Function Usage
/* Scenario: Inside the interrupt service routine for NvicMux7_IRQn: */
if (intrCfg.cm0pSrc == Cy_SysInt_GetInterruptActive(intrCfg.intrSrc))
{
/* Handle the ioss_interrupts_gpio_0_IRQn interrupt */
}

◆ Cy_SysInt_DisconnectInterruptSource()

void Cy_SysInt_DisconnectInterruptSource ( IRQn_Type  IRQn,
cy_en_intr_t  devIntrSrc 
)

Disconnect the interrupt source from the specified NVIC channel.

Parameters
IRQnNVIC channel number connected to the CPU core. This parameter is ignored for devices using CPUSS_ver2.
devIntrSrcDevice interrupt routed to the NVIC channel. This parameter is ignored for devices using CPUSS_ver1.
Note
This function is available for CM0+ core only.
Function Usage
/* Scenario: Disconnect the previously connected interrupt source */

◆ Cy_SysInt_SetNmiSource()

__STATIC_INLINE void Cy_SysInt_SetNmiSource ( cy_en_sysint_nmi_t  nmiNum,
IRQn_Type  intrSrc 
)

Sets the interrupt source of the CPU core NMI.

The interrupt source must be a positive number. Setting the value to "unconnected_IRQn" or "disconnected_IRQn" disconnects the interrupt source from the NMI. Depending on the device, the number of interrupt sources that can provide the NMI trigger signal to the core can vary.

Parameters
nmiNumNMI source number. CPUSS_ver2 allows up to 4 sources to trigger the core NMI. CPUSS_ver1 allows only one source to trigger the core NMI and the specified NMI number is ignored.
intrSrcInterrupt source. This parameter can either be of type cy_en_intr_t or IRQn_Type based on the selected core.
Note
CM0+ may call this function only at PC=0, CM4 may set its NMI handler at any PC.
The CM0+ NMI is used for performing system calls that execute out of ROM.
Function Usage
/* Scenario: Set the NMI trigger source for the processor of interest. The
interrupt was initialized with the "intrCfg" configuration struct. */
#if (CY_CPU_CORTEX_M0P)
if(disconnected_IRQn == Cy_SysInt_GetNmiSource(CY_SYSINT_NMI1))
#else /* CM4 */
if(unconnected_IRQn == Cy_SysInt_GetNmiSource(CY_SYSINT_NMI1))
#endif /* CY_CPU_CORTEX_M0P */
{
/* Set the NMI source to GPIO port 0 interrupt */
Cy_SysInt_SetNmiSource(CY_SYSINT_NMI1, ioss_interrupts_gpio_0_IRQn);
}

◆ Cy_SysInt_GetNmiSource()

__STATIC_INLINE IRQn_Type Cy_SysInt_GetNmiSource ( cy_en_sysint_nmi_t  nmiNum)

Gets the interrupt source of the CPU core NMI for the given NMI source number.

Parameters
nmiNumNMI source number. CPUSS_ver2 allows up to 4 sources to trigger the core NMI (i.e. #1, 2, 3, 4). CPUSS_ver1 allows only 1 source to trigger the core NMI (i.e #1).
Returns
Interrupt Source. This parameter can either be of type cy_en_intr_t or IRQn_Type based on the selected core.
Function Usage
/* Scenario: Set the NMI trigger source for the processor of interest. The
interrupt was initialized with the "intrCfg" configuration struct. */
#if (CY_CPU_CORTEX_M0P)
if(disconnected_IRQn == Cy_SysInt_GetNmiSource(CY_SYSINT_NMI1))
#else /* CM4 */
if(unconnected_IRQn == Cy_SysInt_GetNmiSource(CY_SYSINT_NMI1))
#endif /* CY_CPU_CORTEX_M0P */
{
/* Set the NMI source to GPIO port 0 interrupt */
Cy_SysInt_SetNmiSource(CY_SYSINT_NMI1, ioss_interrupts_gpio_0_IRQn);
}

◆ Cy_SysInt_SoftwareTrig()

__STATIC_INLINE void Cy_SysInt_SoftwareTrig ( IRQn_Type  IRQn)

Triggers an interrupt using software (Not applicable for CM0+).

Parameters
IRQnInterrupt source
Function Usage
/* Scenario: Trigger the CM4 interrupt line connected to the GPIO port 0
interrupt from software. */
/* Enter processor privileged mode */
__set_CONTROL(0);
/* Trigger the ioss_interrupts_gpio_0_IRQn interrupt using software */
Cy_SysInt_SoftwareTrig(ioss_interrupts_gpio_0_IRQn);
/* Enter processor user mode */
__set_CONTROL(1);
Note
Only privileged software can enable unprivileged access to the Software Trigger Interrupt Register (STIR).