summaryrefslogtreecommitdiff
path: root/src/portable
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/portable
parent547cc045fa1d8862e7e00c1d7b4a0026531d0098 (diff)
parent38f7d281d44c69593f1de3885a292ee7c5c39355 (diff)
Merge pull request #49 from hathach/develop
clean up porting API
Diffstat (limited to 'src/portable')
-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.c75
-rw-r--r--src/portable/st/stm32f4/dcd_stm32f4.c33
10 files changed, 75 insertions, 140 deletions
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/portable/st/stm32f3/dcd_stm32f3.c b/src/portable/st/stm32f3/dcd_stm32f3.c
new file mode 100644
index 000000000..138c454a7
--- /dev/null
+++ b/src/portable/st/stm32f3/dcd_stm32f3.c
@@ -0,0 +1,75 @@
+/*
+ * 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.
+ */
+
+#include "tusb_option.h"
+
+#if TUSB_OPT_DEVICE_ENABLED && CFG_TUSB_MCU == OPT_MCU_STM32F3
+
+#include "device/dcd.h"
+#include "stm32f3xx.h"
+
+//--------------------------------------------------------------------+
+// MACRO TYPEDEF CONSTANT ENUM DECLARATION
+//--------------------------------------------------------------------+
+
+
+bool dcd_init (uint8_t rhport)
+{
+ return true;
+}
+
+// Enable device interrupt
+void dcd_int_enable (uint8_t rhport)
+{}
+
+// Disable device interrupt
+void dcd_int_disable(uint8_t rhport)
+{}
+
+// 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 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)