My Marlin configs for Fabrikator Mini and CTC i3 Pro B
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /**
  2. * Marlin 3D Printer Firmware
  3. * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
  4. *
  5. * Based on Sprinter and grbl.
  6. * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
  7. *
  8. * This program is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation, either version 3 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  20. *
  21. */
  22. #include "../inc/MarlinConfig.h"
  23. #include "../gcode/parser.h"
  24. #if ANY(AUTO_BED_LEVELING_UBL, M100_FREE_MEMORY_WATCHER, DEBUG_GCODE_PARSER, TMC_DEBUG)
  25. #include "hex_print_routines.h"
  26. #ifdef CPU_32_BIT
  27. constexpr int byte_start = 4;
  28. static char _hex[] = "0x00000000";
  29. #else
  30. constexpr int byte_start = 0;
  31. static char _hex[] = "0x0000";
  32. #endif
  33. char* hex_byte(const uint8_t b) {
  34. _hex[byte_start + 4] = hex_nybble(b >> 4);
  35. _hex[byte_start + 5] = hex_nybble(b);
  36. return &_hex[byte_start + 4];
  37. }
  38. inline void _hex_word(const uint16_t w) {
  39. _hex[byte_start + 2] = hex_nybble(w >> 12);
  40. _hex[byte_start + 3] = hex_nybble(w >> 8);
  41. _hex[byte_start + 4] = hex_nybble(w >> 4);
  42. _hex[byte_start + 5] = hex_nybble(w);
  43. }
  44. char* hex_word(const uint16_t w) {
  45. _hex_word(w);
  46. return &_hex[byte_start + 2];
  47. }
  48. #ifdef CPU_32_BIT
  49. char* hex_long(const uint32_t l) {
  50. _hex[2] = hex_nybble(l >> 28);
  51. _hex[3] = hex_nybble(l >> 24);
  52. _hex[4] = hex_nybble(l >> 20);
  53. _hex[5] = hex_nybble(l >> 16);
  54. _hex_word((uint16_t)(l & 0xFFFF));
  55. return &_hex[2];
  56. }
  57. #endif
  58. char* hex_address(const void * const w) {
  59. #ifdef CPU_32_BIT
  60. (void)hex_long((ptr_int_t)w);
  61. #else
  62. (void)hex_word((ptr_int_t)w);
  63. #endif
  64. return _hex;
  65. }
  66. void print_hex_nybble(const uint8_t n) { SERIAL_CHAR(hex_nybble(n)); }
  67. void print_hex_byte(const uint8_t b) { SERIAL_ECHO(hex_byte(b)); }
  68. void print_hex_word(const uint16_t w) { SERIAL_ECHO(hex_word(w)); }
  69. void print_hex_address(const void * const w) { SERIAL_ECHO(hex_address(w)); }
  70. void print_hex_long(const uint32_t w, const char delimiter) {
  71. SERIAL_ECHOPGM("0x");
  72. for (int B = 24; B >= 8; B -= 8){
  73. print_hex_byte(w >> B);
  74. SERIAL_CHAR(delimiter);
  75. }
  76. print_hex_byte(w);
  77. }
  78. #endif // AUTO_BED_LEVELING_UBL || M100_FREE_MEMORY_WATCHER || DEBUG_GCODE_PARSER