1 /**************************************************************************//**
2 * @file gr55xx.h
3 * @brief CMSIS Cortex-M# Core Peripheral Access Layer Header File for
4 * Device GR55xx
5 * @version V1.00
6 * @date 12. June 2018
7 ******************************************************************************/
8 /*
9 * Copyright (c) 2016-2018, Shenzhen Huiding Technology Co., Ltd
10 *
11 * SPDX-License-Identifier: Apache-2.0
12 *
13 * Licensed under the Apache License, Version 2.0 (the License); you may
14 * not use this file except in compliance with the License.
15 * You may obtain a copy of the License at
16 *
17 * www.apache.org/licenses/LICENSE-2.0
18 *
19 * Unless required by applicable law or agreed to in writing, software
20 * distributed under the License is distributed on an AS IS BASIS, WITHOUT
21 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 * See the License for the specific language governing permissions and
23 * limitations under the License.
24 */
25
26 /** @addtogroup CMSIS_Device
27 * @{
28 */
29
30 /** @addtogroup GR55xx
31 * @{
32 */
33
34 #ifndef __GR55xx_H__
35 #define __GR55xx_H__
36 #ifndef CFG_LAYER_TAG_SDK
37 #ifndef CFG_LAYER_TAG_ROM
38 #include "custom_config.h"
39 #endif
40 #endif
41
42 /** @addtogroup Library_configuration_section
43 * @{
44 */
45
46 /**
47 * @brief GR55 Family
48 */
49 #if !defined (GR55)
50 #define GR55
51 #endif /* GR55 */
52
53 /* Uncomment the line below according to the target GR55 device used in your
54 application
55 */
56 #if !defined (GR551xx)
57 #define GR551xx
58 #endif
59
60 /** @} */
61
62 /** @addtogroup Device_Included
63 * @{
64 */
65 #if defined(GR551xx)
66 #include "gr551xx.h"
67
68 #define GR55XX_RAM_ADDRESS 0x30000000
69 #define GR55XX_FLASH_ADDRESS 0x01000000
70 #define GR55XX_ALIAS_ADDRESS 0x00800000
71 #else
72 #error "Please select first the target GR55xx device used in your application (in gr551xx.h file)"
73 #endif
74
75 /** @} */
76
77 #ifdef __cplusplus
78 extern "C" {
79 #endif
80
81 /** @addtogroup Exported_types
82 * @{
83 */
84
85 typedef enum {
86 RESET = 0,
87 SET = !RESET
88 } flag_status_t, it_status_t;
89
90 typedef enum {
91 DISABLE = 0,
92 ENABLE = !DISABLE
93 } functional_state_t;
IS_FUNCTIONAL_STATE(uint32_t STATE)94 static inline uint32_t IS_FUNCTIONAL_STATE(uint32_t STATE)
95 {
96 return (((STATE) == DISABLE) || ((STATE) == ENABLE));
97 }
98
99 typedef enum {
100 ERROR = 0,
101 SUCCESS = !ERROR
102 } error_status_t;
103
104 /** @} */
105
106 /** @addtogroup Exported_macros
107 * @{
108 */
109 #ifndef SET_BITS
110 #define SET_BITS(REG, BIT) ((REG) |= (BIT))
111 #endif
112
113 #ifndef CLEAR_BITS
114 #define CLEAR_BITS(REG, BIT) ((REG) &= ~(BIT))
115 #endif
116
117 #ifndef READ_BITS
118 #define READ_BITS(REG, BIT) ((REG) & (BIT))
119 #endif
120
121 #ifndef CLEAR_REG
122 #define CLEAR_REG(REG) ((REG) = (0x0))
123 #endif
124
125 #ifndef WRITE_REG
126 #define WRITE_REG(REG, VAL) ((REG) = (VAL))
127 #endif
128
129 #ifndef READ_REG
130 #define READ_REG(REG) ((REG))
131 #endif
132
133 #ifndef MODIFY_REG
134 #define MODIFY_REG(REG, CLEARMASK, SETMASK) WRITE_REG((REG), (((READ_REG(REG)) & (~(CLEARMASK))) | (SETMASK)))
135 #endif
136
137 #ifndef POSITION_VAL
138 #define POSITION_VAL(VAL) (__CLZ(__RBIT(VAL)))
139 #endif
140
141 #ifndef UNUSED
142 #define UNUSED(x) ((void)(x))
143 #endif
144
145 #ifndef SECTION_RAM_CODE
146 #if (!defined(ROM_RUN_IN_FLASH)) && defined(CFG_LAYER_TAG_ROM)
147 #define SECTION_RAM_CODE
148 #else
149 #if defined ( __ICCARM__ )
150 #define SECTION_RAM_CODE __ramfunc
151 #else
152 /**< To prevent doxygen from misidentifying the function name */
153 #define SECTION_RAM_CODE __attribute__((section("RAM_CODE")))
154 #endif
155 #endif
156 #endif
157
158 #ifndef TINY_RAM_SECTION
159 #if defined(GR5515_D) || defined(GR5515_E)
160 #define TINY_RAM_SECTION SECTION_RAM_CODE
161 #else
162 #if defined ( __ICCARM__ )
163 #define TINY_RAM_SECTION __ramfunc
164 #else
165 /**< To prevent doxygen from misidentifying the function name */
166 #define TINY_RAM_SECTION __attribute__((section("TINY_RAM_SPACE")))
167 #endif
168 #endif
169 #endif
170
171 /** @brief Disable interrupts globally in the system(apart from the NMI).
172 * This macro must be used in conjunction with the @ref GLOBAL_EXCEPTION_ENABLE macro
173 * since this last one will close the brace that the current macro opens. This means
174 * that both macros must be located at the same scope level.
175 */
176 #define GLOBAL_EXCEPTION_DISABLE() \
177 do { \
178 uint32_t __l_irq_rest = __get_PRIMASK(); \
179 __set_PRIMASK(1)
180
181
182 /** @brief Restore interrupts from the previous global disable(apart from the NMI).
183 * @sa GLOBAL_EXCEPTION_ENABLE
184 */
185 #define GLOBAL_EXCEPTION_ENABLE() \
186 if (__l_irq_rest == 0) \
187 { \
188 __set_PRIMASK(0); \
189 } \
190 else \
191 { \
192 __set_PRIMASK(1); \
193 } \
194 } while (0)
195 /** @} */
196
197 /** Array serial numbers are uniformly defined by macros.
198 * Do not use magic numbers.
199 */
200 #define ITEM_0 0
201 #define ITEM_1 1
202 #define ITEM_2 2
203 #define ITEM_3 3
204 #define ITEM_4 4
205 #define ITEM_5 5
206 #define ITEM_6 6
207 #define ITEM_7 7
208 #define ITEM_8 8
209 #define ITEM_9 9
210 #define ITEM_10 10
211 #define ITEM_11 11
212
213 #define ITEM_16 16
214
215 #ifdef __cplusplus
216 }
217 #endif
218
219 #endif /* __GR55xx_H__ */
220
221 /** @} */
222
223 /** @} */
224