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.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. #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. const int32_t baud = parser.ulongval('B');
  33. switch (baud) {
  34. case 2400: case 9600: case 19200: case 38400: case 57600:
  35. case 115200: case 250000: case 500000: case 1000000: {
  36. const int8_t port = parser.intval('P', -99);
  37. const bool set0 = (port == -99 || port == 0);
  38. if (set0) {
  39. SERIAL_ECHO_START();
  40. SERIAL_ECHOLNPAIR(" Serial "
  41. #if NUM_SERIAL > 1
  42. , '0',
  43. #else
  44. "0"
  45. #endif
  46. " baud rate set to ", baud
  47. );
  48. }
  49. #if NUM_SERIAL > 1
  50. const bool set1 = (port == -99 || port == 1);
  51. if (set1) {
  52. SERIAL_ECHO_START();
  53. SERIAL_ECHOLNPAIR(" Serial ", '1', " baud rate set to ", baud);
  54. }
  55. #endif
  56. SERIAL_FLUSH();
  57. if (set0) { MYSERIAL0.end(); MYSERIAL0.begin(baud); }
  58. #if NUM_SERIAL > 1
  59. if (set1) { MYSERIAL1.end(); MYSERIAL1.begin(baud); }
  60. #endif
  61. } break;
  62. default: SERIAL_ECHO_MSG("?(B)aud rate implausible.");
  63. }
  64. }
  65. #endif // NUM_SERIAL > 0 && BAUD_RATE_GCODE