35
35
#include " ../../feature/caselight.h"
36
36
#endif
37
37
38
- #if ENABLED(HAS_STM32_UID ) && !defined(MACHINE_UUID)
38
+ #if !defined(MACHINE_UUID ) && HAS_STM32_UID
39
39
#include " ../../libs/hex_print.h"
40
40
#endif
41
41
62
62
* at https://reprap.org/wiki/Firmware_Capabilities_Protocol
63
63
*/
64
64
void GcodeSuite::M115 () {
65
+
65
66
SERIAL_ECHOPGM (" FIRMWARE_NAME:Marlin"
66
67
" " DETAILED_BUILD_VERSION " (" __DATE__ " " __TIME__ " )"
67
68
" SOURCE_CODE_URL:" SOURCE_CODE_URL
@@ -71,24 +72,31 @@ void GcodeSuite::M115() {
71
72
#if NUM_AXES != XYZ
72
73
" AXIS_COUNT:" STRINGIFY (NUM_AXES)
73
74
#endif
75
+ #if defined(MACHINE_UUID) || HAS_STM32_UID
76
+ " UUID:"
77
+ #endif
74
78
#ifdef MACHINE_UUID
75
- " UUID: " MACHINE_UUID
79
+ MACHINE_UUID
76
80
#endif
77
81
);
78
82
79
- // STM32UID:111122223333
80
- #if ENABLED(HAS_STM32_UID) && !defined(MACHINE_UUID)
81
- // STM32 based devices output the CPU device serial number
82
- // Used by LumenPnP / OpenPNP to keep track of unique hardware/configurations
83
- // https://github.com/opulo-inc/lumenpnp
84
- // Although this code should work on all STM32 based boards
85
- SERIAL_ECHOPGM (" UUID:" );
86
- uint32_t *uid_address = (uint32_t *)UID_BASE;
87
- for (uint8_t i = 0 ; i < 3 ; ++i) {
88
- const uint32_t UID = uint32_t (READ_REG (*(uid_address)));
89
- uid_address += 4U ;
90
- for (int B = 24 ; B >= 0 ; B -= 8 ) print_hex_byte (UID >> B);
91
- }
83
+ #if !defined(MACHINE_UUID) && HAS_STM32_UID
84
+ /* *
85
+ * STM32-based devices have a 96-bit CPU device serial number.
86
+ * Used by LumenPnP / OpenPNP to keep track of unique hardware/configurations.
87
+ * https://github.com/opulo-inc/lumenpnp
88
+ * This code should work on all STM32-based boards.
89
+ */
90
+ #if ENABLED(STM32_UID_SHORT_FORM)
91
+ uint32_t * const UID = (uint32_t *)UID_BASE;
92
+ SERIAL_ECHO (hex_long (UID[0 ]), hex_long (UID[1 ]), hex_long (UID[2 ]));
93
+ #else
94
+ uint16_t * const UID = (uint16_t *)UID_BASE;
95
+ SERIAL_ECHO (
96
+ F (" CEDE2A2F-" ), hex_word (UID[0 ]), ' -' , hex_word (UID[1 ]), ' -' , hex_word (UID[2 ]), ' -' ,
97
+ hex_word (UID[3 ]), hex_word (UID[4 ]), hex_word (UID[5 ])
98
+ );
99
+ #endif
92
100
#endif
93
101
94
102
SERIAL_EOL ();
0 commit comments