8000 Update cores/nRF5/SDK with nRF MDK 8.37.0 · sandeepmistry/arduino-nRF5@8882b99 · GitHub
[go: up one dir, main page]

Skip to content

Commit 8882b99

Browse files
committed
1 parent 8f41ab6 commit 8882b99

File tree

112 files changed

+171462
-7783
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

112 files changed

+171462
-7783
lines changed

cores/nRF5/SDK/components/device/compiler_abstraction.h

Lines changed: 153 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,47 @@
1-
/* Copyright (c) 2015, Nordic Semiconductor ASA
2-
* All rights reserved.
3-
*
4-
* Redistribution and use in source and binary forms, with or without
5-
* modification, are permitted provided that the following conditions are met:
6-
*
7-
* * Redistributions of source code must retain the above copyright notice, this
8-
* list of conditions and the following disclaimer.
9-
*
10-
* * Redistributions in binary form must reproduce the above copyright notice,
11-
* this list of conditions and the following disclaimer in the documentation
12-
* and/or other materials provided with the distribution.
13-
*
14-
* * Neither the name of Nordic Semiconductor ASA nor the names of its
15-
* contributors may be used to endorse or promote products derived from
16-
* this software without specific prior written permission.
17-
*
18-
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19-
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20-
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21-
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
22-
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23-
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24-
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
25-
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26-
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27-
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28-
*
29-
*/
1+
/*
2+
3+
Copyright (c) 2010 - 2020, Nordic Semiconductor ASA All rights reserved.
4+
5+
Redistribution and use in source and binary forms, with or without
6+
modification, are permitted provided that the following conditions are met:
7+
8+
1. Redistributions of source code must retain the above copyright notice, this
9+
list of conditions and the following disclaimer.
10+
11+
2. Redistributions in binary form must reproduce the above copyright
12+
notice, this list of conditions and the following disclaimer in the
13+
documentation and/or other materials provided with the distribution.
14+
15+
3. Neither the name of Nordic Semiconductor ASA nor the names of its
16+
contributors may be used to endorse or promote products derived from this
17+
software without specific prior written permission.
18+
19+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21+
IMPLIED WARRANTIES OF MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE
22+
ARE DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
23+
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24+
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25+
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26+
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27+
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28+
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29+
POSSIBILITY OF SUCH DAMAGE.
30+
31+
*/
32+
3033
#ifndef _COMPILER_ABSTRACTION_H
3134
#define _COMPILER_ABSTRACTION_H
3235

3336
/*lint ++flb "Enter library region" */
3437

38+
#ifndef NRF_STRING_CONCATENATE_IMPL
39+
#define NRF_STRING_CONCATENATE_IMPL(lhs, rhs) lhs ## rhs
40+
#endif
41+
#ifndef NRF_STRING_CONCATENATE
42+
#define NRF_STRING_CONCATENATE(lhs, rhs) NRF_STRING_CONCATENATE_IMPL(lhs, rhs)
43+
#endif
44+
3545
#if defined ( __CC_ARM )
3646

3747
#ifndef __ASM
@@ -50,8 +60,58 @@
5060
#define __ALIGN(n) __align(n)
5161
#endif
5262

63+
#ifndef __PACKED
64+
#define __PACKED __packed
65+
#endif
66+
67+
#ifndef __UNUSED
68+
#define __UNUSED __attribute__((unused))
69+
#endif
70+
71+
#define GET_SP() __current_sp()
72+
73+
#ifndef NRF_STATIC_ASSERT
74+
#define NRF_STATIC_ASSERT(cond, msg) \
75+
;enum { NRF_STRING_CONCATENATE(static_assert_on_line_, __LINE__) = 1 / (!!(cond)) }
76+
#endif
77+
78+
#elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
79+
80+
#ifndef __ASM
81+
#define __ASM __asm
82+
#endif
83+
84+
#ifndef __INLINE
85+
#define __INLINE __inline
86+
#endif
87+
88+
#ifndef __WEAK
89+
#define __WEAK __attribute__((weak))
90+
#endif
91+
92+
#ifndef __ALIGN
93+
#define __ALIGN(n) __attribute__((aligned(n)))
94+
#endif
95+
96+
#ifndef __PACKED
97+
#define __PACKED __attribute__((packed, aligned(1)))
98+
#endif
99+
100+
#ifndef __UNUSED
101+
#define __UNUSED __attribute__((unused))
102+
#endif
103+
53104
#define GET_SP() __current_sp()
54105

106+
#ifndef NRF_STATIC_ASSERT
107+
#ifdef __cplusplus
108+
#ifndef _Static_assert
109+
#define _Static_assert static_assert
110+
#endif
111+
#endif
112+
#define NRF_STATIC_ASSERT(cond, msg) _Static_assert(cond, msg)
113+
#endif
114+
55115
#elif defined ( __ICCARM__ )
56116

57117
#ifndef __ASM
@@ -66,14 +126,26 @@
66126
#define __WEAK __weak
67127
#endif
68128

69-
/* Not defined for IAR since it requires a new line to work, and C preprocessor does not allow that. */
70129
#ifndef __ALIGN
71-
#define __ALIGN(n)
130+
#define STRING_PRAGMA(x) _Pragma(#x)
131+
#define __ALIGN(n) STRING_PRAGMA(data_alignment = n)
72132
#endif
73133

134+
#ifndef __PACKED
135+
#define __PACKED __packed
136+
#endif
137+
138+
#ifndef __UNUSED
139+
#define __UNUSED
140+
#endif
141+
74142
#define GET_SP() __get_SP()
75143

76-
#elif defined ( __GNUC__ )
144+
#ifndef NRF_STATIC_ASSERT
145+
#define NRF_STATIC_ASSERT(cond, msg) static_assert(cond, msg)
146+
#endif
147+
148+
#elif defined ( __GNUC__ ) || defined ( __clang__ )
77149

78150
#ifndef __ASM
79151
#define __ASM __asm
@@ -91,14 +163,32 @@
91163
#define __ALIGN(n) __attribute__((aligned(n)))
92164
#endif
93165

166+
#ifndef __PACKED
167+
#define __PACKED __attribute__((packed))
168+
#endif
169+
170+
#ifndef __UNUSED
171+
#define __UNUSED __attribute__((unused))
172+
#endif
173+
94174
#define GET_SP() gcc_current_sp()
95175

96176
static inline unsigned int gcc_current_sp(void)
97177
{
98-
register unsigned sp __ASM("sp");
99-
return sp;
178+
unsigned int stack_pointer = 0;
179+
__asm__ __volatile__ ("mov %0, sp" : "=r"(stack_pointer));
180+
return stack_pointer;
100181
}
101182

183+
#ifndef NRF_STATIC_ASSERT
184+
#ifdef __cplusplus
185+
#ifndef _Static_assert
186+
#define _Static_assert static_assert
187+
#endif
188+
#endif
189+
#define NRF_STATIC_ASSERT(cond, msg) _Static_assert(cond, msg)
190+
#endif
191+
102192
#elif defined ( __TASKING__ )
103193

104194
#ifndef __ASM
@@ -116,11 +206,40 @@
116206
#ifndef __ALIGN
117207
#define __ALIGN(n) __align(n)
118208
#endif
209+
210+
/* Not defined for TASKING. */
211+
#ifndef __PACKED
212+
#define __PACKED
213+
#endif
214+
215+
#ifndef __UNUSED
216+
#define __UNUSED __attribute__((unused))
217+
#endif
119218

120219
#define GET_SP() __get_MSP()
121220

221+
#ifndef NRF_STATIC_ASSERT
222+
#define NRF_STATIC_ASSERT(cond, msg) static_assert(cond, msg)
223+
#endif
224+
122225
#endif
123226

227+
#define NRF_MDK_VERSION_ASSERT_AT_LEAST(major, minor, micro) \
228+
NRF_STATIC_ASSERT( \
229+
( \
230+
(major < MDK_MAJOR_VERSION) || \
231+
(major == MDK_MAJOR_VERSION && minor < MDK_MINOR_VERSION) || \
232+
(major == MDK_MAJOR_VERSION && minor == MDK_MINOR_VERSION && micro < MDK_MICRO_VERSION) \
233+
), "MDK version mismatch.")
234+
235+
#define NRF_MDK_VERSION_ASSERT_EXACT(major, minor, micro) \
236+
NRF_STATIC_ASSERT( \
237+
( \
< 5AE5 code>238+
(major != MDK_MAJOR_VERSION) || \
239+
(major != MDK_MAJOR_VERSION) || \
240+
(major != MDK_MAJOR_VERSION) \
241+
), "MDK version mismatch.")
242+
124243
/*lint --flb "Leave library region" */
125244

126245
#endif

0 commit comments

Comments
 (0)
0