DUE: Emergency parser for the USB CDC

This commit is contained in:
etagle 2018-05-09 23:54:42 -03:00 committed by Scott Lahteine
parent 306f0f2135
commit 1b225a2809

View File

@ -33,6 +33,10 @@
#include "MarlinSerialUSB_Due.h" #include "MarlinSerialUSB_Due.h"
#if ENABLED(EMERGENCY_PARSER)
#include "../../feature/emergency_parser.h"
#endif
// Imports from Atmel USB Stack/CDC implementation // Imports from Atmel USB Stack/CDC implementation
extern "C" { extern "C" {
bool usb_task_cdc_isenabled(void); bool usb_task_cdc_isenabled(void);
@ -46,6 +50,10 @@ extern "C" {
// Pending character // Pending character
static int pending_char = -1; static int pending_char = -1;
#if ENABLED(EMERGENCY_PARSER)
static EmergencyParser::State emergency_state; // = EP_RESET
#endif
// Public Methods // Public Methods
void MarlinSerialUSB::begin(const long baud_setting) { void MarlinSerialUSB::begin(const long baud_setting) {
} }
@ -66,6 +74,11 @@ int MarlinSerialUSB::peek(void) {
return -1; return -1;
pending_char = udi_cdc_getc(); pending_char = udi_cdc_getc();
#if ENABLED(EMERGENCY_PARSER)
emergency_parser.update(emergency_state, (char)pending_char);
#endif
return pending_char; return pending_char;
} }
@ -84,7 +97,13 @@ int MarlinSerialUSB::read(void) {
if (!udi_cdc_is_rx_ready()) if (!udi_cdc_is_rx_ready())
return -1; return -1;
return udi_cdc_getc(); int c = udi_cdc_getc();
#if ENABLED(EMERGENCY_PARSER)
emergency_parser.update(emergency_state, (char)c);
#endif
return c;
} }
bool MarlinSerialUSB::available(void) { bool MarlinSerialUSB::available(void) {