summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhathach <[email protected]>2018-12-17 12:14:11 +0700
committerhathach <[email protected]>2018-12-17 12:14:11 +0700
commit902697ca079a179221da92f8cb9f873768a5d0d7 (patch)
tree8bc9238d3aa66b4b02139a9e24005e1ce4c3630a
parent455da57f9d66a342383334f3af82c27b57feb6cd (diff)
add dcd_get_microframe()
-rw-r--r--src/class/hid/hid_device.c2
-rw-r--r--src/class/hid/hid_device.h1
-rw-r--r--src/common/tusb_timeout.h10
-rw-r--r--src/device/dcd.h4
-rw-r--r--src/portable/microchip/samd21/dcd_samd21.c6
-rw-r--r--src/portable/microchip/samd51/dcd_samd51.c6
-rw-r--r--src/portable/nordic/nrf5x/dcd_nrf5x.c11
-rw-r--r--src/portable/nxp/lpc11_13_15/dcd_lpc11_13_15.c7
-rw-r--r--src/portable/nxp/lpc17_40/dcd_lpc17_40.c6
-rw-r--r--src/portable/nxp/lpc18_43/dcd_lpc18_43.c28
10 files changed, 58 insertions, 23 deletions
diff --git a/src/class/hid/hid_device.c b/src/class/hid/hid_device.c
index 70aa7370d..3b882f705 100644
--- a/src/class/hid/hid_device.c
+++ b/src/class/hid/hid_device.c
@@ -207,6 +207,7 @@ 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
@@ -231,6 +232,7 @@ bool tud_hid_keyboard_key_sequence(const char* str, uint32_t interval_ms)
return true;
}
+#endif
#endif // CFG_TUD_HID_ASCII_TO_KEYCODE_LOOKUP
diff --git a/src/class/hid/hid_device.h b/src/class/hid/hid_device.h
index 885f33443..f3d5087a2 100644
--- a/src/class/hid/hid_device.h
+++ b/src/class/hid/hid_device.h
@@ -95,7 +95,6 @@ static inline bool tud_hid_keyboard_key_release(void) { return tud_hid_keyboard_
#if CFG_TUD_HID_ASCII_TO_KEYCODE_LOOKUP
bool tud_hid_keyboard_key_press(char ch);
-bool tud_hid_keyboard_key_sequence(const char* str, uint32_t interval_ms);
typedef struct{
uint8_t shift;
diff --git a/src/common/tusb_timeout.h b/src/common/tusb_timeout.h
index 9d80f5fe7..06d5ff5bf 100644
--- a/src/common/tusb_timeout.h
+++ b/src/common/tusb_timeout.h
@@ -79,16 +79,6 @@ static inline void tu_timeout_restart(tu_timeout_t* tt)
tt->start = tusb_hal_millis();
}
-
-static inline void tu_timeout_wait(uint32_t msec)
-{
- tu_timeout_t tt;
- tu_timeout_set(&tt, msec);
-
- // blocking delay
- while ( !tu_timeout_expired(&tt) ) { }
-}
-
#ifdef __cplusplus
}
#endif
diff --git a/src/device/dcd.h b/src/device/dcd.h
index 6b1356cbf..408922740 100644
--- a/src/device/dcd.h
+++ b/src/device/dcd.h
@@ -93,12 +93,16 @@ TU_VERIFY_STATIC(sizeof(dcd_event_t) <= 12, "size is not correct");
/* Device API
*------------------------------------------------------------------*/
bool dcd_init (uint8_t rhport);
+
void dcd_int_enable (uint8_t rhport);
void dcd_int_disable(uint8_t rhport);
void dcd_set_address(uint8_t rhport, uint8_t dev_addr);
void dcd_set_config (uint8_t rhport, uint8_t config_num);
+// Get current micro-frame number
+uint32_t dcd_get_microframe(uint8_t rhport);
+
/*------------------------------------------------------------------*/
/* Event Function
* Called by DCD to notify USBD
diff --git a/src/portable/microchip/samd21/dcd_samd21.c b/src/portable/microchip/samd21/dcd_samd21.c
index af0721ec3..0865f2bda 100644
--- a/src/portable/microchip/samd21/dcd_samd21.c
+++ b/src/portable/microchip/samd21/dcd_samd21.c
@@ -124,6 +124,12 @@ void dcd_set_config (uint8_t rhport, uint8_t config_num)
// Nothing to do
}
+uint32_t dcd_get_microframe(uint8_t rhport)
+{
+ (void) rhport;
+ return USB->DEVICE.FNUM & (TU_BIT(14) - 1);
+}
+
/*------------------------------------------------------------------*/
/* DCD Endpoint port
*------------------------------------------------------------------*/
diff --git a/src/portable/microchip/samd51/dcd_samd51.c b/src/portable/microchip/samd51/dcd_samd51.c
index ce66b8245..fc3d31dea 100644
--- a/src/portable/microchip/samd51/dcd_samd51.c
+++ b/src/portable/microchip/samd51/dcd_samd51.c
@@ -129,6 +129,12 @@ void dcd_set_config (uint8_t rhport, uint8_t config_num)
// Nothing to do
}
+uint32_t dcd_get_microframe(uint8_t rhport)
+{
+ (void) rhport;
+ return USB->DEVICE.FNUM & (TU_BIT(14) - 1);
+}
+
/*------------------------------------------------------------------*/
/* DCD Endpoint port
*------------------------------------------------------------------*/
diff --git a/src/portable/nordic/nrf5x/dcd_nrf5x.c b/src/portable/nordic/nrf5x/dcd_nrf5x.c
index 7d13ef8c3..1e0c34743 100644
--- a/src/portable/nordic/nrf5x/dcd_nrf5x.c
+++ b/src/portable/nordic/nrf5x/dcd_nrf5x.c
@@ -187,7 +187,7 @@ static void xact_in_prepare(uint8_t epnum)
}
//--------------------------------------------------------------------+
-// Tinyusb DCD API
+// Controller API
//--------------------------------------------------------------------+
bool dcd_init (uint8_t rhport)
{
@@ -221,6 +221,15 @@ void dcd_set_config (uint8_t rhport, uint8_t config_num)
// Nothing to do
}
+uint32_t dcd_get_microframe(uint8_t rhport)
+{
+ (void) rhport;
+ return NRF_USBD->FRAMECNTR << 3;
+}
+
+//--------------------------------------------------------------------+
+// Endpoint API
+//--------------------------------------------------------------------+
bool dcd_edpt_open (uint8_t rhport, tusb_desc_endpoint_t const * desc_edpt)
{
(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 26ecaf8be..23522b940 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
@@ -165,6 +165,13 @@ void dcd_set_address(uint8_t rhport, uint8_t dev_addr)
LPC_USB->DEVCMDSTAT |= dev_addr;
}
+uint32_t dcd_get_microframe(uint8_t rhport)
+{
+ (void) rhport;
+
+ return (LPC_USB->INFO & (TU_BIT(11) - 1)) << 3;
+}
+
bool dcd_init(uint8_t rhport)
{
(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 fca2c355d..7406d1770 100644
--- a/src/portable/nxp/lpc17_40/dcd_lpc17_40.c
+++ b/src/portable/nxp/lpc17_40/dcd_lpc17_40.c
@@ -227,6 +227,12 @@ void dcd_set_config(uint8_t rhport, uint8_t config_num)
sie_write(SIE_CMDCODE_CONFIGURE_DEVICE, 1, 1);
}
+uint32_t dcd_get_microframe(uint8_t rhport)
+{
+ (void) rhport;
+ return ((uint32_t) sie_read(SIE_CMDCODE_READ_FRAME_NUMBER)) << 3;
+}
+
//--------------------------------------------------------------------+
// CONTROL HELPER
//--------------------------------------------------------------------+
diff --git a/src/portable/nxp/lpc18_43/dcd_lpc18_43.c b/src/portable/nxp/lpc18_43/dcd_lpc18_43.c
index 7761d547f..796c8c4bb 100644
--- a/src/portable/nxp/lpc18_43/dcd_lpc18_43.c
+++ b/src/portable/nxp/lpc18_43/dcd_lpc18_43.c
@@ -92,17 +92,6 @@ static dcd_data_t* const dcd_data_ptr[2] =
//--------------------------------------------------------------------+
// CONTROLLER API
//--------------------------------------------------------------------+
-void dcd_set_address(uint8_t rhport, uint8_t dev_addr)
-{
- LPC_USB[rhport]->DEVICEADDR = (dev_addr << 25) | TU_BIT(24);
-}
-
-void dcd_set_config(uint8_t rhport, uint8_t config_num)
-{
- (void) rhport;
- (void) config_num;
- // nothing to do
-}
/// follows LPC43xx User Manual 23.10.3
static void bus_reset(uint8_t rhport)
@@ -173,6 +162,23 @@ void dcd_int_disable(uint8_t rhport)
NVIC_DisableIRQ(rhport ? USB1_IRQn : USB0_IRQn);
}
+void dcd_set_address(uint8_t rhport, uint8_t dev_addr)
+{
+ LPC_USB[rhport]->DEVICEADDR = (dev_addr << 25) | TU_BIT(24);
+}
+
+void dcd_set_config(uint8_t rhport, uint8_t config_num)
+{
+ (void) rhport;
+ (void) config_num;
+ // nothing to do
+}
+
+uint32_t dcd_get_microframe(uint8_t rhport)
+{
+ return LPC_USB[rhport]->FRINDEX_D;
+}
+
//--------------------------------------------------------------------+
// HELPER
//--------------------------------------------------------------------+