Functions

group group_sysint_functions

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.

In case of CM33 with Security Extension eanbled, if this function is called from secure world then, the parameters are used to configure secure interrupt. If it is called form non-secure world then the parameters are used to configure non-secure interrupt. In case of CM33 without Security Extension, this function alwasys configures the non-secure interrupt.

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

note

CM0+/CM4
The interrupt vector will be relocated only if the vector table was moved to __ramVectors in SRAM. Otherwise it is ignored.

note

CM33
The interrupt vector will be relocated only if the vector table was moved to __s_vector_table_rw and __ns_vector_table_rw for secure and non-secure world respectively.

Return

Initialization status

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);

Parameters
  • config: Interrupt configuration structure

  • userIsr: Address of the ISR

cy_israddress Cy_SysInt_SetVector(IRQn_Type IRQn, cy_israddress userIsr)

Changes the ISR vector for the interrupt.

CM0+/CM4:

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.

CM33:

When called from secure world. this function relies on the assumption that the vector table is relocated to __s_vector_table_rw[] in secure SRAM. Otherwise it will return the address of the default ISR location in the secure flash/ROM vector table.

When called from non-secure world. this function relies on the assumption that the vector table is relocated to __ns_vector_table_rw[] in non-secure SRAM. Otherwise it will return the address of the default ISR location in the non-secure flash/ROM vector table.

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

note

For CM0+, this function sets the interrupt vector for the interrupt channel on the NVIC.

note

In case of CM33 with Security Extension eanbled, if this function is called from secure world then, it sets the interrupt vector for the secure world. If it is called form non-secure world then it sets the interrupt vector for the non-secure world.

Return

Previous address of the ISR in the interrupt vector table

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);
    }

Parameters
  • IRQn: Interrupt source

  • userIsr: Address of the ISR to set in the interrupt vector table

cy_israddress Cy_SysInt_GetVector(IRQn_Type IRQn)

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

CM0+/CM4:

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.

CM33:

When called from the secure world, this function relies on the assumption that the vector table is relocated to __ns_vector_table_rw[] in non-secure SRAM. Otherwise it will return the address of the default ISR location in the flash/ROM vector table.

note

CM0+:
This function returns the interrupt vector for the interrupt channel on the NVIC.

note

CM33:
In case of CM33 with Security Extension eanbled, if this function is called from secure world then, it returns the interrupt vector for the secure world. If it is called form non-secure world then it returns the interrupt vector for the non-secure world.

Return

Address of the ISR in the interrupt vector table

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);
    }

Parameters
  • IRQn: Interrupt source

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.

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_SetInterruptSource(intrCfg.intrSrc, intrCfg.cm0pSrc);
    }

Parameters
  • IRQn: NVIC channel number connected to the CPU core.

  • devIntrSrc: Device interrupt to be routed to the NVIC channel.

cy_en_intr_t Cy_SysInt_GetInterruptSource(IRQn_Type IRQn)

Gets the interrupt source of the NVIC channel.

note

This function is available for CM0+ core only.

note

This function supports only devices using CPUSS_ver1. For all other devices, use the Cy_SysInt_GetNvicConnection() function.

Return

Device interrupt connected to the NVIC channel. A returned value of “disconnected_IRQn” indicates that the interrupt source is disconnected.

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_SetInterruptSource(intrCfg.intrSrc, intrCfg.cm0pSrc);
    }

Parameters
  • IRQn: NVIC channel number connected to the CPU core

IRQn_Type Cy_SysInt_GetNvicConnection(cy_en_intr_t devIntrSrc)

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

note

This function is available for CM0+ core only.

note

This function supports only devices using CPUSS_ver2 or higher.

Return

NVIC channel number connected to the CPU core. A returned value of “unconnected_IRQn” indicates that the interrupt source is disabled.

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_SetInterruptSource(intrCfg.intrSrc, intrCfg.cm0pSrc);
    }

Parameters
  • devIntrSrc: Device interrupt that is potentially connected to the NVIC channel.

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.

note

This function is available for CM0+ core only.

note

This function supports only devices using CPUSS_ver2 or higher.

Return

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.

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 */
    }

Parameters
  • IRQn: NVIC channel number connected to the CPU core

void Cy_SysInt_DisconnectInterruptSource(IRQn_Type IRQn, cy_en_intr_t devIntrSrc)

Disconnect the interrupt source from the specified NVIC channel.

note

This function is available for CM0+ core only.

Function Usage


    /* Scenario: Disconnect the previously connected interrupt source */

    Cy_SysInt_DisconnectInterruptSource(intrCfg.intrSrc, intrCfg.cm0pSrc);
    

Parameters
  • IRQn: NVIC channel number connected to the CPU core. This parameter is ignored for devices using CPUSS_ver2.

  • devIntrSrc: Device interrupt routed to the NVIC channel. This parameter is ignored for devices using CPUSS_ver1.

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.

note

CM0+ may call this function only at PC=0, CM4 may set its NMI handler at any PC.

note

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);
    }

Parameters
  • nmiNum: NMI 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.

  • intrSrc: Interrupt source. This parameter can either be of type cy_en_intr_t or IRQn_Type for CM0+ and CM4/CM33 respectively.

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.

Return

Interrupt Source. This parameter can either be of type cy_en_intr_t or IRQn_Type for CM0+ and CM4/CM33 respectively.

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);
    }

Parameters
  • nmiNum: NMI 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).

void Cy_SysInt_SoftwareTrig(IRQn_Type IRQn)

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

note

Only privileged software can enable unprivileged access to the Software Trigger Interrupt Register (STIR).

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);

Parameters
  • IRQn: Interrupt source