diff options
| author | hathach <[email protected]> | 2018-03-07 11:01:23 +0700 |
|---|---|---|
| committer | hathach <[email protected]> | 2018-03-07 11:01:23 +0700 |
| commit | 321324a485190a9dce2c49ef7019fc0eda83299b (patch) | |
| tree | 26273c02d1aa5585b842c9e69a55c0ec54e272ab /tinyusb | |
| parent | 7928eaf58a7ef4bd34ac14a2f82102d41484e817 (diff) | |
enhance cdc implementation
Diffstat (limited to 'tinyusb')
| -rw-r--r-- | tinyusb/class/cdc/cdc_device.c | 26 | ||||
| -rw-r--r-- | tinyusb/device/usbd.c | 2 |
2 files changed, 26 insertions, 2 deletions
diff --git a/tinyusb/class/cdc/cdc_device.c b/tinyusb/class/cdc/cdc_device.c index 9867b9e6c..f15255e4a 100644 --- a/tinyusb/class/cdc/cdc_device.c +++ b/tinyusb/class/cdc/cdc_device.c @@ -103,7 +103,13 @@ void cdcd_init(void) // default line coding is : stop bit = 1, parity = none, data bits = 8
memclr_(cdcd_line_coding, sizeof(cdc_line_coding_t)*CONTROLLER_DEVICE_NUMBER);
- for(uint8_t i=0; i<CONTROLLER_DEVICE_NUMBER; i++) cdcd_line_coding[i].data_bits = 8;
+ for(uint8_t i=0; i<CONTROLLER_DEVICE_NUMBER; i++)
+ {
+ cdcd_line_coding[i].bit_rate = 115200;
+ cdcd_line_coding[i].stop_bits = 0;
+ cdcd_line_coding[i].parity = 0;
+ cdcd_line_coding[i].data_bits = 8;
+ }
}
tusb_error_t cdcd_open(uint8_t coreid, tusb_descriptor_interface_t const * p_interface_desc, uint16_t *p_length)
@@ -195,6 +201,24 @@ tusb_error_t cdcd_control_request_subtask(uint8_t coreid, tusb_control_request_t break;
case CDC_REQUEST_SET_CONTROL_LINE_STATE: // TODO extract DTE present
+ {
+ enum {
+ ACTIVE_DTE_PRESENT = 0x0003,
+ ACTIVE_DTE_NOT_PRESENT = 0x0002
+ };
+
+ if (p_request->wValue == ACTIVE_DTE_PRESENT)
+ {
+ // terminal connected
+ }
+ else if (p_request->wValue == ACTIVE_DTE_NOT_PRESENT)
+ {
+ // terminal disconnected
+ }else
+ {
+ // De-active --> disconnected
+ }
+ }
break;
default: return TUSB_ERROR_DCD_CONTROL_REQUEST_NOT_SUPPORT;
diff --git a/tinyusb/device/usbd.c b/tinyusb/device/usbd.c index 4b3620abf..936fd78f1 100644 --- a/tinyusb/device/usbd.c +++ b/tinyusb/device/usbd.c @@ -244,7 +244,7 @@ tusb_error_t usbd_control_request_subtask(uint8_t coreid, tusb_control_request_t tusb_error_t error;
error = TUSB_ERROR_NONE;
- //------------- Standard Control such as those in enumeration -------------//
+ //------------- Standard Control e.g in enumeration -------------//
if( TUSB_REQUEST_RECIPIENT_DEVICE == p_request->bmRequestType_bit.recipient &&
TUSB_REQUEST_TYPE_STANDARD == p_request->bmRequestType_bit.type )
{
|
