1 /***************************************************************************//**
2 * \file cybsp_dsram.c
3 *
4 * Description:
5 * Provides initialization code for handling deepsleep ram.
6 *
7 ********************************************************************************
8 * \copyright
9 * Copyright 2018-2022 Cypress Semiconductor Corporation (an Infineon company) or
10 * an affiliate of Cypress Semiconductor Corporation
11 *
12 * SPDX-License-Identifier: Apache-2.0
13 *
14 * Licensed under the Apache License, Version 2.0 (the "License");
15 * you may not use this file except in compliance with the License.
16 * You may obtain a copy of the License at
17 *
18 *     http://www.apache.org/licenses/LICENSE-2.0
19 *
20 * Unless required by applicable law or agreed to in writing, software
21 * distributed under the License is distributed on an "AS IS" BASIS,
22 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
23 * See the License for the specific language governing permissions and
24 * limitations under the License.
25 *******************************************************************************/
26 #include <stdlib.h>
27 #include "cy_syspm.h"
28 #include "cy_sysclk.h"
29 #include "cybsp.h"
30 #if defined(CY_USING_HAL)
31 #include "cyhal_hwmgr.h"
32 #include "cyhal_syspm.h"
33 #endif
34 #include "cybsp_smif_init.h"
35 #if defined(CY_RTOS_AWARE) || defined(COMPONENT_RTOS_AWARE)
36 #include "cyabs_rtos_dsram.h"
37 #endif
38 #include "system_cat1b.h"
39 #include "cybsp_dsram.h"
40 #include "cmsis_compiler.h"
41 
42 #if defined(__cplusplus)
43 extern "C" {
44 #endif
45 
46 
47 
48 //--------------------------------------------------------------------------------------------------
49 // cybsp_syspm_do_warmboot
50 //--------------------------------------------------------------------------------------------------
cybsp_syspm_do_warmboot(void)51 __WEAK void cybsp_syspm_do_warmboot(void)
52 {
53     #if defined(CY_RTOS_AWARE) || defined(COMPONENT_RTOS_AWARE)
54     cyabs_rtos_exit_dsram();
55     #endif
56 }
57 
58 
59 CY_SECTION_RAMFUNC_BEGIN
60 //--------------------------------------------------------------------------------------------------
61 // cybsp_warmboot_handler
62 //--------------------------------------------------------------------------------------------------
cybsp_warmboot_handler(void)63 void cybsp_warmboot_handler(void)
64 {
65     SystemInit_Warmboot_CAT1B_CM33();
66 
67     #if FLASH_BOOT
68     cybsp_smif_enable();
69     cybsp_smif_init();
70     #endif
71 
72     init_cycfg_all();
73 
74     cybsp_syspm_do_warmboot();
75 }
76 
77 
78 CY_SECTION_RAMFUNC_END
79 
80 /* DS-RAM Warmboot Re-entry*/
81 extern unsigned int __INITIAL_SP /*__StackTop*/;
82 cy_stc_syspm_warmboot_entrypoint_t syspmBspDeepSleepEntryPoint =
83     { (uint32_t*)(&__INITIAL_SP), (uint32_t*)cybsp_warmboot_handler };
84 
85 //--------------------------------------------------------------------------------------------------
86 // cybsp_syspm_dsram_init
87 //--------------------------------------------------------------------------------------------------
cybsp_syspm_dsram_init(void)88 __WEAK cy_rslt_t cybsp_syspm_dsram_init(void)
89 {
90 /* Setup DS-RAM Warmboot Re-entry. IAR is not supported */
91     #if defined(__ARMCC_VERSION) || defined (__GNUC__)
92     Cy_Syslib_SetWarmBootEntryPoint((uint32_t*)&syspmBspDeepSleepEntryPoint, true);
93     #endif
94 
95     return CY_RSLT_SUCCESS;
96 }
97 
98 
99 #if defined(__cplusplus)
100 }
101 #endif
102