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.

M575.cpp 2.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. #include "../../inc/MarlinConfig.h"
  23. #if ENABLED(BAUD_RATE_GCODE)
  24. #include "../gcode.h"
  25. /**
  26. * M575 - Change serial baud rate
  27. *
  28. * P<index> - Serial port index. Omit for all.
  29. * B<baudrate> - Baud rate (bits per second)
  30. */
  31. void GcodeSuite::M575() {
  32. int32_t baud = parser.ulongval('B');
  33. switch (baud) {
  34. case 24:
  35. case 96:
  36. case 192:
  37. case 384:
  38. case 576:
  39. case 1152: baud *= 100; break;
  40. case 250:
  41. case 500: baud *= 1000; break;
  42. case 19: baud = 19200; break;
  43. case 38: baud = 38400; break;
  44. case 57: baud = 57600; break;
  45. case 115: baud = 115200; break;
  46. }
  47. switch (baud) {
  48. case 2400: case 9600: case 19200: case 38400: case 57600:
  49. case 115200: case 250000: case 500000: case 1000000: {
  50. const int8_t port = parser.intval('P', -99);
  51. const bool set1 = (port == -99 || port == 0);
  52. if (set1) SERIAL_ECHO_MSG(" Serial ", AS_DIGIT(0), " baud rate set to ", baud);
  53. #if HAS_MULTI_SERIAL
  54. const bool set2 = (port == -99 || port == 1);
  55. if (set2) SERIAL_ECHO_MSG(" Serial ", AS_DIGIT(1), " baud rate set to ", baud);
  56. #ifdef SERIAL_PORT_3
  57. const bool set3 = (port == -99 || port == 2);
  58. if (set3) SERIAL_ECHO_MSG(" Serial ", AS_DIGIT(2), " baud rate set to ", baud);
  59. #endif
  60. #endif
  61. SERIAL_FLUSH();
  62. if (set1) { MYSERIAL1.end(); MYSERIAL1.begin(baud); }
  63. #if HAS_MULTI_SERIAL
  64. if (set2) { MYSERIAL2.end(); MYSERIAL2.begin(baud); }
  65. #ifdef SERIAL_PORT_3
  66. if (set3) { MYSERIAL3.end(); MYSERIAL3.begin(baud); }
  67. #endif
  68. #endif
  69. } break;
  70. default: SERIAL_ECHO_MSG("?(B)aud rate implausible.");
  71. }
  72. }
  73. #endif // BAUD_RATE_GCODE