1 /***********************************************************************************************//**
2 * \file cyabs_freertos_dsram.c
3 *
4 * \brief
5 * Provides implementations for functions required to enable 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 <cmsis_compiler.h> // For __WEAK
27 #include "FreeRTOS.h"
28 #include "cyabs_rtos.h"
29 #include "cyabs_rtos_dsram.h"
30 #if defined(COMPONENT_CAT1B)
31 #include "cy_syslib.h"
32 #endif
33
34 void vPortSetupTimerInterrupt(void);
35 void Cy_SysPm_StoreDSContext_Wfi(void);
36
37 #if defined(COMPONENT_CAT1B)
38 //--------------------------------------------------------------------------------------------------
39 // vStoreDSRAMContextWithWFI
40 //--------------------------------------------------------------------------------------------------
vStoreDSRAMContextWithWFI(void)41 __WEAK void vStoreDSRAMContextWithWFI(void)
42 {
43 }
44
45
46 //--------------------------------------------------------------------------------------------------
47 // vRestoreDSRAMContext
48 //--------------------------------------------------------------------------------------------------
vRestoreDSRAMContext(void)49 __WEAK void vRestoreDSRAMContext(void)
50 {
51 }
52
53
54 CY_RAMFUNC_BEGIN
55 //--------------------------------------------------------------------------------------------------
56 // Cy_SysPm_StoreDSContext_Wfi
57 // Cy_SysPm_StoreDSContext_Wfi is defined as a weak function in pdl.
58 // This implementation under abstraction rtos implements FreeRTOS
59 // specific context store required for deep sleep entry.
60 //--------------------------------------------------------------------------------------------------
Cy_SysPm_StoreDSContext_Wfi(void)61 void Cy_SysPm_StoreDSContext_Wfi(void)
62 {
63 System_Store_NVIC_Reg();
64 /* Clear the Warm Boot Entry status Flag */
65 Cy_SysLib_ClearDSRAMWarmBootEntryStatus();
66 vStoreDSRAMContextWithWFI();
67 System_Restore_NVIC_Reg();
68 }
69
70
71 CY_RAMFUNC_END
72
73
74 //--------------------------------------------------------------------------------------------------
75 // cyabs_dsram_exit_dsram
76 //--------------------------------------------------------------------------------------------------
cyabs_rtos_exit_dsram(void)77 __WEAK void cyabs_rtos_exit_dsram(void)
78 {
79 vPortSetupTimerInterrupt();
80
81 vRestoreDSRAMContext();
82 }
83
84
85 #endif // if defined(COMPONENT_CAT1B)
86