summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorhathach <[email protected]>2019-03-27 08:52:25 -0700
committerGitHub <[email protected]>2019-03-27 08:52:25 -0700
commit86c24b310509a368cc6a9dfbec43ce531e71d598 (patch)
tree81fec0b3724083a3515ef09e0b7d601ce01ec621 /src
parent547cc045fa1d8862e7e00c1d7b4a0026531d0098 (diff)
parent38f7d281d44c69593f1de3885a292ee7c5c39355 (diff)
Merge pull request #49 from hathach/develop
clean up porting API
Diffstat (limited to 'src')
-rw-r--r--src/class/cdc/cdc_device.c2
-rw-r--r--src/class/cdc/cdc_device.h7
-rw-r--r--src/class/cdc/cdc_host.c2
-rw-r--r--src/class/cdc/cdc_host.h6
-rw-r--r--src/class/cdc/cdc_rndis_host.c2
-rw-r--r--src/class/cdc/cdc_rndis_host.h6
-rw-r--r--src/class/custom/custom_device.c2
-rw-r--r--src/class/custom/custom_device.h6
-rw-r--r--src/class/custom/custom_host.c2
-rw-r--r--src/class/custom/custom_host.h7
-rw-r--r--src/class/hid/hid_device.c54
-rw-r--r--src/class/hid/hid_device.h4
-rw-r--r--src/class/hid/hid_host.c4
-rw-r--r--src/class/hid/hid_host.h6
-rw-r--r--src/class/midi/midi_device.c1
-rw-r--r--src/class/midi/midi_device.h10
-rw-r--r--src/class/msc/msc_device.c13
-rw-r--r--src/class/msc/msc_device.h6
-rw-r--r--src/class/msc/msc_host.c2
-rw-r--r--src/class/msc/msc_host.h6
-rw-r--r--src/common/tusb_timeout.h8
-rw-r--r--src/device/dcd.h35
-rw-r--r--src/device/usbd.c50
-rw-r--r--src/device/usbd.h5
-rw-r--r--src/device/usbd_control.c14
-rw-r--r--src/device/usbd_pvt.h5
-rw-r--r--src/host/hub.c2
-rw-r--r--src/host/hub.h6
-rw-r--r--src/host/usbh.c2
-rw-r--r--src/host/usbh.h5
-rw-r--r--src/osal/osal.h2
-rw-r--r--src/osal/osal_none.h9
-rw-r--r--src/portable/microchip/samd21/dcd_samd21.c20
-rw-r--r--src/portable/microchip/samd51/dcd_samd51.c20
-rw-r--r--src/portable/nordic/nrf5x/dcd_nrf5x.c17
-rw-r--r--src/portable/nordic/nrf5x/hal_nrf5x.c2
-rw-r--r--src/portable/nxp/lpc11_13_15/dcd_lpc11_13_15.c15
-rw-r--r--src/portable/nxp/lpc17_40/dcd_lpc17_40.c14
-rw-r--r--src/portable/nxp/lpc18_43/dcd_lpc18_43.c15
-rw-r--r--src/portable/readme.md4
-rw-r--r--src/portable/st/stm32f3/dcd_stm32f3.c (renamed from src/osal/osal.c)43
-rw-r--r--src/portable/st/stm32f4/dcd_stm32f4.c33
-rw-r--r--src/tusb.c1
-rw-r--r--src/tusb.h1
-rw-r--r--src/tusb_hal.h52
-rw-r--r--src/tusb_option.h18
46 files changed, 149 insertions, 397 deletions
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 73af0c9a2..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
//--------------------------------------------------------------------+
@@ -43,7 +42,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 +68,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 +91,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 +150,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 +189,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 +213,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));
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 728f4d363..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"
@@ -412,7 +407,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 +507,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 +568,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 +594,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/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/common/tusb_timeout.h b/src/common/tusb_timeout.h
index 556b8d4a3..83a4dac63 100644
--- a/src/common/tusb_timeout.h
+++ b/src/common/tusb_timeout.h
@@ -28,11 +28,11 @@
* \defgroup Group_TimeoutTimer timeout timer
* @{ */
-
#ifndef _TUSB_TIMEOUT_H_
#define _TUSB_TIMEOUT_H_
-#include "tusb_compiler.h"
+#include <stdbool.h>
+#include <stdint.h>
#ifdef __cplusplus
extern "C" {
@@ -43,6 +43,8 @@ typedef struct {
uint32_t interval;
}tu_timeout_t;
+#if 0
+
extern uint32_t tusb_hal_millis(void);
static inline void tu_timeout_set(tu_timeout_t* tt, uint32_t msec)
@@ -67,6 +69,8 @@ static inline void tu_timeout_restart(tu_timeout_t* tt)
tt->start = tusb_hal_millis();
}
+#endif
+
#ifdef __cplusplus
}
#endif
diff --git a/src/device/dcd.h b/src/device/dcd.h
index 95a187298..186c4af0c 100644
--- a/src/device/dcd.h
+++ b/src/device/dcd.h
@@ -94,24 +94,6 @@ void dcd_set_address(uint8_t rhport, uint8_t dev_addr);
// Receive Set Config request
void dcd_set_config (uint8_t rhport, uint8_t config_num);
-// Get current frame number
-uint32_t dcd_get_frame_number(uint8_t rhport);
-
-/*------------------------------------------------------------------*/
-/* Event Function
- * Called by DCD to notify USBD
- *------------------------------------------------------------------*/
-void dcd_event_handler(dcd_event_t const * event, bool in_isr);
-
-// helper to send bus signal event
-void dcd_event_bus_signal (uint8_t rhport, dcd_eventid_t eid, bool in_isr);
-
-// helper to send setup received
-void dcd_event_setup_received(uint8_t rhport, uint8_t const * setup, bool in_isr);
-
-// helper to send transfer complete event
-void dcd_event_xfer_complete (uint8_t rhport, uint8_t ep_addr, uint32_t xferred_bytes, uint8_t result, bool in_isr);
-
/*------------------------------------------------------------------*/
/* Endpoint API
* - open : Configure endpoint's registers
@@ -120,7 +102,6 @@ void dcd_event_xfer_complete (uint8_t rhport, uint8_t ep_addr, uint32_t xferred_
* - 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);
@@ -128,7 +109,21 @@ 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
+ * Called by DCD to notify USBD
+ *------------------------------------------------------------------*/
+void dcd_event_handler(dcd_event_t const * event, bool in_isr);
+
+// helper to send bus signal event
+void dcd_event_bus_signal (uint8_t rhport, dcd_eventid_t eid, bool in_isr);
+
+// helper to send setup received
+void dcd_event_setup_received(uint8_t rhport, uint8_t const * setup, bool in_isr);
+
+// helper to send transfer complete event
+void dcd_event_xfer_complete (uint8_t rhport, uint8_t ep_addr, uint32_t xferred_bytes, uint8_t result, bool in_isr);
#ifdef __cplusplus
}
diff --git a/src/device/usbd.c b/src/device/usbd.c
index 877837fae..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"
@@ -44,9 +42,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 };
@@ -102,7 +102,6 @@ static usbd_class_driver_t const usbd_class_drivers[] =
},
#endif
-
#if CFG_TUD_HID
{
.class_code = TUSB_CLASS_HID,
@@ -241,10 +240,12 @@ void tud_task (void)
switch ( event.event_id )
{
case DCD_EVENT_SETUP_RECEIVED:
- // Process control request, if failed control endpoint is stalled
+ // Process control request
if ( !process_control_request(event.rhport, &event.setup_received) )
{
- usbd_control_stall(event.rhport);
+ // Failed -> stall both control endpoint IN and OUT
+ dcd_edpt_stall(event.rhport, 0);
+ dcd_edpt_stall(event.rhport, 0 | TUSB_DIR_IN_MASK);
}
break;
@@ -379,7 +380,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 +393,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 +651,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..614b4f311 100644
--- a/src/device/usbd.h
+++ b/src/device/usbd.h
@@ -38,7 +38,6 @@
// INCLUDE
//--------------------------------------------------------------------+
#include <common/tusb_common.h>
-#include "osal/osal.h"
#include "device/dcd.h"
//--------------------------------------------------------------------+
@@ -75,10 +74,10 @@ void tud_task (void);
// APPLICATION CALLBACK (WEAK is optional)
//--------------------------------------------------------------------+
-/** Callback invoked when device is mounted (configured) */
+// Callback invoked when device is mounted (configured)
ATTR_WEAK void tud_mount_cb(void);
-/** Callback invoked when device is unmounted (bus reset/unplugged) */
+// Callback invoked when device is unmounted (bus reset/unplugged)
ATTR_WEAK void tud_umount_cb(void);
//void tud_device_suspended_cb(void);
diff --git a/src/device/usbd_control.c b/src/device/usbd_control.c
index 094d2fb44..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"
@@ -60,13 +58,6 @@ void usbd_control_reset (uint8_t rhport)
tu_varclr(&_control_state);
}
-void usbd_control_stall(uint8_t rhport)
-{
- // when stalling control endpoint both IN and OUt will be stalled
- dcd_edpt_stall(rhport, EDPT_CTRL_OUT);
- dcd_edpt_stall(rhport, EDPT_CTRL_IN);
-}
-
bool usbd_control_status(uint8_t rhport, tusb_control_request_t const * request)
{
// status direction is reversed to one in the setup packet
@@ -147,8 +138,9 @@ bool usbd_control_xfer_cb (uint8_t rhport, uint8_t ep_addr, xfer_result_t result
TU_ASSERT( usbd_control_status(rhport, &_control_state.request) );
}else
{
- // stall due to callback
- usbd_control_stall(rhport);
+ // Stall both IN and OUT control endpoint
+ dcd_edpt_stall(rhport, EDPT_CTRL_OUT);
+ dcd_edpt_stall(rhport, EDPT_CTRL_IN);
}
}
else
diff --git a/src/device/usbd_pvt.h b/src/device/usbd_pvt.h
index d2562d298..dab67581f 100644
--- a/src/device/usbd_pvt.h
+++ b/src/device/usbd_pvt.h
@@ -49,8 +49,9 @@ bool usbd_control_xfer(uint8_t rhport, tusb_control_request_t const * request, v
// Send STATUS (zero length) packet
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/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..b8d15305f 100644
--- a/src/host/usbh.h
+++ b/src/host/usbh.h
@@ -88,14 +88,9 @@ 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
-
#ifdef __cplusplus
}
#endif
diff --git a/src/osal/osal.h b/src/osal/osal.h
index 413189b4e..7ceb22125 100644
--- a/src/osal/osal.h
+++ b/src/osal/osal.h
@@ -53,8 +53,6 @@ typedef void (*osal_task_func_t)( void * );
#else
/* RTOS Porting API
*
- * uint32_t tusb_hal_millis(void)
- *
* Task
* void osal_task_delay(uint32_t msec)
*
diff --git a/src/osal/osal_none.h b/src/osal/osal_none.h
index 17a802ed8..6144f3e5c 100644
--- a/src/osal/osal_none.h
+++ b/src/osal/osal_none.h
@@ -27,8 +27,6 @@
#ifndef _TUSB_OSAL_NONE_H_
#define _TUSB_OSAL_NONE_H_
-#include "tusb_hal.h"
-
#ifdef __cplusplus
extern "C" {
#endif
@@ -38,8 +36,11 @@
//--------------------------------------------------------------------+
static inline void osal_task_delay(uint32_t msec)
{
- uint32_t start = tusb_hal_millis();
- while ( ( tusb_hal_millis() - start ) < msec ) {}
+ (void) msec;
+ // TODO only used by Host stack, will implement using SOF
+
+// uint32_t start = tusb_hal_millis();
+// while ( ( tusb_hal_millis() - start ) < msec ) {}
}
//--------------------------------------------------------------------+
diff --git a/src/portable/microchip/samd21/dcd_samd21.c b/src/portable/microchip/samd21/dcd_samd21.c
index 706a62ed9..723bd6c3a 100644
--- a/src/portable/microchip/samd21/dcd_samd21.c
+++ b/src/portable/microchip/samd21/dcd_samd21.c
@@ -114,12 +114,6 @@ void dcd_set_config (uint8_t rhport, uint8_t config_num)
// Nothing to do
}
-uint32_t dcd_get_frame_number(uint8_t rhport)
-{
- (void) rhport;
- return USB->DEVICE.FNUM.bit.FNUM;
-}
-
/*------------------------------------------------------------------*/
/* DCD Endpoint port
*------------------------------------------------------------------*/
@@ -195,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 9773ad71e..9869956c7 100644
--- a/src/portable/microchip/samd51/dcd_samd51.c
+++ b/src/portable/microchip/samd51/dcd_samd51.c
@@ -119,12 +119,6 @@ void dcd_set_config (uint8_t rhport, uint8_t config_num)
// Nothing to do
}
-uint32_t dcd_get_frame_number(uint8_t rhport)
-{
- (void) rhport;
- return USB->DEVICE.FNUM.bit.FNUM;
-}
-
/*------------------------------------------------------------------*/
/* DCD Endpoint port
*------------------------------------------------------------------*/
@@ -199,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 a65087173..3c2b6d45b 100644
--- a/src/portable/nordic/nrf5x/dcd_nrf5x.c
+++ b/src/portable/nordic/nrf5x/dcd_nrf5x.c
@@ -209,12 +209,6 @@ void dcd_set_config (uint8_t rhport, uint8_t config_num)
// Nothing to do
}
-uint32_t dcd_get_frame_number(uint8_t rhport)
-{
- (void) rhport;
- return NRF_USBD->FRAMECNTR;
-}
-
//--------------------------------------------------------------------+
// Endpoint API
//--------------------------------------------------------------------+
@@ -285,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/nordic/nrf5x/hal_nrf5x.c b/src/portable/nordic/nrf5x/hal_nrf5x.c
index 1d149eb8c..8477a56cd 100644
--- a/src/portable/nordic/nrf5x/hal_nrf5x.c
+++ b/src/portable/nordic/nrf5x/hal_nrf5x.c
@@ -40,8 +40,6 @@
#endif
#include "nrfx_power.h"
-
-#include "tusb_hal.h"
#include "device/dcd.h"
/*------------------------------------------------------------------*/
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 c1a6f4a8b..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
@@ -153,13 +153,6 @@ void dcd_set_address(uint8_t rhport, uint8_t dev_addr)
LPC_USB->DEVCMDSTAT |= dev_addr;
}
-uint32_t dcd_get_frame_number(uint8_t rhport)
-{
- (void) rhport;
-
- return LPC_USB->INFO & (TU_BIT(11) - 1);
-}
-
bool dcd_init(uint8_t rhport)
{
(void) rhport;
@@ -189,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 ba6a66d84..f18a91b1c 100644
--- a/src/portable/nxp/lpc17_40/dcd_lpc17_40.c
+++ b/src/portable/nxp/lpc17_40/dcd_lpc17_40.c
@@ -217,12 +217,6 @@ void dcd_set_config(uint8_t rhport, uint8_t config_num)
sie_write(SIE_CMDCODE_CONFIGURE_DEVICE, 1, 1);
}
-uint32_t dcd_get_frame_number(uint8_t rhport)
-{
- (void) rhport;
- return (uint32_t) sie_read(SIE_CMDCODE_READ_FRAME_NUMBER);
-}
-
//--------------------------------------------------------------------+
// CONTROL HELPER
//--------------------------------------------------------------------+
@@ -350,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 ec3ac188b..a92a1c7b1 100644
--- a/src/portable/nxp/lpc18_43/dcd_lpc18_43.c
+++ b/src/portable/nxp/lpc18_43/dcd_lpc18_43.c
@@ -32,8 +32,6 @@
// INCLUDE
//--------------------------------------------------------------------+
#include "common/tusb_common.h"
-#include "tusb_hal.h"
-
#include "device/dcd.h"
#include "dcd_lpc18_43.h"
@@ -165,11 +163,6 @@ void dcd_set_config(uint8_t rhport, uint8_t config_num)
// nothing to do
}
-uint32_t dcd_get_frame_number(uint8_t rhport)
-{
- return LPC_USB[rhport]->FRINDEX_D >> 3;
-}
-
//--------------------------------------------------------------------+
// HELPER
//--------------------------------------------------------------------+
@@ -208,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/readme.md b/src/portable/readme.md
deleted file mode 100644
index a3e8557dc..000000000
--- a/src/portable/readme.md
+++ /dev/null
@@ -1,4 +0,0 @@
-To port tinyusb to support new MCU you need to implement all API in the
-- tusb_hal.h (mandatory for both device and host stack)
-- device/dcd.h for device stack
-- host/hcd.h for host stack
diff --git a/src/osal/osal.c b/src/portable/st/stm32f3/dcd_stm32f3.c
index b1ffa3942..138c454a7 100644
--- a/src/osal/osal.c
+++ b/src/portable/st/stm32f3/dcd_stm32f3.c
@@ -25,24 +25,51 @@
*/
#include "tusb_option.h"
-#include "osal.h"
+
+#if TUSB_OPT_DEVICE_ENABLED && CFG_TUSB_MCU == OPT_MCU_STM32F3
+
+#include "device/dcd.h"
+#include "stm32f3xx.h"
//--------------------------------------------------------------------+
-// TICK API
+// MACRO TYPEDEF CONSTANT ENUM DECLARATION
//--------------------------------------------------------------------+
-#if CFG_TUSB_OS == OPT_OS_FREERTOS
-uint32_t tusb_hal_millis(void)
+
+bool dcd_init (uint8_t rhport)
{
- return ( ( ((uint64_t) xTaskGetTickCount()) * 1000) / configTICK_RATE_HZ );
+ return true;
}
-#elif CFG_TUSB_OS == OPT_OS_MYNEWT
+// Enable device interrupt
+void dcd_int_enable (uint8_t rhport)
+{}
+
+// Disable device interrupt
+void dcd_int_disable(uint8_t rhport)
+{}
-uint32_t tusb_hal_millis(void)
+// Receive Set Address request, mcu port must also include status IN response
+void dcd_set_address(uint8_t rhport, uint8_t dev_addr)
+{}
+
+// Receive Set Config request
+void dcd_set_config (uint8_t rhport, uint8_t config_num)
+{}
+
+bool dcd_edpt_open (uint8_t rhport, tusb_desc_endpoint_t const * p_endpoint_desc)
{
- return os_time_ticks_to_ms32( os_time_get() );
+ return false;
}
+bool dcd_edpt_xfer (uint8_t rhport, uint8_t ep_addr, uint8_t * buffer, uint16_t total_bytes)
+{ return false;}
+bool dcd_edpt_busy (uint8_t rhport, uint8_t ep_addr)
+{ return false;}
+
+void dcd_edpt_stall (uint8_t rhport, uint8_t ep_addr)
+{}
+void dcd_edpt_clear_stall (uint8_t rhport, uint8_t ep_addr)
+{}
#endif
diff --git a/src/portable/st/stm32f4/dcd_stm32f4.c b/src/portable/st/stm32f4/dcd_stm32f4.c
index 472a63f32..db72f92d3 100644
--- a/src/portable/st/stm32f4/dcd_stm32f4.c
+++ b/src/portable/st/stm32f4/dcd_stm32f4.c
@@ -196,15 +196,6 @@ void dcd_set_config (uint8_t rhport, uint8_t config_num)
// Nothing to do
}
-uint32_t dcd_get_frame_number(uint8_t rhport)
-{
- (void) rhport;
-
- USB_OTG_DeviceTypeDef * dev = DEVICE_BASE;
-
- return (dev->DSTS & USB_OTG_DSTS_FNSOF_Msk) >> USB_OTG_DSTS_FNSOF_Pos;
-}
-
/*------------------------------------------------------------------*/
/* DCD Endpoint port
*------------------------------------------------------------------*/
@@ -308,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/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"
diff --git a/src/tusb.h b/src/tusb.h
index c6d572436..122851b45 100644
--- a/src/tusb.h
+++ b/src/tusb.h
@@ -35,7 +35,6 @@
// INCLUDE
//--------------------------------------------------------------------+
#include "common/tusb_common.h"
-#include "tusb_hal.h"
#include "osal/osal.h"
#include "common/tusb_fifo.h"
diff --git a/src/tusb_hal.h b/src/tusb_hal.h
deleted file mode 100644
index 2dcafa77f..000000000
--- a/src/tusb_hal.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * The MIT License (MIT)
- *
- * Copyright (c) 2018, hathach (tinyusb.org)
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- * This file is part of the TinyUSB stack.
- */
-
-#ifndef _TUSB_HAL_H_
-#define _TUSB_HAL_H_
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-//--------------------------------------------------------------------+
-// INCLUDES
-//--------------------------------------------------------------------+
-#include "common/tusb_common.h"
-
-//--------------------------------------------------------------------+
-// HAL API
-//--------------------------------------------------------------------+
-
-// Only required to implement if using No RTOS (osal_none)
-// TODO could be remove
-uint32_t tusb_hal_millis(void);
-
-#ifdef __cplusplus
- }
-#endif
-
-#endif /* _TUSB_HAL_H_ */
-
diff --git a/src/tusb_option.h b/src/tusb_option.h
index 40705bc00..46d2186a0 100644
--- a/src/tusb_option.h
+++ b/src/tusb_option.h
@@ -36,21 +36,21 @@
/** \defgroup group_mcu Supported MCU
* \ref CFG_TUSB_MCU must be defined to one of these
* @{ */
-#define OPT_MCU_LPC11UXX 1 ///< NXP LPC11Uxx
+#define OPT_MCU_LPC11UXX 1 ///< NXP LPC11Uxx
+#define OPT_MCU_LPC13XX 3 ///< NXP LPC13xx
+#define OPT_MCU_LPC175X_6X 4 ///< NXP LPC175x, LPC176x
+#define OPT_MCU_LPC177X_8X 5 ///< NXP LPC177x, LPC178x
+#define OPT_MCU_LPC18XX 6 ///< NXP LPC18xx
+#define OPT_MCU_LPC40XX 7 ///< NXP LPC40xx
+#define OPT_MCU_LPC43XX 8 ///< NXP LPC43xx
-#define OPT_MCU_LPC13XX 3 ///< NXP LPC13xx
-#define OPT_MCU_LPC175X_6X 4 ///< NXP LPC175x, LPC176x
-#define OPT_MCU_LPC177X_8X 5 ///< NXP LPC177x, LPC178x
-#define OPT_MCU_LPC18XX 6 ///< NXP LPC18xx
-#define OPT_MCU_LPC40XX 7 ///< NXP LPC40xx
-#define OPT_MCU_LPC43XX 8 ///< NXP LPC43xx
-
-#define OPT_MCU_NRF5X 100 ///< Nordic nRF5x series
+#define OPT_MCU_NRF5X 100 ///< Nordic nRF5x series
#define OPT_MCU_SAMD21 200 ///< MicroChip SAMD21
#define OPT_MCU_SAMD51 201 ///< MicroChip SAMD51
#define OPT_MCU_STM32F4 300 ///< ST STM32F4
+#define OPT_MCU_STM32F3 301 ///< ST STM32F3
/** @} */