|
|
@ -33,10 +33,9 @@ |
|
|
|
#include "stepper.h" |
|
|
|
#include "Marlin.h" |
|
|
|
|
|
|
|
#ifndef USBCON |
|
|
|
// this next line disables the entire HardwareSerial.cpp,
|
|
|
|
// this is so I can support Attiny series and any other chip without a UART
|
|
|
|
#if defined(UBRRH) || defined(UBRR0H) || defined(UBRR1H) || defined(UBRR2H) || defined(UBRR3H) |
|
|
|
// Disable HardwareSerial.cpp to support chips without a UART (Attiny, etc.)
|
|
|
|
|
|
|
|
#if !defined(USBCON) && (defined(UBRRH) || defined(UBRR0H) || defined(UBRR1H) || defined(UBRR2H) || defined(UBRR3H)) |
|
|
|
|
|
|
|
#if UART_PRESENT(SERIAL_PORT) |
|
|
|
ring_buffer_r rx_buffer = { { 0 }, 0, 0 }; |
|
|
@ -46,6 +45,97 @@ |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
|
|
|
|
#if ENABLED(EMERGENCY_PARSER) |
|
|
|
|
|
|
|
#include "language.h" |
|
|
|
|
|
|
|
// Currently looking for: M108, M112, M410
|
|
|
|
// If you alter the parser please don't forget to update the capabilities in Conditionals_post.h
|
|
|
|
|
|
|
|
FORCE_INLINE void emergency_parser(const unsigned char c) { |
|
|
|
|
|
|
|
static e_parser_state state = state_RESET; |
|
|
|
|
|
|
|
switch (state) { |
|
|
|
case state_RESET: |
|
|
|
switch (c) { |
|
|
|
case ' ': break; |
|
|
|
case 'N': state = state_N; break; |
|
|
|
case 'M': state = state_M; break; |
|
|
|
default: state = state_IGNORE; |
|
|
|
} |
|
|
|
break; |
|
|
|
|
|
|
|
case state_N: |
|
|
|
switch (c) { |
|
|
|
case '0': case '1': case '2': |
|
|
|
case '3': case '4': case '5': |
|
|
|
case '6': case '7': case '8': |
|
|
|
case '9': case '-': case ' ': break; |
|
|
|
case 'M': state = state_M; break; |
|
|
|
default: state = state_IGNORE; |
|
|
|
} |
|
|
|
break; |
|
|
|
|
|
|
|
case state_M: |
|
|
|
switch (c) { |
|
|
|
case ' ': break; |
|
|
|
case '1': state = state_M1; break; |
|
|
|
case '4': state = state_M4; break; |
|
|
|
default: state = state_IGNORE; |
|
|
|
} |
|
|
|
break; |
|
|
|
|
|
|
|
case state_M1: |
|
|
|
switch (c) { |
|
|
|
case '0': state = state_M10; break; |
|
|
|
case '1': state = state_M11; break; |
|
|
|
default: state = state_IGNORE; |
|
|
|
} |
|
|
|
break; |
|
|
|
|
|
|
|
case state_M10: |
|
|
|
state = (c == '8') ? state_M108 : state_IGNORE; |
|
|
|
break; |
|
|
|
|
|
|
|
case state_M11: |
|
|
|
state = (c == '2') ? state_M112 : state_IGNORE; |
|
|
|
break; |
|
|
|
|
|
|
|
case state_M4: |
|
|
|
state = (c == '1') ? state_M41 : state_IGNORE; |
|
|
|
break; |
|
|
|
|
|
|
|
case state_M41: |
|
|
|
state = (c == '0') ? state_M410 : state_IGNORE; |
|
|
|
break; |
|
|
|
|
|
|
|
case state_IGNORE: |
|
|
|
if (c == '\n') state = state_RESET; |
|
|
|
break; |
|
|
|
|
|
|
|
default: |
|
|
|
if (c == '\n') { |
|
|
|
switch (state) { |
|
|
|
case state_M108: |
|
|
|
wait_for_user = wait_for_heatup = false; |
|
|
|
break; |
|
|
|
case state_M112: |
|
|
|
kill(PSTR(MSG_KILLED)); |
|
|
|
break; |
|
|
|
case state_M410: |
|
|
|
quickstop_stepper(); |
|
|
|
break; |
|
|
|
default: |
|
|
|
break; |
|
|
|
} |
|
|
|
state = state_RESET; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
FORCE_INLINE void store_char(unsigned char c) { |
|
|
|
CRITICAL_SECTION_START; |
|
|
@ -104,11 +194,7 @@ FORCE_INLINE void store_char(unsigned char c) { |
|
|
|
} |
|
|
|
#endif |
|
|
|
|
|
|
|
// Constructors ////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
MarlinSerial::MarlinSerial() { } |
|
|
|
|
|
|
|
// Public Methods //////////////////////////////////////////////////////////////
|
|
|
|
// Public Methods
|
|
|
|
|
|
|
|
void MarlinSerial::begin(long baud) { |
|
|
|
uint16_t baud_setting; |
|
|
@ -376,7 +462,7 @@ void MarlinSerial::println(double n, int digits) { |
|
|
|
println(); |
|
|
|
} |
|
|
|
|
|
|
|
// Private Methods /////////////////////////////////////////////////////////////
|
|
|
|
// Private Methods
|
|
|
|
|
|
|
|
void MarlinSerial::printNumber(unsigned long n, uint8_t base) { |
|
|
|
if (n) { |
|
|
@ -424,104 +510,13 @@ void MarlinSerial::printFloat(double number, uint8_t digits) { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
// Preinstantiate Objects //////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
|
|
// Preinstantiate
|
|
|
|
MarlinSerial customizedSerial; |
|
|
|
|
|
|
|
#endif // whole file
|
|
|
|
#endif // !USBCON
|
|
|
|
#endif // !USBCON && (UBRRH || UBRR0H || UBRR1H || UBRR2H || UBRR3H)
|
|
|
|
|
|
|
|
// For AT90USB targets use the UART for BT interfacing
|
|
|
|
#if defined(USBCON) && ENABLED(BLUETOOTH) |
|
|
|
HardwareSerial bluetoothSerial; |
|
|
|
#endif |
|
|
|
|
|
|
|
#if ENABLED(EMERGENCY_PARSER) |
|
|
|
|
|
|
|
// Currently looking for: M108, M112, M410
|
|
|
|
// If you alter the parser please don't forget to update the capabilities in Conditionals_post.h
|
|
|
|
|
|
|
|
FORCE_INLINE void emergency_parser(unsigned char c) { |
|
|
|
|
|
|
|
static e_parser_state state = state_RESET; |
|
|
|
|
|
|
|
switch (state) { |
|
|
|
case state_RESET: |
|
|
|
switch (c) { |
|
|
|
case ' ': break; |
|
|
|
case 'N': state = state_N; break; |
|
|
|
case 'M': state = state_M; break; |
|
|
|
default: state = state_IGNORE; |
|
|
|
} |
|
|
|
break; |
|
|
|
|
|
|
|
case state_N: |
|
|
|
switch (c) { |
|
|
|
case '0': case '1': case '2': |
|
|
|
case '3': case '4': case '5': |
|
|
|
case '6': case '7': case '8': |
|
|
|
case '9': case '-': case ' ': break; |
|
|
|
case 'M': state = state_M; break; |
|
|
|
default: state = state_IGNORE; |
|
|
|
} |
|
|
|
break; |
|
|
|
|
|
|
|
case state_M: |
|
|
|
switch (c) { |
|
|
|
case ' ': break; |
|
|
|
case '1': state = state_M1; break; |
|
|
|
case '4': state = state_M4; break; |
|
|
|
default: state = state_IGNORE; |
|
|
|
} |
|
|
|
break; |
|
|
|
|
|
|
|
case state_M1: |
|
|
|
switch (c) { |
|
|
|
case '0': state = state_M10; break; |
|
|
|
case '1': state = state_M11; break; |
|
|
|
default: state = state_IGNORE; |
|
|
|
} |
|
|
|
break; |
|
|
|
|
|
|
|
case state_M10: |
|
|
|
state = (c == '8') ? state_M108 : state_IGNORE; |
|
|
|
break; |
|
|
|
|
|
|
|
case state_M11: |
|
|
|
state = (c == '2') ? state_M112 : state_IGNORE; |
|
|
|
break; |
|
|
|
|
|
|
|
case state_M4: |
|
|
|
state = (c == '1') ? state_M41 : state_IGNORE; |
|
|
|
break; |
|
|
|
|
|
|
|
case state_M41: |
|
|
|
state = (c == '0') ? state_M410 : state_IGNORE; |
|
|
|
break; |
|
|
|
|
|
|
|
case state_IGNORE: |
|
|
|
if (c == '\n') state = state_RESET; |
|
|
|
break; |
|
|
|
|
|
|
|
default: |
|
|
|
if (c == '\n') { |
|
|
|
switch (state) { |
|
|
|
case state_M108: |
|
|
|
wait_for_user = wait_for_heatup = false; |
|
|
|
break; |
|
|
|
case state_M112: |
|
|
|
kill(PSTR(MSG_KILLED)); |
|
|
|
break; |
|
|
|
case state_M410: |
|
|
|
quickstop_stepper(); |
|
|
|
break; |
|
|
|
default: |
|
|
|
break; |
|
|
|
} |
|
|
|
state = state_RESET; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
#endif |
|
|
|