浏览代码

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

[2.0.x] DUE - add programming capability to native port
Bob-the-Kuhn 7 年前
父节点
当前提交
c4467da53a
没有帐户链接到提交者的电子邮件
共有 1 个文件被更改,包括 17 次插入3 次删除
  1. 17
    3
      Marlin/src/HAL/HAL_DUE/usb/usb_task.c

+ 17
- 3
Marlin/src/HAL/HAL_DUE/usb/usb_task.c 查看文件

@@ -48,6 +48,7 @@
48 48
 #include "conf_usb.h"
49 49
 #include "udc.h"
50 50
 #include <Arduino.h>
51
+#include <Reset.h>
51 52
 
52 53
 static volatile bool main_b_msc_enable = false;
53 54
 static volatile bool main_b_cdc_enable = false;
@@ -80,11 +81,24 @@ void usb_task_cdc_rx_notify(const uint8_t port) { }
80 81
  *
81 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 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
 

正在加载...
取消
保存