From d866999bf0f41b0d3db0354c599d014c66dc6870 Mon Sep 17 00:00:00 2001 From: hathach Date: Sat, 23 Mar 2019 17:15:00 +0700 Subject: remove idle rate enforcement, should be done in application level --- src/class/hid/hid_device.c | 53 ++++++++++------------------------------------ 1 file changed, 11 insertions(+), 42 deletions(-) (limited to 'src/class') diff --git a/src/class/hid/hid_device.c b/src/class/hid/hid_device.c index 73af0c9a2..fd7602251 100644 --- a/src/class/hid/hid_device.c +++ b/src/class/hid/hid_device.c @@ -43,7 +43,6 @@ // Max report len is keyboard's one with 8 byte + 1 byte report id #define REPORT_BUFSIZE 12 - #define ITF_IDX_BOOT_KBD 0 #define ITF_IDX_BOOT_MSE ( ITF_IDX_BOOT_KBD + (CFG_TUD_HID_KEYBOARD && CFG_TUD_HID_KEYBOARD_BOOT) ) #define ITF_IDX_GENERIC ( ITF_IDX_BOOT_MSE + (CFG_TUD_HID_MOUSE && CFG_TUD_HID_MOUSE_BOOT) ) @@ -70,8 +69,10 @@ typedef struct typedef struct { - uint8_t usage; // HID_USAGE_* - uint8_t idle_rate; // in unit of 4 ms + uint8_t usage; // HID_USAGE_* + uint8_t idle_rate; // Idle Rate = 0 : only send report if there is changes, i.e skip duplication + // Idle Rate > 0 : skip duplication, but send at least 1 report every idle rate (in unit of 4 ms). + // If idle time is less than interrupt polling then use the polling. uint8_t report_id; uint8_t report_len; @@ -91,7 +92,6 @@ static hidd_report_t _mse_rpt; #endif /*------------- Helpers -------------*/ - static inline hidd_interface_t* get_interface_by_itfnum(uint8_t itf_num) { for (uint8_t i=0; i < ITF_COUNT; i++ ) @@ -151,19 +151,14 @@ static bool hidd_kbd_report(hid_keyboard_report_t const *p_report) hidd_interface_t * p_hid = _kbd_rpt.itf; - // Idle Rate = 0 : only send report if there is changes, i.e skip duplication - // Idle Rate > 0 : skip duplication, but send at least 1 report every idle rate (in unit of 4 ms). - // If idle time is less than interrupt polling then use the polling. - static tu_timeout_t idle_tm = { 0, 0 }; - - if ( (_kbd_rpt.idle_rate == 0) || !tu_timeout_expired(&idle_tm) ) - { - if ( 0 == memcmp(p_hid->report_buf, p_report, sizeof(hid_keyboard_report_t)) ) return true; - } - - tu_timeout_set(&idle_tm, _kbd_rpt.idle_rate * 4); + // only send report if there is changes, i.e skip duplication +// if ( _kbd_rpt.idle_rate == 0 ) +// { +// if ( 0 == memcmp(p_hid->report_buf, p_report, sizeof(hid_keyboard_report_t)) ) return true; +// } memcpy(p_hid->report_buf, p_report, sizeof(hid_keyboard_report_t)); + return dcd_edpt_xfer(TUD_OPT_RHPORT, p_hid->ep_in, p_hid->report_buf, sizeof(hid_keyboard_report_t)); } @@ -195,33 +190,6 @@ bool tud_hid_keyboard_key_press(char ch) return tud_hid_keyboard_keycode(modifier, keycode); } -#if 0 // should be at application -bool tud_hid_keyboard_key_sequence(const char* str, uint32_t interval_ms) -{ - // Send each key in string - char ch; - while( (ch = *str++) != 0 ) - { - char lookahead = *str; - - tud_hid_keyboard_key_press(ch); - - // Blocking delay - tu_timeout_wait(interval_ms); - - /* Only need to empty report if the next character is NULL or the same with - * the current one, else no need to send */ - if ( lookahead == ch || lookahead == 0 ) - { - tud_hid_keyboard_key_release(); - tu_timeout_wait(interval_ms); - } - } - - return true; -} -#endif - #endif // CFG_TUD_HID_ASCII_TO_KEYCODE_LOOKUP #endif // CFG_TUD_HID_KEYBOARD @@ -246,6 +214,7 @@ static bool hidd_mouse_report(hid_mouse_report_t const *p_report) TU_VERIFY( tud_hid_mouse_ready() ); hidd_interface_t * p_hid = _mse_rpt.itf; +// only send report if there is changes, i.e skip duplication memcpy(p_hid->report_buf, p_report, sizeof(hid_mouse_report_t)); return dcd_edpt_xfer(TUD_OPT_RHPORT, p_hid->ep_in, p_hid->report_buf, sizeof(hid_mouse_report_t)); -- cgit v1.3.1 From 1e9848d917550b0af2115bc629d5e7e4743f23c7 Mon Sep 17 00:00:00 2001 From: hathach Date: Wed, 27 Mar 2019 16:09:49 +0700 Subject: replace dcd_edpt_(clear)stall by usbd_edpt_(clear)stall - remove dcd_edpt_stalled() from dcd porting --- docs/porting.md | 4 +-- src/class/msc/msc_device.c | 8 ++--- src/device/dcd.h | 2 -- src/device/usbd.c | 41 +++++++++++++++++++++++--- src/device/usbd.h | 1 - src/device/usbd_pvt.h | 5 ++++ src/portable/microchip/samd21/dcd_samd21.c | 14 --------- src/portable/microchip/samd51/dcd_samd51.c | 14 --------- src/portable/nordic/nrf5x/dcd_nrf5x.c | 11 ------- src/portable/nxp/lpc11_13_15/dcd_lpc11_13_15.c | 8 ----- src/portable/nxp/lpc17_40/dcd_lpc17_40.c | 8 ----- src/portable/nxp/lpc18_43/dcd_lpc18_43.c | 8 ----- src/portable/st/stm32f3/dcd_stm32f3.c | 3 -- src/portable/st/stm32f4/dcd_stm32f4.c | 24 --------------- tools/top.mk | 4 +-- 15 files changed, 50 insertions(+), 105 deletions(-) (limited to 'src/class') diff --git a/docs/porting.md b/docs/porting.md index 70c9f25aa..5f1df0d7a 100644 --- a/docs/porting.md +++ b/docs/porting.md @@ -147,9 +147,9 @@ The arguments are: * the result of the transfer. Failure isn't handled yet. * `true` to note the call is from an interrupt handler. -##### dcd_edpt_stall / dcd_edpt_stalled / dcd_edpt_clear_stall +##### dcd_edpt_stall / dcd_edpt_clear_stall -Stalling is one way an endpoint can indicate failure such as when an unsupported command is transmitted. The trio of `dcd_edpt_stall`, `dcd_edpt_stalled`, `dcd_edpt_clear_stall` help manage the stall state of all endpoints. +Stalling is one way an endpoint can indicate failure such as when an unsupported command is transmitted. The pair of `dcd_edpt_stall`, `dcd_edpt_clear_stall` help manage the stall state of all endpoints. ## Woohoo! diff --git a/src/class/msc/msc_device.c b/src/class/msc/msc_device.c index 728f4d363..4585d520a 100644 --- a/src/class/msc/msc_device.c +++ b/src/class/msc/msc_device.c @@ -412,7 +412,7 @@ bool mscd_xfer_cb(uint8_t rhport, uint8_t ep_addr, xfer_result_t event, uint32_t p_msc->stage = MSC_STAGE_STATUS; tud_msc_set_sense(p_cbw->lun, SCSI_SENSE_ILLEGAL_REQUEST, 0x20, 0x00); // Sense = Invalid Command Operation - dcd_edpt_stall(rhport, p_msc->ep_in); + usbd_edpt_stall(rhport, p_msc->ep_in); } } } @@ -512,7 +512,7 @@ bool mscd_xfer_cb(uint8_t rhport, uint8_t ep_addr, xfer_result_t event, uint32_t if ( p_msc->stage == MSC_STAGE_STATUS ) { // Either endpoints is stalled, need to wait until it is cleared by host - if ( dcd_edpt_stalled(rhport, p_msc->ep_in) || dcd_edpt_stalled(rhport, p_msc->ep_out) ) + if ( usbd_edpt_stalled(rhport, p_msc->ep_in) || usbd_edpt_stalled(rhport, p_msc->ep_out) ) { // simulate an transfer complete with adjusted parameters --> this driver callback will fired again dcd_event_xfer_complete(rhport, p_msc->ep_out, 0, XFER_RESULT_SUCCESS, false); @@ -573,7 +573,7 @@ static void proc_read10_cmd(uint8_t rhport, mscd_interface_t* p_msc) p_csw->status = MSC_CSW_STATUS_FAILED; tud_msc_set_sense(p_cbw->lun, SCSI_SENSE_ILLEGAL_REQUEST, 0x20, 0x00); // Sense = Invalid Command Operation - dcd_edpt_stall(rhport, p_msc->ep_in); + usbd_edpt_stall(rhport, p_msc->ep_in); } else if ( nbytes == 0 ) { @@ -599,7 +599,7 @@ static void proc_write10_cmd(uint8_t rhport, mscd_interface_t* p_msc) p_csw->status = MSC_CSW_STATUS_FAILED; tud_msc_set_sense(p_cbw->lun, SCSI_SENSE_DATA_PROTECT, 0x27, 0x00); // Sense = Write protected - dcd_edpt_stall(rhport, p_msc->ep_out); + usbd_edpt_stall(rhport, p_msc->ep_out); return; } diff --git a/src/device/dcd.h b/src/device/dcd.h index 588839ccb..186c4af0c 100644 --- a/src/device/dcd.h +++ b/src/device/dcd.h @@ -102,7 +102,6 @@ void dcd_set_config (uint8_t rhport, uint8_t config_num); * - busy : Check if endpoint transferring is complete (TODO remove) * - stall : stall endpoint * - clear_stall : clear stall - * - stalled : check if stalled ( TODO remove ) *------------------------------------------------------------------*/ bool dcd_edpt_open (uint8_t rhport, tusb_desc_endpoint_t const * p_endpoint_desc); bool dcd_edpt_xfer (uint8_t rhport, uint8_t ep_addr, uint8_t * buffer, uint16_t total_bytes); @@ -110,7 +109,6 @@ bool dcd_edpt_busy (uint8_t rhport, uint8_t ep_addr); void dcd_edpt_stall (uint8_t rhport, uint8_t ep_addr); void dcd_edpt_clear_stall (uint8_t rhport, uint8_t ep_addr); -bool dcd_edpt_stalled (uint8_t rhport, uint8_t ep_addr); /*------------------------------------------------------------------*/ /* Event Function diff --git a/src/device/usbd.c b/src/device/usbd.c index 877837fae..b79ccae2b 100644 --- a/src/device/usbd.c +++ b/src/device/usbd.c @@ -44,9 +44,11 @@ typedef struct { uint8_t config_num; - uint8_t itf2drv[16]; // map interface number to driver (0xff is invalid) - uint8_t ep2drv[8][2]; // map endpoint to driver ( 0xff is invalid ) + uint8_t itf2drv[16]; // map interface number to driver (0xff is invalid) + uint8_t ep2drv[8][2]; // map endpoint to driver ( 0xff is invalid ) + uint8_t ep_busy_mask[2]; // bit mask for busy endpoint + uint8_t ep_stall_mask[2]; // bit mask for stalled endpoint }usbd_device_t; static usbd_device_t _usbd_dev = { 0 }; @@ -379,7 +381,7 @@ static bool process_control_request(uint8_t rhport, tusb_control_request_t const { case TUSB_REQ_GET_STATUS: { - uint16_t status = dcd_edpt_stalled(rhport, tu_u16_low(p_request->wIndex)) ? 0x0001 : 0x0000; + uint16_t status = usbd_edpt_stalled(rhport, tu_u16_low(p_request->wIndex)) ? 0x0001 : 0x0000; usbd_control_xfer(rhport, p_request, &status, 2); } break; @@ -392,7 +394,7 @@ static bool process_control_request(uint8_t rhport, tusb_control_request_t const case TUSB_REQ_SET_FEATURE: // only endpoint feature is halted/stalled - dcd_edpt_stall(rhport, tu_u16_low(p_request->wIndex)); + usbd_edpt_stall(rhport, tu_u16_low(p_request->wIndex)); usbd_control_status(rhport, p_request); break; @@ -650,4 +652,35 @@ void usbd_defer_func(osal_task_func_t func, void* param, bool in_isr) dcd_event_handler(&event, in_isr); } +//--------------------------------------------------------------------+ +// USBD Endpoint API +//--------------------------------------------------------------------+ +void usbd_edpt_stall(uint8_t rhport, uint8_t ep_addr) +{ + uint8_t const epnum = tu_edpt_number(ep_addr); + uint8_t const dir = tu_edpt_dir(ep_addr); + + dcd_edpt_stall(rhport, ep_addr); + _usbd_dev.ep_stall_mask[dir] = tu_bit_set(_usbd_dev.ep_stall_mask[dir], epnum); +} + +void usbd_edpt_clear_stall(uint8_t rhport, uint8_t ep_addr) +{ + uint8_t const epnum = tu_edpt_number(ep_addr); + uint8_t const dir = tu_edpt_dir(ep_addr); + + dcd_edpt_clear_stall(rhport, ep_addr); + _usbd_dev.ep_stall_mask[dir] = tu_bit_clear(_usbd_dev.ep_stall_mask[dir], epnum); +} + +bool usbd_edpt_stalled(uint8_t rhport, uint8_t ep_addr) +{ + (void) rhport; + + uint8_t const epnum = tu_edpt_number(ep_addr); + uint8_t const dir = tu_edpt_dir(ep_addr); + + return tu_bit_test(_usbd_dev.ep_stall_mask[dir], epnum); +} + #endif diff --git a/src/device/usbd.h b/src/device/usbd.h index 11ef63887..e8f3f2bc8 100644 --- a/src/device/usbd.h +++ b/src/device/usbd.h @@ -38,7 +38,6 @@ // INCLUDE //--------------------------------------------------------------------+ #include -#include "osal/osal.h" #include "device/dcd.h" //--------------------------------------------------------------------+ diff --git a/src/device/usbd_pvt.h b/src/device/usbd_pvt.h index d2562d298..dee194f0f 100644 --- a/src/device/usbd_pvt.h +++ b/src/device/usbd_pvt.h @@ -52,6 +52,11 @@ bool usbd_control_status(uint8_t rhport, tusb_control_request_t const * request) // Stall control endpoint (both IN and OUT) until new setup packet arrived void usbd_control_stall(uint8_t rhport); + +void usbd_edpt_stall(uint8_t rhport, uint8_t ep_addr); +void usbd_edpt_clear_stall(uint8_t rhport, uint8_t ep_addr); +bool usbd_edpt_stalled(uint8_t rhport, uint8_t ep_addr); + /*------------------------------------------------------------------*/ /* Helper *------------------------------------------------------------------*/ diff --git a/src/portable/microchip/samd21/dcd_samd21.c b/src/portable/microchip/samd21/dcd_samd21.c index e7e5f01b8..723bd6c3a 100644 --- a/src/portable/microchip/samd21/dcd_samd21.c +++ b/src/portable/microchip/samd21/dcd_samd21.c @@ -189,20 +189,6 @@ bool dcd_edpt_xfer (uint8_t rhport, uint8_t ep_addr, uint8_t * buffer, uint16_t return true; } -bool dcd_edpt_stalled (uint8_t rhport, uint8_t ep_addr) -{ - (void) rhport; - - // control is never got halted - if ( ep_addr == 0 ) { - return false; - } - - uint8_t const epnum = tu_edpt_number(ep_addr); - UsbDeviceEndpoint* ep = &USB->DEVICE.DeviceEndpoint[epnum]; - return (tu_edpt_dir(ep_addr) == TUSB_DIR_IN ) ? ep->EPINTFLAG.bit.STALL1 : ep->EPINTFLAG.bit.STALL0; -} - void dcd_edpt_stall (uint8_t rhport, uint8_t ep_addr) { (void) rhport; diff --git a/src/portable/microchip/samd51/dcd_samd51.c b/src/portable/microchip/samd51/dcd_samd51.c index c4c4b3bec..9869956c7 100644 --- a/src/portable/microchip/samd51/dcd_samd51.c +++ b/src/portable/microchip/samd51/dcd_samd51.c @@ -193,20 +193,6 @@ bool dcd_edpt_xfer (uint8_t rhport, uint8_t ep_addr, uint8_t * buffer, uint16_t return true; } -bool dcd_edpt_stalled (uint8_t rhport, uint8_t ep_addr) -{ - (void) rhport; - - // control is never got halted - if ( ep_addr == 0 ) { - return false; - } - - uint8_t const epnum = tu_edpt_number(ep_addr); - UsbDeviceEndpoint* ep = &USB->DEVICE.DeviceEndpoint[epnum]; - return (tu_edpt_dir(ep_addr) == TUSB_DIR_IN ) ? ep->EPINTFLAG.bit.STALL1 : ep->EPINTFLAG.bit.STALL0; -} - void dcd_edpt_stall (uint8_t rhport, uint8_t ep_addr) { (void) rhport; diff --git a/src/portable/nordic/nrf5x/dcd_nrf5x.c b/src/portable/nordic/nrf5x/dcd_nrf5x.c index 1afe4faca..3c2b6d45b 100644 --- a/src/portable/nordic/nrf5x/dcd_nrf5x.c +++ b/src/portable/nordic/nrf5x/dcd_nrf5x.c @@ -279,17 +279,6 @@ bool dcd_edpt_xfer (uint8_t rhport, uint8_t ep_addr, uint8_t * buffer, uint16_t return true; } -bool dcd_edpt_stalled (uint8_t rhport, uint8_t ep_addr) -{ - (void) rhport; - - // control is never got halted - if ( ep_addr == 0 ) return false; - - uint8_t const epnum = tu_edpt_number(ep_addr); - return (tu_edpt_dir(ep_addr) == TUSB_DIR_IN ) ? NRF_USBD->HALTED.EPIN[epnum] : NRF_USBD->HALTED.EPOUT[epnum]; -} - void dcd_edpt_stall (uint8_t rhport, uint8_t ep_addr) { (void) rhport; diff --git a/src/portable/nxp/lpc11_13_15/dcd_lpc11_13_15.c b/src/portable/nxp/lpc11_13_15/dcd_lpc11_13_15.c index 79e681035..65b345957 100644 --- a/src/portable/nxp/lpc11_13_15/dcd_lpc11_13_15.c +++ b/src/portable/nxp/lpc11_13_15/dcd_lpc11_13_15.c @@ -182,14 +182,6 @@ void dcd_edpt_stall(uint8_t rhport, uint8_t ep_addr) _dcd.ep[ep_id][0].stall = 1; } -bool dcd_edpt_stalled(uint8_t rhport, uint8_t ep_addr) -{ - (void) rhport; - - uint8_t const ep_id = ep_addr2id(ep_addr); - return _dcd.ep[ep_id][0].stall; -} - void dcd_edpt_clear_stall(uint8_t rhport, uint8_t ep_addr) { (void) rhport; diff --git a/src/portable/nxp/lpc17_40/dcd_lpc17_40.c b/src/portable/nxp/lpc17_40/dcd_lpc17_40.c index 8da1cebff..f18a91b1c 100644 --- a/src/portable/nxp/lpc17_40/dcd_lpc17_40.c +++ b/src/portable/nxp/lpc17_40/dcd_lpc17_40.c @@ -344,14 +344,6 @@ void dcd_edpt_clear_stall(uint8_t rhport, uint8_t ep_addr) sie_write(SIE_CMDCODE_ENDPOINT_SET_STATUS+ep_id, 1, 0); } -bool dcd_edpt_stalled (uint8_t rhport, uint8_t ep_addr) -{ - (void) rhport; - - uint8_t const ep_state = sie_read(SIE_CMDCODE_ENDPOINT_SELECT + ep_addr2idx(ep_addr)); - return (ep_state & SIE_SELECT_ENDPOINT_STALL_MASK) ? true : false; -} - static bool control_xact(uint8_t rhport, uint8_t dir, uint8_t * buffer, uint8_t len) { (void) rhport; diff --git a/src/portable/nxp/lpc18_43/dcd_lpc18_43.c b/src/portable/nxp/lpc18_43/dcd_lpc18_43.c index 35465f91f..a92a1c7b1 100644 --- a/src/portable/nxp/lpc18_43/dcd_lpc18_43.c +++ b/src/portable/nxp/lpc18_43/dcd_lpc18_43.c @@ -201,14 +201,6 @@ void dcd_edpt_stall(uint8_t rhport, uint8_t ep_addr) LPC_USB[rhport]->ENDPTCTRL[epnum] |= ENDPTCTRL_MASK_STALL << (dir ? 16 : 0); } -bool dcd_edpt_stalled (uint8_t rhport, uint8_t ep_addr) -{ - uint8_t const epnum = tu_edpt_number(ep_addr); - uint8_t const dir = tu_edpt_dir(ep_addr); - - return LPC_USB[rhport]->ENDPTCTRL[epnum] & (ENDPTCTRL_MASK_STALL << (dir ? 16 : 0)); -} - void dcd_edpt_clear_stall(uint8_t rhport, uint8_t ep_addr) { uint8_t const epnum = tu_edpt_number(ep_addr); diff --git a/src/portable/st/stm32f3/dcd_stm32f3.c b/src/portable/st/stm32f3/dcd_stm32f3.c index 3b3dc418c..138c454a7 100644 --- a/src/portable/st/stm32f3/dcd_stm32f3.c +++ b/src/portable/st/stm32f3/dcd_stm32f3.c @@ -70,9 +70,6 @@ void dcd_edpt_stall (uint8_t rhport, uint8_t ep_addr) {} void dcd_edpt_clear_stall (uint8_t rhport, uint8_t ep_addr) {} -bool dcd_edpt_stalled (uint8_t rhport, uint8_t ep_addr) -{ - return false;} #endif diff --git a/src/portable/st/stm32f4/dcd_stm32f4.c b/src/portable/st/stm32f4/dcd_stm32f4.c index 850b7b1b3..db72f92d3 100644 --- a/src/portable/st/stm32f4/dcd_stm32f4.c +++ b/src/portable/st/stm32f4/dcd_stm32f4.c @@ -299,30 +299,6 @@ bool dcd_edpt_xfer (uint8_t rhport, uint8_t ep_addr, uint8_t * buffer, uint16_t return true; } -bool dcd_edpt_stalled (uint8_t rhport, uint8_t ep_addr) -{ - (void) rhport; - USB_OTG_OUTEndpointTypeDef * out_ep = OUT_EP_BASE; - USB_OTG_INEndpointTypeDef * in_ep = IN_EP_BASE; - - // control is never got halted - if(ep_addr == 0) { - return false; - } - - uint8_t const epnum = tu_edpt_number(ep_addr); - uint8_t const dir = tu_edpt_dir(ep_addr); - bool stalled = false; - - if(dir == TUSB_DIR_IN) { - stalled = (in_ep[epnum].DIEPCTL & USB_OTG_DIEPCTL_STALL_Msk); - } else { - stalled = (out_ep[epnum].DOEPCTL & USB_OTG_DOEPCTL_STALL_Msk); - } - - return stalled; -} - // TODO: The logic for STALLing and disabling an endpoint is very similar // (send STALL versus NAK handshakes back). Refactor into resuable function. void dcd_edpt_stall (uint8_t rhport, uint8_t ep_addr) diff --git a/tools/top.mk b/tools/top.mk index 991f9b16a..be51b3f4f 100644 --- a/tools/top.mk +++ b/tools/top.mk @@ -11,7 +11,7 @@ TOP := $(patsubst %/tools/top.mk,%,$(THIS_MAKEFILE)) TOP := $(shell realpath $(TOP)) -$(info Top directory is $(TOP)) +#$(info Top directory is $(TOP)) CURRENT_PATH := $(shell realpath --relative-to=$(TOP) `pwd`) -$(info Path from top is $(CURRENT_PATH)) +#$(info Path from top is $(CURRENT_PATH)) -- cgit v1.3.1 From da452d4ba6127b2b3b83832ba142bece911e2490 Mon Sep 17 00:00:00 2001 From: hathach Date: Wed, 27 Mar 2019 17:48:42 +0700 Subject: cleanup, remove the use of _TINY_USB_SOURCE_FILE_ --- src/class/cdc/cdc_device.c | 2 -- src/class/cdc/cdc_device.h | 7 ++----- src/class/cdc/cdc_host.c | 2 -- src/class/cdc/cdc_host.h | 6 +----- src/class/cdc/cdc_rndis_host.c | 2 -- src/class/cdc/cdc_rndis_host.h | 6 +----- src/class/custom/custom_device.c | 2 -- src/class/custom/custom_device.h | 6 +----- src/class/custom/custom_host.c | 2 -- src/class/custom/custom_host.h | 7 +++---- src/class/hid/hid_device.c | 1 - src/class/hid/hid_device.h | 4 ---- src/class/hid/hid_host.c | 4 ---- src/class/hid/hid_host.h | 6 +----- src/class/midi/midi_device.c | 1 - src/class/midi/midi_device.h | 10 +++------- src/class/msc/msc_device.c | 5 ----- src/class/msc/msc_device.h | 6 +----- src/class/msc/msc_host.c | 2 -- src/class/msc/msc_host.h | 6 +----- src/device/usbd.c | 2 -- src/device/usbd_control.c | 2 -- src/host/hub.c | 2 -- src/host/hub.h | 6 +----- src/host/usbh.c | 2 -- src/host/usbh.h | 3 --- src/tusb.c | 1 - 27 files changed, 15 insertions(+), 90 deletions(-) (limited to 'src/class') diff --git a/src/class/cdc/cdc_device.c b/src/class/cdc/cdc_device.c index 48e94a6e1..2ac8d471c 100644 --- a/src/class/cdc/cdc_device.c +++ b/src/class/cdc/cdc_device.c @@ -28,8 +28,6 @@ #if (TUSB_OPT_DEVICE_ENABLED && CFG_TUD_CDC) -#define _TINY_USB_SOURCE_FILE_ - #include "cdc_device.h" #include "device/usbd_pvt.h" diff --git a/src/class/cdc/cdc_device.h b/src/class/cdc/cdc_device.h index 3375fc98d..468edef45 100644 --- a/src/class/cdc/cdc_device.h +++ b/src/class/cdc/cdc_device.h @@ -96,10 +96,9 @@ ATTR_WEAK void tud_cdc_line_state_cb(uint8_t itf, bool dtr, bool rts); ATTR_WEAK void tud_cdc_line_coding_cb(uint8_t itf, cdc_line_coding_t const* p_line_coding); //--------------------------------------------------------------------+ -// USBD-CLASS DRIVER API -//--------------------------------------------------------------------+ -#ifdef _TINY_USB_SOURCE_FILE_ +// INTERNAL USBD-CLASS DRIVER API +//--------------------------------------------------------------------+ void cdcd_init (void); bool cdcd_open (uint8_t rhport, tusb_desc_interface_t const * p_interface_desc, uint16_t *p_length); bool cdcd_control_request (uint8_t rhport, tusb_control_request_t const * p_request); @@ -107,8 +106,6 @@ bool cdcd_control_request_complete (uint8_t rhport, tusb_control_request_t const bool cdcd_xfer_cb (uint8_t rhport, uint8_t ep_addr, xfer_result_t result, uint32_t xferred_bytes); void cdcd_reset (uint8_t rhport); -#endif - #ifdef __cplusplus } #endif diff --git a/src/class/cdc/cdc_host.c b/src/class/cdc/cdc_host.c index 4932a61ac..75c805152 100644 --- a/src/class/cdc/cdc_host.c +++ b/src/class/cdc/cdc_host.c @@ -28,8 +28,6 @@ #if (TUSB_OPT_HOST_ENABLED && CFG_TUH_CDC) -#define _TINY_USB_SOURCE_FILE_ - #include "common/tusb_common.h" #include "cdc_host.h" diff --git a/src/class/cdc/cdc_host.h b/src/class/cdc/cdc_host.h index 716203b96..7a302eb0f 100644 --- a/src/class/cdc/cdc_host.h +++ b/src/class/cdc/cdc_host.h @@ -109,17 +109,13 @@ void tuh_cdc_xfer_isr(uint8_t dev_addr, xfer_result_t event, cdc_pipeid_t pipe_i /// @} //--------------------------------------------------------------------+ -// USBH-CLASS API +// Internal Class Driver API //--------------------------------------------------------------------+ -#ifdef _TINY_USB_SOURCE_FILE_ - void cdch_init(void); bool cdch_open(uint8_t rhport, uint8_t dev_addr, tusb_desc_interface_t const *itf_desc, uint16_t *p_length); void cdch_isr(uint8_t dev_addr, uint8_t ep_addr, xfer_result_t event, uint32_t xferred_bytes); void cdch_close(uint8_t dev_addr); -#endif - #ifdef __cplusplus } #endif diff --git a/src/class/cdc/cdc_rndis_host.c b/src/class/cdc/cdc_rndis_host.c index d377ddca3..587e9ddc8 100644 --- a/src/class/cdc/cdc_rndis_host.c +++ b/src/class/cdc/cdc_rndis_host.c @@ -28,8 +28,6 @@ #if (TUSB_OPT_HOST_ENABLED && CFG_TUH_CDC && CFG_TUH_CDC_RNDIS) -#define _TINY_USB_SOURCE_FILE_ - //--------------------------------------------------------------------+ // INCLUDE //--------------------------------------------------------------------+ diff --git a/src/class/cdc/cdc_rndis_host.h b/src/class/cdc/cdc_rndis_host.h index 377ae64ba..24becee07 100644 --- a/src/class/cdc/cdc_rndis_host.h +++ b/src/class/cdc/cdc_rndis_host.h @@ -40,10 +40,8 @@ #endif //--------------------------------------------------------------------+ -// RNDIS-CDC Driver API +// INTERNAL RNDIS-CDC Driver API //--------------------------------------------------------------------+ -#ifdef _TINY_USB_SOURCE_FILE_ - typedef struct { OSAL_SEM_DEF(semaphore_notification); osal_semaphore_handle_t sem_notification_hdl; // used to wait on notification pipe @@ -56,8 +54,6 @@ tusb_error_t rndish_open_subtask(uint8_t dev_addr, cdch_data_t *p_cdc); void rndish_xfer_isr(cdch_data_t *p_cdc, pipe_handle_t pipe_hdl, xfer_result_t event, uint32_t xferred_bytes); void rndish_close(uint8_t dev_addr); -#endif - #ifdef __cplusplus } #endif diff --git a/src/class/custom/custom_device.c b/src/class/custom/custom_device.c index bc2f98c1b..04921259f 100644 --- a/src/class/custom/custom_device.c +++ b/src/class/custom/custom_device.c @@ -28,8 +28,6 @@ #if (TUSB_OPT_DEVICE_ENABLED && CFG_TUD_CUSTOM_CLASS) -#define _TINY_USB_SOURCE_FILE_ - #include "common/tusb_common.h" #include "custom_device.h" #include "device/usbd_pvt.h" diff --git a/src/class/custom/custom_device.h b/src/class/custom/custom_device.h index a1dc09430..704ecb23a 100644 --- a/src/class/custom/custom_device.h +++ b/src/class/custom/custom_device.h @@ -46,17 +46,13 @@ //--------------------------------------------------------------------+ //--------------------------------------------------------------------+ -// USBD-CLASS DRIVER API +// Internal Class Driver API //--------------------------------------------------------------------+ -#ifdef _TINY_USB_SOURCE_FILE_ - void cusd_init(void); bool cusd_open(uint8_t rhport, tusb_desc_interface_t const * itf_desc, uint16_t *p_length); bool cusd_control_request_st(uint8_t rhport, tusb_control_request_t const * p_request); bool cusd_control_request_complete (uint8_t rhport, tusb_control_request_t const * p_request); bool cusd_xfer_cb(uint8_t rhport, uint8_t ep_addr, xfer_result_t event, uint32_t xferred_bytes); void cusd_reset(uint8_t rhport); -#endif - #endif /* _TUSB_CUSTOM_DEVICE_H_ */ diff --git a/src/class/custom/custom_host.c b/src/class/custom/custom_host.c index 3ac12a688..488e26b20 100644 --- a/src/class/custom/custom_host.c +++ b/src/class/custom/custom_host.c @@ -28,8 +28,6 @@ #if (TUSB_OPT_HOST_ENABLED && CFG_TUSB_HOST_CUSTOM_CLASS) -#define _TINY_USB_SOURCE_FILE_ - //--------------------------------------------------------------------+ // INCLUDE //--------------------------------------------------------------------+ diff --git a/src/class/custom/custom_host.h b/src/class/custom/custom_host.h index 2ba288e1f..cf612a40b 100644 --- a/src/class/custom/custom_host.h +++ b/src/class/custom/custom_host.h @@ -57,15 +57,14 @@ static inline bool tusbh_custom_is_mounted(uint8_t dev_addr, uint16_t vendor_id, tusb_error_t tusbh_custom_read(uint8_t dev_addr, uint16_t vendor_id, uint16_t product_id, void * p_buffer, uint16_t length); tusb_error_t tusbh_custom_write(uint8_t dev_addr, uint16_t vendor_id, uint16_t product_id, void const * p_data, uint16_t length); -#ifdef _TINY_USB_SOURCE_FILE_ - +//--------------------------------------------------------------------+ +// Internal Class Driver API +//--------------------------------------------------------------------+ void cush_init(void); tusb_error_t cush_open_subtask(uint8_t dev_addr, tusb_desc_interface_t const *p_interface_desc, uint16_t *p_length); void cush_isr(pipe_handle_t pipe_hdl, xfer_result_t event); void cush_close(uint8_t dev_addr); -#endif - #ifdef __cplusplus } #endif diff --git a/src/class/hid/hid_device.c b/src/class/hid/hid_device.c index fd7602251..3a20a9cc8 100644 --- a/src/class/hid/hid_device.c +++ b/src/class/hid/hid_device.c @@ -28,7 +28,6 @@ #if (TUSB_OPT_DEVICE_ENABLED && CFG_TUD_HID) -#define _TINY_USB_SOURCE_FILE_ //--------------------------------------------------------------------+ // INCLUDE //--------------------------------------------------------------------+ diff --git a/src/class/hid/hid_device.h b/src/class/hid/hid_device.h index e0d8907de..096daad18 100644 --- a/src/class/hid/hid_device.h +++ b/src/class/hid/hid_device.h @@ -361,8 +361,6 @@ ATTR_WEAK void tud_hid_mouse_set_report_cb(uint8_t report_id, hid_report_type_t //--------------------------------------------------------------------+ // INTERNAL API //--------------------------------------------------------------------+ -#ifdef _TINY_USB_SOURCE_FILE_ - void hidd_init(void); bool hidd_open(uint8_t rhport, tusb_desc_interface_t const * itf_desc, uint16_t *p_length); bool hidd_control_request(uint8_t rhport, tusb_control_request_t const * p_request); @@ -370,8 +368,6 @@ bool hidd_control_request_complete (uint8_t rhport, tusb_control_request_t const bool hidd_xfer_cb(uint8_t rhport, uint8_t ep_addr, xfer_result_t event, uint32_t xferred_bytes); void hidd_reset(uint8_t rhport); -#endif - #ifdef __cplusplus } #endif diff --git a/src/class/hid/hid_host.c b/src/class/hid/hid_host.c index a52cf64b3..5aabbc01f 100644 --- a/src/class/hid/hid_host.c +++ b/src/class/hid/hid_host.c @@ -28,10 +28,6 @@ #if (TUSB_OPT_HOST_ENABLED && HOST_CLASS_HID) -#define _TINY_USB_SOURCE_FILE_ -//--------------------------------------------------------------------+ -// INCLUDE -//--------------------------------------------------------------------+ #include "common/tusb_common.h" #include "hid_host.h" diff --git a/src/class/hid/hid_host.h b/src/class/hid/hid_host.h index 0e5e48c64..8fa974c92 100644 --- a/src/class/hid/hid_host.h +++ b/src/class/hid/hid_host.h @@ -193,10 +193,8 @@ void tuh_hid_generic_isr(uint8_t dev_addr, xfer_result_t event); /** @} */ // ClassDriver_HID_Generic //--------------------------------------------------------------------+ -// USBH-CLASS DRIVER API +// Internal Class Driver API //--------------------------------------------------------------------+ -#ifdef _TINY_USB_SOURCE_FILE_ - typedef struct { pipe_handle_t pipe_hdl; uint16_t report_size; @@ -208,8 +206,6 @@ bool hidh_open_subtask(uint8_t dev_addr, tusb_desc_interface_t const *p_interfac void hidh_isr(pipe_handle_t pipe_hdl, xfer_result_t event, uint32_t xferred_bytes); void hidh_close(uint8_t dev_addr); -#endif - #ifdef __cplusplus } #endif diff --git a/src/class/midi/midi_device.c b/src/class/midi/midi_device.c index 53c7575f4..5ba111a22 100644 --- a/src/class/midi/midi_device.c +++ b/src/class/midi/midi_device.c @@ -28,7 +28,6 @@ #if (TUSB_OPT_DEVICE_ENABLED && CFG_TUD_MIDI) -#define _TINY_USB_SOURCE_FILE_ //--------------------------------------------------------------------+ // INCLUDE //--------------------------------------------------------------------+ diff --git a/src/class/midi/midi_device.h b/src/class/midi/midi_device.h index 7cbad6e22..a43514044 100644 --- a/src/class/midi/midi_device.h +++ b/src/class/midi/midi_device.h @@ -85,18 +85,14 @@ static inline bool tud_midi_write_flush (void) ATTR_WEAK void tud_midi_rx_cb(uint8_t itf); //--------------------------------------------------------------------+ -// USBD-CLASS DRIVER API +// Internal Class Driver API //--------------------------------------------------------------------+ -#ifdef _TINY_USB_SOURCE_FILE_ - -void midid_init (void); +void midid_init (void); bool midid_open (uint8_t rhport, tusb_desc_interface_t const * p_interface_desc, uint16_t *p_length); bool midid_control_request (uint8_t rhport, tusb_control_request_t const * p_request); bool midid_control_request_complete (uint8_t rhport, tusb_control_request_t const * p_request); bool midid_xfer_cb (uint8_t rhport, uint8_t edpt_addr, xfer_result_t result, uint32_t xferred_bytes); -void midid_reset (uint8_t rhport); - -#endif +void midid_reset (uint8_t rhport); #ifdef __cplusplus } diff --git a/src/class/msc/msc_device.c b/src/class/msc/msc_device.c index 4585d520a..04a3178a3 100644 --- a/src/class/msc/msc_device.c +++ b/src/class/msc/msc_device.c @@ -28,11 +28,6 @@ #if (TUSB_OPT_DEVICE_ENABLED && CFG_TUD_MSC) -//--------------------------------------------------------------------+ -// INCLUDE -//--------------------------------------------------------------------+ -#define _TINY_USB_SOURCE_FILE_ - #include "common/tusb_common.h" #include "msc_device.h" #include "device/usbd_pvt.h" diff --git a/src/class/msc/msc_device.h b/src/class/msc/msc_device.h index c97f6d111..e030951be 100644 --- a/src/class/msc/msc_device.h +++ b/src/class/msc/msc_device.h @@ -154,10 +154,8 @@ ATTR_WEAK bool tud_msc_is_writable_cb(uint8_t lun); /** @} */ //--------------------------------------------------------------------+ -// USBD-CLASS DRIVER API +// Internal Class Driver API //--------------------------------------------------------------------+ -#ifdef _TINY_USB_SOURCE_FILE_ - void mscd_init(void); bool mscd_open(uint8_t rhport, tusb_desc_interface_t const * itf_desc, uint16_t *p_length); bool mscd_control_request(uint8_t rhport, tusb_control_request_t const * p_request); @@ -165,8 +163,6 @@ bool mscd_control_request_complete (uint8_t rhport, tusb_control_request_t const bool mscd_xfer_cb(uint8_t rhport, uint8_t ep_addr, xfer_result_t event, uint32_t xferred_bytes); void mscd_reset(uint8_t rhport); -#endif - #ifdef __cplusplus } #endif diff --git a/src/class/msc/msc_host.c b/src/class/msc/msc_host.c index 4e438a787..bb12c52d7 100644 --- a/src/class/msc/msc_host.c +++ b/src/class/msc/msc_host.c @@ -28,8 +28,6 @@ #if TUSB_OPT_HOST_ENABLED & CFG_TUH_MSC -#define _TINY_USB_SOURCE_FILE_ - //--------------------------------------------------------------------+ // INCLUDE //--------------------------------------------------------------------+ diff --git a/src/class/msc/msc_host.h b/src/class/msc/msc_host.h index dea090a94..1edce82c5 100644 --- a/src/class/msc/msc_host.h +++ b/src/class/msc/msc_host.h @@ -171,10 +171,8 @@ void tuh_msc_isr(uint8_t dev_addr, xfer_result_t event, uint32_t xferred_bytes); //--------------------------------------------------------------------+ -// USBH-CLASS DRIVER API +// Internal Class Driver API //--------------------------------------------------------------------+ -#ifdef _TINY_USB_SOURCE_FILE_ - typedef struct { uint8_t itf_numr; @@ -198,8 +196,6 @@ bool msch_open(uint8_t rhport, uint8_t dev_addr, tusb_desc_interface_t const *it void msch_isr(uint8_t dev_addr, uint8_t ep_addr, xfer_result_t event, uint32_t xferred_bytes); void msch_close(uint8_t dev_addr); -#endif - #ifdef __cplusplus } #endif diff --git a/src/device/usbd.c b/src/device/usbd.c index 17914fb6c..604f35bc5 100644 --- a/src/device/usbd.c +++ b/src/device/usbd.c @@ -28,8 +28,6 @@ #if TUSB_OPT_DEVICE_ENABLED -#define _TINY_USB_SOURCE_FILE_ - #include "tusb.h" #include "usbd.h" #include "device/usbd_pvt.h" diff --git a/src/device/usbd_control.c b/src/device/usbd_control.c index d907aca3b..24234f4d2 100644 --- a/src/device/usbd_control.c +++ b/src/device/usbd_control.c @@ -28,8 +28,6 @@ #if TUSB_OPT_DEVICE_ENABLED -#define _TINY_USB_SOURCE_FILE_ - #include "tusb.h" #include "device/usbd_pvt.h" diff --git a/src/host/hub.c b/src/host/hub.c index d54032299..157a77937 100644 --- a/src/host/hub.c +++ b/src/host/hub.c @@ -28,8 +28,6 @@ #if (TUSB_OPT_HOST_ENABLED && CFG_TUH_HUB) -#define _TINY_USB_SOURCE_FILE_ - //--------------------------------------------------------------------+ // INCLUDE //--------------------------------------------------------------------+ diff --git a/src/host/hub.h b/src/host/hub.h index c3a02af5e..5a4a5eb7f 100644 --- a/src/host/hub.h +++ b/src/host/hub.h @@ -178,17 +178,13 @@ tusb_speed_t hub_port_get_speed(void); bool hub_status_pipe_queue(uint8_t dev_addr); //--------------------------------------------------------------------+ -// USBH-CLASS DRIVER API +// Internal Class Driver API //--------------------------------------------------------------------+ -#ifdef _TINY_USB_SOURCE_FILE_ - void hub_init(void); bool hub_open(uint8_t rhport, uint8_t dev_addr, tusb_desc_interface_t const *itf_desc, uint16_t *p_length); void hub_isr(uint8_t dev_addr, uint8_t ep_addr, xfer_result_t event, uint32_t xferred_bytes); void hub_close(uint8_t dev_addr); -#endif - #ifdef __cplusplus } #endif diff --git a/src/host/usbh.c b/src/host/usbh.c index 640bbfc8d..60d7afa76 100644 --- a/src/host/usbh.c +++ b/src/host/usbh.c @@ -28,8 +28,6 @@ #if TUSB_OPT_HOST_ENABLED -#define _TINY_USB_SOURCE_FILE_ - #ifndef CFG_TUH_TASK_QUEUE_SZ #define CFG_TUH_TASK_QUEUE_SZ 16 #endif diff --git a/src/host/usbh.h b/src/host/usbh.h index a7e053626..84d0f0ec6 100644 --- a/src/host/usbh.h +++ b/src/host/usbh.h @@ -88,10 +88,7 @@ ATTR_WEAK void tuh_umount_cb(uint8_t dev_addr); //--------------------------------------------------------------------+ // CLASS-USBH & INTERNAL API //--------------------------------------------------------------------+ -#ifdef _TINY_USB_SOURCE_FILE_ - bool usbh_init(void); - bool usbh_control_xfer (uint8_t dev_addr, tusb_control_request_t* request, uint8_t* data); #endif diff --git a/src/tusb.c b/src/tusb.c index ec8f328b0..825aa988c 100644 --- a/src/tusb.c +++ b/src/tusb.c @@ -27,7 +27,6 @@ #include "tusb_option.h" #if TUSB_OPT_HOST_ENABLED || TUSB_OPT_DEVICE_ENABLED -#define _TINY_USB_SOURCE_FILE_ #include "tusb.h" -- cgit v1.3.1