Browse Source

Merge pull request #10063 from ejtagle/bugfix-2.0.x

[2.0.x] DUE - add programming capability to native port
Bob-the-Kuhn 7 years ago
parent
commit
c4467da53a
No account linked to committer's email address
1 changed files with 17 additions and 3 deletions
  1. 17
    3
      Marlin/src/HAL/HAL_DUE/usb/usb_task.c

+ 17
- 3
Marlin/src/HAL/HAL_DUE/usb/usb_task.c View File

48
 #include "conf_usb.h"
48
 #include "conf_usb.h"
49
 #include "udc.h"
49
 #include "udc.h"
50
 #include <Arduino.h>
50
 #include <Arduino.h>
51
+#include <Reset.h>
51
 
52
 
52
 static volatile bool main_b_msc_enable = false;
53
 static volatile bool main_b_msc_enable = false;
53
 static volatile bool main_b_cdc_enable = false;
54
 static volatile bool main_b_cdc_enable = false;
80
  *
81
  *
81
  * \param cfg      line configuration
82
  * \param cfg      line configuration
82
  */
83
  */
83
-void usb_task_cdc_config(const uint8_t port, usb_cdc_line_coding_t *cfg) { }
84
+static uint16_t dwDTERate = 0;
85
+void usb_task_cdc_config(const uint8_t port, usb_cdc_line_coding_t *cfg) {
86
+    // Store last DTE rate
87
+    dwDTERate = cfg->dwDTERate;
88
+}
84
 
89
 
85
 void usb_task_cdc_set_dtr(const uint8_t port, const bool b_enable) {
90
 void usb_task_cdc_set_dtr(const uint8_t port, const bool b_enable) {
86
-  if (b_enable) {
87
-  } else {
91
+  //  Implement Arduino-Compatible kludge to enter programming mode from
92
+  // the native port:
93
+  //  "Auto-reset into the bootloader is triggered when the port, already
94
+  // open at 1200 bps, is closed."
95
+    
96
+  if (1200 == dwDTERate) {
97
+    // We check DTR state to determine if host port is open (bit 0 of lineState).
98
+    if (!b_enable)
99
+      initiateReset(250);
100
+    else
101
+      cancelReset();
88
   }
102
   }
89
 }
103
 }
90
 
104
 

Loading…
Cancel
Save