Bläddra i källkod

Merge pull request #683 from amitv87/handle_break_req

Handle CDC_REQUEST_SEND_BREAK
Ha Thach 5 år sedan
förälder
incheckning
c6eeee1b79
2 ändrade filer med 14 tillägg och 0 borttagningar
  1. 11 0
      src/class/cdc/cdc_device.c
  2. 3 0
      src/class/cdc/cdc_device.h

+ 11 - 0
src/class/cdc/cdc_device.c

@@ -396,6 +396,17 @@ bool cdcd_control_xfer_cb(uint8_t rhport, uint8_t stage, tusb_control_request_t
         if ( tud_cdc_line_state_cb ) tud_cdc_line_state_cb(itf, dtr, rts);
         if ( tud_cdc_line_state_cb ) tud_cdc_line_state_cb(itf, dtr, rts);
       }
       }
     break;
     break;
+    case CDC_REQUEST_SEND_BREAK:
+      if (stage == CONTROL_STAGE_SETUP)
+      {
+        tud_control_status(rhport, request);
+      }
+      else if (stage == CONTROL_STAGE_ACK)
+      {
+        TU_LOG2("  Send Break\r\n");
+        if ( tud_cdc_send_break_cb ) tud_cdc_send_break_cb(itf, request->wValue);
+      }
+    break;
 
 
     default: return false; // stall unsupported request
     default: return false; // stall unsupported request
   }
   }

+ 3 - 0
src/class/cdc/cdc_device.h

@@ -145,6 +145,9 @@ TU_ATTR_WEAK void tud_cdc_line_state_cb(uint8_t itf, bool dtr, bool rts);
 // Invoked when line coding is change via SET_LINE_CODING
 // Invoked when line coding is change via SET_LINE_CODING
 TU_ATTR_WEAK void tud_cdc_line_coding_cb(uint8_t itf, cdc_line_coding_t const* p_line_coding);
 TU_ATTR_WEAK void tud_cdc_line_coding_cb(uint8_t itf, cdc_line_coding_t const* p_line_coding);
 
 
+// Invoked when received send break
+TU_ATTR_WEAK void tud_cdc_send_break_cb(uint8_t itf, uint16_t duration_ms);
+
 //--------------------------------------------------------------------+
 //--------------------------------------------------------------------+
 // Inline Functions
 // Inline Functions
 //--------------------------------------------------------------------+
 //--------------------------------------------------------------------+