Skip to content

Commit 42c2d54

Browse files
committed
fixup
1 parent 1fc9763 commit 42c2d54

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

Marlin/src/gcode/host/M115.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -88,13 +88,13 @@ void GcodeSuite::M115() {
8888
* This code should work on all STM32-based boards.
8989
*/
9090
#if ENABLED(STM32_UID_SHORT_FORM)
91-
uint32_t * const UID = (uint32_t*)UID_BASE;
91+
const uint32_t * const UID = (uint32_t*)UID_BASE;
9292
for (uint8_t i = 0; i < 3; i++) print_hex_long(UID[i]);
9393
#else
94-
uint16_t * const UID = (uint16_t*)UID_BASE; // Little-endian!
94+
const uint16_t * const UID = (uint16_t*)UID_BASE; // Little-endian!
9595
SERIAL_ECHO(F("CEDE2A2F-"));
96-
for (uint8_t i = 1; i < 7; i++) {
97-
print_hex_word((i % 2) ? UID[i] : UID[i - 2]); // 1111-0000-3333-2222555544447777
96+
for (uint8_t i = 1; i <= 6; i++) {
97+
print_hex_word(UID[(i % 2) ? i : i - 2]); // 1111-0000-3333-2222555544446666
9898
if (i <= 3) SERIAL_ECHO(C('-'));
9999
}
100100
#endif

Marlin/src/libs/hex_print.cpp

+8-8
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,19 @@
2727
#include "hex_print.h"
2828
#include "../core/serial.h"
2929

30-
static char _hex[] = "0x00000000";
30+
static char _hex[] = "0x00000000"; // 0:adr32 2:long 4:adr16 6:word 8:byte
3131

3232
inline void __hex_byte(const uint8_t b, const uint8_t o=8) {
3333
_hex[o + 0] = hex_nybble(b >> 4);
3434
_hex[o + 1] = hex_nybble(b);
3535
}
3636
inline void __hex_word(const uint16_t w, const uint8_t o=6) {
37-
__hex_byte(w >> 2, o + 0);
38-
__hex_byte(w >> 0, o + 2);
37+
__hex_byte(w >> 8, o + 0);
38+
__hex_byte(w , o + 2);
3939
}
40-
inline void __hex_long(const uint16_t w) {
41-
__hex_word(w >> 4, 2);
42-
__hex_word(w >> 0, 6);
40+
inline void __hex_long(const uint32_t w) {
41+
__hex_word(w >> 16, 2);
42+
__hex_word(w , 6);
4343
}
4444

4545
char* hex_byte(const uint8_t b) { __hex_byte(b); return &_hex[8]; }
@@ -51,15 +51,15 @@ char* hex_address(const void * const a) {
5151
(void)_hex_long((uintptr_t)a);
5252
return _hex;
5353
#else
54-
hex[4] = '0'; hex[5] = 'x';
54+
_hex[4] = '0'; _hex[5] = 'x';
5555
(void)_hex_word((uintptr_t)a);
5656
return &_hex[4];
5757
#endif
5858
}
5959

6060
void print_hex_nybble(const uint8_t n) { SERIAL_CHAR(hex_nybble(n)); }
6161
void print_hex_byte(const uint8_t b) { SERIAL_ECHO(hex_byte(b)); }
62-
void print_hex_word(const uint16_t w) { SERIAL_ECHO(hex_word(w)); }
62+
void print_hex_word(const uint16_t w) { SERIAL_ECHO(_hex_word(w)); }
6363
void print_hex_address(const void * const w) { SERIAL_ECHO(hex_address(w)); }
6464

6565
void print_hex_long(const uint32_t w, const char delimiter/*='\0'*/, const bool prefix/*=false*/) {

0 commit comments

Comments
 (0)