diff options
| author | hathach <[email protected]> | 2018-03-08 14:55:02 +0700 |
|---|---|---|
| committer | hathach <[email protected]> | 2018-03-08 14:55:02 +0700 |
| commit | 23fa9eeebe1581e4cc877a2fe52336469974ddc9 (patch) | |
| tree | fc3c56db34401a2490676064d3ec8a0add278645 | |
| parent | 4ddac8bc88822fc7439b8b2532fe8234d74fee8d (diff) | |
cdc device require SOF to operate
| -rw-r--r-- | hw/mcu/nxp/lpc43xx/hal/dcd_lpc43xx.c | 4 | ||||
| -rw-r--r-- | tinyusb/class/cdc/cdc_device.c | 10 |
2 files changed, 8 insertions, 6 deletions
diff --git a/hw/mcu/nxp/lpc43xx/hal/dcd_lpc43xx.c b/hw/mcu/nxp/lpc43xx/hal/dcd_lpc43xx.c index a7ec01d79..cb6311287 100644 --- a/hw/mcu/nxp/lpc43xx/hal/dcd_lpc43xx.c +++ b/hw/mcu/nxp/lpc43xx/hal/dcd_lpc43xx.c @@ -252,7 +252,7 @@ bool hal_dcd_init(uint8_t coreid) lpc_usb->ENDPOINTLISTADDR = (uint32_t) p_dcd->qhd; // Endpoint List Address has to be 2K alignment
lpc_usb->USBSTS_D = lpc_usb->USBSTS_D;
- lpc_usb->USBINTR_D = INT_MASK_USB | INT_MASK_ERROR | INT_MASK_PORT_CHANGE | INT_MASK_RESET | INT_MASK_SUSPEND /*| INT_MASK_SOF */;
+ lpc_usb->USBINTR_D = INT_MASK_USB | INT_MASK_ERROR | INT_MASK_PORT_CHANGE | INT_MASK_RESET | INT_MASK_SUSPEND | INT_MASK_SOF;
lpc_usb->USBCMD_D &= ~0x00FF0000; // Interrupt Threshold Interval = 0
lpc_usb->USBCMD_D |= BIT_(0); // connect
@@ -595,7 +595,7 @@ void hal_dcd_isr(uint8_t coreid) if (int_status & INT_MASK_SOF)
{
-// hal_dcd_bus_event(coreid, USBD_BUS_EVENT_SOF);
+ hal_dcd_bus_event(coreid, USBD_BUS_EVENT_SOF);
}
if (int_status & INT_MASK_NAK) {}
diff --git a/tinyusb/class/cdc/cdc_device.c b/tinyusb/class/cdc/cdc_device.c index 4e9a22539..0b83457b5 100644 --- a/tinyusb/class/cdc/cdc_device.c +++ b/tinyusb/class/cdc/cdc_device.c @@ -270,6 +270,8 @@ tusb_error_t cdcd_xfer_cb(endpoint_handle_t edpt_hdl, tusb_event_t event, uint32 void cdcd_sof(uint8_t coreid)
{
+ if ( !tud_cdc_connected(coreid) ) return;
+
endpoint_handle_t ep = cdcd_data[coreid].edpt_hdl[CDC_PIPE_DATA_IN];
if ( !dcd_pipe_is_busy( ep ) )
@@ -280,14 +282,14 @@ void cdcd_sof(uint8_t coreid) }
}
-uint32_t tud_cdc_available(uint8_t coreid)
+bool tud_cdc_connected(uint8_t coreid)
{
- return fifo_count(&_rx_ff);
+ return cdcd_data[coreid].connected;
}
-bool tud_cdc_connected(uint8_t coreid)
+uint32_t tud_cdc_available(uint8_t coreid)
{
- return cdcd_data[coreid].connected;
+ return fifo_count(&_rx_ff);
}
int tud_cdc_read_char(uint8_t coreid)
|
