Browse Source

DUE: Emergency parser for the USB CDC

etagle 6 years ago
parent
commit
1b225a2809
1 changed files with 20 additions and 1 deletions
  1. 20
    1
      Marlin/src/HAL/HAL_DUE/MarlinSerialUSB_Due.cpp

+ 20
- 1
Marlin/src/HAL/HAL_DUE/MarlinSerialUSB_Due.cpp View File

33
 
33
 
34
 #include "MarlinSerialUSB_Due.h"
34
 #include "MarlinSerialUSB_Due.h"
35
 
35
 
36
+#if ENABLED(EMERGENCY_PARSER)
37
+  #include "../../feature/emergency_parser.h"
38
+#endif
39
+
36
 // Imports from Atmel USB Stack/CDC implementation
40
 // Imports from Atmel USB Stack/CDC implementation
37
 extern "C" {
41
 extern "C" {
38
   bool usb_task_cdc_isenabled(void);
42
   bool usb_task_cdc_isenabled(void);
46
 // Pending character
50
 // Pending character
47
 static int pending_char = -1;
51
 static int pending_char = -1;
48
 
52
 
53
+#if ENABLED(EMERGENCY_PARSER)
54
+  static EmergencyParser::State emergency_state; // = EP_RESET
55
+#endif
56
+
49
 // Public Methods
57
 // Public Methods
50
 void MarlinSerialUSB::begin(const long baud_setting) {
58
 void MarlinSerialUSB::begin(const long baud_setting) {
51
 }
59
 }
66
     return -1;
74
     return -1;
67
 
75
 
68
   pending_char = udi_cdc_getc();
76
   pending_char = udi_cdc_getc();
77
+
78
+  #if ENABLED(EMERGENCY_PARSER)
79
+    emergency_parser.update(emergency_state, (char)pending_char);
80
+  #endif
81
+
69
   return pending_char;
82
   return pending_char;
70
 }
83
 }
71
 
84
 
84
   if (!udi_cdc_is_rx_ready())
97
   if (!udi_cdc_is_rx_ready())
85
     return -1;
98
     return -1;
86
 
99
 
87
-  return udi_cdc_getc();
100
+  int c = udi_cdc_getc();
101
+
102
+  #if ENABLED(EMERGENCY_PARSER)
103
+    emergency_parser.update(emergency_state, (char)c);
104
+  #endif
105
+
106
+  return c;
88
 }
107
 }
89
 
108
 
90
 bool MarlinSerialUSB::available(void) {
109
 bool MarlinSerialUSB::available(void) {

Loading…
Cancel
Save