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.

MarlinSerialUSB.h 3.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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 <https://www.gnu.org/licenses/>.
  20. *
  21. */
  22. #pragma once
  23. /**
  24. * MarlinSerialUSB_Due.h - Hardware Serial over USB (CDC) library for Arduino DUE
  25. * Copyright (c) 2017 Eduardo José Tagle. All right reserved
  26. */
  27. #include "../../inc/MarlinConfig.h"
  28. #if HAS_USB_SERIAL
  29. #include <WString.h>
  30. #define DEC 10
  31. #define HEX 16
  32. #define OCT 8
  33. #define BIN 2
  34. class MarlinSerialUSB {
  35. public:
  36. MarlinSerialUSB() {};
  37. static void begin(const long);
  38. static void end();
  39. static int peek();
  40. static int read();
  41. static void flush();
  42. static void flushTX();
  43. static bool available();
  44. static void write(const uint8_t c);
  45. #if ENABLED(SERIAL_STATS_DROPPED_RX)
  46. FORCE_INLINE static uint32_t dropped() { return 0; }
  47. #endif
  48. #if ENABLED(SERIAL_STATS_MAX_RX_QUEUED)
  49. FORCE_INLINE static int rxMaxEnqueued() { return 0; }
  50. #endif
  51. FORCE_INLINE static void write(const char* str) { while (*str) write(*str++); }
  52. FORCE_INLINE static void write(const uint8_t* buffer, size_t size) { while (size--) write(*buffer++); }
  53. FORCE_INLINE static void print(const String& s) { for (int i = 0; i < (int)s.length(); i++) write(s[i]); }
  54. FORCE_INLINE static void print(const char* str) { write(str); }
  55. static void print(char, int = 0);
  56. static void print(unsigned char, int = 0);
  57. static void print(int, int = DEC);
  58. static void print(unsigned int, int = DEC);
  59. static void print(long, int = DEC);
  60. static void print(unsigned long, int = DEC);
  61. static void print(double, int = 2);
  62. static void println(const String& s);
  63. static void println(const char[]);
  64. static void println(char, int = 0);
  65. static void println(unsigned char, int = 0);
  66. static void println(int, int = DEC);
  67. static void println(unsigned int, int = DEC);
  68. static void println(long, int = DEC);
  69. static void println(unsigned long, int = DEC);
  70. static void println(double, int = 2);
  71. static void println();
  72. operator bool() { return true; }
  73. private:
  74. static void printNumber(unsigned long, const uint8_t);
  75. static void printFloat(double, uint8_t);
  76. };
  77. #if SERIAL_PORT == -1
  78. extern MarlinSerialUSB customizedSerial1;
  79. #endif
  80. #if SERIAL_PORT_2 == -1
  81. extern MarlinSerialUSB customizedSerial2;
  82. #endif
  83. #endif // HAS_USB_SERIAL