Skip to content

Commit

Permalink
fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkyhead committed Jan 31, 2024
1 parent 1fc9763 commit 42c2d54
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
8 changes: 4 additions & 4 deletions Marlin/src/gcode/host/M115.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,13 @@ void GcodeSuite::M115() {
* This code should work on all STM32-based boards.
*/
#if ENABLED(STM32_UID_SHORT_FORM)
uint32_t * const UID = (uint32_t*)UID_BASE;
const uint32_t * const UID = (uint32_t*)UID_BASE;
for (uint8_t i = 0; i < 3; i++) print_hex_long(UID[i]);
#else
uint16_t * const UID = (uint16_t*)UID_BASE; // Little-endian!
const uint16_t * const UID = (uint16_t*)UID_BASE; // Little-endian!
SERIAL_ECHO(F("CEDE2A2F-"));
for (uint8_t i = 1; i < 7; i++) {
print_hex_word((i % 2) ? UID[i] : UID[i - 2]); // 1111-0000-3333-2222555544447777
for (uint8_t i = 1; i <= 6; i++) {
print_hex_word(UID[(i % 2) ? i : i - 2]); // 1111-0000-3333-2222555544446666
if (i <= 3) SERIAL_ECHO(C('-'));
}
#endif
Expand Down
16 changes: 8 additions & 8 deletions Marlin/src/libs/hex_print.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,19 @@
#include "hex_print.h"
#include "../core/serial.h"

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

inline void __hex_byte(const uint8_t b, const uint8_t o=8) {
_hex[o + 0] = hex_nybble(b >> 4);
_hex[o + 1] = hex_nybble(b);
}
inline void __hex_word(const uint16_t w, const uint8_t o=6) {
__hex_byte(w >> 2, o + 0);
__hex_byte(w >> 0, o + 2);
__hex_byte(w >> 8, o + 0);
__hex_byte(w , o + 2);
}
inline void __hex_long(const uint16_t w) {
__hex_word(w >> 4, 2);
__hex_word(w >> 0, 6);
inline void __hex_long(const uint32_t w) {
__hex_word(w >> 16, 2);
__hex_word(w , 6);
}

char* hex_byte(const uint8_t b) { __hex_byte(b); return &_hex[8]; }
Expand All @@ -51,15 +51,15 @@ char* hex_address(const void * const a) {
(void)_hex_long((uintptr_t)a);
return _hex;
#else
hex[4] = '0'; hex[5] = 'x';
_hex[4] = '0'; _hex[5] = 'x';
(void)_hex_word((uintptr_t)a);
return &_hex[4];
#endif
}

void print_hex_nybble(const uint8_t n) { SERIAL_CHAR(hex_nybble(n)); }
void print_hex_byte(const uint8_t b) { SERIAL_ECHO(hex_byte(b)); }
void print_hex_word(const uint16_t w) { SERIAL_ECHO(hex_word(w)); }
void print_hex_word(const uint16_t w) { SERIAL_ECHO(_hex_word(w)); }
void print_hex_address(const void * const w) { SERIAL_ECHO(hex_address(w)); }

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

0 comments on commit 42c2d54

Please sign in to comment.