1 /*
2 * Copyright (c) 2021 Cypress Semiconductor Corporation (an Infineon company) or
3 * an affiliate of Cypress Semiconductor Corporation
4 *
5 * SPDX-License-Identifier: Apache-2.0
6 */
7
8 /**
9 * @brief Infineon PSoC 6 SOC.
10 */
11
12 #include <zephyr/device.h>
13 #include <zephyr/init.h>
14 #include <zephyr/kernel.h>
15 #include <cy_sysint.h>
16
Cy_SysInt_Init(const cy_stc_sysint_t * config,cy_israddress userIsr)17 cy_en_sysint_status_t Cy_SysInt_Init(const cy_stc_sysint_t *config, cy_israddress userIsr)
18 {
19 CY_ASSERT_L3(CY_SYSINT_IS_PRIORITY_VALID(config->intrPriority));
20 cy_en_sysint_status_t status = CY_SYSINT_SUCCESS;
21
22 /* The interrupt vector will be relocated only if the vector table was
23 * moved to SRAM (CONFIG_DYNAMIC_INTERRUPTS and CONFIG_GEN_ISR_TABLES
24 * must be enabled). Otherwise it is ignored.
25 */
26
27 #if (CY_CPU_CORTEX_M0P)
28 #error Cy_SysInt_Init does not support CM0p core.
29 #endif /* (CY_CPU_CORTEX_M0P) */
30
31 #if defined(CONFIG_DYNAMIC_INTERRUPTS) && defined(CONFIG_GEN_ISR_TABLES)
32 if (config != NULL) {
33 uint32_t priority;
34
35 /* NOTE:
36 * PendSV IRQ (which is used in Cortex-M variants to implement thread
37 * context-switching) is assigned the lowest IRQ priority level.
38 * If priority is same as PendSV, we will catch assertion in
39 * z_arm_irq_priority_set function. To avoid this, change priority
40 * to IRQ_PRIO_LOWEST, if it > IRQ_PRIO_LOWEST. Macro IRQ_PRIO_LOWEST
41 * takes in to account PendSV specific.
42 */
43 priority = (config->intrPriority > IRQ_PRIO_LOWEST) ?
44 IRQ_PRIO_LOWEST : config->intrPriority;
45
46 /* Configure a dynamic interrupt */
47 (void) irq_connect_dynamic(config->intrSrc, priority,
48 (void *) userIsr, NULL, 0);
49 } else {
50 status = CY_SYSINT_BAD_PARAM;
51 }
52 #endif /* defined(CONFIG_DYNAMIC_INTERRUPTS) && defined(CONFIG_GEN_ISR_TABLES) */
53
54 return status;
55 }
56
init_cycfg_platform_wraper(void)57 static int init_cycfg_platform_wraper(void)
58 {
59
60 /* Initializes the system */
61 SystemInit();
62 return 0;
63 }
64
65 SYS_INIT(init_cycfg_platform_wraper, PRE_KERNEL_1, 0);
66