diff options
author | QMK Bot <hello@qmk.fm> | 2022-02-21 09:44:27 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-21 17:44:27 +0000 |
commit | 2f0dc0fb6d36b43e0d143224e4a9058b77c4e0e3 (patch) | |
tree | ecdbdccbb5fde38e22f6228f6a20a4ca2fed8b99 /tmk_core | |
parent | 32903779181c31244c7c7b97a04bda0fd5b59de1 (diff) | |
download | qmk_firmware-2f0dc0fb6d36b43e0d143224e4a9058b77c4e0e3.tar.gz qmk_firmware-2f0dc0fb6d36b43e0d143224e4a9058b77c4e0e3.zip |
Format code according to conventions (#16419)
Diffstat (limited to 'tmk_core')
-rw-r--r-- | tmk_core/protocol/arm_atsam/usb/compiler.h | 556 | ||||
-rw-r--r-- | tmk_core/protocol/arm_atsam/usb/udi_cdc.c | 16 | ||||
-rw-r--r-- | tmk_core/protocol/arm_atsam/usb/usb_device_udd.c | 5 |
3 files changed, 288 insertions, 289 deletions
diff --git a/tmk_core/protocol/arm_atsam/usb/compiler.h b/tmk_core/protocol/arm_atsam/usb/compiler.h index 6ba232234..4eeef96cf 100644 --- a/tmk_core/protocol/arm_atsam/usb/compiler.h +++ b/tmk_core/protocol/arm_atsam/usb/compiler.h | |||
@@ -43,7 +43,7 @@ | |||
43 | */ | 43 | */ |
44 | 44 | ||
45 | #ifndef UTILS_COMPILER_H_INCLUDED | 45 | #ifndef UTILS_COMPILER_H_INCLUDED |
46 | # define UTILS_COMPILER_H_INCLUDED | 46 | #define UTILS_COMPILER_H_INCLUDED |
47 | 47 | ||
48 | /** | 48 | /** |
49 | * \defgroup group_sam0_utils Compiler abstraction layer and code utilities | 49 | * \defgroup group_sam0_utils Compiler abstraction layer and code utilities |
@@ -54,38 +54,38 @@ | |||
54 | * @{ | 54 | * @{ |
55 | */ | 55 | */ |
56 | 56 | ||
57 | # if (defined __ICCARM__) | 57 | #if (defined __ICCARM__) |
58 | # include <intrinsics.h> | 58 | # include <intrinsics.h> |
59 | # endif | 59 | #endif |
60 | 60 | ||
61 | # include <stddef.h> | 61 | #include <stddef.h> |
62 | //#include <parts.h> | 62 | //#include <parts.h> |
63 | //#include <status_codes.h> | 63 | //#include <status_codes.h> |
64 | //#include <preprocessor.h> | 64 | //#include <preprocessor.h> |
65 | //#include <io.h> | 65 | //#include <io.h> |
66 | 66 | ||
67 | # ifndef __ASSEMBLY__ | 67 | #ifndef __ASSEMBLY__ |
68 | 68 | ||
69 | # include <stdio.h> | 69 | # include <stdio.h> |
70 | # include <stdbool.h> | 70 | # include <stdbool.h> |
71 | # include <stdint.h> | 71 | # include <stdint.h> |
72 | # include <stdlib.h> | 72 | # include <stdlib.h> |
73 | 73 | ||
74 | /** | 74 | /** |
75 | * \def UNUSED | 75 | * \def UNUSED |
76 | * \brief Marking \a v as a unused parameter or value. | 76 | * \brief Marking \a v as a unused parameter or value. |
77 | */ | 77 | */ |
78 | # define UNUSED(v) (void)(v) | 78 | # define UNUSED(v) (void)(v) |
79 | 79 | ||
80 | /** | 80 | /** |
81 | * \def barrier | 81 | * \def barrier |
82 | * \brief Memory barrier | 82 | * \brief Memory barrier |
83 | */ | 83 | */ |
84 | # ifdef __GNUC__ | 84 | # ifdef __GNUC__ |
85 | # define barrier() asm volatile("" ::: "memory") | 85 | # define barrier() asm volatile("" ::: "memory") |
86 | # else | 86 | # else |
87 | # define barrier() asm("") | 87 | # define barrier() asm("") |
88 | # endif | 88 | # endif |
89 | 89 | ||
90 | /** | 90 | /** |
91 | * \brief Emit the compiler pragma \a arg. | 91 | * \brief Emit the compiler pragma \a arg. |
@@ -93,37 +93,37 @@ | |||
93 | * \param[in] arg The pragma directive as it would appear after \e \#pragma | 93 | * \param[in] arg The pragma directive as it would appear after \e \#pragma |
94 | * (i.e. not stringified). | 94 | * (i.e. not stringified). |
95 | */ | 95 | */ |
96 | # define COMPILER_PRAGMA(arg) _Pragma(# arg) | 96 | # define COMPILER_PRAGMA(arg) _Pragma(# arg) |
97 | 97 | ||
98 | /** | 98 | /** |
99 | * \def COMPILER_PACK_SET(alignment) | 99 | * \def COMPILER_PACK_SET(alignment) |
100 | * \brief Set maximum alignment for subsequent struct and union definitions to \a alignment. | 100 | * \brief Set maximum alignment for subsequent struct and union definitions to \a alignment. |
101 | */ | 101 | */ |
102 | # define COMPILER_PACK_SET(alignment) COMPILER_PRAGMA(pack(alignment)) | 102 | # define COMPILER_PACK_SET(alignment) COMPILER_PRAGMA(pack(alignment)) |
103 | 103 | ||
104 | /** | 104 | /** |
105 | * \def COMPILER_PACK_RESET() | 105 | * \def COMPILER_PACK_RESET() |
106 | * \brief Set default alignment for subsequent struct and union definitions. | 106 | * \brief Set default alignment for subsequent struct and union definitions. |
107 | */ | 107 | */ |
108 | # define COMPILER_PACK_RESET() COMPILER_PRAGMA(pack()) | 108 | # define COMPILER_PACK_RESET() COMPILER_PRAGMA(pack()) |
109 | 109 | ||
110 | /** | 110 | /** |
111 | * \brief Set aligned boundary. | 111 | * \brief Set aligned boundary. |
112 | */ | 112 | */ |
113 | # if (defined __GNUC__) || (defined __CC_ARM) | 113 | # if (defined __GNUC__) || (defined __CC_ARM) |
114 | # define COMPILER_ALIGNED(a) __attribute__((__aligned__(a))) | 114 | # define COMPILER_ALIGNED(a) __attribute__((__aligned__(a))) |
115 | # elif (defined __ICCARM__) | 115 | # elif (defined __ICCARM__) |
116 | # define COMPILER_ALIGNED(a) COMPILER_PRAGMA(data_alignment = a) | 116 | # define COMPILER_ALIGNED(a) COMPILER_PRAGMA(data_alignment = a) |
117 | # endif | 117 | # endif |
118 | 118 | ||
119 | /** | 119 | /** |
120 | * \brief Set word-aligned boundary. | 120 | * \brief Set word-aligned boundary. |
121 | */ | 121 | */ |
122 | # if (defined __GNUC__) || defined(__CC_ARM) | 122 | # if (defined __GNUC__) || defined(__CC_ARM) |
123 | # define COMPILER_WORD_ALIGNED __attribute__((__aligned__(4))) | 123 | # define COMPILER_WORD_ALIGNED __attribute__((__aligned__(4))) |
124 | # elif (defined __ICCARM__) | 124 | # elif (defined __ICCARM__) |
125 | # define COMPILER_WORD_ALIGNED COMPILER_PRAGMA(data_alignment = 4) | 125 | # define COMPILER_WORD_ALIGNED COMPILER_PRAGMA(data_alignment = 4) |
126 | # endif | 126 | # endif |
127 | 127 | ||
128 | /** | 128 | /** |
129 | * \def __always_inline | 129 | * \def __always_inline |
@@ -133,15 +133,15 @@ | |||
133 | * heuristics and inline the function no matter how big it thinks it | 133 | * heuristics and inline the function no matter how big it thinks it |
134 | * becomes. | 134 | * becomes. |
135 | */ | 135 | */ |
136 | # if !defined(__always_inline) | 136 | # if !defined(__always_inline) |
137 | # if defined(__CC_ARM) | 137 | # if defined(__CC_ARM) |
138 | # define __always_inline __forceinline | 138 | # define __always_inline __forceinline |
139 | # elif (defined __GNUC__) | 139 | # elif (defined __GNUC__) |
140 | # define __always_inline __attribute__((__always_inline__)) | 140 | # define __always_inline __attribute__((__always_inline__)) |
141 | # elif (defined __ICCARM__) | 141 | # elif (defined __ICCARM__) |
142 | # define __always_inline _Pragma("inline=forced") | 142 | # define __always_inline _Pragma("inline=forced") |
143 | # endif | ||
144 | # endif | 143 | # endif |
144 | # endif | ||
145 | 145 | ||
146 | /** | 146 | /** |
147 | * \def __no_inline | 147 | * \def __no_inline |
@@ -151,13 +151,13 @@ | |||
151 | * heuristics and not inline the function no matter how small it thinks it | 151 | * heuristics and not inline the function no matter how small it thinks it |
152 | * becomes. | 152 | * becomes. |
153 | */ | 153 | */ |
154 | # if defined(__CC_ARM) | 154 | # if defined(__CC_ARM) |
155 | # define __no_inline __attribute__((noinline)) | 155 | # define __no_inline __attribute__((noinline)) |
156 | # elif (defined __GNUC__) | 156 | # elif (defined __GNUC__) |
157 | # define __no_inline __attribute__((noinline)) | 157 | # define __no_inline __attribute__((noinline)) |
158 | # elif (defined __ICCARM__) | 158 | # elif (defined __ICCARM__) |
159 | # define __no_inline _Pragma("inline=never") | 159 | # define __no_inline _Pragma("inline=never") |
160 | # endif | 160 | # endif |
161 | 161 | ||
162 | /** \brief This macro is used to test fatal errors. | 162 | /** \brief This macro is used to test fatal errors. |
163 | * | 163 | * |
@@ -168,47 +168,47 @@ | |||
168 | * | 168 | * |
169 | * \param[in] expr Expression to evaluate and supposed to be nonzero. | 169 | * \param[in] expr Expression to evaluate and supposed to be nonzero. |
170 | */ | 170 | */ |
171 | # if defined(_ASSERT_ENABLE_) | 171 | # if defined(_ASSERT_ENABLE_) |
172 | # if defined(TEST_SUITE_DEFINE_ASSERT_MACRO) | 172 | # if defined(TEST_SUITE_DEFINE_ASSERT_MACRO) |
173 | # include "unit_test/suite.h" | 173 | # include "unit_test/suite.h" |
174 | # else | ||
175 | # undef TEST_SUITE_DEFINE_ASSERT_MACRO | ||
176 | # define Assert(expr) \ | ||
177 | { \ | ||
178 | if (!(expr)) asm("BKPT #0"); \ | ||
179 | } | ||
180 | # endif | ||
181 | # else | 174 | # else |
182 | # define Assert(expr) ((void)0) | 175 | # undef TEST_SUITE_DEFINE_ASSERT_MACRO |
176 | # define Assert(expr) \ | ||
177 | { \ | ||
178 | if (!(expr)) asm("BKPT #0"); \ | ||
179 | } | ||
183 | # endif | 180 | # endif |
181 | # else | ||
182 | # define Assert(expr) ((void)0) | ||
183 | # endif | ||
184 | 184 | ||
185 | /* Define WEAK attribute */ | 185 | /* Define WEAK attribute */ |
186 | # if defined(__CC_ARM) | 186 | # if defined(__CC_ARM) |
187 | # define WEAK __attribute__((weak)) | 187 | # define WEAK __attribute__((weak)) |
188 | # elif defined(__ICCARM__) | 188 | # elif defined(__ICCARM__) |
189 | # define WEAK __weak | 189 | # define WEAK __weak |
190 | # elif defined(__GNUC__) | 190 | # elif defined(__GNUC__) |
191 | # define WEAK __attribute__((weak)) | 191 | # define WEAK __attribute__((weak)) |
192 | # endif | 192 | # endif |
193 | 193 | ||
194 | /* Define NO_INIT attribute */ | 194 | /* Define NO_INIT attribute */ |
195 | # if defined(__CC_ARM) | 195 | # if defined(__CC_ARM) |
196 | # define NO_INIT __attribute__((zero_init)) | 196 | # define NO_INIT __attribute__((zero_init)) |
197 | # elif defined(__ICCARM__) | 197 | # elif defined(__ICCARM__) |
198 | # define NO_INIT __no_init | 198 | # define NO_INIT __no_init |
199 | # elif defined(__GNUC__) | 199 | # elif defined(__GNUC__) |
200 | # define NO_INIT __attribute__((section(".no_init"))) | 200 | # define NO_INIT __attribute__((section(".no_init"))) |
201 | # endif | 201 | # endif |
202 | 202 | ||
203 | //#include "interrupt.h" | 203 | //#include "interrupt.h" |
204 | 204 | ||
205 | /** \name Usual Types | 205 | /** \name Usual Types |
206 | * @{ */ | 206 | * @{ */ |
207 | # ifndef __cplusplus | 207 | # ifndef __cplusplus |
208 | # if !defined(__bool_true_false_are_defined) | 208 | # if !defined(__bool_true_false_are_defined) |
209 | typedef unsigned char bool; | 209 | typedef unsigned char bool; |
210 | # endif | ||
211 | # endif | 210 | # endif |
211 | # endif | ||
212 | typedef uint16_t le16_t; | 212 | typedef uint16_t le16_t; |
213 | typedef uint16_t be16_t; | 213 | typedef uint16_t be16_t; |
214 | typedef uint32_t le32_t; | 214 | typedef uint32_t le32_t; |
@@ -347,22 +347,22 @@ typedef struct { | |||
347 | 347 | ||
348 | /** @} */ | 348 | /** @} */ |
349 | 349 | ||
350 | # endif /* #ifndef __ASSEMBLY__ */ | 350 | #endif /* #ifndef __ASSEMBLY__ */ |
351 | 351 | ||
352 | /** \name Usual Constants | 352 | /** \name Usual Constants |
353 | * @{ */ | 353 | * @{ */ |
354 | // kmod #define DISABLE 0 | 354 | // kmod #define DISABLE 0 |
355 | // kmod #define ENABLE 1 | 355 | // kmod #define ENABLE 1 |
356 | 356 | ||
357 | # ifndef __cplusplus | 357 | #ifndef __cplusplus |
358 | # if !defined(__bool_true_false_are_defined) | 358 | # if !defined(__bool_true_false_are_defined) |
359 | # define false 0 | 359 | # define false 0 |
360 | # define true 1 | 360 | # define true 1 |
361 | # endif | ||
362 | # endif | 361 | # endif |
362 | #endif | ||
363 | /** @} */ | 363 | /** @} */ |
364 | 364 | ||
365 | # ifndef __ASSEMBLY__ | 365 | #ifndef __ASSEMBLY__ |
366 | 366 | ||
367 | /** \name Optimization Control | 367 | /** \name Optimization Control |
368 | * @{ */ | 368 | * @{ */ |
@@ -371,17 +371,17 @@ typedef struct { | |||
371 | * \def likely(exp) | 371 | * \def likely(exp) |
372 | * \brief The expression \a exp is likely to be true | 372 | * \brief The expression \a exp is likely to be true |
373 | */ | 373 | */ |
374 | # if !defined(likely) || defined(__DOXYGEN__) | 374 | # if !defined(likely) || defined(__DOXYGEN__) |
375 | # define likely(exp) (exp) | 375 | # define likely(exp) (exp) |
376 | # endif | 376 | # endif |
377 | 377 | ||
378 | /** | 378 | /** |
379 | * \def unlikely(exp) | 379 | * \def unlikely(exp) |
380 | * \brief The expression \a exp is unlikely to be true | 380 | * \brief The expression \a exp is unlikely to be true |
381 | */ | 381 | */ |
382 | # if !defined(unlikely) || defined(__DOXYGEN__) | 382 | # if !defined(unlikely) || defined(__DOXYGEN__) |
383 | # define unlikely(exp) (exp) | 383 | # define unlikely(exp) (exp) |
384 | # endif | 384 | # endif |
385 | 385 | ||
386 | /** | 386 | /** |
387 | * \def is_constant(exp) | 387 | * \def is_constant(exp) |
@@ -391,11 +391,11 @@ typedef struct { | |||
391 | * | 391 | * |
392 | * \return true if \a exp is constant, false otherwise. | 392 | * \return true if \a exp is constant, false otherwise. |
393 | */ | 393 | */ |
394 | # if (defined __GNUC__) || (defined __CC_ARM) | 394 | # if (defined __GNUC__) || (defined __CC_ARM) |
395 | # define is_constant(exp) __builtin_constant_p(exp) | 395 | # define is_constant(exp) __builtin_constant_p(exp) |
396 | # else | 396 | # else |
397 | # define is_constant(exp) (0) | 397 | # define is_constant(exp) (0) |
398 | # endif | 398 | # endif |
399 | 399 | ||
400 | /** @} */ | 400 | /** @} */ |
401 | 401 | ||
@@ -409,7 +409,7 @@ typedef struct { | |||
409 | * | 409 | * |
410 | * \return Read bits. | 410 | * \return Read bits. |
411 | */ | 411 | */ |
412 | # define Rd_bits(value, mask) ((value) & (mask)) | 412 | # define Rd_bits(value, mask) ((value) & (mask)) |
413 | 413 | ||
414 | /** \brief Writes the bits of a C lvalue specified by a given bit-mask. | 414 | /** \brief Writes the bits of a C lvalue specified by a given bit-mask. |
415 | * | 415 | * |
@@ -419,7 +419,7 @@ typedef struct { | |||
419 | * | 419 | * |
420 | * \return Resulting value with written bits. | 420 | * \return Resulting value with written bits. |
421 | */ | 421 | */ |
422 | # define Wr_bits(lvalue, mask, bits) ((lvalue) = ((lvalue) & ~(mask)) | ((bits) & (mask))) | 422 | # define Wr_bits(lvalue, mask, bits) ((lvalue) = ((lvalue) & ~(mask)) | ((bits) & (mask))) |
423 | 423 | ||
424 | /** \brief Tests the bits of a value specified by a given bit-mask. | 424 | /** \brief Tests the bits of a value specified by a given bit-mask. |
425 | * | 425 | * |
@@ -428,7 +428,7 @@ typedef struct { | |||
428 | * | 428 | * |
429 | * \return \c 1 if at least one of the tested bits is set, else \c 0. | 429 | * \return \c 1 if at least one of the tested bits is set, else \c 0. |
430 | */ | 430 | */ |
431 | # define Tst_bits(value, mask) (Rd_bits(value, mask) != 0) | 431 | # define Tst_bits(value, mask) (Rd_bits(value, mask) != 0) |
432 | 432 | ||
433 | /** \brief Clears the bits of a C lvalue specified by a given bit-mask. | 433 | /** \brief Clears the bits of a C lvalue specified by a given bit-mask. |
434 | * | 434 | * |
@@ -437,7 +437,7 @@ typedef struct { | |||
437 | * | 437 | * |
438 | * \return Resulting value with cleared bits. | 438 | * \return Resulting value with cleared bits. |
439 | */ | 439 | */ |
440 | # define Clr_bits(lvalue, mask) ((lvalue) &= ~(mask)) | 440 | # define Clr_bits(lvalue, mask) ((lvalue) &= ~(mask)) |
441 | 441 | ||
442 | /** \brief Sets the bits of a C lvalue specified by a given bit-mask. | 442 | /** \brief Sets the bits of a C lvalue specified by a given bit-mask. |
443 | * | 443 | * |
@@ -446,7 +446,7 @@ typedef struct { | |||
446 | * | 446 | * |
447 | * \return Resulting value with set bits. | 447 | * \return Resulting value with set bits. |
448 | */ | 448 | */ |
449 | # define Set_bits(lvalue, mask) ((lvalue) |= (mask)) | 449 | # define Set_bits(lvalue, mask) ((lvalue) |= (mask)) |
450 | 450 | ||
451 | /** \brief Toggles the bits of a C lvalue specified by a given bit-mask. | 451 | /** \brief Toggles the bits of a C lvalue specified by a given bit-mask. |
452 | * | 452 | * |
@@ -455,7 +455,7 @@ typedef struct { | |||
455 | * | 455 | * |
456 | * \return Resulting value with toggled bits. | 456 | * \return Resulting value with toggled bits. |
457 | */ | 457 | */ |
458 | # define Tgl_bits(lvalue, mask) ((lvalue) ^= (mask)) | 458 | # define Tgl_bits(lvalue, mask) ((lvalue) ^= (mask)) |
459 | 459 | ||
460 | /** \brief Reads the bit-field of a value specified by a given bit-mask. | 460 | /** \brief Reads the bit-field of a value specified by a given bit-mask. |
461 | * | 461 | * |
@@ -464,7 +464,7 @@ typedef struct { | |||
464 | * | 464 | * |
465 | * \return Read bit-field. | 465 | * \return Read bit-field. |
466 | */ | 466 | */ |
467 | # define Rd_bitfield(value, mask) (Rd_bits(value, mask) >> ctz(mask)) | 467 | # define Rd_bitfield(value, mask) (Rd_bits(value, mask) >> ctz(mask)) |
468 | 468 | ||
469 | /** \brief Writes the bit-field of a C lvalue specified by a given bit-mask. | 469 | /** \brief Writes the bit-field of a C lvalue specified by a given bit-mask. |
470 | * | 470 | * |
@@ -474,7 +474,7 @@ typedef struct { | |||
474 | * | 474 | * |
475 | * \return Resulting value with written bit-field. | 475 | * \return Resulting value with written bit-field. |
476 | */ | 476 | */ |
477 | # define Wr_bitfield(lvalue, mask, bitfield) (Wr_bits(lvalue, mask, (uint32_t)(bitfield) << ctz(mask))) | 477 | # define Wr_bitfield(lvalue, mask, bitfield) (Wr_bits(lvalue, mask, (uint32_t)(bitfield) << ctz(mask))) |
478 | 478 | ||
479 | /** @} */ | 479 | /** @} */ |
480 | 480 | ||
@@ -498,11 +498,11 @@ typedef struct { | |||
498 | * | 498 | * |
499 | * \return The count of leading zero bits in \a u. | 499 | * \return The count of leading zero bits in \a u. |
500 | */ | 500 | */ |
501 | # if (defined __GNUC__) || (defined __CC_ARM) | 501 | # if (defined __GNUC__) || (defined __CC_ARM) |
502 | # define clz(u) ((u) ? __builtin_clz(u) : 32) | 502 | # define clz(u) ((u) ? __builtin_clz(u) : 32) |
503 | # else | 503 | # else |
504 | # define clz(u) (((u) == 0) ? 32 : ((u) & (1ul << 31)) ? 0 : ((u) & (1ul << 30)) ? 1 : ((u) & (1ul << 29)) ? 2 : ((u) & (1ul << 28)) ? 3 : ((u) & (1ul << 27)) ? 4 : ((u) & (1ul << 26)) ? 5 : ((u) & (1ul << 25)) ? 6 : ((u) & (1ul << 24)) ? 7 : ((u) & (1ul << 23)) ? 8 : ((u) & (1ul << 22)) ? 9 : ((u) & (1ul << 21)) ? 10 : ((u) & (1ul << 20)) ? 11 : ((u) & (1ul << 19)) ? 12 : ((u) & (1ul << 18)) ? 13 : ((u) & (1ul << 17)) ? 14 : ((u) & (1ul << 16)) ? 15 : ((u) & (1ul << 15)) ? 16 : ((u) & (1ul << 14)) ? 17 : ((u) & (1ul << 13)) ? 18 : ((u) & (1ul << 12)) ? 19 : ((u) & (1ul << 11)) ? 20 : ((u) & (1ul << 10)) ? 21 : ((u) & (1ul << 9)) ? 22 : ((u) & (1ul << 8)) ? 23 : ((u) & (1ul << 7)) ? 24 : ((u) & (1ul << 6)) ? 25 : ((u) & (1ul << 5)) ? 26 : ((u) & (1ul << 4)) ? 27 : ((u) & (1ul << 3)) ? 28 : ((u) & (1ul << 2)) ? 29 : ((u) & (1ul << 1)) ? 30 : 31) | 504 | # define clz(u) (((u) == 0) ? 32 : ((u) & (1ul << 31)) ? 0 : ((u) & (1ul << 30)) ? 1 : ((u) & (1ul << 29)) ? 2 : ((u) & (1ul << 28)) ? 3 : ((u) & (1ul << 27)) ? 4 : ((u) & (1ul << 26)) ? 5 : ((u) & (1ul << 25)) ? 6 : ((u) & (1ul << 24)) ? 7 : ((u) & (1ul << 23)) ? 8 : ((u) & (1ul << 22)) ? 9 : ((u) & (1ul << 21)) ? 10 : ((u) & (1ul << 20)) ? 11 : ((u) & (1ul << 19)) ? 12 : ((u) & (1ul << 18)) ? 13 : ((u) & (1ul << 17)) ? 14 : ((u) & (1ul << 16)) ? 15 : ((u) & (1ul << 15)) ? 16 : ((u) & (1ul << 14)) ? 17 : ((u) & (1ul << 13)) ? 18 : ((u) & (1ul << 12)) ? 19 : ((u) & (1ul << 11)) ? 20 : ((u) & (1ul << 10)) ? 21 : ((u) & (1ul << 9)) ? 22 : ((u) & (1ul << 8)) ? 23 : ((u) & (1ul << 7)) ? 24 : ((u) & (1ul << 6)) ? 25 : ((u) & (1ul << 5)) ? 26 : ((u) & (1ul << 4)) ? 27 : ((u) & (1ul << 3)) ? 28 : ((u) & (1ul << 2)) ? 29 : ((u) & (1ul << 1)) ? 30 : 31) |
505 | # endif | 505 | # endif |
506 | 506 | ||
507 | /** \brief Counts the trailing zero bits of the given value considered as a 32-bit integer. | 507 | /** \brief Counts the trailing zero bits of the given value considered as a 32-bit integer. |
508 | * | 508 | * |
@@ -510,11 +510,11 @@ typedef struct { | |||
510 | * | 510 | * |
511 | * \return The count of trailing zero bits in \a u. | 511 | * \return The count of trailing zero bits in \a u. |
512 | */ | 512 | */ |
513 | # if (defined __GNUC__) || (defined __CC_ARM) | 513 | # if (defined __GNUC__) || (defined __CC_ARM) |
514 | # define ctz(u) ((u) ? __builtin_ctz(u) : 32) | 514 | # define ctz(u) ((u) ? __builtin_ctz(u) : 32) |
515 | # else | 515 | # else |
516 | # define ctz(u) ((u) & (1ul << 0) ? 0 : (u) & (1ul << 1) ? 1 : (u) & (1ul << 2) ? 2 : (u) & (1ul << 3) ? 3 : (u) & (1ul << 4) ? 4 : (u) & (1ul << 5) ? 5 : (u) & (1ul << 6) ? 6 : (u) & (1ul << 7) ? 7 : (u) & (1ul << 8) ? 8 : (u) & (1ul << 9) ? 9 : (u) & (1ul << 10) ? 10 : (u) & (1ul << 11) ? 11 : (u) & (1ul << 12) ? 12 : (u) & (1ul << 13) ? 13 : (u) & (1ul << 14) ? 14 : (u) & (1ul << 15) ? 15 : (u) & (1ul << 16) ? 16 : (u) & (1ul << 17) ? 17 : (u) & (1ul << 18) ? 18 : (u) & (1ul << 19) ? 19 : (u) & (1ul << 20) ? 20 : (u) & (1ul << 21) ? 21 : (u) & (1ul << 22) ? 22 : (u) & (1ul << 23) ? 23 : (u) & (1ul << 24) ? 24 : (u) & (1ul << 25) ? 25 : (u) & (1ul << 26) ? 26 : (u) & (1ul << 27) ? 27 : (u) & (1ul << 28) ? 28 : (u) & (1ul << 29) ? 29 : (u) & (1ul << 30) ? 30 : (u) & (1ul << 31) ? 31 : 32) | 516 | # define ctz(u) ((u) & (1ul << 0) ? 0 : (u) & (1ul << 1) ? 1 : (u) & (1ul << 2) ? 2 : (u) & (1ul << 3) ? 3 : (u) & (1ul << 4) ? 4 : (u) & (1ul << 5) ? 5 : (u) & (1ul << 6) ? 6 : (u) & (1ul << 7) ? 7 : (u) & (1ul << 8) ? 8 : (u) & (1ul << 9) ? 9 : (u) & (1ul << 10) ? 10 : (u) & (1ul << 11) ? 11 : (u) & (1ul << 12) ? 12 : (u) & (1ul << 13) ? 13 : (u) & (1ul << 14) ? 14 : (u) & (1ul << 15) ? 15 : (u) & (1ul << 16) ? 16 : (u) & (1ul << 17) ? 17 : (u) & (1ul << 18) ? 18 : (u) & (1ul << 19) ? 19 : (u) & (1ul << 20) ? 20 : (u) & (1ul << 21) ? 21 : (u) & (1ul << 22) ? 22 : (u) & (1ul << 23) ? 23 : (u) & (1ul << 24) ? 24 : (u) & (1ul << 25) ? 25 : (u) & (1ul << 26) ? 26 : (u) & (1ul << 27) ? 27 : (u) & (1ul << 28) ? 28 : (u) & (1ul << 29) ? 29 : (u) & (1ul << 30) ? 30 : (u) & (1ul << 31) ? 31 : 32) |
517 | # endif | 517 | # endif |
518 | 518 | ||
519 | /** @} */ | 519 | /** @} */ |
520 | 520 | ||
@@ -527,7 +527,7 @@ typedef struct { | |||
527 | * | 527 | * |
528 | * \return Value resulting from \a u8 with reversed bits. | 528 | * \return Value resulting from \a u8 with reversed bits. |
529 | */ | 529 | */ |
530 | # define bit_reverse8(u8) ((U8)(bit_reverse32((U8)(u8)) >> 24)) | 530 | # define bit_reverse8(u8) ((U8)(bit_reverse32((U8)(u8)) >> 24)) |
531 | 531 | ||
532 | /** \brief Reverses the bits of \a u16. | 532 | /** \brief Reverses the bits of \a u16. |
533 | * | 533 | * |
@@ -535,7 +535,7 @@ typedef struct { | |||
535 | * | 535 | * |
536 | * \return Value resulting from \a u16 with reversed bits. | 536 | * \return Value resulting from \a u16 with reversed bits. |
537 | */ | 537 | */ |
538 | # define bit_reverse16(u16) ((uint16_t)(bit_reverse32((uint16_t)(u16)) >> 16)) | 538 | # define bit_reverse16(u16) ((uint16_t)(bit_reverse32((uint16_t)(u16)) >> 16)) |
539 | 539 | ||
540 | /** \brief Reverses the bits of \a u32. | 540 | /** \brief Reverses the bits of \a u32. |
541 | * | 541 | * |
@@ -543,7 +543,7 @@ typedef struct { | |||
543 | * | 543 | * |
544 | * \return Value resulting from \a u32 with reversed bits. | 544 | * \return Value resulting from \a u32 with reversed bits. |
545 | */ | 545 | */ |
546 | # define bit_reverse32(u32) __RBIT(u32) | 546 | # define bit_reverse32(u32) __RBIT(u32) |
547 | 547 | ||
548 | /** \brief Reverses the bits of \a u64. | 548 | /** \brief Reverses the bits of \a u64. |
549 | * | 549 | * |
@@ -551,7 +551,7 @@ typedef struct { | |||
551 | * | 551 | * |
552 | * \return Value resulting from \a u64 with reversed bits. | 552 | * \return Value resulting from \a u64 with reversed bits. |
553 | */ | 553 | */ |
554 | # define bit_reverse64(u64) ((uint64_t)(((uint64_t)bit_reverse32((uint64_t)(u64) >> 32)) | ((uint64_t)bit_reverse32((uint64_t)(u64)) << 32))) | 554 | # define bit_reverse64(u64) ((uint64_t)(((uint64_t)bit_reverse32((uint64_t)(u64) >> 32)) | ((uint64_t)bit_reverse32((uint64_t)(u64)) << 32))) |
555 | 555 | ||
556 | /** @} */ | 556 | /** @} */ |
557 | 557 | ||
@@ -565,7 +565,7 @@ typedef struct { | |||
565 | * | 565 | * |
566 | * \return \c 1 if the number \a val is aligned with the \a n boundary, else \c 0. | 566 | * \return \c 1 if the number \a val is aligned with the \a n boundary, else \c 0. |
567 | */ | 567 | */ |
568 | # define Test_align(val, n) (!Tst_bits(val, (n)-1)) | 568 | # define Test_align(val, n) (!Tst_bits(val, (n)-1)) |
569 | 569 | ||
570 | /** \brief Gets alignment of the number \a val with respect to the \a n boundary. | 570 | /** \brief Gets alignment of the number \a val with respect to the \a n boundary. |
571 | * | 571 | * |
@@ -574,7 +574,7 @@ typedef struct { | |||
574 | * | 574 | * |
575 | * \return Alignment of the number \a val with respect to the \a n boundary. | 575 | * \return Alignment of the number \a val with respect to the \a n boundary. |
576 | */ | 576 | */ |
577 | # define Get_align(val, n) (Rd_bits(val, (n)-1)) | 577 | # define Get_align(val, n) (Rd_bits(val, (n)-1)) |
578 | 578 | ||
579 | /** \brief Sets alignment of the lvalue number \a lval to \a alg with respect to the \a n boundary. | 579 | /** \brief Sets alignment of the lvalue number \a lval to \a alg with respect to the \a n boundary. |
580 | * | 580 | * |
@@ -584,7 +584,7 @@ typedef struct { | |||
584 | * | 584 | * |
585 | * \return New value of \a lval resulting from its alignment set to \a alg with respect to the \a n boundary. | 585 | * \return New value of \a lval resulting from its alignment set to \a alg with respect to the \a n boundary. |
586 | */ | 586 | */ |
587 | # define Set_align(lval, n, alg) (Wr_bits(lval, (n)-1, alg)) | 587 | # define Set_align(lval, n, alg) (Wr_bits(lval, (n)-1, alg)) |
588 | 588 | ||
589 | /** \brief Aligns the number \a val with the upper \a n boundary. | 589 | /** \brief Aligns the number \a val with the upper \a n boundary. |
590 | * | 590 | * |
@@ -593,7 +593,7 @@ typedef struct { | |||
593 | * | 593 | * |
594 | * \return Value resulting from the number \a val aligned with the upper \a n boundary. | 594 | * \return Value resulting from the number \a val aligned with the upper \a n boundary. |
595 | */ | 595 | */ |
596 | # define Align_up(val, n) (((val) + ((n)-1)) & ~((n)-1)) | 596 | # define Align_up(val, n) (((val) + ((n)-1)) & ~((n)-1)) |
597 | 597 | ||
598 | /** \brief Aligns the number \a val with the lower \a n boundary. | 598 | /** \brief Aligns the number \a val with the lower \a n boundary. |
599 | * | 599 | * |
@@ -602,7 +602,7 @@ typedef struct { | |||
602 | * | 602 | * |
603 | * \return Value resulting from the number \a val aligned with the lower \a n boundary. | 603 | * \return Value resulting from the number \a val aligned with the lower \a n boundary. |
604 | */ | 604 | */ |
605 | # define Align_down(val, n) ((val) & ~((n)-1)) | 605 | # define Align_down(val, n) ((val) & ~((n)-1)) |
606 | 606 | ||
607 | /** @} */ | 607 | /** @} */ |
608 | 608 | ||
@@ -627,9 +627,9 @@ typedef struct { | |||
627 | * | 627 | * |
628 | * \note More optimized if only used with values known at compile time. | 628 | * \note More optimized if only used with values known at compile time. |
629 | */ | 629 | */ |
630 | # define Abs(a) (((a) < 0) ? -(a) : (a)) | 630 | # define Abs(a) (((a) < 0) ? -(a) : (a)) |
631 | 631 | ||
632 | # ifndef __cplusplus | 632 | # ifndef __cplusplus |
633 | /** \brief Takes the minimal value of \a a and \a b. | 633 | /** \brief Takes the minimal value of \a a and \a b. |
634 | * | 634 | * |
635 | * \param[in] a Input value. | 635 | * \param[in] a Input value. |
@@ -639,7 +639,7 @@ typedef struct { | |||
639 | * | 639 | * |
640 | * \note More optimized if only used with values known at compile time. | 640 | * \note More optimized if only used with values known at compile time. |
641 | */ | 641 | */ |
642 | # define Min(a, b) (((a) < (b)) ? (a) : (b)) | 642 | # define Min(a, b) (((a) < (b)) ? (a) : (b)) |
643 | 643 | ||
644 | /** \brief Takes the maximal value of \a a and \a b. | 644 | /** \brief Takes the maximal value of \a a and \a b. |
645 | * | 645 | * |
@@ -650,7 +650,7 @@ typedef struct { | |||
650 | * | 650 | * |
651 | * \note More optimized if only used with values known at compile time. | 651 | * \note More optimized if only used with values known at compile time. |
652 | */ | 652 | */ |
653 | # define Max(a, b) (((a) > (b)) ? (a) : (b)) | 653 | # define Max(a, b) (((a) > (b)) ? (a) : (b)) |
654 | 654 | ||
655 | /** \brief Takes the minimal value of \a a and \a b. | 655 | /** \brief Takes the minimal value of \a a and \a b. |
656 | * | 656 | * |
@@ -661,7 +661,7 @@ typedef struct { | |||
661 | * | 661 | * |
662 | * \note More optimized if only used with values unknown at compile time. | 662 | * \note More optimized if only used with values unknown at compile time. |
663 | */ | 663 | */ |
664 | # define min(a, b) Min(a, b) | 664 | # define min(a, b) Min(a, b) |
665 | 665 | ||
666 | /** \brief Takes the maximal value of \a a and \a b. | 666 | /** \brief Takes the maximal value of \a a and \a b. |
667 | * | 667 | * |
@@ -672,8 +672,8 @@ typedef struct { | |||
672 | * | 672 | * |
673 | * \note More optimized if only used with values unknown at compile time. | 673 | * \note More optimized if only used with values unknown at compile time. |
674 | */ | 674 | */ |
675 | # define max(a, b) Max(a, b) | 675 | # define max(a, b) Max(a, b) |
676 | # endif | 676 | # endif |
677 | 677 | ||
678 | /** @} */ | 678 | /** @} */ |
679 | 679 | ||
@@ -688,34 +688,34 @@ typedef struct { | |||
688 | * | 688 | * |
689 | * \note It may be used as a long jump opcode in some special cases. | 689 | * \note It may be used as a long jump opcode in some special cases. |
690 | */ | 690 | */ |
691 | # define Long_call(addr) ((*(void (*)(void))(addr))()) | 691 | # define Long_call(addr) ((*(void (*)(void))(addr))()) |
692 | 692 | ||
693 | /** \name MCU Endianism Handling | 693 | /** \name MCU Endianism Handling |
694 | * ARM is MCU little endian. | 694 | * ARM is MCU little endian. |
695 | * | 695 | * |
696 | * @{ */ | 696 | * @{ */ |
697 | # define BE16(x) swap16(x) | 697 | # define BE16(x) swap16(x) |
698 | # define LE16(x) (x) | 698 | # define LE16(x) (x) |
699 | 699 | ||
700 | # define le16_to_cpu(x) (x) | 700 | # define le16_to_cpu(x) (x) |
701 | # define cpu_to_le16(x) (x) | 701 | # define cpu_to_le16(x) (x) |
702 | # define LE16_TO_CPU(x) (x) | 702 | # define LE16_TO_CPU(x) (x) |
703 | # define CPU_TO_LE16(x) (x) | 703 | # define CPU_TO_LE16(x) (x) |
704 | 704 | ||
705 | # define be16_to_cpu(x) swap16(x) | 705 | # define be16_to_cpu(x) swap16(x) |
706 | # define cpu_to_be16(x) swap16(x) | 706 | # define cpu_to_be16(x) swap16(x) |
707 | # define BE16_TO_CPU(x) swap16(x) | 707 | # define BE16_TO_CPU(x) swap16(x) |
708 | # define CPU_TO_BE16(x) swap16(x) | 708 | # define CPU_TO_BE16(x) swap16(x) |
709 | 709 | ||
710 | # define le32_to_cpu(x) (x) | 710 | # define le32_to_cpu(x) (x) |
711 | # define cpu_to_le32(x) (x) | 711 | # define cpu_to_le32(x) (x) |
712 | # define LE32_TO_CPU(x) (x) | 712 | # define LE32_TO_CPU(x) (x) |
713 | # define CPU_TO_LE32(x) (x) | 713 | # define CPU_TO_LE32(x) (x) |
714 | 714 | ||
715 | # define be32_to_cpu(x) swap32(x) | 715 | # define be32_to_cpu(x) swap32(x) |
716 | # define cpu_to_be32(x) swap32(x) | 716 | # define cpu_to_be32(x) swap32(x) |
717 | # define BE32_TO_CPU(x) swap32(x) | 717 | # define BE32_TO_CPU(x) swap32(x) |
718 | # define CPU_TO_BE32(x) swap32(x) | 718 | # define CPU_TO_BE32(x) swap32(x) |
719 | /** @} */ | 719 | /** @} */ |
720 | 720 | ||
721 | /** \name Endianism Conversion | 721 | /** \name Endianism Conversion |
@@ -738,7 +738,7 @@ typedef struct { | |||
738 | * | 738 | * |
739 | * \note More optimized if only used with values known at compile time. | 739 | * \note More optimized if only used with values known at compile time. |
740 | */ | 740 | */ |
741 | # define Swap16(u16) ((uint16_t)(((uint16_t)(u16) >> 8) | ((uint16_t)(u16) << 8))) | 741 | # define Swap16(u16) ((uint16_t)(((uint16_t)(u16) >> 8) | ((uint16_t)(u16) << 8))) |
742 | 742 | ||
743 | /** \brief Toggles the endianism of \a u32 (by swapping its bytes). | 743 | /** \brief Toggles the endianism of \a u32 (by swapping its bytes). |
744 | * | 744 | * |
@@ -748,7 +748,7 @@ typedef struct { | |||
748 | * | 748 | * |
749 | * \note More optimized if only used with values known at compile time. | 749 | * \note More optimized if only used with values known at compile time. |
750 | */ | 750 | */ |
751 | # define Swap32(u32) ((uint32_t)(((uint32_t)Swap16((uint32_t)(u32) >> 16)) | ((uint32_t)Swap16((uint32_t)(u32)) << 16))) | 751 | # define Swap32(u32) ((uint32_t)(((uint32_t)Swap16((uint32_t)(u32) >> 16)) | ((uint32_t)Swap16((uint32_t)(u32)) << 16))) |
752 | 752 | ||
753 | /** \brief Toggles the endianism of \a u64 (by swapping its bytes). | 753 | /** \brief Toggles the endianism of \a u64 (by swapping its bytes). |
754 | * | 754 | * |
@@ -758,7 +758,7 @@ typedef struct { | |||
758 | * | 758 | * |
759 | * \note More optimized if only used with values known at compile time. | 759 | * \note More optimized if only used with values known at compile time. |
760 | */ | 760 | */ |
761 | # define Swap64(u64) ((uint64_t)(((uint64_t)Swap32((uint64_t)(u64) >> 32)) | ((uint64_t)Swap32((uint64_t)(u64)) << 32))) | 761 | # define Swap64(u64) ((uint64_t)(((uint64_t)Swap32((uint64_t)(u64) >> 32)) | ((uint64_t)Swap32((uint64_t)(u64)) << 32))) |
762 | 762 | ||
763 | /** \brief Toggles the endianism of \a u16 (by swapping its bytes). | 763 | /** \brief Toggles the endianism of \a u16 (by swapping its bytes). |
764 | * | 764 | * |
@@ -768,7 +768,7 @@ typedef struct { | |||
768 | * | 768 | * |
769 | * \note More optimized if only used with values unknown at compile time. | 769 | * \note More optimized if only used with values unknown at compile time. |
770 | */ | 770 | */ |
771 | # define swap16(u16) Swap16(u16) | 771 | # define swap16(u16) Swap16(u16) |
772 | 772 | ||
773 | /** \brief Toggles the endianism of \a u32 (by swapping its bytes). | 773 | /** \brief Toggles the endianism of \a u32 (by swapping its bytes). |
774 | * | 774 | * |
@@ -778,11 +778,11 @@ typedef struct { | |||
778 | * | 778 | * |
779 | * \note More optimized if only used with values unknown at compile time. | 779 | * \note More optimized if only used with values unknown at compile time. |
780 | */ | 780 | */ |
781 | # if (defined __GNUC__) | 781 | # if (defined __GNUC__) |
782 | # define swap32(u32) ((uint32_t)__builtin_bswap32((uint32_t)(u32))) | 782 | # define swap32(u32) ((uint32_t)__builtin_bswap32((uint32_t)(u32))) |
783 | # else | 783 | # else |
784 | # define swap32(u32) Swap32(u32) | 784 | # define swap32(u32) Swap32(u32) |
785 | # endif | 785 | # endif |
786 | 786 | ||
787 | /** \brief Toggles the endianism of \a u64 (by swapping its bytes). | 787 | /** \brief Toggles the endianism of \a u64 (by swapping its bytes). |
788 | * | 788 | * |
@@ -792,11 +792,11 @@ typedef struct { | |||
792 | * | 792 | * |
793 | * \note More optimized if only used with values unknown at compile time. | 793 | * \note More optimized if only used with values unknown at compile time. |
794 | */ | 794 | */ |
795 | # if (defined __GNUC__) | 795 | # if (defined __GNUC__) |
796 | # define swap64(u64) ((uint64_t)__builtin_bswap64((uint64_t)(u64))) | 796 | # define swap64(u64) ((uint64_t)__builtin_bswap64((uint64_t)(u64))) |
797 | # else | 797 | # else |
798 | # define swap64(u64) ((uint64_t)(((uint64_t)swap32((uint64_t)(u64) >> 32)) | ((uint64_t)swap32((uint64_t)(u64)) << 32))) | 798 | # define swap64(u64) ((uint64_t)(((uint64_t)swap32((uint64_t)(u64) >> 32)) | ((uint64_t)swap32((uint64_t)(u64)) << 32))) |
799 | # endif | 799 | # endif |
800 | 800 | ||
801 | /** @} */ | 801 | /** @} */ |
802 | 802 | ||
@@ -804,16 +804,16 @@ typedef struct { | |||
804 | * | 804 | * |
805 | * @{ */ | 805 | * @{ */ |
806 | 806 | ||
807 | # define _GLOBEXT_ extern /**< extern storage-class specifier. */ | 807 | # define _GLOBEXT_ extern /**< extern storage-class specifier. */ |
808 | # define _CONST_TYPE_ const /**< const type qualifier. */ | 808 | # define _CONST_TYPE_ const /**< const type qualifier. */ |
809 | # define _MEM_TYPE_SLOW_ /**< Slow memory type. */ | 809 | # define _MEM_TYPE_SLOW_ /**< Slow memory type. */ |
810 | # define _MEM_TYPE_MEDFAST_ /**< Fairly fast memory type. */ | 810 | # define _MEM_TYPE_MEDFAST_ /**< Fairly fast memory type. */ |
811 | # define _MEM_TYPE_FAST_ /**< Fast memory type. */ | 811 | # define _MEM_TYPE_FAST_ /**< Fast memory type. */ |
812 | 812 | ||
813 | # define memcmp_ram2ram memcmp /**< Target-specific memcmp of RAM to RAM. */ | 813 | # define memcmp_ram2ram memcmp /**< Target-specific memcmp of RAM to RAM. */ |
814 | # define memcmp_code2ram memcmp /**< Target-specific memcmp of RAM to NVRAM. */ | 814 | # define memcmp_code2ram memcmp /**< Target-specific memcmp of RAM to NVRAM. */ |
815 | # define memcpy_ram2ram memcpy /**< Target-specific memcpy from RAM to RAM. */ | 815 | # define memcpy_ram2ram memcpy /**< Target-specific memcpy from RAM to RAM. */ |
816 | # define memcpy_code2ram memcpy /**< Target-specific memcpy from NVRAM to RAM. */ | 816 | # define memcpy_code2ram memcpy /**< Target-specific memcpy from NVRAM to RAM. */ |
817 | 817 | ||
818 | /** @} */ | 818 | /** @} */ |
819 | 819 | ||
@@ -826,51 +826,51 @@ typedef struct { | |||
826 | * | 826 | * |
827 | * \return (\a a / \a b) rounded up to the nearest integer. | 827 | * \return (\a a / \a b) rounded up to the nearest integer. |
828 | */ | 828 | */ |
829 | # define div_ceil(a, b) (((a) + (b)-1) / (b)) | 829 | # define div_ceil(a, b) (((a) + (b)-1) / (b)) |
830 | 830 | ||
831 | # endif /* #ifndef __ASSEMBLY__ */ | 831 | #endif /* #ifndef __ASSEMBLY__ */ |
832 | # ifdef __ICCARM__ | 832 | #ifdef __ICCARM__ |
833 | /** \name Compiler Keywords | 833 | /** \name Compiler Keywords |
834 | * | 834 | * |
835 | * Port of some keywords from GCC to IAR Embedded Workbench. | 835 | * Port of some keywords from GCC to IAR Embedded Workbench. |
836 | * | 836 | * |
837 | * @{ */ | 837 | * @{ */ |
838 | 838 | ||
839 | # define __asm__ asm | 839 | # define __asm__ asm |
840 | # define __inline__ inline | 840 | # define __inline__ inline |
841 | # define __volatile__ | 841 | # define __volatile__ |
842 | 842 | ||
843 | /** @} */ | 843 | /** @} */ |
844 | 844 | ||
845 | # endif | 845 | #endif |
846 | 846 | ||
847 | # define FUNC_PTR void * | 847 | #define FUNC_PTR void * |
848 | /** | 848 | /** |
849 | * \def unused | 849 | * \def unused |
850 | * \brief Marking \a v as a unused parameter or value. | 850 | * \brief Marking \a v as a unused parameter or value. |
851 | */ | 851 | */ |
852 | # define unused(v) \ | 852 | #define unused(v) \ |
853 | do { \ | 853 | do { \ |
854 | (void)(v); \ | 854 | (void)(v); \ |
855 | } while (0) | 855 | } while (0) |
856 | 856 | ||
857 | /* Define RAMFUNC attribute */ | 857 | /* Define RAMFUNC attribute */ |
858 | # if defined(__CC_ARM) /* Keil uVision 4 */ | 858 | #if defined(__CC_ARM) /* Keil uVision 4 */ |
859 | # define RAMFUNC __attribute__((section(".ramfunc"))) | 859 | # define RAMFUNC __attribute__((section(".ramfunc"))) |
860 | # elif defined(__ICCARM__) /* IAR Ewarm 5.41+ */ | 860 | #elif defined(__ICCARM__) /* IAR Ewarm 5.41+ */ |
861 | # define RAMFUNC __ramfunc | 861 | # define RAMFUNC __ramfunc |
862 | # elif defined(__GNUC__) /* GCC CS3 2009q3-68 */ | 862 | #elif defined(__GNUC__) /* GCC CS3 2009q3-68 */ |
863 | # define RAMFUNC __attribute__((section(".ramfunc"))) | 863 | # define RAMFUNC __attribute__((section(".ramfunc"))) |
864 | # endif | 864 | #endif |
865 | 865 | ||
866 | /* Define OPTIMIZE_HIGH attribute */ | 866 | /* Define OPTIMIZE_HIGH attribute */ |
867 | # if defined(__CC_ARM) /* Keil uVision 4 */ | 867 | #if defined(__CC_ARM) /* Keil uVision 4 */ |
868 | # define OPTIMIZE_HIGH _Pragma("O3") | 868 | # define OPTIMIZE_HIGH _Pragma("O3") |
869 | # elif defined(__ICCARM__) /* IAR Ewarm 5.41+ */ | 869 | #elif defined(__ICCARM__) /* IAR Ewarm 5.41+ */ |
870 | # define OPTIMIZE_HIGH _Pragma("optimize=high") | 870 | # define OPTIMIZE_HIGH _Pragma("optimize=high") |
871 | # elif defined(__GNUC__) /* GCC CS3 2009q3-68 */ | 871 | #elif defined(__GNUC__) /* GCC CS3 2009q3-68 */ |
872 | # define OPTIMIZE_HIGH __attribute__((optimize("s"))) | 872 | # define OPTIMIZE_HIGH __attribute__((optimize("s"))) |
873 | # endif | 873 | #endif |
874 | // kmod #define PASS 0 | 874 | // kmod #define PASS 0 |
875 | // kmod #define FAIL 1 | 875 | // kmod #define FAIL 1 |
876 | // kmod #define LOW 0 | 876 | // kmod #define LOW 0 |
@@ -887,101 +887,101 @@ typedef uint64_t U64; //!< 64-bit unsigned integer. | |||
887 | typedef float F32; //!< 32-bit floating-point number. | 887 | typedef float F32; //!< 32-bit floating-point number. |
888 | typedef double F64; //!< 64-bit floating-point number. | 888 | typedef double F64; //!< 64-bit floating-point number. |
889 | 889 | ||
890 | # define MSB(u16) (((U8 *)&(u16))[1]) //!< Most significant byte of \a u16. | 890 | #define MSB(u16) (((U8 *)&(u16))[1]) //!< Most significant byte of \a u16. |
891 | # define LSB(u16) (((U8 *)&(u16))[0]) //!< Least significant byte of \a u16. | 891 | #define LSB(u16) (((U8 *)&(u16))[0]) //!< Least significant byte of \a u16. |
892 | 892 | ||
893 | # define MSH(u32) (((U16 *)&(u32))[1]) //!< Most significant half-word of \a u32. | 893 | #define MSH(u32) (((U16 *)&(u32))[1]) //!< Most significant half-word of \a u32. |
894 | # define LSH(u32) (((U16 *)&(u32))[0]) //!< Least significant half-word of \a u32. | 894 | #define LSH(u32) (((U16 *)&(u32))[0]) //!< Least significant half-word of \a u32. |
895 | # define MSB0W(u32) (((U8 *)&(u32))[3]) //!< Most significant byte of 1st rank of \a u32. | 895 | #define MSB0W(u32) (((U8 *)&(u32))[3]) //!< Most significant byte of 1st rank of \a u32. |
896 | # define MSB1W(u32) (((U8 *)&(u32))[2]) //!< Most significant byte of 2nd rank of \a u32. | 896 | #define MSB1W(u32) (((U8 *)&(u32))[2]) //!< Most significant byte of 2nd rank of \a u32. |
897 | # define MSB2W(u32) (((U8 *)&(u32))[1]) //!< Most significant byte of 3rd rank of \a u32. | 897 | #define MSB2W(u32) (((U8 *)&(u32))[1]) //!< Most significant byte of 3rd rank of \a u32. |
898 | # define MSB3W(u32) (((U8 *)&(u32))[0]) //!< Most significant byte of 4th rank of \a u32. | 898 | #define MSB3W(u32) (((U8 *)&(u32))[0]) //!< Most significant byte of 4th rank of \a u32. |
899 | # define LSB3W(u32) MSB0W(u32) //!< Least significant byte of 4th rank of \a u32. | 899 | #define LSB3W(u32) MSB0W(u32) //!< Least significant byte of 4th rank of \a u32. |
900 | # define LSB2W(u32) MSB1W(u32) //!< Least significant byte of 3rd rank of \a u32. | 900 | #define LSB2W(u32) MSB1W(u32) //!< Least significant byte of 3rd rank of \a u32. |
901 | # define LSB1W(u32) MSB2W(u32) //!< Least significant byte of 2nd rank of \a u32. | 901 | #define LSB1W(u32) MSB2W(u32) //!< Least significant byte of 2nd rank of \a u32. |
902 | # define LSB0W(u32) MSB3W(u32) //!< Least significant byte of 1st rank of \a u32. | 902 | #define LSB0W(u32) MSB3W(u32) //!< Least significant byte of 1st rank of \a u32. |
903 | 903 | ||
904 | # define MSW(u64) (((U32 *)&(u64))[1]) //!< Most significant word of \a u64. | 904 | #define MSW(u64) (((U32 *)&(u64))[1]) //!< Most significant word of \a u64. |
905 | # define LSW(u64) (((U32 *)&(u64))[0]) //!< Least significant word of \a u64. | 905 | #define LSW(u64) (((U32 *)&(u64))[0]) //!< Least significant word of \a u64. |
906 | # define MSH0(u64) (((U16 *)&(u64))[3]) //!< Most significant half-word of 1st rank of \a u64. | 906 | #define MSH0(u64) (((U16 *)&(u64))[3]) //!< Most significant half-word of 1st rank of \a u64. |
907 | # define MSH1(u64) (((U16 *)&(u64))[2]) //!< Most significant half-word of 2nd rank of \a u64. | 907 | #define MSH1(u64) (((U16 *)&(u64))[2]) //!< Most significant half-word of 2nd rank of \a u64. |
908 | # define MSH2(u64) (((U16 *)&(u64))[1]) //!< Most significant half-word of 3rd rank of \a u64. | 908 | #define MSH2(u64) (((U16 *)&(u64))[1]) //!< Most significant half-word of 3rd rank of \a u64. |
909 | # define MSH3(u64) (((U16 *)&(u64))[0]) //!< Most significant half-word of 4th rank of \a u64. | 909 | #define MSH3(u64) (((U16 *)&(u64))[0]) //!< Most significant half-word of 4th rank of \a u64. |
910 | # define LSH3(u64) MSH0(u64) //!< Least significant half-word of 4th rank of \a u64. | 910 | #define LSH3(u64) MSH0(u64) //!< Least significant half-word of 4th rank of \a u64. |
911 | # define LSH2(u64) MSH1(u64) //!< Least significant half-word of 3rd rank of \a u64. | 911 | #define LSH2(u64) MSH1(u64) //!< Least significant half-word of 3rd rank of \a u64. |
912 | # define LSH1(u64) MSH2(u64) //!< Least significant half-word of 2nd rank of \a u64. | 912 | #define LSH1(u64) MSH2(u64) //!< Least significant half-word of 2nd rank of \a u64. |
913 | # define LSH0(u64) MSH3(u64) //!< Least significant half-word of 1st rank of \a u64. | 913 | #define LSH0(u64) MSH3(u64) //!< Least significant half-word of 1st rank of \a u64. |
914 | # define MSB0D(u64) (((U8 *)&(u64))[7]) //!< Most significant byte of 1st rank of \a u64. | 914 | #define MSB0D(u64) (((U8 *)&(u64))[7]) //!< Most significant byte of 1st rank of \a u64. |
915 | # define MSB1D(u64) (((U8 *)&(u64))[6]) //!< Most significant byte of 2nd rank of \a u64. | 915 | #define MSB1D(u64) (((U8 *)&(u64))[6]) //!< Most significant byte of 2nd rank of \a u64. |
916 | # define MSB2D(u64) (((U8 *)&(u64))[5]) //!< Most significant byte of 3rd rank of \a u64. | 916 | #define MSB2D(u64) (((U8 *)&(u64))[5]) //!< Most significant byte of 3rd rank of \a u64. |
917 | # define MSB3D(u64) (((U8 *)&(u64))[4]) //!< Most significant byte of 4th rank of \a u64. | 917 | #define MSB3D(u64) (((U8 *)&(u64))[4]) //!< Most significant byte of 4th rank of \a u64. |
918 | # define MSB4D(u64) (((U8 *)&(u64))[3]) //!< Most significant byte of 5th rank of \a u64. | 918 | #define MSB4D(u64) (((U8 *)&(u64))[3]) //!< Most significant byte of 5th rank of \a u64. |
919 | # define MSB5D(u64) (((U8 *)&(u64))[2]) //!< Most significant byte of 6th rank of \a u64. | 919 | #define MSB5D(u64) (((U8 *)&(u64))[2]) //!< Most significant byte of 6th rank of \a u64. |
920 | # define MSB6D(u64) (((U8 *)&(u64))[1]) //!< Most significant byte of 7th rank of \a u64. | 920 | #define MSB6D(u64) (((U8 *)&(u64))[1]) //!< Most significant byte of 7th rank of \a u64. |
921 | # define MSB7D(u64) (((U8 *)&(u64))[0]) //!< Most significant byte of 8th rank of \a u64. | 921 | #define MSB7D(u64) (((U8 *)&(u64))[0]) //!< Most significant byte of 8th rank of \a u64. |
922 | # define LSB7D(u64) MSB0D(u64) //!< Least significant byte of 8th rank of \a u64. | 922 | #define LSB7D(u64) MSB0D(u64) //!< Least significant byte of 8th rank of \a u64. |
923 | # define LSB6D(u64) MSB1D(u64) //!< Least significant byte of 7th rank of \a u64. | 923 | #define LSB6D(u64) MSB1D(u64) //!< Least significant byte of 7th rank of \a u64. |
924 | # define LSB5D(u64) MSB2D(u64) //!< Least significant byte of 6th rank of \a u64. | 924 | #define LSB5D(u64) MSB2D(u64) //!< Least significant byte of 6th rank of \a u64. |
925 | # define LSB4D(u64) MSB3D(u64) //!< Least significant byte of 5th rank of \a u64. | 925 | #define LSB4D(u64) MSB3D(u64) //!< Least significant byte of 5th rank of \a u64. |
926 | # define LSB3D(u64) MSB4D(u64) //!< Least significant byte of 4th rank of \a u64. | 926 | #define LSB3D(u64) MSB4D(u64) //!< Least significant byte of 4th rank of \a u64. |
927 | # define LSB2D(u64) MSB5D(u64) //!< Least significant byte of 3rd rank of \a u64. | 927 | #define LSB2D(u64) MSB5D(u64) //!< Least significant byte of 3rd rank of \a u64. |
928 | # define LSB1D(u64) MSB6D(u64) //!< Least significant byte of 2nd rank of \a u64. | 928 | #define LSB1D(u64) MSB6D(u64) //!< Least significant byte of 2nd rank of \a u64. |
929 | # define LSB0D(u64) MSB7D(u64) //!< Least significant byte of 1st rank of \a u64. | 929 | #define LSB0D(u64) MSB7D(u64) //!< Least significant byte of 1st rank of \a u64. |
930 | 930 | ||
931 | # define LSB0(u32) LSB0W(u32) //!< Least significant byte of 1st rank of \a u32. | 931 | #define LSB0(u32) LSB0W(u32) //!< Least significant byte of 1st rank of \a u32. |
932 | # define LSB1(u32) LSB1W(u32) //!< Least significant byte of 2nd rank of \a u32. | 932 | #define LSB1(u32) LSB1W(u32) //!< Least significant byte of 2nd rank of \a u32. |
933 | # define LSB2(u32) LSB2W(u32) //!< Least significant byte of 3rd rank of \a u32. | 933 | #define LSB2(u32) LSB2W(u32) //!< Least significant byte of 3rd rank of \a u32. |
934 | # define LSB3(u32) LSB3W(u32) //!< Least significant byte of 4th rank of \a u32. | 934 | #define LSB3(u32) LSB3W(u32) //!< Least significant byte of 4th rank of \a u32. |
935 | # define MSB3(u32) MSB3W(u32) //!< Most significant byte of 4th rank of \a u32. | 935 | #define MSB3(u32) MSB3W(u32) //!< Most significant byte of 4th rank of \a u32. |
936 | # define MSB2(u32) MSB2W(u32) //!< Most significant byte of 3rd rank of \a u32. | 936 | #define MSB2(u32) MSB2W(u32) //!< Most significant byte of 3rd rank of \a u32. |
937 | # define MSB1(u32) MSB1W(u32) //!< Most significant byte of 2nd rank of \a u32. | 937 | #define MSB1(u32) MSB1W(u32) //!< Most significant byte of 2nd rank of \a u32. |
938 | # define MSB0(u32) MSB0W(u32) //!< Most significant byte of 1st rank of \a u32. | 938 | #define MSB0(u32) MSB0W(u32) //!< Most significant byte of 1st rank of \a u32. |
939 | 939 | ||
940 | # if defined(__ICCARM__) | 940 | #if defined(__ICCARM__) |
941 | # define SHORTENUM __packed | 941 | # define SHORTENUM __packed |
942 | # elif defined(__GNUC__) | 942 | #elif defined(__GNUC__) |
943 | # define SHORTENUM __attribute__((packed)) | 943 | # define SHORTENUM __attribute__((packed)) |
944 | # endif | 944 | #endif |
945 | 945 | ||
946 | /* No operation */ | 946 | /* No operation */ |
947 | # if defined(__ICCARM__) | 947 | #if defined(__ICCARM__) |
948 | # define nop() __no_operation() | 948 | # define nop() __no_operation() |
949 | # elif defined(__GNUC__) | 949 | #elif defined(__GNUC__) |
950 | # define nop() (__NOP()) | 950 | # define nop() (__NOP()) |
951 | # endif | 951 | #endif |
952 | 952 | ||
953 | # define FLASH_DECLARE(x) const x | 953 | #define FLASH_DECLARE(x) const x |
954 | # define FLASH_EXTERN(x) extern const x | 954 | #define FLASH_EXTERN(x) extern const x |
955 | # define PGM_READ_BYTE(x) *(x) | 955 | #define PGM_READ_BYTE(x) *(x) |
956 | # define PGM_READ_WORD(x) *(x) | 956 | #define PGM_READ_WORD(x) *(x) |
957 | # define MEMCPY_ENDIAN memcpy | 957 | #define MEMCPY_ENDIAN memcpy |
958 | # define PGM_READ_BLOCK(dst, src, len) memcpy((dst), (src), (len)) | 958 | #define PGM_READ_BLOCK(dst, src, len) memcpy((dst), (src), (len)) |
959 | 959 | ||
960 | /*Defines the Flash Storage for the request and response of MAC*/ | 960 | /*Defines the Flash Storage for the request and response of MAC*/ |
961 | # define CMD_ID_OCTET (0) | 961 | #define CMD_ID_OCTET (0) |
962 | 962 | ||
963 | /* Converting of values from CPU endian to little endian. */ | 963 | /* Converting of values from CPU endian to little endian. */ |
964 | # define CPU_ENDIAN_TO_LE16(x) (x) | 964 | #define CPU_ENDIAN_TO_LE16(x) (x) |
965 | # define CPU_ENDIAN_TO_LE32(x) (x) | 965 | #define CPU_ENDIAN_TO_LE32(x) (x) |
966 | # define CPU_ENDIAN_TO_LE64(x) (x) | 966 | #define CPU_ENDIAN_TO_LE64(x) (x) |
967 | 967 | ||
968 | /* Converting of values from little endian to CPU endian. */ | 968 | /* Converting of values from little endian to CPU endian. */ |
969 | # define LE16_TO_CPU_ENDIAN(x) (x) | 969 | #define LE16_TO_CPU_ENDIAN(x) (x) |
970 | # define LE32_TO_CPU_ENDIAN(x) (x) | 970 | #define LE32_TO_CPU_ENDIAN(x) (x) |
971 | # define LE64_TO_CPU_ENDIAN(x) (x) | 971 | #define LE64_TO_CPU_ENDIAN(x) (x) |
972 | 972 | ||
973 | /* Converting of constants from little endian to CPU endian. */ | 973 | /* Converting of constants from little endian to CPU endian. */ |
974 | # define CLE16_TO_CPU_ENDIAN(x) (x) | 974 | #define CLE16_TO_CPU_ENDIAN(x) (x) |
975 | # define CLE32_TO_CPU_ENDIAN(x) (x) | 975 | #define CLE32_TO_CPU_ENDIAN(x) (x) |
976 | # define CLE64_TO_CPU_ENDIAN(x) (x) | 976 | #define CLE64_TO_CPU_ENDIAN(x) (x) |
977 | 977 | ||
978 | /* Converting of constants from CPU endian to little endian. */ | 978 | /* Converting of constants from CPU endian to little endian. */ |
979 | # define CCPU_ENDIAN_TO_LE16(x) (x) | 979 | #define CCPU_ENDIAN_TO_LE16(x) (x) |
980 | # define CCPU_ENDIAN_TO_LE32(x) (x) | 980 | #define CCPU_ENDIAN_TO_LE32(x) (x) |
981 | # define CCPU_ENDIAN_TO_LE64(x) (x) | 981 | #define CCPU_ENDIAN_TO_LE64(x) (x) |
982 | 982 | ||
983 | # define ADDR_COPY_DST_SRC_16(dst, src) ((dst) = (src)) | 983 | #define ADDR_COPY_DST_SRC_16(dst, src) ((dst) = (src)) |
984 | # define ADDR_COPY_DST_SRC_64(dst, src) ((dst) = (src)) | 984 | #define ADDR_COPY_DST_SRC_64(dst, src) ((dst) = (src)) |
985 | 985 | ||
986 | /** | 986 | /** |
987 | * @brief Converts a 64-Bit value into a 8 Byte array | 987 | * @brief Converts a 64-Bit value into a 8 Byte array |
diff --git a/tmk_core/protocol/arm_atsam/usb/udi_cdc.c b/tmk_core/protocol/arm_atsam/usb/udi_cdc.c index 27db4017c..322a32ebc 100644 --- a/tmk_core/protocol/arm_atsam/usb/udi_cdc.c +++ b/tmk_core/protocol/arm_atsam/usb/udi_cdc.c | |||
@@ -89,14 +89,14 @@ | |||
89 | * | 89 | * |
90 | * @{ | 90 | * @{ |
91 | */ | 91 | */ |
92 | bool udi_cdc_comm_enable(void); | 92 | bool udi_cdc_comm_enable(void); |
93 | void udi_cdc_comm_disable(void); | 93 | void udi_cdc_comm_disable(void); |
94 | bool udi_cdc_comm_setup(void); | 94 | bool udi_cdc_comm_setup(void); |
95 | bool udi_cdc_data_enable(void); | 95 | bool udi_cdc_data_enable(void); |
96 | void udi_cdc_data_disable(void); | 96 | void udi_cdc_data_disable(void); |
97 | bool udi_cdc_data_setup(void); | 97 | bool udi_cdc_data_setup(void); |
98 | uint8_t udi_cdc_getsetting(void); | 98 | uint8_t udi_cdc_getsetting(void); |
99 | void udi_cdc_data_sof_notify(void); | 99 | void udi_cdc_data_sof_notify(void); |
100 | UDC_DESC_STORAGE udi_api_t udi_api_cdc_comm = {.enable = udi_cdc_comm_enable, .disable = udi_cdc_comm_disable, .setup = udi_cdc_comm_setup, .getsetting = udi_cdc_getsetting, .sof_notify = NULL}; | 100 | UDC_DESC_STORAGE udi_api_t udi_api_cdc_comm = {.enable = udi_cdc_comm_enable, .disable = udi_cdc_comm_disable, .setup = udi_cdc_comm_setup, .getsetting = udi_cdc_getsetting, .sof_notify = NULL}; |
101 | UDC_DESC_STORAGE udi_api_t udi_api_cdc_data = { | 101 | UDC_DESC_STORAGE udi_api_t udi_api_cdc_data = { |
102 | .enable = udi_cdc_data_enable, | 102 | .enable = udi_cdc_data_enable, |
diff --git a/tmk_core/protocol/arm_atsam/usb/usb_device_udd.c b/tmk_core/protocol/arm_atsam/usb/usb_device_udd.c index f138b4278..b3d9cba82 100644 --- a/tmk_core/protocol/arm_atsam/usb/usb_device_udd.c +++ b/tmk_core/protocol/arm_atsam/usb/usb_device_udd.c | |||
@@ -596,11 +596,10 @@ void udd_set_address(uint8_t address) { usb_device_set_address(&usb_device, addr | |||
596 | uint8_t udd_getaddress(void) { return usb_device_get_address(&usb_device); } | 596 | uint8_t udd_getaddress(void) { return usb_device_get_address(&usb_device); } |
597 | 597 | ||
598 | void udd_send_remotewakeup(void) { | 598 | void udd_send_remotewakeup(void) { |
599 | uint32_t try | 599 | uint32_t try = 5; |
600 | = 5; | ||
601 | udd_wait_clock_ready(); | 600 | udd_wait_clock_ready(); |
602 | udd_sleep_mode(UDD_STATE_IDLE); | 601 | udd_sleep_mode(UDD_STATE_IDLE); |
603 | while (2 != usb_get_state_machine_status(&usb_device) && try --) { | 602 | while (2 != usb_get_state_machine_status(&usb_device) && try--) { |
604 | usb_device_send_remote_wake_up(&usb_device); | 603 | usb_device_send_remote_wake_up(&usb_device); |
605 | } | 604 | } |
606 | } | 605 | } |