1 /**
2 *********************************************************************************
3 *
4 * @file ald_syscfg.h
5 * @brief SYSCFG module driver.
6 *
7 * @version V1.0
8 * @date 04 Jun 2017
9 * @author AE Team
10 * @note
11 *
12 * Copyright (C) Shanghai Eastsoft Microelectronics Co. Ltd. All rights reserved.
13 *
14 * SPDX-License-Identifier: Apache-2.0
15 *
16 * Licensed under the Apache License, Version 2.0 (the License); you may
17 * not use this file except in compliance with the License.
18 * You may obtain a copy of the License at
19 *
20 * www.apache.org/licenses/LICENSE-2.0
21 *
22 * Unless required by applicable law or agreed to in writing, software
23 * distributed under the License is distributed on an AS IS BASIS, WITHOUT
24 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
25 * See the License for the specific language governing permissions and
26 * limitations under the License.
27 *
28 *********************************************************************************
29 */
30
31 #ifndef __ALD_SYSCFG_H__
32 #define __ALD_SYSCFG_H__
33
34 #ifdef __cplusplus
35 extern "C" {
36 #endif
37
38 #include "utils.h"
39
40
41 /** @addtogroup ES32FXXX_ALD
42 * @{
43 */
44
45 /** @defgroup SYSCFG SYSCFG
46 * @brief SYSCFG module driver
47 * @{
48 */
49
50 /** @defgroup SYSCFG_Public_Macros SYSCFG Public Macros
51 * @{
52 */
53 #define SYSCFG_LOCK() WRITE_REG(SYSCFG->PROT, 0x0U)
54 #define SYSCFG_UNLOCK() WRITE_REG(SYSCFG->PROT, 0x55AA6996U)
55 #define GET_SYSCFG_LOCK() READ_BIT(SYSCFG->PROT, SYSCFG_PROT_PROT_MSK)
56
57 #define BOOT_FROM_BOOT_ROM() \
58 do { \
59 SYSCFG_UNLOCK(); \
60 SET_BIT(SYSCFG->MEMRMP, SYSCFG_MEMRMP_BRRMPEN_MSK); \
61 CLEAR_BIT(SYSCFG->MEMRMP, SYSCFG_MEMRMP_BFRMPEN_MSK); \
62 SYSCFG_LOCK(); \
63 } while (0)
64
65 #define BOOT_FROM_BOOT_FLASH() \
66 do { \
67 SYSCFG_UNLOCK(); \
68 CLEAR_BIT(SYSCFG->MEMRMP, SYSCFG_MEMRMP_BRRMPEN_MSK); \
69 SET_BIT(SYSCFG->MEMRMP, SYSCFG_MEMRMP_BFRMPEN_MSK); \
70 SYSCFG_LOCK(); \
71 } while (0)
72
73 #define BOOT_FROM_FLASH() \
74 do { \
75 SYSCFG_UNLOCK(); \
76 CLEAR_BIT(SYSCFG->MEMRMP, SYSCFG_MEMRMP_BRRMPEN_MSK); \
77 CLEAR_BIT(SYSCFG->MEMRMP, SYSCFG_MEMRMP_BFRMPEN_MSK); \
78 SYSCFG_LOCK(); \
79 } while (0)
80 /**
81 * @}
82 */
83
84
85 /** @defgroup SYSCFG_Public_Functions SYSCFG Public Functions
86 * @{
87 */
ald_vtor_config(uint32_t offset,type_func_t status)88 __STATIC_INLINE__ void ald_vtor_config(uint32_t offset, type_func_t status)
89 {
90 SYSCFG_UNLOCK();
91
92 if (status) {
93 MODIFY_REG(SYSCFG->VTOR, SYSCFG_VTOR_VTO_MSK, (offset & ~0x3FU));
94 SET_BIT(SYSCFG->MEMRMP, SYSCFG_MEMRMP_VTOEN_MSK);
95 }
96 else {
97 CLEAR_BIT(SYSCFG->MEMRMP, SYSCFG_MEMRMP_VTOEN_MSK);
98 }
99
100 SYSCFG_LOCK();
101 return;
102 }
103 /**
104 * @}
105 */
106
107 /**
108 * @}
109 */
110
111 /**
112 * @}
113 */
114
115 #ifdef __cplusplus
116 }
117 #endif
118
119 #endif
120