From c98f91e375ba1d7292086c067b7446866036da78 Mon Sep 17 00:00:00 2001 From: Volodymyr Medvid Date: Tue, 23 Apr 2019 13:41:22 +0300 Subject: [PATCH] PSOC6: move mbed_sdk_init to mbed_overrides.c Purposes: * Remove MbedOS-specific code from system_psoc6_{cm4,cm0plus}.c to simplify updates to new PDL version (startup code is part of PDL). * Unify mbed_sdk_init initialization sequence for both CPU cores. This change is non-functional, sequence itself is not changed for any of the PSoC 6 M4/M0 PSA/non-PSA targets. --- .../device/system_psoc6_cm4.c | 45 +------------ .../device/system_psoc6_cm4.c | 45 +------------ .../system_psoc6_cm0plus.c | 42 +----------- .../TARGET_MCU_PSOC6_M4/system_psoc6_cm4.c | 45 +------------ .../device/system_psoc6_cm4.c | 45 +------------ .../system_psoc6_cm0plus.c | 42 +----------- .../TARGET_MCU_PSOC6_M4/system_psoc6_cm4.c | 45 +------------ .../TARGET_PSOC6/mbed_overrides.c | 65 +++++++++++++++++++ 8 files changed, 72 insertions(+), 302 deletions(-) create mode 100644 targets/TARGET_Cypress/TARGET_PSOC6/mbed_overrides.c diff --git a/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062_4343W/device/system_psoc6_cm4.c b/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062_4343W/device/system_psoc6_cm4.c index b0242124874..c040a5c713d 100644 --- a/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062_4343W/device/system_psoc6_cm4.c +++ b/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062_4343W/device/system_psoc6_cm4.c @@ -22,16 +22,12 @@ * limitations under the License. *******************************************************************************/ -#include #include -#include "cy_device.h" -#include "device.h" #include "system_psoc6.h" +#include "cy_device.h" #include "cy_device_headers.h" -#include "psoc6_utils.h" #include "cy_syslib.h" #include "cy_wdt.h" -#include "cycfg.h" #if !defined(CY_IPC_DEFAULT_CFG_DISABLE) #include "cy_ipc_sema.h" @@ -43,10 +39,6 @@ #endif /* defined(CY_DEVICE_PSOC6ABLE2) */ #endif /* !defined(CY_IPC_DEFAULT_CFG_DISABLE) */ -#if defined(COMPONENT_SPM_MAILBOX) -void mailbox_init(void); -#endif - /******************************************************************************* * SystemCoreClockUpdate() @@ -271,41 +263,6 @@ void SystemInit(void) } -/******************************************************************************* -* Function Name: mbed_sdk_init -****************************************************************************//** -* -* Mbed's post-memory-initialization function. -* Used here to initialize common parts of the Cypress libraries. -* -*******************************************************************************/ -void mbed_sdk_init(void) -{ -#if !defined(COMPONENT_SPM_MAILBOX) - /* Disable global interrupts */ - __disable_irq(); -#endif - - /* Initialize shared resource manager */ - cy_srm_initialize(); - - /* Initialize system and clocks. */ - /* Placed here as it must be done after proper LIBC initialization. */ - SystemInit(); - -#if defined(COMPONENT_SPM_MAILBOX) - mailbox_init(); -#endif - - /* Set up the device based on configurator selections */ - init_cycfg_all(); - - /* Enable global interrupts */ - __enable_irq(); -} - - - /******************************************************************************* * Function Name: Cy_SystemInit ****************************************************************************//** diff --git a/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062_BLE/device/system_psoc6_cm4.c b/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062_BLE/device/system_psoc6_cm4.c index b0242124874..c040a5c713d 100644 --- a/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062_BLE/device/system_psoc6_cm4.c +++ b/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062_BLE/device/system_psoc6_cm4.c @@ -22,16 +22,12 @@ * limitations under the License. *******************************************************************************/ -#include #include -#include "cy_device.h" -#include "device.h" #include "system_psoc6.h" +#include "cy_device.h" #include "cy_device_headers.h" -#include "psoc6_utils.h" #include "cy_syslib.h" #include "cy_wdt.h" -#include "cycfg.h" #if !defined(CY_IPC_DEFAULT_CFG_DISABLE) #include "cy_ipc_sema.h" @@ -43,10 +39,6 @@ #endif /* defined(CY_DEVICE_PSOC6ABLE2) */ #endif /* !defined(CY_IPC_DEFAULT_CFG_DISABLE) */ -#if defined(COMPONENT_SPM_MAILBOX) -void mailbox_init(void); -#endif - /******************************************************************************* * SystemCoreClockUpdate() @@ -271,41 +263,6 @@ void SystemInit(void) } -/******************************************************************************* -* Function Name: mbed_sdk_init -****************************************************************************//** -* -* Mbed's post-memory-initialization function. -* Used here to initialize common parts of the Cypress libraries. -* -*******************************************************************************/ -void mbed_sdk_init(void) -{ -#if !defined(COMPONENT_SPM_MAILBOX) - /* Disable global interrupts */ - __disable_irq(); -#endif - - /* Initialize shared resource manager */ - cy_srm_initialize(); - - /* Initialize system and clocks. */ - /* Placed here as it must be done after proper LIBC initialization. */ - SystemInit(); - -#if defined(COMPONENT_SPM_MAILBOX) - mailbox_init(); -#endif - - /* Set up the device based on configurator selections */ - init_cycfg_all(); - - /* Enable global interrupts */ - __enable_irq(); -} - - - /******************************************************************************* * Function Name: Cy_SystemInit ****************************************************************************//** diff --git a/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062_WIFI_BT/device/TARGET_MCU_PSOC6_M0/system_psoc6_cm0plus.c b/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062_WIFI_BT/device/TARGET_MCU_PSOC6_M0/system_psoc6_cm0plus.c index 4ec179b62ee..b28ca951206 100644 --- a/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062_WIFI_BT/device/TARGET_MCU_PSOC6_M0/system_psoc6_cm0plus.c +++ b/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062_WIFI_BT/device/TARGET_MCU_PSOC6_M0/system_psoc6_cm0plus.c @@ -22,16 +22,12 @@ * limitations under the License. *******************************************************************************/ -#include #include -#include "cy_device.h" -#include "device.h" #include "system_psoc6.h" +#include "cy_device.h" #include "cy_device_headers.h" -#include "psoc6_utils.h" #include "cy_syslib.h" #include "cy_wdt.h" -#include "cycfg.h" #if !defined(CY_IPC_DEFAULT_CFG_DISABLE) #include "cy_ipc_sema.h" @@ -44,10 +40,6 @@ #endif /* !defined(CY_IPC_DEFAULT_CFG_DISABLE) */ -#if defined(COMPONENT_SPM_MAILBOX) -void mailbox_init(void); -#endif - /******************************************************************************* * SystemCoreClockUpdate() @@ -165,38 +157,6 @@ uint32_t cy_delay32kMs = CY_DELAY_MS_OVERFLOW_THRESHOLD * #define CY_SYS_CM4_VECTOR_TABLE_VALID_ADDR (0x000003FFUL) -/******************************************************************************* -* Function Name: mbed_sdk_init -****************************************************************************//** -* -* Mbed's post-memory-initialization function. -* Used here to initialize common parts of the Cypress libraries. -* -*******************************************************************************/ -void mbed_sdk_init(void) -{ -#if !defined(COMPONENT_SPM_MAILBOX) - /* Disable global interrupts */ - __disable_irq(); -#endif - - /* Initialize shared resource manager */ - cy_srm_initialize(); - - /* Initialize system and clocks. */ - /* Placed here as it must be done after proper LIBC initialization. */ - SystemInit(); - -#if defined(COMPONENT_SPM_MAILBOX) - /* Configure mailbox IPC interrupts */ - mailbox_init(); -#else - /* Enable global interrupts */ - __enable_irq(); -#endif -} - - /******************************************************************************* * Function Name: SystemInit ****************************************************************************//** diff --git a/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062_WIFI_BT/device/TARGET_MCU_PSOC6_M4/system_psoc6_cm4.c b/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062_WIFI_BT/device/TARGET_MCU_PSOC6_M4/system_psoc6_cm4.c index b0242124874..c040a5c713d 100644 --- a/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062_WIFI_BT/device/TARGET_MCU_PSOC6_M4/system_psoc6_cm4.c +++ b/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062_WIFI_BT/device/TARGET_MCU_PSOC6_M4/system_psoc6_cm4.c @@ -22,16 +22,12 @@ * limitations under the License. *******************************************************************************/ -#include #include -#include "cy_device.h" -#include "device.h" #include "system_psoc6.h" +#include "cy_device.h" #include "cy_device_headers.h" -#include "psoc6_utils.h" #include "cy_syslib.h" #include "cy_wdt.h" -#include "cycfg.h" #if !defined(CY_IPC_DEFAULT_CFG_DISABLE) #include "cy_ipc_sema.h" @@ -43,10 +39,6 @@ #endif /* defined(CY_DEVICE_PSOC6ABLE2) */ #endif /* !defined(CY_IPC_DEFAULT_CFG_DISABLE) */ -#if defined(COMPONENT_SPM_MAILBOX) -void mailbox_init(void); -#endif - /******************************************************************************* * SystemCoreClockUpdate() @@ -271,41 +263,6 @@ void SystemInit(void) } -/******************************************************************************* -* Function Name: mbed_sdk_init -****************************************************************************//** -* -* Mbed's post-memory-initialization function. -* Used here to initialize common parts of the Cypress libraries. -* -*******************************************************************************/ -void mbed_sdk_init(void) -{ -#if !defined(COMPONENT_SPM_MAILBOX) - /* Disable global interrupts */ - __disable_irq(); -#endif - - /* Initialize shared resource manager */ - cy_srm_initialize(); - - /* Initialize system and clocks. */ - /* Placed here as it must be done after proper LIBC initialization. */ - SystemInit(); - -#if defined(COMPONENT_SPM_MAILBOX) - mailbox_init(); -#endif - - /* Set up the device based on configurator selections */ - init_cycfg_all(); - - /* Enable global interrupts */ - __enable_irq(); -} - - - /******************************************************************************* * Function Name: Cy_SystemInit ****************************************************************************//** diff --git a/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CMOD_062_4343W/device/system_psoc6_cm4.c b/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CMOD_062_4343W/device/system_psoc6_cm4.c index b0242124874..c040a5c713d 100644 --- a/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CMOD_062_4343W/device/system_psoc6_cm4.c +++ b/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CMOD_062_4343W/device/system_psoc6_cm4.c @@ -22,16 +22,12 @@ * limitations under the License. *******************************************************************************/ -#include #include -#include "cy_device.h" -#include "device.h" #include "system_psoc6.h" +#include "cy_device.h" #include "cy_device_headers.h" -#include "psoc6_utils.h" #include "cy_syslib.h" #include "cy_wdt.h" -#include "cycfg.h" #if !defined(CY_IPC_DEFAULT_CFG_DISABLE) #include "cy_ipc_sema.h" @@ -43,10 +39,6 @@ #endif /* defined(CY_DEVICE_PSOC6ABLE2) */ #endif /* !defined(CY_IPC_DEFAULT_CFG_DISABLE) */ -#if defined(COMPONENT_SPM_MAILBOX) -void mailbox_init(void); -#endif - /******************************************************************************* * SystemCoreClockUpdate() @@ -271,41 +263,6 @@ void SystemInit(void) } -/******************************************************************************* -* Function Name: mbed_sdk_init -****************************************************************************//** -* -* Mbed's post-memory-initialization function. -* Used here to initialize common parts of the Cypress libraries. -* -*******************************************************************************/ -void mbed_sdk_init(void) -{ -#if !defined(COMPONENT_SPM_MAILBOX) - /* Disable global interrupts */ - __disable_irq(); -#endif - - /* Initialize shared resource manager */ - cy_srm_initialize(); - - /* Initialize system and clocks. */ - /* Placed here as it must be done after proper LIBC initialization. */ - SystemInit(); - -#if defined(COMPONENT_SPM_MAILBOX) - mailbox_init(); -#endif - - /* Set up the device based on configurator selections */ - init_cycfg_all(); - - /* Enable global interrupts */ - __enable_irq(); -} - - - /******************************************************************************* * Function Name: Cy_SystemInit ****************************************************************************//** diff --git a/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CYW943012P6EVB_01/device/TARGET_MCU_PSOC6_M0/system_psoc6_cm0plus.c b/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CYW943012P6EVB_01/device/TARGET_MCU_PSOC6_M0/system_psoc6_cm0plus.c index 4ec179b62ee..b28ca951206 100644 --- a/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CYW943012P6EVB_01/device/TARGET_MCU_PSOC6_M0/system_psoc6_cm0plus.c +++ b/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CYW943012P6EVB_01/device/TARGET_MCU_PSOC6_M0/system_psoc6_cm0plus.c @@ -22,16 +22,12 @@ * limitations under the License. *******************************************************************************/ -#include #include -#include "cy_device.h" -#include "device.h" #include "system_psoc6.h" +#include "cy_device.h" #include "cy_device_headers.h" -#include "psoc6_utils.h" #include "cy_syslib.h" #include "cy_wdt.h" -#include "cycfg.h" #if !defined(CY_IPC_DEFAULT_CFG_DISABLE) #include "cy_ipc_sema.h" @@ -44,10 +40,6 @@ #endif /* !defined(CY_IPC_DEFAULT_CFG_DISABLE) */ -#if defined(COMPONENT_SPM_MAILBOX) -void mailbox_init(void); -#endif - /******************************************************************************* * SystemCoreClockUpdate() @@ -165,38 +157,6 @@ uint32_t cy_delay32kMs = CY_DELAY_MS_OVERFLOW_THRESHOLD * #define CY_SYS_CM4_VECTOR_TABLE_VALID_ADDR (0x000003FFUL) -/******************************************************************************* -* Function Name: mbed_sdk_init -****************************************************************************//** -* -* Mbed's post-memory-initialization function. -* Used here to initialize common parts of the Cypress libraries. -* -*******************************************************************************/ -void mbed_sdk_init(void) -{ -#if !defined(COMPONENT_SPM_MAILBOX) - /* Disable global interrupts */ - __disable_irq(); -#endif - - /* Initialize shared resource manager */ - cy_srm_initialize(); - - /* Initialize system and clocks. */ - /* Placed here as it must be done after proper LIBC initialization. */ - SystemInit(); - -#if defined(COMPONENT_SPM_MAILBOX) - /* Configure mailbox IPC interrupts */ - mailbox_init(); -#else - /* Enable global interrupts */ - __enable_irq(); -#endif -} - - /******************************************************************************* * Function Name: SystemInit ****************************************************************************//** diff --git a/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CYW943012P6EVB_01/device/TARGET_MCU_PSOC6_M4/system_psoc6_cm4.c b/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CYW943012P6EVB_01/device/TARGET_MCU_PSOC6_M4/system_psoc6_cm4.c index b0242124874..c040a5c713d 100644 --- a/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CYW943012P6EVB_01/device/TARGET_MCU_PSOC6_M4/system_psoc6_cm4.c +++ b/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CYW943012P6EVB_01/device/TARGET_MCU_PSOC6_M4/system_psoc6_cm4.c @@ -22,16 +22,12 @@ * limitations under the License. *******************************************************************************/ -#include #include -#include "cy_device.h" -#include "device.h" #include "system_psoc6.h" +#include "cy_device.h" #include "cy_device_headers.h" -#include "psoc6_utils.h" #include "cy_syslib.h" #include "cy_wdt.h" -#include "cycfg.h" #if !defined(CY_IPC_DEFAULT_CFG_DISABLE) #include "cy_ipc_sema.h" @@ -43,10 +39,6 @@ #endif /* defined(CY_DEVICE_PSOC6ABLE2) */ #endif /* !defined(CY_IPC_DEFAULT_CFG_DISABLE) */ -#if defined(COMPONENT_SPM_MAILBOX) -void mailbox_init(void); -#endif - /******************************************************************************* * SystemCoreClockUpdate() @@ -271,41 +263,6 @@ void SystemInit(void) } -/******************************************************************************* -* Function Name: mbed_sdk_init -****************************************************************************//** -* -* Mbed's post-memory-initialization function. -* Used here to initialize common parts of the Cypress libraries. -* -*******************************************************************************/ -void mbed_sdk_init(void) -{ -#if !defined(COMPONENT_SPM_MAILBOX) - /* Disable global interrupts */ - __disable_irq(); -#endif - - /* Initialize shared resource manager */ - cy_srm_initialize(); - - /* Initialize system and clocks. */ - /* Placed here as it must be done after proper LIBC initialization. */ - SystemInit(); - -#if defined(COMPONENT_SPM_MAILBOX) - mailbox_init(); -#endif - - /* Set up the device based on configurator selections */ - init_cycfg_all(); - - /* Enable global interrupts */ - __enable_irq(); -} - - - /******************************************************************************* * Function Name: Cy_SystemInit ****************************************************************************//** diff --git a/targets/TARGET_Cypress/TARGET_PSOC6/mbed_overrides.c b/targets/TARGET_Cypress/TARGET_PSOC6/mbed_overrides.c new file mode 100644 index 00000000000..eb1b091b3c6 --- /dev/null +++ b/targets/TARGET_Cypress/TARGET_PSOC6/mbed_overrides.c @@ -0,0 +1,65 @@ +/* + * mbed Microcontroller Library + * Copyright (c) 2018-2019 Cypress Semiconductor Corporation + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "device.h" +#include "psoc6_utils.h" +#include "cycfg.h" + +#if defined(COMPONENT_SPM_MAILBOX) +void mailbox_init(void); +#endif + +/******************************************************************************* +* Function Name: mbed_sdk_init +****************************************************************************//** +* +* Mbed's post-memory-initialization function. +* Used here to initialize common parts of the Cypress libraries. +* +*******************************************************************************/ +void mbed_sdk_init(void) +{ +#if !defined(COMPONENT_SPM_MAILBOX) + /* Disable global interrupts */ + __disable_irq(); +#endif + + /* Initialize shared resource manager */ + cy_srm_initialize(); + + /* Initialize system and clocks. */ + /* Placed here as it must be done after proper LIBC initialization. */ + SystemInit(); + +#if defined(COMPONENT_SPM_MAILBOX) + mailbox_init(); +#endif + +#if (CY_CPU_CORTEX_M0P) + #if !defined(COMPONENT_SPM_MAILBOX) + /* Enable global interrupts */ + __enable_irq(); + #endif +#else + /* Set up the device based on configurator selections */ + init_cycfg_all(); + + /* Enable global interrupts */ + __enable_irq(); +#endif +}