1 /***************************************************************************//**
2 * \file psoc6_system_init.c
3 * \version 1.00
4 *
5 * The device custom system init source file for CM0P core.
6 *
7 ********************************************************************************
8 * \copyright
9 * Copyright 2020 Cypress Semiconductor Corporation
10 * SPDX-License-Identifier: Apache-2.0
11 *
12 * Licensed under the Apache License, Version 2.0 (the "License");
13 * you may not use this file except in compliance with the License.
14 * You may obtain a copy of the License at
15 *
16 *     http://www.apache.org/licenses/LICENSE-2.0
17 *
18 * Unless required by applicable law or agreed to in writing, software
19 * distributed under the License is distributed on an "AS IS" BASIS,
20 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21 * See the License for the specific language governing permissions and
22 * limitations under the License.
23 *******************************************************************************/
24 
25 #include "cycfg.h"
26 
27 #if defined(CY_IPC_DEFAULT_CFG_DISABLE)
28     #include "cy_ipc_sema.h"
29     #include "cy_ipc_pipe.h"
30     #include "cy_ipc_drv.h"
31 
32     #if defined(CY_DEVICE_PSOC6ABLE2)
33         #include "cy_flash.h"
34     #endif /* defined(CY_DEVICE_PSOC6ABLE2) */
35 #endif /* defined(CY_IPC_DEFAULT_CFG_DISABLE) */
36 
37 #if defined(CY_DEVICE_SECURE)
38     #include "cy_pra.h"
39 #endif /* defined(CY_DEVICE_SECURE) */
40 
41 #if defined(CY_IPC_DEFAULT_CFG_DISABLE)
42 /*******************************************************************************
43 * Function Name: Cy_SysIpcPipeIsrCm0
44 ****************************************************************************//**
45 *
46 * This is the interrupt service routine for the system pipe.
47 *
48 *******************************************************************************/
Cy_SysIpcPipeIsrCm0(void)49 void Cy_SysIpcPipeIsrCm0(void)
50 {
51     Cy_IPC_Pipe_ExecuteCallback(CY_IPC_EP_CYPIPE_CM0_ADDR);
52 }
53 #endif
54 
55 
56 /*******************************************************************************
57 * Function Name: Cy_Platform_Init
58 ****************************************************************************//**
59 *
60 * CM0 custom HW initialization
61 *
62 *******************************************************************************/
Cy_Platform_Init(void)63 void Cy_Platform_Init(void)
64 {
65     Cy_PDL_Init(CY_DEVICE_CFG);
66 
67 #if defined(CY_IPC_DEFAULT_CFG_DISABLE)
68 
69     /* Initialize semaphores for the system operations.
70      * Semaphore structure is allocated on NSPE CM4 side in non-secure memory*/
71     (void) Cy_IPC_Sema_Init(CY_IPC_CHAN_SEMA, 0ul, NULL);
72 
73     /********************************************************************************
74     *
75     * Initializes the system pipes. The system pipes are used by BLE and Flash.
76     *
77     * If the default startup file is not used, or SystemInit() is not called in your
78     * project, call the following three functions prior to executing any flash or
79     * EmEEPROM write or erase operation:
80     *  -# Cy_IPC_Sema_Init()
81     *  -# Cy_IPC_Pipe_Config()
82     *  -# Cy_IPC_Pipe_Init()
83     *  -# Cy_Flash_Init()
84     *
85     *******************************************************************************/
86 
87     /* Create an array of endpoint structures */
88     static cy_stc_ipc_pipe_ep_t systemIpcPipeEpArray[CY_IPC_MAX_ENDPOINTS];
89 
90     Cy_IPC_Pipe_Config(systemIpcPipeEpArray);
91 
92     static cy_ipc_pipe_callback_ptr_t systemIpcPipeSysCbArray[CY_SYS_CYPIPE_CLIENT_CNT];
93 
94     static const cy_stc_ipc_pipe_config_t systemIpcPipeConfigCm0 =
95     {
96     /* .ep0ConfigData */
97         {
98             /* .ipcNotifierNumber    */  CY_IPC_INTR_CYPIPE_EP0,
99             /* .ipcNotifierPriority  */  CY_SYS_INTR_CYPIPE_PRIOR_EP0,
100             /* .ipcNotifierMuxNumber */  CY_SYS_INTR_CYPIPE_MUX_EP0,
101             /* .epAddress            */  CY_IPC_EP_CYPIPE_CM0_ADDR,
102             /* .epConfig             */  CY_SYS_CYPIPE_CONFIG_EP0
103         },
104     /* .ep1ConfigData */
105         {
106             /* .ipcNotifierNumber    */  CY_IPC_INTR_CYPIPE_EP1,
107             /* .ipcNotifierPriority  */  CY_SYS_INTR_CYPIPE_PRIOR_EP1,
108             /* .ipcNotifierMuxNumber */  0u,
109             /* .epAddress            */  CY_IPC_EP_CYPIPE_CM4_ADDR,
110             /* .epConfig             */  CY_SYS_CYPIPE_CONFIG_EP1
111         },
112     /* .endpointClientsCount     */  CY_SYS_CYPIPE_CLIENT_CNT,
113     /* .endpointsCallbacksArray  */  systemIpcPipeSysCbArray,
114     /* .userPipeIsrHandler       */  &Cy_SysIpcPipeIsrCm0
115     };
116 
117     Cy_IPC_Pipe_Init(&systemIpcPipeConfigCm0);
118 
119 #if defined(CY_DEVICE_PSOC6ABLE2)
120     Cy_Flash_Init();
121 #endif /* defined(CY_DEVICE_PSOC6ABLE2) */
122 
123 #endif /* defined(CY_IPC_DEFAULT_CFG_DISABLE) */
124 
125 #if defined(CY_DEVICE_SECURE)
126     /* Initialize Protected Register Access driver */
127     Cy_PRA_Init();
128 #endif /* defined(CY_DEVICE_SECURE) */
129 }
130 
131 /* [] END OF FILE */
132