The SysInt driver provides an API to configure the device peripheral interrupts.
It provides a lightweight interface to complement the CMSIS core NVIC API. The provided functions are applicable for all cores in a device and they can be used to configure and connect device peripheral interrupts to one or more cores.
The functions and other declarations used in this driver are in cy_sysint.h. You can include cy_pdl.h to get access to all functions and declarations in the PDL.
The vector table defines the entry addresses of the processor exceptions and the device specific interrupts. It is located at the start address of the flash and is copied by the startup code to RAM. The symbol code __Vectors is the address of the vector table in the startup code and the register SCB->VTOR holds the start address of the vector table. See Vectors Table Copy from Flash to RAM section for the implementation details.
The default interrupt handler functions are defined as weak functions to a dummy handler in the startup file. The naming convention is <interrupt_name>_IRQHandler. Defining these in the user application allows the linker to place them in the vector table in flash. For example:
And can be used like this:
Using this method avoids the need for a RAM vector table. However in this scenario, interrupt handler re-location at run-time is not possible, unless the vector table is relocated to RAM.
Interrupt numbers are defined in a device-specific header file, such as cy8c68237bz_ble.h, and are consistent with interrupt handlers defined in the vector table.
To configure an interrupt, call Cy_SysInt_Init(). Populate the configuration structure (cy_stc_sysint_t) and pass it as a parameter along with the ISR address. This initializes the interrupt and instructs the CPU to jump to the specified ISR vector upon a valid trigger. For CM0+ core, the configuration structure (cy_stc_sysint_t) must specify the device interrupt source (cm0pSrc) that feeds into the CM0+ NVIC mux (intrSrc).
For CM4 core, system interrupt source 'n' is connected to the corresponding IRQn. Deep-sleep capable interrupts are allocated to Deep Sleep capable IRQn channels.
For CM0+ core, deep Sleep wakeup-capability is determined by the CPUSS_CM0_DPSLP_IRQ_NR parameter, where the first N number of muxes (NvicMux0 ... NvicMuxN-1) have the capability to trigger Deep Sleep interrupts. A Deep Sleep capable interrupt source must be connected to one of these muxes to be able to trigger in Deep Sleep. Refer to the IRQn_Type definition in the device header.
After initializing an interrupt, use the CMSIS Core NVIC_EnableIRQ() function to enable it. Given an initialization structure named config, the function should be called as follows:
Servicing interrupts in the Peripheral Drivers should follow a prescribed recipe to ensure all interrupts are serviced and duplicate interrupts are not received. Any peripheral-specific register that must be written to clear the source of the interrupt should be written as soon as possible in the interrupt service routine. However, note that due to buffering on the output bus to the peripherals, the write clearing of the interrupt may be delayed. After performing the normal interrupt service that should respond to the interrupting condition, the interrupt register that was initially written to clear the register should be read before returning from the interrupt service routine. This read ensures that the initial write has been flushed out to the hardware. Note, no additional processing should be performed based on the result of this read, as this read is intended only to ensure the write operation is flushed.
This final read may indicate a pending interrupt. What this means is that in the interval between when the write actually happened at the peripheral and when the read actually happened at the peripheral, an interrupting condition occurred. This is ok and a return from the interrupt is still the correct action. As soon as conditions warrant, meaning interrupts are enabled and there are no higher priority interrupts pending, the interrupt will be triggered again to service the additional condition.
Certain CM0+ NVIC IRQn channels are reserved for system use:
NVIC channel (IRQn_Type) | Interrupt source (cy_en_intr_t) | Purpose |
---|---|---|
#0 (NvicMux0_IRQn) | IPC Interrupt #0 (cpuss_interrupts_ipc_0_IRQn) | System Calls to ROM |
#1 (NvicMux1_IRQn) | IPC Interrupt #3 (cpuss_interrupts_ipc_3_IRQn) | System IPC pipe in the default startup |
Refer to the technical reference manual (TRM) and the device datasheet.
MISRA Rule | Rule Class (Required/Advisory) | Rule Description | Description of Deviation(s) |
---|---|---|---|
8.12 | R | Array declared with unknown size. | __Vectors and __ramVectors arrays can have the different size depend on the selected device. |
Version | Changes | Reason for Change |
---|---|---|
1.40 | Updated the CY_SYSINT_IS_PC_0 macro to access the protected register for the secure CYB06xx7 devices via PRA (Protected Register Access) driver. | Added PSoC 64 devices support. |
1.30.1 | Minor documentation updates. | Documentation enhancement. |
1.30 | The Cy_SysInt_SetNmiSource is updated with Protection Context check for CM0+. | User experience enhancement. |
1.20.1 | The Vector Table section is extended with a code snippet. | Documentation enhancement. |
1.20 | Flattened the organization of the driver source code into the single source directory and the single include directory. | Driver library directory-structure simplification. |
Added CPUSS_ver2 support to the following API functions: Added new API functions: Deprecated following functions:
| New devices support. | |
Added register access layer. Use register access macros instead of direct register access using dereferenced pointers. | Makes register access device-independent, so that the PDL does not need to be recompiled for each supported part number. | |
1.10 | Cy_SysInt_GetState() function is redefined to call NVIC_GetEnableIRQ() | |
1.0 | Initial version |
API Reference | |
Macros | |
Global variables | |
Functions | |
Data Structures | |
Enumerated Types | |