keyboard stuff
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Format code according to conventions (#16421)

authored by

QMK Bot and committed by
GitHub
25ba9b41 a44abeb9

+320 -337
+2 -3
drivers/ps2/ps2_busywait.c
··· 125 125 // Command may take 25ms/20ms at most([5]p.46, [3]p.21) 126 126 // 250 * 100us(wait for start bit in ps2_host_recv) 127 127 uint8_t data = 0; 128 - uint8_t try 129 - = 250; 128 + uint8_t try = 250; 130 129 do { 131 130 data = ps2_host_recv(); 132 - } while (try --&&ps2_error); 131 + } while (try-- && ps2_error); 133 132 return data; 134 133 } 135 134
+38 -53
quantum/action.c
··· 833 833 } 834 834 #endif 835 835 836 - else if 837 - IS_KEY(code) { 838 - // TODO: should push command_proc out of this block? 839 - if (command_proc(code)) return; 836 + else if IS_KEY (code) { 837 + // TODO: should push command_proc out of this block? 838 + if (command_proc(code)) return; 840 839 841 840 #ifndef NO_ACTION_ONESHOT 842 841 /* TODO: remove ··· 853 852 } else 854 853 */ 855 854 #endif 856 - { 857 - // Force a new key press if the key is already pressed 858 - // without this, keys with the same keycode, but different 859 - // modifiers will be reported incorrectly, see issue #1708 860 - if (is_key_pressed(keyboard_report, code)) { 861 - del_key(code); 862 - send_keyboard_report(); 863 - } 864 - add_key(code); 855 + { 856 + // Force a new key press if the key is already pressed 857 + // without this, keys with the same keycode, but different 858 + // modifiers will be reported incorrectly, see issue #1708 859 + if (is_key_pressed(keyboard_report, code)) { 860 + del_key(code); 865 861 send_keyboard_report(); 866 862 } 867 - } 868 - else if 869 - IS_MOD(code) { 870 - add_mods(MOD_BIT(code)); 863 + add_key(code); 871 864 send_keyboard_report(); 872 865 } 866 + } else if IS_MOD (code) { 867 + add_mods(MOD_BIT(code)); 868 + send_keyboard_report(); 869 + } 873 870 #ifdef EXTRAKEY_ENABLE 874 - else if 875 - IS_SYSTEM(code) { 876 - host_system_send(KEYCODE2SYSTEM(code)); 877 - } 878 - else if 879 - IS_CONSUMER(code) { 880 - host_consumer_send(KEYCODE2CONSUMER(code)); 881 - } 871 + else if IS_SYSTEM (code) { 872 + host_system_send(KEYCODE2SYSTEM(code)); 873 + } else if IS_CONSUMER (code) { 874 + host_consumer_send(KEYCODE2CONSUMER(code)); 875 + } 882 876 #endif 883 877 #ifdef MOUSEKEY_ENABLE 884 - else if 885 - IS_MOUSEKEY(code) { 886 - mousekey_on(code); 887 - mousekey_send(); 888 - } 878 + else if IS_MOUSEKEY (code) { 879 + mousekey_on(code); 880 + mousekey_send(); 881 + } 889 882 #endif 890 883 } 891 884 ··· 930 923 } 931 924 #endif 932 925 933 - else if 934 - IS_KEY(code) { 935 - del_key(code); 936 - send_keyboard_report(); 937 - } 938 - else if 939 - IS_MOD(code) { 940 - del_mods(MOD_BIT(code)); 941 - send_keyboard_report(); 942 - } 943 - else if 944 - IS_SYSTEM(code) { 945 - host_system_send(0); 946 - } 947 - else if 948 - IS_CONSUMER(code) { 949 - host_consumer_send(0); 950 - } 926 + else if IS_KEY (code) { 927 + del_key(code); 928 + send_keyboard_report(); 929 + } else if IS_MOD (code) { 930 + del_mods(MOD_BIT(code)); 931 + send_keyboard_report(); 932 + } else if IS_SYSTEM (code) { 933 + host_system_send(0); 934 + } else if IS_CONSUMER (code) { 935 + host_consumer_send(0); 936 + } 951 937 #ifdef MOUSEKEY_ENABLE 952 - else if 953 - IS_MOUSEKEY(code) { 954 - mousekey_off(code); 955 - mousekey_send(); 956 - } 938 + else if IS_MOUSEKEY (code) { 939 + mousekey_off(code); 940 + mousekey_send(); 941 + } 957 942 #endif 958 943 } 959 944
+1 -1
quantum/action.h
··· 72 72 73 73 /* Code for handling one-handed key modifiers. */ 74 74 #ifdef SWAP_HANDS_ENABLE 75 - extern bool swap_hands; 75 + extern bool swap_hands; 76 76 extern const keypos_t PROGMEM hand_swap_config[MATRIX_ROWS][MATRIX_COLS]; 77 77 # if (MATRIX_COLS <= 8) 78 78 typedef uint8_t swap_state_row_t;
+269 -269
tmk_core/protocol/arm_atsam/usb/compiler.h
··· 43 43 */ 44 44 45 45 #ifndef UTILS_COMPILER_H_INCLUDED 46 - # define UTILS_COMPILER_H_INCLUDED 46 + #define UTILS_COMPILER_H_INCLUDED 47 47 48 48 /** 49 49 * \defgroup group_sam0_utils Compiler abstraction layer and code utilities ··· 54 54 * @{ 55 55 */ 56 56 57 - # if (defined __ICCARM__) 58 - # include <intrinsics.h> 59 - # endif 57 + #if (defined __ICCARM__) 58 + # include <intrinsics.h> 59 + #endif 60 60 61 - # include <stddef.h> 61 + #include <stddef.h> 62 62 //#include <parts.h> 63 63 //#include <status_codes.h> 64 64 //#include <preprocessor.h> 65 65 //#include <io.h> 66 66 67 - # ifndef __ASSEMBLY__ 67 + #ifndef __ASSEMBLY__ 68 68 69 - # include <stdio.h> 70 - # include <stdbool.h> 71 - # include <stdint.h> 72 - # include <stdlib.h> 69 + # include <stdio.h> 70 + # include <stdbool.h> 71 + # include <stdint.h> 72 + # include <stdlib.h> 73 73 74 74 /** 75 75 * \def UNUSED 76 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 81 * \def barrier 82 82 * \brief Memory barrier 83 83 */ 84 - # ifdef __GNUC__ 85 - # define barrier() asm volatile("" ::: "memory") 86 - # else 87 - # define barrier() asm("") 88 - # endif 84 + # ifdef __GNUC__ 85 + # define barrier() asm volatile("" ::: "memory") 86 + # else 87 + # define barrier() asm("") 88 + # endif 89 89 90 90 /** 91 91 * \brief Emit the compiler pragma \a arg. ··· 93 93 * \param[in] arg The pragma directive as it would appear after \e \#pragma 94 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 99 * \def COMPILER_PACK_SET(alignment) 100 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 105 * \def COMPILER_PACK_RESET() 106 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 111 * \brief Set aligned boundary. 112 112 */ 113 - # if (defined __GNUC__) || (defined __CC_ARM) 114 - # define COMPILER_ALIGNED(a) __attribute__((__aligned__(a))) 115 - # elif (defined __ICCARM__) 116 - # define COMPILER_ALIGNED(a) COMPILER_PRAGMA(data_alignment = a) 117 - # endif 113 + # if (defined __GNUC__) || (defined __CC_ARM) 114 + # define COMPILER_ALIGNED(a) __attribute__((__aligned__(a))) 115 + # elif (defined __ICCARM__) 116 + # define COMPILER_ALIGNED(a) COMPILER_PRAGMA(data_alignment = a) 117 + # endif 118 118 119 119 /** 120 120 * \brief Set word-aligned boundary. 121 121 */ 122 - # if (defined __GNUC__) || defined(__CC_ARM) 123 - # define COMPILER_WORD_ALIGNED __attribute__((__aligned__(4))) 124 - # elif (defined __ICCARM__) 125 - # define COMPILER_WORD_ALIGNED COMPILER_PRAGMA(data_alignment = 4) 126 - # endif 122 + # if (defined __GNUC__) || defined(__CC_ARM) 123 + # define COMPILER_WORD_ALIGNED __attribute__((__aligned__(4))) 124 + # elif (defined __ICCARM__) 125 + # define COMPILER_WORD_ALIGNED COMPILER_PRAGMA(data_alignment = 4) 126 + # endif 127 127 128 128 /** 129 129 * \def __always_inline ··· 133 133 * heuristics and inline the function no matter how big it thinks it 134 134 * becomes. 135 135 */ 136 - # if !defined(__always_inline) 137 - # if defined(__CC_ARM) 138 - # define __always_inline __forceinline 139 - # elif (defined __GNUC__) 140 - # define __always_inline __attribute__((__always_inline__)) 141 - # elif (defined __ICCARM__) 142 - # define __always_inline _Pragma("inline=forced") 143 - # endif 136 + # if !defined(__always_inline) 137 + # if defined(__CC_ARM) 138 + # define __always_inline __forceinline 139 + # elif (defined __GNUC__) 140 + # define __always_inline __attribute__((__always_inline__)) 141 + # elif (defined __ICCARM__) 142 + # define __always_inline _Pragma("inline=forced") 144 143 # endif 144 + # endif 145 145 146 146 /** 147 147 * \def __no_inline ··· 151 151 * heuristics and not inline the function no matter how small it thinks it 152 152 * becomes. 153 153 */ 154 - # if defined(__CC_ARM) 155 - # define __no_inline __attribute__((noinline)) 156 - # elif (defined __GNUC__) 157 - # define __no_inline __attribute__((noinline)) 158 - # elif (defined __ICCARM__) 159 - # define __no_inline _Pragma("inline=never") 160 - # endif 154 + # if defined(__CC_ARM) 155 + # define __no_inline __attribute__((noinline)) 156 + # elif (defined __GNUC__) 157 + # define __no_inline __attribute__((noinline)) 158 + # elif (defined __ICCARM__) 159 + # define __no_inline _Pragma("inline=never") 160 + # endif 161 161 162 162 /** \brief This macro is used to test fatal errors. 163 163 * ··· 168 168 * 169 169 * \param[in] expr Expression to evaluate and supposed to be nonzero. 170 170 */ 171 - # if defined(_ASSERT_ENABLE_) 172 - # if defined(TEST_SUITE_DEFINE_ASSERT_MACRO) 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 171 + # if defined(_ASSERT_ENABLE_) 172 + # if defined(TEST_SUITE_DEFINE_ASSERT_MACRO) 173 + # include "unit_test/suite.h" 181 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 180 # endif 181 + # else 182 + # define Assert(expr) ((void)0) 183 + # endif 184 184 185 185 /* Define WEAK attribute */ 186 - # if defined(__CC_ARM) 187 - # define WEAK __attribute__((weak)) 188 - # elif defined(__ICCARM__) 189 - # define WEAK __weak 190 - # elif defined(__GNUC__) 191 - # define WEAK __attribute__((weak)) 192 - # endif 186 + # if defined(__CC_ARM) 187 + # define WEAK __attribute__((weak)) 188 + # elif defined(__ICCARM__) 189 + # define WEAK __weak 190 + # elif defined(__GNUC__) 191 + # define WEAK __attribute__((weak)) 192 + # endif 193 193 194 194 /* Define NO_INIT attribute */ 195 - # if defined(__CC_ARM) 196 - # define NO_INIT __attribute__((zero_init)) 197 - # elif defined(__ICCARM__) 198 - # define NO_INIT __no_init 199 - # elif defined(__GNUC__) 200 - # define NO_INIT __attribute__((section(".no_init"))) 201 - # endif 195 + # if defined(__CC_ARM) 196 + # define NO_INIT __attribute__((zero_init)) 197 + # elif defined(__ICCARM__) 198 + # define NO_INIT __no_init 199 + # elif defined(__GNUC__) 200 + # define NO_INIT __attribute__((section(".no_init"))) 201 + # endif 202 202 203 203 //#include "interrupt.h" 204 204 205 205 /** \name Usual Types 206 206 * @{ */ 207 - # ifndef __cplusplus 208 - # if !defined(__bool_true_false_are_defined) 207 + # ifndef __cplusplus 208 + # if !defined(__bool_true_false_are_defined) 209 209 typedef unsigned char bool; 210 - # endif 211 210 # endif 211 + # endif 212 212 typedef uint16_t le16_t; 213 213 typedef uint16_t be16_t; 214 214 typedef uint32_t le32_t; ··· 347 347 348 348 /** @} */ 349 349 350 - # endif /* #ifndef __ASSEMBLY__ */ 350 + #endif /* #ifndef __ASSEMBLY__ */ 351 351 352 352 /** \name Usual Constants 353 353 * @{ */ 354 354 // kmod #define DISABLE 0 355 355 // kmod #define ENABLE 1 356 356 357 - # ifndef __cplusplus 358 - # if !defined(__bool_true_false_are_defined) 359 - # define false 0 360 - # define true 1 361 - # endif 357 + #ifndef __cplusplus 358 + # if !defined(__bool_true_false_are_defined) 359 + # define false 0 360 + # define true 1 362 361 # endif 362 + #endif 363 363 /** @} */ 364 364 365 - # ifndef __ASSEMBLY__ 365 + #ifndef __ASSEMBLY__ 366 366 367 367 /** \name Optimization Control 368 368 * @{ */ ··· 371 371 * \def likely(exp) 372 372 * \brief The expression \a exp is likely to be true 373 373 */ 374 - # if !defined(likely) || defined(__DOXYGEN__) 375 - # define likely(exp) (exp) 376 - # endif 374 + # if !defined(likely) || defined(__DOXYGEN__) 375 + # define likely(exp) (exp) 376 + # endif 377 377 378 378 /** 379 379 * \def unlikely(exp) 380 380 * \brief The expression \a exp is unlikely to be true 381 381 */ 382 - # if !defined(unlikely) || defined(__DOXYGEN__) 383 - # define unlikely(exp) (exp) 384 - # endif 382 + # if !defined(unlikely) || defined(__DOXYGEN__) 383 + # define unlikely(exp) (exp) 384 + # endif 385 385 386 386 /** 387 387 * \def is_constant(exp) ··· 391 391 * 392 392 * \return true if \a exp is constant, false otherwise. 393 393 */ 394 - # if (defined __GNUC__) || (defined __CC_ARM) 395 - # define is_constant(exp) __builtin_constant_p(exp) 396 - # else 397 - # define is_constant(exp) (0) 398 - # endif 394 + # if (defined __GNUC__) || (defined __CC_ARM) 395 + # define is_constant(exp) __builtin_constant_p(exp) 396 + # else 397 + # define is_constant(exp) (0) 398 + # endif 399 399 400 400 /** @} */ 401 401 ··· 409 409 * 410 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 414 /** \brief Writes the bits of a C lvalue specified by a given bit-mask. 415 415 * ··· 419 419 * 420 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 424 /** \brief Tests the bits of a value specified by a given bit-mask. 425 425 * ··· 428 428 * 429 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 433 /** \brief Clears the bits of a C lvalue specified by a given bit-mask. 434 434 * ··· 437 437 * 438 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 442 /** \brief Sets the bits of a C lvalue specified by a given bit-mask. 443 443 * ··· 446 446 * 447 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 451 /** \brief Toggles the bits of a C lvalue specified by a given bit-mask. 452 452 * ··· 455 455 * 456 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 460 /** \brief Reads the bit-field of a value specified by a given bit-mask. 461 461 * ··· 464 464 * 465 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 469 /** \brief Writes the bit-field of a C lvalue specified by a given bit-mask. 470 470 * ··· 474 474 * 475 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 498 * 499 499 * \return The count of leading zero bits in \a u. 500 500 */ 501 - # if (defined __GNUC__) || (defined __CC_ARM) 502 - # define clz(u) ((u) ? __builtin_clz(u) : 32) 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) 505 - # endif 501 + # if (defined __GNUC__) || (defined __CC_ARM) 502 + # define clz(u) ((u) ? __builtin_clz(u) : 32) 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) 505 + # endif 506 506 507 507 /** \brief Counts the trailing zero bits of the given value considered as a 32-bit integer. 508 508 * ··· 510 510 * 511 511 * \return The count of trailing zero bits in \a u. 512 512 */ 513 - # if (defined __GNUC__) || (defined __CC_ARM) 514 - # define ctz(u) ((u) ? __builtin_ctz(u) : 32) 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) 517 - # endif 513 + # if (defined __GNUC__) || (defined __CC_ARM) 514 + # define ctz(u) ((u) ? __builtin_ctz(u) : 32) 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) 517 + # endif 518 518 519 519 /** @} */ 520 520 ··· 527 527 * 528 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 532 /** \brief Reverses the bits of \a u16. 533 533 * ··· 535 535 * 536 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 540 /** \brief Reverses the bits of \a u32. 541 541 * ··· 543 543 * 544 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 548 /** \brief Reverses the bits of \a u64. 549 549 * ··· 551 551 * 552 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 565 * 566 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 570 /** \brief Gets alignment of the number \a val with respect to the \a n boundary. 571 571 * ··· 574 574 * 575 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 579 /** \brief Sets alignment of the lvalue number \a lval to \a alg with respect to the \a n boundary. 580 580 * ··· 584 584 * 585 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 589 /** \brief Aligns the number \a val with the upper \a n boundary. 590 590 * ··· 593 593 * 594 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 598 /** \brief Aligns the number \a val with the lower \a n boundary. 599 599 * ··· 602 602 * 603 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 627 * 628 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 633 /** \brief Takes the minimal value of \a a and \a b. 634 634 * 635 635 * \param[in] a Input value. ··· 639 639 * 640 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 644 /** \brief Takes the maximal value of \a a and \a b. 645 645 * ··· 650 650 * 651 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 655 /** \brief Takes the minimal value of \a a and \a b. 656 656 * ··· 661 661 * 662 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 666 /** \brief Takes the maximal value of \a a and \a b. 667 667 * ··· 672 672 * 673 673 * \note More optimized if only used with values unknown at compile time. 674 674 */ 675 - # define max(a, b) Max(a, b) 676 - # endif 675 + # define max(a, b) Max(a, b) 676 + # endif 677 677 678 678 /** @} */ 679 679 ··· 688 688 * 689 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 693 /** \name MCU Endianism Handling 694 694 * ARM is MCU little endian. 695 695 * 696 696 * @{ */ 697 - # define BE16(x) swap16(x) 698 - # define LE16(x) (x) 697 + # define BE16(x) swap16(x) 698 + # define LE16(x) (x) 699 699 700 - # define le16_to_cpu(x) (x) 701 - # define cpu_to_le16(x) (x) 702 - # define LE16_TO_CPU(x) (x) 703 - # define CPU_TO_LE16(x) (x) 700 + # define le16_to_cpu(x) (x) 701 + # define cpu_to_le16(x) (x) 702 + # define LE16_TO_CPU(x) (x) 703 + # define CPU_TO_LE16(x) (x) 704 704 705 - # define be16_to_cpu(x) swap16(x) 706 - # define cpu_to_be16(x) swap16(x) 707 - # define BE16_TO_CPU(x) swap16(x) 708 - # define CPU_TO_BE16(x) swap16(x) 705 + # define be16_to_cpu(x) swap16(x) 706 + # define cpu_to_be16(x) swap16(x) 707 + # define BE16_TO_CPU(x) swap16(x) 708 + # define CPU_TO_BE16(x) swap16(x) 709 709 710 - # define le32_to_cpu(x) (x) 711 - # define cpu_to_le32(x) (x) 712 - # define LE32_TO_CPU(x) (x) 713 - # define CPU_TO_LE32(x) (x) 710 + # define le32_to_cpu(x) (x) 711 + # define cpu_to_le32(x) (x) 712 + # define LE32_TO_CPU(x) (x) 713 + # define CPU_TO_LE32(x) (x) 714 714 715 - # define be32_to_cpu(x) swap32(x) 716 - # define cpu_to_be32(x) swap32(x) 717 - # define BE32_TO_CPU(x) swap32(x) 718 - # define CPU_TO_BE32(x) swap32(x) 715 + # define be32_to_cpu(x) swap32(x) 716 + # define cpu_to_be32(x) swap32(x) 717 + # define BE32_TO_CPU(x) swap32(x) 718 + # define CPU_TO_BE32(x) swap32(x) 719 719 /** @} */ 720 720 721 721 /** \name Endianism Conversion ··· 738 738 * 739 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 743 /** \brief Toggles the endianism of \a u32 (by swapping its bytes). 744 744 * ··· 748 748 * 749 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 753 /** \brief Toggles the endianism of \a u64 (by swapping its bytes). 754 754 * ··· 758 758 * 759 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 763 /** \brief Toggles the endianism of \a u16 (by swapping its bytes). 764 764 * ··· 768 768 * 769 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 773 /** \brief Toggles the endianism of \a u32 (by swapping its bytes). 774 774 * ··· 778 778 * 779 779 * \note More optimized if only used with values unknown at compile time. 780 780 */ 781 - # if (defined __GNUC__) 782 - # define swap32(u32) ((uint32_t)__builtin_bswap32((uint32_t)(u32))) 783 - # else 784 - # define swap32(u32) Swap32(u32) 785 - # endif 781 + # if (defined __GNUC__) 782 + # define swap32(u32) ((uint32_t)__builtin_bswap32((uint32_t)(u32))) 783 + # else 784 + # define swap32(u32) Swap32(u32) 785 + # endif 786 786 787 787 /** \brief Toggles the endianism of \a u64 (by swapping its bytes). 788 788 * ··· 792 792 * 793 793 * \note More optimized if only used with values unknown at compile time. 794 794 */ 795 - # if (defined __GNUC__) 796 - # define swap64(u64) ((uint64_t)__builtin_bswap64((uint64_t)(u64))) 797 - # else 798 - # define swap64(u64) ((uint64_t)(((uint64_t)swap32((uint64_t)(u64) >> 32)) | ((uint64_t)swap32((uint64_t)(u64)) << 32))) 799 - # endif 795 + # if (defined __GNUC__) 796 + # define swap64(u64) ((uint64_t)__builtin_bswap64((uint64_t)(u64))) 797 + # else 798 + # define swap64(u64) ((uint64_t)(((uint64_t)swap32((uint64_t)(u64) >> 32)) | ((uint64_t)swap32((uint64_t)(u64)) << 32))) 799 + # endif 800 800 801 801 /** @} */ 802 802 ··· 804 804 * 805 805 * @{ */ 806 806 807 - # define _GLOBEXT_ extern /**< extern storage-class specifier. */ 808 - # define _CONST_TYPE_ const /**< const type qualifier. */ 809 - # define _MEM_TYPE_SLOW_ /**< Slow memory type. */ 810 - # define _MEM_TYPE_MEDFAST_ /**< Fairly fast memory type. */ 811 - # define _MEM_TYPE_FAST_ /**< Fast memory type. */ 807 + # define _GLOBEXT_ extern /**< extern storage-class specifier. */ 808 + # define _CONST_TYPE_ const /**< const type qualifier. */ 809 + # define _MEM_TYPE_SLOW_ /**< Slow memory type. */ 810 + # define _MEM_TYPE_MEDFAST_ /**< Fairly 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. */ 814 - # define memcmp_code2ram memcmp /**< Target-specific memcmp of RAM to NVRAM. */ 815 - # define memcpy_ram2ram memcpy /**< Target-specific memcpy from RAM to RAM. */ 816 - # define memcpy_code2ram memcpy /**< Target-specific memcpy from NVRAM 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. */ 815 + # define memcpy_ram2ram memcpy /**< Target-specific memcpy from RAM to RAM. */ 816 + # define memcpy_code2ram memcpy /**< Target-specific memcpy from NVRAM to RAM. */ 817 817 818 818 /** @} */ 819 819 ··· 826 826 * 827 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__ */ 832 - # ifdef __ICCARM__ 831 + #endif /* #ifndef __ASSEMBLY__ */ 832 + #ifdef __ICCARM__ 833 833 /** \name Compiler Keywords 834 834 * 835 835 * Port of some keywords from GCC to IAR Embedded Workbench. 836 836 * 837 837 * @{ */ 838 838 839 - # define __asm__ asm 840 - # define __inline__ inline 841 - # define __volatile__ 839 + # define __asm__ asm 840 + # define __inline__ inline 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 849 * \def unused 850 850 * \brief Marking \a v as a unused parameter or value. 851 851 */ 852 - # define unused(v) \ 853 - do { \ 854 - (void)(v); \ 855 - } while (0) 852 + #define unused(v) \ 853 + do { \ 854 + (void)(v); \ 855 + } while (0) 856 856 857 857 /* Define RAMFUNC attribute */ 858 - # if defined(__CC_ARM) /* Keil uVision 4 */ 859 - # define RAMFUNC __attribute__((section(".ramfunc"))) 860 - # elif defined(__ICCARM__) /* IAR Ewarm 5.41+ */ 861 - # define RAMFUNC __ramfunc 862 - # elif defined(__GNUC__) /* GCC CS3 2009q3-68 */ 863 - # define RAMFUNC __attribute__((section(".ramfunc"))) 864 - # endif 858 + #if defined(__CC_ARM) /* Keil uVision 4 */ 859 + # define RAMFUNC __attribute__((section(".ramfunc"))) 860 + #elif defined(__ICCARM__) /* IAR Ewarm 5.41+ */ 861 + # define RAMFUNC __ramfunc 862 + #elif defined(__GNUC__) /* GCC CS3 2009q3-68 */ 863 + # define RAMFUNC __attribute__((section(".ramfunc"))) 864 + #endif 865 865 866 866 /* Define OPTIMIZE_HIGH attribute */ 867 - # if defined(__CC_ARM) /* Keil uVision 4 */ 868 - # define OPTIMIZE_HIGH _Pragma("O3") 869 - # elif defined(__ICCARM__) /* IAR Ewarm 5.41+ */ 870 - # define OPTIMIZE_HIGH _Pragma("optimize=high") 871 - # elif defined(__GNUC__) /* GCC CS3 2009q3-68 */ 872 - # define OPTIMIZE_HIGH __attribute__((optimize("s"))) 873 - # endif 867 + #if defined(__CC_ARM) /* Keil uVision 4 */ 868 + # define OPTIMIZE_HIGH _Pragma("O3") 869 + #elif defined(__ICCARM__) /* IAR Ewarm 5.41+ */ 870 + # define OPTIMIZE_HIGH _Pragma("optimize=high") 871 + #elif defined(__GNUC__) /* GCC CS3 2009q3-68 */ 872 + # define OPTIMIZE_HIGH __attribute__((optimize("s"))) 873 + #endif 874 874 // kmod #define PASS 0 875 875 // kmod #define FAIL 1 876 876 // kmod #define LOW 0 ··· 887 887 typedef float F32; //!< 32-bit floating-point number. 888 888 typedef double F64; //!< 64-bit floating-point number. 889 889 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. 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. 892 892 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 903 903 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 930 930 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. 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. 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. 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. 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. 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. 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. 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. 939 939 940 - # if defined(__ICCARM__) 941 - # define SHORTENUM __packed 942 - # elif defined(__GNUC__) 943 - # define SHORTENUM __attribute__((packed)) 944 - # endif 940 + #if defined(__ICCARM__) 941 + # define SHORTENUM __packed 942 + #elif defined(__GNUC__) 943 + # define SHORTENUM __attribute__((packed)) 944 + #endif 945 945 946 946 /* No operation */ 947 - # if defined(__ICCARM__) 948 - # define nop() __no_operation() 949 - # elif defined(__GNUC__) 950 - # define nop() (__NOP()) 951 - # endif 947 + #if defined(__ICCARM__) 948 + # define nop() __no_operation() 949 + #elif defined(__GNUC__) 950 + # define nop() (__NOP()) 951 + #endif 952 952 953 - # define FLASH_DECLARE(x) const x 954 - # define FLASH_EXTERN(x) extern const x 955 - # define PGM_READ_BYTE(x) *(x) 956 - # define PGM_READ_WORD(x) *(x) 957 - # define MEMCPY_ENDIAN memcpy 958 - # define PGM_READ_BLOCK(dst, src, len) memcpy((dst), (src), (len)) 953 + #define FLASH_DECLARE(x) const x 954 + #define FLASH_EXTERN(x) extern const x 955 + #define PGM_READ_BYTE(x) *(x) 956 + #define PGM_READ_WORD(x) *(x) 957 + #define MEMCPY_ENDIAN memcpy 958 + #define PGM_READ_BLOCK(dst, src, len) memcpy((dst), (src), (len)) 959 959 960 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 963 /* Converting of values from CPU endian to little endian. */ 964 - # define CPU_ENDIAN_TO_LE16(x) (x) 965 - # define CPU_ENDIAN_TO_LE32(x) (x) 966 - # define CPU_ENDIAN_TO_LE64(x) (x) 964 + #define CPU_ENDIAN_TO_LE16(x) (x) 965 + #define CPU_ENDIAN_TO_LE32(x) (x) 966 + #define CPU_ENDIAN_TO_LE64(x) (x) 967 967 968 968 /* Converting of values from little endian to CPU endian. */ 969 - # define LE16_TO_CPU_ENDIAN(x) (x) 970 - # define LE32_TO_CPU_ENDIAN(x) (x) 971 - # define LE64_TO_CPU_ENDIAN(x) (x) 969 + #define LE16_TO_CPU_ENDIAN(x) (x) 970 + #define LE32_TO_CPU_ENDIAN(x) (x) 971 + #define LE64_TO_CPU_ENDIAN(x) (x) 972 972 973 973 /* Converting of constants from little endian to CPU endian. */ 974 - # define CLE16_TO_CPU_ENDIAN(x) (x) 975 - # define CLE32_TO_CPU_ENDIAN(x) (x) 976 - # define CLE64_TO_CPU_ENDIAN(x) (x) 974 + #define CLE16_TO_CPU_ENDIAN(x) (x) 975 + #define CLE32_TO_CPU_ENDIAN(x) (x) 976 + #define CLE64_TO_CPU_ENDIAN(x) (x) 977 977 978 978 /* Converting of constants from CPU endian to little endian. */ 979 - # define CCPU_ENDIAN_TO_LE16(x) (x) 980 - # define CCPU_ENDIAN_TO_LE32(x) (x) 981 - # define CCPU_ENDIAN_TO_LE64(x) (x) 979 + #define CCPU_ENDIAN_TO_LE16(x) (x) 980 + #define CCPU_ENDIAN_TO_LE32(x) (x) 981 + #define CCPU_ENDIAN_TO_LE64(x) (x) 982 982 983 - # define ADDR_COPY_DST_SRC_16(dst, src) ((dst) = (src)) 984 - # define ADDR_COPY_DST_SRC_64(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)) 985 985 986 986 /** 987 987 * @brief Converts a 64-Bit value into a 8 Byte array
+8 -8
tmk_core/protocol/arm_atsam/usb/udi_cdc.c
··· 89 89 * 90 90 * @{ 91 91 */ 92 - bool udi_cdc_comm_enable(void); 93 - void udi_cdc_comm_disable(void); 94 - bool udi_cdc_comm_setup(void); 95 - bool udi_cdc_data_enable(void); 96 - void udi_cdc_data_disable(void); 97 - bool udi_cdc_data_setup(void); 98 - uint8_t udi_cdc_getsetting(void); 99 - void udi_cdc_data_sof_notify(void); 92 + bool udi_cdc_comm_enable(void); 93 + void udi_cdc_comm_disable(void); 94 + bool udi_cdc_comm_setup(void); 95 + bool udi_cdc_data_enable(void); 96 + void udi_cdc_data_disable(void); 97 + bool udi_cdc_data_setup(void); 98 + uint8_t udi_cdc_getsetting(void); 99 + void udi_cdc_data_sof_notify(void); 100 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 101 UDC_DESC_STORAGE udi_api_t udi_api_cdc_data = { 102 102 .enable = udi_cdc_data_enable,
+2 -3
tmk_core/protocol/arm_atsam/usb/usb_device_udd.c
··· 608 608 } 609 609 610 610 void udd_send_remotewakeup(void) { 611 - uint32_t try 612 - = 5; 611 + uint32_t try = 5; 613 612 udd_wait_clock_ready(); 614 613 udd_sleep_mode(UDD_STATE_IDLE); 615 - while (2 != usb_get_state_machine_status(&usb_device) && try --) { 614 + while (2 != usb_get_state_machine_status(&usb_device) && try--) { 616 615 usb_device_send_remote_wake_up(&usb_device); 617 616 } 618 617 }