summaryrefslogtreecommitdiff
path: root/tinyusb
diff options
context:
space:
mode:
authorhathach <[email protected]>2013-12-09 11:28:11 +0700
committerhathach <[email protected]>2013-12-09 11:28:11 +0700
commit055285c55932af1396b92a31248f1df0ead25ffb (patch)
treed2d0fcc4be422c114699b30035910b2fa25acbd8 /tinyusb
parente320659f8a4869a81e656285ed1263d8515aa7ee (diff)
minor refractor
Diffstat (limited to 'tinyusb')
-rw-r--r--tinyusb/device/dcd_lpc_11uxx_13uxx.c56
1 files changed, 31 insertions, 25 deletions
diff --git a/tinyusb/device/dcd_lpc_11uxx_13uxx.c b/tinyusb/device/dcd_lpc_11uxx_13uxx.c
index 1b64154e8..5e162a2eb 100644
--- a/tinyusb/device/dcd_lpc_11uxx_13uxx.c
+++ b/tinyusb/device/dcd_lpc_11uxx_13uxx.c
@@ -255,6 +255,35 @@ static void endpoint_non_control_isr(uint32_t int_status)
}
}
+static void endpoint_control_isr(uint32_t int_status)
+{
+ uint8_t const ep_id = ( int_status & BIT_(0) ) ? 0 : 1;
+
+ // there are still data to transfer.
+ if ( (dcd_data.qhd[ep_id][0].total_bytes == 0) && (dcd_data.current_td[ep_id].remaining_bytes > 0) )
+ {
+ queue_xfer_to_buffer(ep_id, 0, dcd_data.qhd[ep_id][0].buff_addr_offset, dcd_data.current_td[ep_id].remaining_bytes);
+ }else
+ {
+ dcd_data.current_td[ep_id].remaining_bytes = 0;
+
+ if ( BIT_TEST_(dcd_data.current_ioc, ep_id) )
+ {
+ endpoint_handle_t edpt_hdl =
+ {
+ .coreid = 0,
+ .index = 0,
+ .class_code = 0
+ };
+
+ dcd_data.current_ioc = BIT_CLR_(dcd_data.current_ioc, edpt_hdl.index);
+
+ // FIXME xferred_byte for control xfer is not needed now !!!
+ usbd_xfer_isr(edpt_hdl, TUSB_EVENT_XFER_COMPLETE, 0);
+ }
+ }
+}
+
void dcd_isr(uint8_t coreid)
{
(void) coreid;
@@ -317,31 +346,8 @@ void dcd_isr(uint8_t coreid)
}
//------------- Control Endpoint -------------//
else if ( int_status & 0x03 )
- { // either control endpoints
- uint8_t const ep_id = ( int_status & BIT_(0) ) ? 0 : 1;
-
- // there are still data to transfer.
- if ( (dcd_data.qhd[ep_id][0].total_bytes == 0) && (dcd_data.current_td[ep_id].remaining_bytes > 0) )
- {
- queue_xfer_to_buffer(ep_id, 0, dcd_data.qhd[ep_id][0].buff_addr_offset, dcd_data.current_td[ep_id].remaining_bytes);
- }else
- {
- dcd_data.current_td[ep_id].remaining_bytes = 0;
-
- if ( BIT_TEST_(dcd_data.current_ioc, ep_id) )
- {
- endpoint_handle_t edpt_hdl =
- {
- .coreid = coreid,
- .index = 0
- };
-
- dcd_data.current_ioc = BIT_CLR_(dcd_data.current_ioc, edpt_hdl.index);
-
- // FIXME xferred_byte for control xfer is not needed now !!!
- usbd_xfer_isr(edpt_hdl, TUSB_EVENT_XFER_COMPLETE, 0);
- }
- }
+ {
+ endpoint_control_isr(int_status);
}
//------------- Non-Control Endpoints -------------//