|
2 | 2 | * @file debug_printbits.h |
3 | 3 | * |
4 | 4 | */ |
5 | | - /* Copyright (C) 2025 by Arjan van Vught mailto:info@gd32-dmx.org |
6 | | - * |
7 | | - * Permission is hereby granted, free of charge, to any person obtaining a copy |
8 | | - * of this software and associated documentation files (the "Software"), to deal |
9 | | - * in the Software without restriction, including without limitation the rights |
10 | | - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
11 | | - * copies of the Software, and to permit persons to whom the Software is |
12 | | - * furnished to do so, subject to the following conditions: |
13 | | -
|
14 | | - * The above copyright notice and this permission notice shall be included in |
15 | | - * all copies or substantial portions of the Software. |
16 | | -
|
17 | | - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
18 | | - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
19 | | - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
20 | | - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
21 | | - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
22 | | - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
23 | | - * THE SOFTWARE. |
24 | | - */ |
| 5 | +/* Copyright (C) 2025-2026 by Arjan van Vught mailto:info@gd32-dmx.org |
| 6 | +* |
| 7 | +* Permission is hereby granted, free of charge, to any person obtaining a copy |
| 8 | +* of this software and associated documentation files (the "Software"), to deal |
| 9 | +* in the Software without restriction, including without limitation the rights |
| 10 | +* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 11 | +* copies of the Software, and to permit persons to whom the Software is |
| 12 | +* furnished to do so, subject to the following conditions: |
| 13 | +
|
| 14 | +* The above copyright notice and this permission notice shall be included in |
| 15 | +* all copies or substantial portions of the Software. |
| 16 | +
|
| 17 | +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 18 | +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 19 | +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 20 | +* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 21 | +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 22 | +* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
| 23 | +* THE SOFTWARE. |
| 24 | +*/ |
25 | 25 |
|
26 | 26 | #ifndef COMMON_DEBUG_DEBUG_PRINTBITS_H_ |
27 | 27 | #define COMMON_DEBUG_DEBUG_PRINTBITS_H_ |
28 | 28 |
|
29 | 29 | #include <cstdio> |
30 | 30 | #include <cstdint> |
31 | 31 |
|
32 | | -#if defined(H3) |
33 | | -namespace uart0 |
34 | | -{ |
35 | | -int Printf(const char* fmt, ...); |
36 | | -} |
37 | | -#define printf uart0::Printf // NOLINT |
38 | | -#endif |
39 | | - |
40 | | -namespace debug |
41 | | -{ |
| 32 | +namespace debug { |
42 | 33 | #ifdef NDEBUG |
43 | 34 | inline void PrintBits([[maybe_unused]] uint32_t u) {} |
44 | 35 | #else |
45 | 36 | inline void PrintBits(uint32_t u) { |
46 | | - printf("%.8x ", u); |
| 37 | + printf("%.8x ", u); |
47 | 38 | uint32_t b = 1U << 31; |
48 | 39 |
|
49 | | - for (uint32_t i = 0; i < 32; i++) |
50 | | - { |
51 | | - if ((b & u) == b) |
52 | | - { |
| 40 | + for (uint32_t i = 0; i < 32; i++) { |
| 41 | + if ((b & u) == b) { |
53 | 42 | uint32_t bit_number = 31 - i; |
54 | 43 | printf("%-2d ", bit_number); |
55 | 44 | } |
|
0 commit comments