ST / ST_Events-old

Dependents:   HelloWorld_CCA01M1 HelloWorld_CCA02M1 CI-data-logger-server HelloWorld_CCA02M1 ... more

This is a fork of the events subdirectory of https://github.com/ARMmbed/mbed-os.

Note, you must import this library with import name: events!!!

Files at this revision

API Documentation at this revision

Comitter:
Sam Grove
Date:
Fri Feb 10 11:48:44 2017 -0600
Parent:
9813:04e7540a00ca
Parent:
9814:ff35fc856f7c
Child:
9816:0561b171462a
Commit message:
Merge pull request #3734 from ARMmbed/revert-3684-TARGET_STM_USB_CONFIG

Revert "Target stm usb config"

Changed in this revision

targets/TARGET_STM/TARGET_STM32F1/TARGET_NUCLEO_F103RB/USBHAL_STM32F103RB.h Show diff for this revision Revisions of this file
targets/TARGET_STM/TARGET_STM32F1/TARGET_NUCLEO_F103RB/USBHAL_STM_TARGET.h Show diff for this revision Revisions of this file
targets/TARGET_STM/TARGET_STM32F2/TARGET_NUCLEO_F207ZG/USBHALHost_STM_TARGET.h Show diff for this revision Revisions of this file
targets/TARGET_STM/TARGET_STM32F2/TARGET_NUCLEO_F207ZG/USBHAL_STM_TARGET.h Show diff for this revision Revisions of this file
targets/TARGET_STM/TARGET_STM32F3/TARGET_NUCLEO_F303ZE/USBHAL_STM32F303ZE.h Show diff for this revision Revisions of this file
targets/TARGET_STM/TARGET_STM32F3/TARGET_NUCLEO_F303ZE/USBHAL_STM_TARGET.h Show diff for this revision Revisions of this file
targets/TARGET_STM/TARGET_STM32F4/TARGET_DISCO_F407VG/USBHAL_STM_TARGET.h Show diff for this revision Revisions of this file
targets/TARGET_STM/TARGET_STM32F4/TARGET_DISCO_F429ZI/USBHALHost_DISCOF429ZI.h Show diff for this revision Revisions of this file
targets/TARGET_STM/TARGET_STM32F4/TARGET_DISCO_F429ZI/USBHALHost_STM_TARGET.h Show diff for this revision Revisions of this file
targets/TARGET_STM/TARGET_STM32F4/TARGET_F429_F439/USBHALHost_STM_TARGET.h Show diff for this revision Revisions of this file
targets/TARGET_STM/TARGET_STM32F4/TARGET_F429_F439/USBHAL_STM_TARGET.h Show diff for this revision Revisions of this file
targets/TARGET_STM/TARGET_STM32F4/TARGET_NUCLEO_F401RE/USBHALHost_STM_TARGET.h Show diff for this revision Revisions of this file
targets/TARGET_STM/TARGET_STM32F4/TARGET_NUCLEO_F401RE/USBHAL_STM_TARGET.h Show diff for this revision Revisions of this file
targets/TARGET_STM/TARGET_STM32F4/TARGET_NUCLEO_F411RE/USBHALHost_STM_TARGET.h Show diff for this revision Revisions of this file
targets/TARGET_STM/TARGET_STM32F4/TARGET_NUCLEO_F411RE/USBHAL_STM_TARGET.h Show diff for this revision Revisions of this file
targets/TARGET_STM/TARGET_STM32F4/TARGET_NUCLEO_F412ZG/USBHALHost_STM_TARGET.h Show diff for this revision Revisions of this file
targets/TARGET_STM/TARGET_STM32F4/TARGET_NUCLEO_F412ZG/USBHAL_STM_TARGET.h Show diff for this revision Revisions of this file
targets/TARGET_STM/TARGET_STM32F4/TARGET_NUCLEO_F446ZE/USBHALHost_STM_TARGET.h Show diff for this revision Revisions of this file
targets/TARGET_STM/TARGET_STM32F4/TARGET_NUCLEO_F446ZE/USBHAL_STM_TARGET.h Show diff for this revision Revisions of this file
targets/TARGET_STM/TARGET_STM32F7/TARGET_DISCO_F769NI/USBHAL_STM32F769NI.h Show diff for this revision Revisions of this file
targets/TARGET_STM/TARGET_STM32F7/TARGET_DISCO_F769NI/USBHAL_STM_TARGET.h Show diff for this revision Revisions of this file
targets/TARGET_STM/TARGET_STM32F7/TARGET_F746_F756/USBHALHost_STM_TARGET.h Show diff for this revision Revisions of this file
targets/TARGET_STM/TARGET_STM32F7/TARGET_F746_F756/USBHAL_STM_TARGET.h Show diff for this revision Revisions of this file
targets/TARGET_STM/TARGET_STM32F7/TARGET_NUCLEO_F767ZI/USBHALHost_STM_TARGET.h Show diff for this revision Revisions of this file
targets/TARGET_STM/TARGET_STM32F7/TARGET_NUCLEO_F767ZI/USBHAL_STM_TARGET.h Show diff for this revision Revisions of this file
targets/TARGET_STM/TARGET_STM32L4/TARGET_DISCO_L476VG/USBHALHost_DISCOL476VG.h Show diff for this revision Revisions of this file
targets/TARGET_STM/TARGET_STM32L4/TARGET_DISCO_L476VG/USBHALHost_STM_TARGET.h Show diff for this revision Revisions of this file
targets/TARGET_STM/TARGET_STM32L4/TARGET_DISCO_L476VG/USBHAL_STM32L476VG.h Show diff for this revision Revisions of this file
targets/TARGET_STM/TARGET_STM32L4/TARGET_DISCO_L476VG/USBHAL_STM_TARGET.h Show diff for this revision Revisions of this file
targets/TARGET_STM/TARGET_STM32L4/TARGET_L476_L486/TARGET_NUCLEO_L476RG/USBHALHost_STM_TARGET.h Show diff for this revision Revisions of this file
targets/TARGET_STM/USBHALHost_STM_144_64pins.h Show diff for this revision Revisions of this file
targets/TARGET_STM/USBHAL_STM_144_64pins.h Show diff for this revision Revisions of this file
--- a/features/unsupported/USBDevice/USBDevice/TARGET_STM/USBHAL_STM32.cpp	Thu Feb 09 10:05:54 2017 -0600
+++ b/features/unsupported/USBDevice/USBDevice/TARGET_STM/USBHAL_STM32.cpp	Fri Feb 10 11:48:44 2017 -0600
@@ -15,16 +15,9 @@
 * 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.
 */
-/* TARGET NOT STM does not support this HAL */
-#ifndef TARGET_STM
-#define USBSTM_HAL_UNSUPPORTED
-#endif
-/* F4 famlily wihtout USB_STM_HAL use another HAL*/
-#if defined(TARGET_STM) && defined(TARGET_STM32F4) && !defined(USB_STM_HAL)
-#define USBSTM_HAL_UNSUPPORTED
-#endif
+#if (defined (USB_STM_HAL) && defined(TARGET_STM32F4)) \
+|| defined(TARGET_STM32F2) || defined (TARGET_STM32F7) || defined (TARGET_STM32F3) || defined (TARGET_STM32L4)
 
-#ifndef USBSTM_HAL_UNSUPPORTED
 #include "USBHAL.h"
 #include "pinmap.h"
 /* mbed endpoint definition to hal definition   */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/features/unsupported/USBDevice/USBDevice/TARGET_STM/USBHAL_STM32F303ZE.h	Fri Feb 10 11:48:44 2017 -0600
@@ -0,0 +1,128 @@
+/* Copyright (c) 2016 mbed.org, MIT License
+*
+* 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.
+*/
+#ifndef USBHAL_STM32F303ZE_H
+#define USBHAL_STM32F303ZE_H
+#define USBHAL_IRQn  USB_LP_CAN_RX0_IRQn
+/*  must be multiple of 4 bytes */
+#define NB_ENDPOINT 8
+#define MAXTRANSFER_SIZE  0x200
+#define FIFO_USB_RAM_SIZE (MAXTRANSFER_SIZE+MAX_PACKET_SIZE_EP0+MAX_PACKET_SIZE_EP1+MAX_PACKET_SIZE_EP2+MAX_PACKET_SIZE_EP3)
+#if (FIFO_USB_RAM_SIZE > 0x500)
+#error "FIFO dimensioning incorrect"
+#endif
+
+typedef struct
+{
+	USBHAL *inst;
+	void (USBHAL::*bus_reset)(void);
+	void (USBHAL::*sof)(int frame);
+	void (USBHAL::*connect_change)(unsigned int  connected);
+	void (USBHAL::*suspend_change)(unsigned int suspended);
+	void (USBHAL::*ep0_setup)(void);
+	void (USBHAL::*ep0_in)(void);
+	void (USBHAL::*ep0_out)(void);
+	void (USBHAL::*ep0_read)(void);
+	bool (USBHAL::*ep_realise)(uint8_t endpoint, uint32_t maxPacket, uint32_t flags);
+	bool (USBHAL::*epCallback[6])(void);
+	uint8_t epComplete[2*NB_ENDPOINT];
+	/*  memorize dummy buffer used for reception */
+	uint32_t pBufRx[MAXTRANSFER_SIZE>>2];
+	uint32_t pBufRx0[MAX_PACKET_SIZE_EP0>>2];
+    gpio_t usb_switch;
+}USBHAL_Private_t;
+
+uint32_t HAL_PCDEx_GetTxFiFo(PCD_HandleTypeDef *hpcd, uint8_t fifo)
+{
+        return 1024;
+}
+
+void HAL_PCDEx_SetConnectionState(PCD_HandleTypeDef *hpcd, uint8_t state){
+    USBHAL_Private_t *priv=((USBHAL_Private_t *)(hpcd->pData));
+    gpio_write(&(priv->usb_switch),state);
+}
+
+void HAL_PCD_SOFCallback(PCD_HandleTypeDef *hpcd) {
+    USBHAL_Private_t *priv=((USBHAL_Private_t *)(hpcd->pData));
+    USBHAL *obj= priv->inst;
+    uint32_t sofnum = (hpcd->Instance->FNR) & USB_FNR_FN;
+    void (USBHAL::*func)(int frame) = priv->sof;
+    /* fix me  call with same frame number */
+    (obj->*func)(sofnum);
+}
+
+USBHAL * USBHAL::instance;
+
+USBHAL::USBHAL(void) {
+    /*  init parameter  */
+    USBHAL_Private_t *HALPriv = new(USBHAL_Private_t);
+    hpcd.Instance = USB;
+    /*  initialized Init to zero (constructor does not zero initialized the
+     *  area */
+    /*  initialized all field of init including 0 field  */
+    /*  constructor does not fill with zero */
+    memset(&hpcd.Init, 0, sizeof(hpcd.Init));
+    hpcd.Init.dev_endpoints = NB_ENDPOINT;
+    hpcd.Init.ep0_mps =   MAX_PACKET_SIZE_EP0;
+    hpcd.Init.phy_itface = PCD_PHY_EMBEDDED;
+    hpcd.Init.Sof_enable = 1;
+    hpcd.Init.speed = PCD_SPEED_FULL;
+    /*  pass instance for usage inside call back */
+    HALPriv->inst = this;
+    HALPriv->bus_reset = &USBHAL::busReset;
+    HALPriv->suspend_change = &USBHAL::suspendStateChanged;
+    HALPriv->connect_change = &USBHAL::connectStateChanged;
+    HALPriv->sof = &USBHAL::SOF;
+    HALPriv->ep0_setup = &USBHAL::EP0setupCallback;
+    HALPriv->ep_realise = &USBHAL::realiseEndpoint;
+    HALPriv->ep0_in = &USBHAL::EP0in;
+    HALPriv->ep0_out = &USBHAL::EP0out;
+    HALPriv->ep0_read = &USBHAL::EP0read;
+    hpcd.pData = (void*)HALPriv;
+    HALPriv->epCallback[0] = &USBHAL::EP1_OUT_callback;
+    HALPriv->epCallback[1] = &USBHAL::EP1_IN_callback;
+    HALPriv->epCallback[2] = &USBHAL::EP2_OUT_callback;
+    HALPriv->epCallback[3] = &USBHAL::EP2_IN_callback;
+    HALPriv->epCallback[4] = &USBHAL::EP3_OUT_callback;
+    HALPriv->epCallback[5] = &USBHAL::EP3_IN_callback;
+    instance = this;
+    __HAL_RCC_GPIOA_CLK_ENABLE();
+    /* Configure USB DM pin. This is optional, and maintained only for user guidance. */
+    pin_function(PA_11, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF14_USB));
+    pin_function(PA_12, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF14_USB));
+    __HAL_RCC_GPIOG_CLK_ENABLE();
+    gpio_init_out(&HALPriv->usb_switch,PG_6);
+    /* Enable USB Clock */
+    __HAL_RCC_USB_CLK_ENABLE();
+    /* Enable SYSCFG Clock */
+    __HAL_RCC_SYSCFG_CLK_ENABLE();
+    hpcd.State = HAL_PCD_STATE_RESET;
+    HAL_PCD_Init(&hpcd);
+    /* hardcoded size of FIFO according definition*/
+    HAL_PCDEx_PMAConfig(&hpcd , 0x00 , PCD_SNG_BUF, 0x30);
+    HAL_PCDEx_PMAConfig(&hpcd , 0x80 , PCD_SNG_BUF, 0x70);
+#if 1
+    HAL_PCDEx_PMAConfig(&hpcd , 0x3, PCD_DBL_BUF, 0x018000b0);
+#else
+    HAL_PCDEx_PMAConfig(&hpcd , 0x3, PCD_SNG_BUF, 0x180);
+#endif
+    HAL_PCDEx_PMAConfig(&hpcd , 0x83, PCD_SNG_BUF, 0xb0);
+    NVIC_SetVector(USBHAL_IRQn,(uint32_t)&_usbisr);
+    NVIC_SetPriority(USBHAL_IRQn, 1);
+    HAL_PCD_Start(&hpcd);
+}
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/features/unsupported/USBDevice/USBDevice/TARGET_STM/USBHAL_STM32F769NI.h	Fri Feb 10 11:48:44 2017 -0600
@@ -0,0 +1,147 @@
+/* Copyright (c) 2016 mbed.org, MIT License
+*
+* 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.
+*/
+#ifndef USBHAL_STM32F769NI_H
+#define USBHAL_STM32F769NI_H
+#define USBHAL_IRQn  OTG_HS_IRQn
+/*  must be multiple of 4 bytes */
+#define NB_ENDPOINT 4
+#define MAXTRANSFER_SIZE  0x200
+#define FIFO_USB_RAM_SIZE (MAXTRANSFER_SIZE+MAX_PACKET_SIZE_EP0+MAX_PACKET_SIZE_EP1+MAX_PACKET_SIZE_EP2+MAX_PACKET_SIZE_EP3)
+#if (FIFO_USB_RAM_SIZE > 0x500)
+#error "FIFO dimensioning incorrect"
+#endif
+
+typedef struct
+{
+    USBHAL *inst;
+    void (USBHAL::*bus_reset)(void);
+    void (USBHAL::*sof)(int frame);
+    void (USBHAL::*connect_change)(unsigned int  connected);
+    void (USBHAL::*suspend_change)(unsigned int suspended);
+    void (USBHAL::*ep0_setup)(void);
+    void (USBHAL::*ep0_in)(void);
+    void (USBHAL::*ep0_out)(void);
+    void (USBHAL::*ep0_read)(void);
+    bool (USBHAL::*ep_realise)(uint8_t endpoint, uint32_t maxPacket, uint32_t flags);
+    bool (USBHAL::*epCallback[2*NB_ENDPOINT-2])(void);
+    /*  memorize dummy buffer used for reception */
+    uint32_t pBufRx[MAXTRANSFER_SIZE>>2];
+    uint32_t pBufRx0[MAX_PACKET_SIZE_EP0>>2];
+    uint8_t epComplete[2*NB_ENDPOINT];
+}USBHAL_Private_t;
+
+uint32_t HAL_PCDEx_GetTxFiFo(PCD_HandleTypeDef *hpcd, uint8_t fifo)
+{
+    uint32_t len;
+    if (fifo == 0) len = hpcd->Instance->DIEPTXF0_HNPTXFSIZ>>16;
+    else
+        len =  hpcd->Instance->DIEPTXF[fifo - 1] >> 16;
+    return len*4;
+}
+void HAL_PCD_SOFCallback(PCD_HandleTypeDef *hpcd) 
+{
+    USBHAL_Private_t *priv=((USBHAL_Private_t *)(hpcd->pData));
+    USBHAL *obj= priv->inst;
+    USB_OTG_GlobalTypeDef *USBx = hpcd->Instance;
+    uint32_t sofnum = (USBx_DEVICE->DSTS & USB_OTG_DSTS_FNSOF) >> 8;
+    void (USBHAL::*func)(int frame) = priv->sof;
+    /* fix me  call with same frame number */
+    (obj->*func)(sofnum);
+}
+
+
+USBHAL * USBHAL::instance;
+
+USBHAL::USBHAL(void) {
+    /*  init parameter  */
+    USBHAL_Private_t *HALPriv = new(USBHAL_Private_t);
+    hpcd.Instance = USB_OTG_HS;
+    memset(&hpcd.Init, 0, sizeof(hpcd.Init));
+    hpcd.Init.dev_endpoints = NB_ENDPOINT;
+    hpcd.Init.ep0_mps =   MAX_PACKET_SIZE_EP0;
+    hpcd.Init.phy_itface = PCD_PHY_ULPI;
+    hpcd.Init.Sof_enable = 0;
+
+    hpcd.Init.speed = PCD_SPEED_HIGH;
+    //hpcd.Init.vbus_sensing_enable = 0;
+    //hpcd.Init.lpm_enable = 0;
+    /*  pass instance for usage inside call back */
+    HALPriv->inst = this;
+    HALPriv->bus_reset = &USBHAL::busReset;
+    HALPriv->suspend_change = &USBHAL::suspendStateChanged;
+    HALPriv->connect_change = &USBHAL::connectStateChanged;
+    HALPriv->sof = &USBHAL::SOF;
+    HALPriv->ep0_setup = &USBHAL::EP0setupCallback;
+    HALPriv->ep_realise = &USBHAL::realiseEndpoint;
+    HALPriv->ep0_in = &USBHAL::EP0in;
+    HALPriv->ep0_out = &USBHAL::EP0out;
+    HALPriv->ep0_read = &USBHAL::EP0read;
+    hpcd.pData = (void*)HALPriv;
+    HALPriv->epCallback[0] = &USBHAL::EP1_OUT_callback;
+    HALPriv->epCallback[1] = &USBHAL::EP1_IN_callback;
+    HALPriv->epCallback[2] = &USBHAL::EP2_OUT_callback;
+    HALPriv->epCallback[3] = &USBHAL::EP2_IN_callback;
+    HALPriv->epCallback[4] = &USBHAL::EP3_OUT_callback;
+    HALPriv->epCallback[5] = &USBHAL::EP3_IN_callback;
+    instance = this;
+    /* Enable power and clocking */
+    __HAL_RCC_GPIOA_CLK_ENABLE();
+    __HAL_RCC_GPIOB_CLK_ENABLE();
+    __HAL_RCC_GPIOC_CLK_ENABLE();
+    __HAL_RCC_GPIOH_CLK_ENABLE();
+    __HAL_RCC_GPIOI_CLK_ENABLE();
+
+    pin_function(PA_5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF10_OTG_HS)); // CLK
+    pin_function(PA_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF10_OTG_HS)); // D0
+
+    pin_function(PB_0, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF10_OTG_HS)); // D1
+    pin_function(PB_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF10_OTG_HS)); // D2
+    pin_function(PB_5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF10_OTG_HS)); // D3
+    pin_function(PB_10, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF10_OTG_HS)); // D4
+    pin_function(PB_11, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF10_OTG_HS)); // D5
+    pin_function(PB_12, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF10_OTG_HS)); // D6
+    pin_function(PB_13, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF10_OTG_HS)); // D7
+
+    pin_function(PC_0, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF10_OTG_HS)); // STP
+    pin_function(PH_4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF10_OTG_HS)); // NXT
+    pin_function(PI_11, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF10_OTG_HS)); // DIR
+
+    __HAL_RCC_USB_OTG_HS_ULPI_CLK_ENABLE();
+    __HAL_RCC_USB_OTG_HS_CLK_ENABLE();
+
+    __HAL_RCC_SYSCFG_CLK_ENABLE();
+    hpcd.State = HAL_PCD_STATE_RESET;
+    HAL_PCD_Init(&hpcd);
+    /* 1.25kbytes */
+    /* min value 16 (= 16 x 4 bytes) */
+    /*  max value 256 (= 1K bytes ) */
+    /*  maximum sum is 0x140 */
+    HAL_PCDEx_SetRxFiFo(&hpcd, (MAXTRANSFER_SIZE/4));
+    /*  bulk/int 64 bytes in FS  */
+    HAL_PCDEx_SetTxFiFo(&hpcd, 0, (MAX_PACKET_SIZE_EP0/4)+1);
+    /*  bulk/int bytes in FS */
+    HAL_PCDEx_SetTxFiFo(&hpcd, 1, (MAX_PACKET_SIZE_EP1/4));
+    HAL_PCDEx_SetTxFiFo(&hpcd, 2, (MAX_PACKET_SIZE_EP2/4));
+    /* ISOchronous */
+    HAL_PCDEx_SetTxFiFo(&hpcd, 3, (MAX_PACKET_SIZE_EP3/4));
+    NVIC_SetVector(USBHAL_IRQn, (uint32_t)&_usbisr);
+    NVIC_SetPriority(USBHAL_IRQn, 1);
+    HAL_PCD_Start(&hpcd);
+}
+#endif
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/features/unsupported/USBDevice/USBDevice/TARGET_STM/USBHAL_STM32L476VG.h	Fri Feb 10 11:48:44 2017 -0600
@@ -0,0 +1,145 @@
+/* Copyright (c) 2016 mbed.org, MIT License
+*
+* 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.
+*/
+#ifndef USBHAL_STM32L476VG
+#define USBHAL_STM32L476VG
+
+#define USBHAL_IRQn  OTG_FS_IRQn
+
+
+#define NB_ENDPOINT  4
+/*  must be multiple of 4 bytes */
+#define MAXTRANSFER_SIZE  0x200
+#define FIFO_USB_RAM_SIZE (MAXTRANSFER_SIZE+MAX_PACKET_SIZE_EP0+MAX_PACKET_SIZE_EP1+MAX_PACKET_SIZE_EP2+MAX_PACKET_SIZE_EP3)
+#if (FIFO_USB_RAM_SIZE > 0x500)
+#error "FIFO dimensioning incorrect"
+#endif
+
+typedef struct
+{
+    USBHAL *inst;
+    void (USBHAL::*bus_reset)(void);
+    void (USBHAL::*sof)(int frame);
+    void (USBHAL::*connect_change)(unsigned int  connected);
+    void (USBHAL::*suspend_change)(unsigned int suspended);
+    void (USBHAL::*ep0_setup)(void);
+    void (USBHAL::*ep0_in)(void);
+    void (USBHAL::*ep0_out)(void);
+    void (USBHAL::*ep0_read)(void);
+    bool (USBHAL::*ep_realise)(uint8_t endpoint, uint32_t maxPacket, uint32_t flags);
+    bool (USBHAL::*epCallback[2*NB_ENDPOINT-2])(void);
+    uint8_t epComplete[8];
+    /*  memorize dummy buffer used for reception */
+    uint32_t pBufRx[MAXTRANSFER_SIZE>>2];
+    uint32_t pBufRx0[MAX_PACKET_SIZE_EP0>>2];
+}USBHAL_Private_t;
+
+uint32_t HAL_PCDEx_GetTxFiFo(PCD_HandleTypeDef *hpcd, uint8_t fifo)
+{
+    uint32_t len;
+    if (fifo == 0) len = hpcd->Instance->DIEPTXF0_HNPTXFSIZ>>16;
+    else
+        len =  hpcd->Instance->DIEPTXF[fifo - 1] >> 16;
+    return len*4;
+}
+void HAL_PCD_SOFCallback(PCD_HandleTypeDef *hpcd) {
+    USBHAL_Private_t *priv=((USBHAL_Private_t *)(hpcd->pData));
+    USBHAL *obj= priv->inst;
+    USB_OTG_GlobalTypeDef *USBx = hpcd->Instance;
+    uint32_t sofnum = (USBx_DEVICE->DSTS & USB_OTG_DSTS_FNSOF) >> 8;
+    void (USBHAL::*func)(int frame) = priv->sof;
+    /* fix me  call with same frame number */
+    (obj->*func)(sofnum);
+}
+
+USBHAL * USBHAL::instance;
+
+USBHAL::USBHAL(void) {
+    /*  init parameter  */
+    USBHAL_Private_t *HALPriv = new(USBHAL_Private_t);
+    /*  initialized all field of init including 0 field  */
+    /*  constructor does not fill with zero */
+    hpcd.Instance = USB_OTG_FS;
+    /*  initialized all field of init including 0 field  */
+    /*  constructor does not fill with zero */
+    memset(&hpcd.Init, 0, sizeof(hpcd.Init));
+    hpcd.Init.dev_endpoints = NB_ENDPOINT;
+    hpcd.Init.ep0_mps =   MAX_PACKET_SIZE_EP0;
+    hpcd.Init.phy_itface = PCD_PHY_EMBEDDED;
+    hpcd.Init.Sof_enable = 1;
+    hpcd.Init.speed = PCD_SPEED_FULL;
+    /*  pass instance for usage inside call back */
+    HALPriv->inst = this;
+    HALPriv->bus_reset = &USBHAL::busReset;
+    HALPriv->suspend_change = &USBHAL::suspendStateChanged;
+    HALPriv->connect_change = &USBHAL::connectStateChanged;
+    HALPriv->sof = &USBHAL::SOF;
+    HALPriv->ep0_setup = &USBHAL::EP0setupCallback;
+    HALPriv->ep_realise = &USBHAL::realiseEndpoint;
+    HALPriv->ep0_in = &USBHAL::EP0in;
+    HALPriv->ep0_out = &USBHAL::EP0out;
+    HALPriv->ep0_read = &USBHAL::EP0read;
+    hpcd.pData = (void*)HALPriv;
+    HALPriv->epCallback[0] = &USBHAL::EP1_OUT_callback;
+    HALPriv->epCallback[1] = &USBHAL::EP1_IN_callback;
+    HALPriv->epCallback[2] = &USBHAL::EP2_OUT_callback;
+    HALPriv->epCallback[3] = &USBHAL::EP2_IN_callback;
+    HALPriv->epCallback[4] = &USBHAL::EP3_OUT_callback;
+    HALPriv->epCallback[5] = &USBHAL::EP3_IN_callback;
+    instance = this;
+
+    __HAL_RCC_PWR_CLK_ENABLE();
+
+    HAL_PWREx_EnableVddUSB(); 
+    /* Configure USB VBUS GPIO */
+    __HAL_RCC_GPIOC_CLK_ENABLE();
+
+    /* Configure USB FS GPIOs */
+    __HAL_RCC_GPIOA_CLK_ENABLE();
+
+    /* Configure DM DP Pins */
+    pin_function(PA_11, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF10_OTG_FS));
+    pin_function(PA_12, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF10_OTG_FS));
+
+    /* Configure VBUS Pin */
+    pin_function(PC_11, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF10_OTG_FS));
+
+    __HAL_RCC_USB_OTG_FS_CLK_ENABLE();
+
+    hpcd.State = HAL_PCD_STATE_RESET;
+
+    HAL_PCD_Init(&hpcd);
+    /* 1.25kbytes */
+    /* min value 16 (= 16 x 4 bytes) */
+    /*  max value 256 (= 1K bytes ) */
+    /*  maximum sum is 0x140 */
+    HAL_PCDEx_SetRxFiFo(&hpcd, (MAXTRANSFER_SIZE/4));
+    /*  bulk/int 64 bytes in FS  */
+    HAL_PCDEx_SetTxFiFo(&hpcd, 0, (MAX_PACKET_SIZE_EP0/4)+1);
+    /*  bulk/int bytes in FS */
+    HAL_PCDEx_SetTxFiFo(&hpcd, 1, (MAX_PACKET_SIZE_EP1/4));
+    HAL_PCDEx_SetTxFiFo(&hpcd, 2, (MAX_PACKET_SIZE_EP2/4));
+    /* ISOchronous */
+    HAL_PCDEx_SetTxFiFo(&hpcd, 3, (MAX_PACKET_SIZE_EP3/4));
+
+    NVIC_SetVector(USBHAL_IRQn,(uint32_t)&_usbisr);
+    NVIC_SetPriority( USBHAL_IRQn, 1);
+
+    HAL_PCD_Start(&hpcd);
+}
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/features/unsupported/USBDevice/USBDevice/TARGET_STM/USBHAL_STM_144_64pins.h	Fri Feb 10 11:48:44 2017 -0600
@@ -0,0 +1,133 @@
+/* Copyright (c) 2016 mbed.org, MIT License
+*
+* 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.
+*/
+#ifndef USBHAL_STM32_144_64
+#define USBHAL_STM32_144_64
+
+#define USBHAL_IRQn  OTG_FS_IRQn
+/*  must be multiple of 4 bytes */
+#define NB_ENDPOINT 4
+#define MAXTRANSFER_SIZE  0x200
+#define FIFO_USB_RAM_SIZE (MAXTRANSFER_SIZE+MAX_PACKET_SIZE_EP0+MAX_PACKET_SIZE_EP1+MAX_PACKET_SIZE_EP2+MAX_PACKET_SIZE_EP3)
+#if (FIFO_USB_RAM_SIZE > 0x500)
+#error "FIFO dimensioning incorrect"
+#endif
+
+typedef struct
+{
+    USBHAL *inst;
+    void (USBHAL::*bus_reset)(void);
+    void (USBHAL::*sof)(int frame);
+    void (USBHAL::*connect_change)(unsigned int  connected);
+    void (USBHAL::*suspend_change)(unsigned int suspended);
+    void (USBHAL::*ep0_setup)(void);
+    void (USBHAL::*ep0_in)(void);
+    void (USBHAL::*ep0_out)(void);
+    void (USBHAL::*ep0_read)(void);
+    bool (USBHAL::*ep_realise)(uint8_t endpoint, uint32_t maxPacket, uint32_t flags);
+    bool (USBHAL::*epCallback[2*NB_ENDPOINT-2])(void);
+    /*  memorize dummy buffer used for reception */
+    uint32_t pBufRx[MAXTRANSFER_SIZE>>2];
+    uint32_t pBufRx0[MAX_PACKET_SIZE_EP0>>2];
+    uint8_t epComplete[2*NB_ENDPOINT];
+}USBHAL_Private_t;
+
+uint32_t HAL_PCDEx_GetTxFiFo(PCD_HandleTypeDef *hpcd, uint8_t fifo)
+{
+    uint32_t len;
+    if (fifo == 0) len = hpcd->Instance->DIEPTXF0_HNPTXFSIZ>>16;
+    else
+        len =  hpcd->Instance->DIEPTXF[fifo - 1] >> 16;
+    return len*4;
+}
+void HAL_PCD_SOFCallback(PCD_HandleTypeDef *hpcd) 
+{
+    USBHAL_Private_t *priv=((USBHAL_Private_t *)(hpcd->pData));
+    USBHAL *obj= priv->inst;
+    USB_OTG_GlobalTypeDef *USBx = hpcd->Instance;
+    uint32_t sofnum = (USBx_DEVICE->DSTS & USB_OTG_DSTS_FNSOF) >> 8;
+    void (USBHAL::*func)(int frame) = priv->sof;
+    /* fix me  call with same frame number */
+    (obj->*func)(sofnum);
+}
+
+
+USBHAL * USBHAL::instance;
+
+USBHAL::USBHAL(void) {
+    /*  init parameter  */
+    USBHAL_Private_t *HALPriv = new(USBHAL_Private_t);
+    hpcd.Instance = USB_OTG_FS;
+    memset(&hpcd.Init, 0, sizeof(hpcd.Init));
+    hpcd.Init.dev_endpoints = NB_ENDPOINT;
+    hpcd.Init.ep0_mps =   MAX_PACKET_SIZE_EP0;
+    hpcd.Init.phy_itface = PCD_PHY_EMBEDDED;
+    hpcd.Init.Sof_enable = 1;
+
+    hpcd.Init.speed = PCD_SPEED_FULL;
+    //hpcd.Init.vbus_sensing_enable = 0;
+    //hpcd.Init.lpm_enable = 0;
+    /*  pass instance for usage inside call back */
+    HALPriv->inst = this;
+    HALPriv->bus_reset = &USBHAL::busReset;
+    HALPriv->suspend_change = &USBHAL::suspendStateChanged;
+    HALPriv->connect_change = &USBHAL::connectStateChanged;
+    HALPriv->sof = &USBHAL::SOF;
+    HALPriv->ep0_setup = &USBHAL::EP0setupCallback;
+    HALPriv->ep_realise = &USBHAL::realiseEndpoint;
+    HALPriv->ep0_in = &USBHAL::EP0in;
+    HALPriv->ep0_out = &USBHAL::EP0out;
+    HALPriv->ep0_read = &USBHAL::EP0read;
+    hpcd.pData = (void*)HALPriv;
+    HALPriv->epCallback[0] = &USBHAL::EP1_OUT_callback;
+    HALPriv->epCallback[1] = &USBHAL::EP1_IN_callback;
+    HALPriv->epCallback[2] = &USBHAL::EP2_OUT_callback;
+    HALPriv->epCallback[3] = &USBHAL::EP2_IN_callback;
+    HALPriv->epCallback[4] = &USBHAL::EP3_OUT_callback;
+    HALPriv->epCallback[5] = &USBHAL::EP3_IN_callback;
+    instance = this;
+    // Enable power and clocking
+    /*  board 144 pin all similar  */
+    __HAL_RCC_GPIOA_CLK_ENABLE();
+    pin_function(PA_8, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF10_OTG_FS));
+    pin_function(PA_9, STM_PIN_DATA(STM_MODE_INPUT, GPIO_NOPULL, GPIO_AF10_OTG_FS));
+    pin_function(PA_10, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_PULLUP, GPIO_AF10_OTG_FS));
+    pin_function(PA_11, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF10_OTG_FS));
+    pin_function(PA_12, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF10_OTG_FS));
+
+    __HAL_RCC_USB_OTG_FS_CLK_ENABLE();
+    __HAL_RCC_SYSCFG_CLK_ENABLE();
+    hpcd.State = HAL_PCD_STATE_RESET;
+    HAL_PCD_Init(&hpcd);
+    /* 1.25kbytes */
+    /* min value 16 (= 16 x 4 bytes) */
+    /*  max value 256 (= 1K bytes ) */
+    /*  maximum sum is 0x140 */
+    HAL_PCDEx_SetRxFiFo(&hpcd, (MAXTRANSFER_SIZE/4));
+    /*  bulk/int 64 bytes in FS  */
+    HAL_PCDEx_SetTxFiFo(&hpcd, 0, (MAX_PACKET_SIZE_EP0/4)+1);
+    /*  bulk/int bytes in FS */
+    HAL_PCDEx_SetTxFiFo(&hpcd, 1, (MAX_PACKET_SIZE_EP1/4));
+    HAL_PCDEx_SetTxFiFo(&hpcd, 2, (MAX_PACKET_SIZE_EP2/4));
+    /* ISOchronous */
+    HAL_PCDEx_SetTxFiFo(&hpcd, 3, (MAX_PACKET_SIZE_EP3/4));
+    NVIC_SetVector(USBHAL_IRQn, (uint32_t)&_usbisr);
+    NVIC_SetPriority(USBHAL_IRQn, 1);
+    HAL_PCD_Start(&hpcd);
+}
+#endif
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/features/unsupported/USBDevice/USBDevice/TARGET_STM/USBHAL_STM_TARGET.h	Fri Feb 10 11:48:44 2017 -0600
@@ -0,0 +1,41 @@
+/* Copyright (c) 2016 mbed.org, MIT License
+*
+* 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.
+*/
+
+#ifdef TARGET_STM32F303ZE
+#include "USBHAL_STM32F303ZE.h"
+#endif
+
+#if defined(TARGET_STM32F207ZG) || \
+    defined(TARGET_STM32F401RE) || \
+    defined(TARGET_STM32F407VG) || \
+    defined(TARGET_STM32F411RE) || \
+    defined(TARGET_STM32F412ZG) || \
+    defined(TARGET_STM32F429ZI) || \
+    defined(TARGET_STM32F446ZE) || \
+    defined(TARGET_STM32F746ZG) || \
+    defined(TARGET_STM32F767ZI)
+#include "USBHAL_STM_144_64pins.h"
+#endif
+
+#ifdef TARGET_STM32L476VG
+#include "USBHAL_STM32L476VG.h"
+#endif
+
+#ifdef TARGET_STM32F769NI
+#include "USBHAL_STM32F769NI.h"
+#endif
--- a/features/unsupported/USBDevice/USBDevice/USBEndpoints.h	Thu Feb 09 10:05:54 2017 -0600
+++ b/features/unsupported/USBDevice/USBDevice/USBEndpoints.h	Fri Feb 10 11:48:44 2017 -0600
@@ -45,7 +45,7 @@
 #include "USBEndpoints_KL25Z.h"
 #elif !defined(USB_STM_HAL) && defined(TARGET_STM32F4)
 #include "USBEndpoints_STM32F4.h"
-#elif defined (TARGET_STM32F4) || defined (TARGET_STM32F2) || defined (TARGET_STM32F7) || defined (TARGET_STM32F3) || defined(TARGET_STM32L4) || defined(TARGET_STM32F1)
+#elif defined (TARGET_STM32F4) || defined (TARGET_STM32F2) || defined (TARGET_STM32F7) || defined (TARGET_STM32F3) || defined(TARGET_STM32L4)
 #include "USBEndpoints_STM32.h"
 #elif defined (TARGET_RZ_A1H) || defined (TARGET_VK_RZ_A1H)
 #include "USBEndpoints_RZ_A1H.h"
--- a/features/unsupported/USBDevice/USBDevice/USBHAL.h	Thu Feb 09 10:05:54 2017 -0600
+++ b/features/unsupported/USBDevice/USBDevice/USBHAL.h	Fri Feb 10 11:48:44 2017 -0600
@@ -130,7 +130,7 @@
     bool (USBHAL::*epCallback[10 - 2])(void);
 #elif (defined(TARGET_STM32F4) && !defined(USB_STM_HAL)) || defined(TARGET_NUMAKER_PFM_M453)
     bool (USBHAL::*epCallback[8 - 2])(void);
-#elif defined(TARGET_STM)
+#elif defined(TARGET_STM32F4) || defined(TARGET_STM32F3) || defined (TARGET_STM32F2)|| defined(TARGET_STM32L4) || defined(TARGET_STM32F7)
     PCD_HandleTypeDef hpcd;
 #elif defined(TARGET_NUMAKER_PFM_NUC472)
     bool (USBHAL::*epCallback[14 - 2])(void);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/features/unsupported/USBHost/USBHost/TARGET_STM/USBHALHost_DISCOF429ZI.h	Fri Feb 10 11:48:44 2017 -0600
@@ -0,0 +1,112 @@
+/* mbed USBHost Library
+ * Copyright (c) 2006-2013 ARM Limited
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifndef USBHALHOST_DISCOF429ZI
+#define USBHALHOST_DISCOF429ZI
+
+#define USBHAL_IRQn  OTG_HS_IRQn
+
+#define HCCA_SIZE sizeof(HCD_HandleTypeDef)
+#define ED_SIZE  sizeof(HCED)
+#define TD_SIZE  sizeof(HCTD)
+
+#define TOTAL_SIZE (HCCA_SIZE + (MAX_ENDPOINT*ED_SIZE) + (MAX_TD*TD_SIZE))
+/* STM device FS have 11 channels  (definition is for 60 channels) */
+static volatile  uint8_t usb_buf[TOTAL_SIZE];
+typedef struct
+{
+    /* store the request ongoing on each endpoit  */
+    /*  1st field of structure avoid  giving knowledge of all structure to
+     *  endpoint */
+    volatile uint32_t addr[MAX_ENDPOINT];
+    USBHALHost *inst;
+    void (USBHALHost::*deviceConnected)(int hub, int port, bool lowSpeed, USBHostHub * hub_parent);
+    void (USBHALHost::*deviceDisconnected)(int hub, int port, USBHostHub * hub_parent, volatile uint32_t addr);
+    void (USBHALHost::*transferCompleted)(volatile uint32_t addr);
+}USBHALHost_Private_t;
+/*  CONFIGURATION for USB_VBUS  
+ *  on 64 bits board PC_0 is used  (0  VBUS on,  1 VBUS off)
+ *  on 144 pins board PG_6 is used ( 1 VBUS on, 0 VBUS on)
+ */
+static gpio_t gpio_vbus;
+
+#define  VBUS_OFF 1
+#define  VBUS_ON 0
+#define USB_VBUS_CONFIG \
+    do {__HAL_RCC_GPIOC_CLK_ENABLE();\
+		gpio_init_out_ex(&gpio_vbus, PC_4, VBUS_OFF);\
+	}while(0);
+
+
+void  usb_vbus( uint8_t state)
+{
+    if(state == 0)
+    {
+        gpio_write(&gpio_vbus, VBUS_OFF);
+    }
+    else
+    {
+        gpio_write(&gpio_vbus, VBUS_ON);
+    }
+    wait(0.2);
+}
+
+
+USBHALHost::USBHALHost() {
+    gpio_t  pin_vbus;
+    instHost = this;
+    HCD_HandleTypeDef *hhcd;
+    USBHALHost_Private_t *HALPriv = new(USBHALHost_Private_t);
+    memset(HALPriv, 0, sizeof(USBHALHost_Private_t));
+    memInit();
+    memset((void*)usb_hcca, 0, HCCA_SIZE);
+    hhcd = (HCD_HandleTypeDef *)usb_hcca;
+    hhcd->Instance = USB_OTG_HS;
+    hhcd->pData = (void*)HALPriv;
+    hhcd->Init.Host_channels = 11;
+    /*   for now failed with dma */
+    hhcd->Init.dma_enable = 0;
+    hhcd->Init.speed = HCD_SPEED_HIGH;
+    hhcd->Init.phy_itface = HCD_PHY_EMBEDDED;
+    hhcd->Init.use_external_vbus = 1;
+    HALPriv->inst = this;
+    HALPriv->deviceConnected = &USBHALHost::deviceConnected;
+    HALPriv->deviceDisconnected = &USBHALHost::deviceDisconnected;
+    HALPriv->transferCompleted = &USBHALHost::transferCompleted;
+    for (int i = 0; i < MAX_ENDPOINT; i++) {
+        edBufAlloc[i] = false;
+        HALPriv->addr[i]=(uint32_t)-1;
+    }
+    for (int i = 0; i < MAX_TD; i++) {
+        tdBufAlloc[i] = false;
+    }
+    /* Configure USB HS GPIOs */
+    __HAL_RCC_GPIOB_CLK_ENABLE();
+
+    /*USB DM and DP */
+    pin_function(PB_14, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF12_OTG_HS_FS));
+    pin_function(PB_15, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF12_OTG_HS_FS));
+    /* Configure  VBUS Pin */
+    gpio_init_in(&pin_vbus, PB_13);
+    /* Configure POWER_SWITCH IO pin */
+    USB_VBUS_CONFIG;
+    /* Enable USB HS Clocks */
+    __HAL_RCC_USB_OTG_HS_CLK_ENABLE();
+
+    /* Set USBFS Interrupt priority */
+    HAL_NVIC_SetPriority(USBHAL_IRQn, 5, 0);
+    NVIC_SetVector(USBHAL_IRQn, (uint32_t)&_usbisr);
+}
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/features/unsupported/USBHost/USBHost/TARGET_STM/USBHALHost_DISCOL476VG.h	Fri Feb 10 11:48:44 2017 -0600
@@ -0,0 +1,118 @@
+/* Copyright (c) 2016 mbed.org, MIT License
+*
+* 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.
+*/
+#ifndef USBHALHOST_DISCOL476VG
+#define USBHALHOST_DISCOL476VG
+
+#define USBHAL_IRQn  OTG_FS_IRQn
+
+#define HCCA_SIZE sizeof(HCD_HandleTypeDef)
+#define ED_SIZE  sizeof(HCED)
+#define TD_SIZE  sizeof(HCTD)
+
+#define TOTAL_SIZE (HCCA_SIZE + (MAX_ENDPOINT*ED_SIZE) + (MAX_TD*TD_SIZE))
+/* STM device FS have 11 channels  (definition is for 60 channels) */
+static volatile  uint8_t usb_buf[TOTAL_SIZE];
+typedef struct
+{
+    /* store the request ongoing on each endpoit  */
+    /*  1st field of structure avoid  giving knowledge of all structure to
+     *  endpoint */
+    volatile uint32_t addr[MAX_ENDPOINT];
+    USBHALHost *inst;
+    void (USBHALHost::*deviceConnected)(int hub, int port, bool lowSpeed, USBHostHub * hub_parent);
+    void (USBHALHost::*deviceDisconnected)(int hub, int port, USBHostHub * hub_parent, volatile uint32_t addr);
+    void (USBHALHost::*transferCompleted)(volatile uint32_t addr);
+}USBHALHost_Private_t;
+
+static gpio_t gpio_vbus;
+
+#define  VBUS_OFF 1
+#define  VBUS_ON 0
+#define USB_VBUS_CONFIG \
+    do {\
+		gpio_init_out_ex(&gpio_vbus, PC_9, VBUS_OFF);\
+	}while(0);
+
+
+void  usb_vbus( uint8_t state)
+{
+    if(state == 0)
+    {
+        gpio_write(&gpio_vbus, VBUS_OFF);
+    }
+    else
+    {
+        gpio_write(&gpio_vbus, VBUS_ON);
+    }
+    wait(0.2);
+}
+
+
+USBHALHost::USBHALHost() {
+    instHost = this;
+    HCD_HandleTypeDef *hhcd;
+    USBHALHost_Private_t *HALPriv = new(USBHALHost_Private_t);
+    memset(HALPriv, 0, sizeof(USBHALHost_Private_t));
+    memInit();
+    memset((void*)usb_hcca, 0, HCCA_SIZE);
+    hhcd = (HCD_HandleTypeDef *)usb_hcca;
+    hhcd->Instance = USB_OTG_FS;
+    hhcd->pData = (void*)HALPriv;
+    hhcd->Init.Host_channels = 11;
+    /*   for now failed with dma */
+    hhcd->Init.dma_enable = 0;
+    hhcd->Init.speed =  HCD_SPEED_FULL;
+    hhcd->Init.phy_itface = HCD_PHY_EMBEDDED;
+    hhcd->Init.use_external_vbus = 1;
+    HALPriv->inst = this;
+    HALPriv->deviceConnected = &USBHALHost::deviceConnected;
+    HALPriv->deviceDisconnected = &USBHALHost::deviceDisconnected;
+    HALPriv->transferCompleted = &USBHALHost::transferCompleted;
+    for (int i = 0; i < MAX_ENDPOINT; i++) {
+        edBufAlloc[i] = false;
+        HALPriv->addr[i]=(uint32_t)-1;
+    }
+    for (int i = 0; i < MAX_TD; i++) {
+        tdBufAlloc[i] = false;
+    }
+    __HAL_RCC_PWR_CLK_ENABLE();
+#ifdef TARGET_STM32L4
+    HAL_PWREx_EnableVddUSB();
+#endif
+
+    /* Configure USB HS GPIOs */
+    __HAL_RCC_GPIOA_CLK_ENABLE();
+
+    /*USB DM and DP */
+    pin_function(PA_11, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF10_OTG_FS));
+    pin_function(PA_12, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF10_OTG_FS));
+
+    /* Configure  VBUS Pin */
+    __HAL_RCC_GPIOC_CLK_ENABLE();
+    pin_function(PC_11, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF10_OTG_FS));
+    /* Configure POWER_SWITCH IO pin */
+    USB_VBUS_CONFIG;
+    __HAL_RCC_SYSCFG_CLK_ENABLE();
+
+    /* Enable USB FS Clocks */
+    __HAL_RCC_USB_OTG_FS_CLK_ENABLE();
+    /* Set USBFS Interrupt priority */
+    HAL_NVIC_SetPriority(USBHAL_IRQn, 5, 0);
+    NVIC_SetVector(USBHAL_IRQn, (uint32_t)&_usbisr);
+}
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/features/unsupported/USBHost/USBHost/TARGET_STM/USBHALHost_STM_144_64pins.h	Fri Feb 10 11:48:44 2017 -0600
@@ -0,0 +1,121 @@
+/* mbed USBHost Library
+ * Copyright (c) 2006-2013 ARM Limited
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifndef USBHALHOST_STM32_144_64
+#define USBHALHOST_STM32_144_64
+
+#define USBHAL_IRQn  OTG_FS_IRQn
+
+#define HCCA_SIZE sizeof(HCD_HandleTypeDef)
+#define ED_SIZE  sizeof(HCED)
+#define TD_SIZE  sizeof(HCTD)
+
+#define TOTAL_SIZE (HCCA_SIZE + (MAX_ENDPOINT*ED_SIZE) + (MAX_TD*TD_SIZE))
+/* STM device FS have 11 channels  (definition is for 60 channels) */
+static volatile  uint8_t usb_buf[TOTAL_SIZE];
+typedef struct
+{
+	/* store the request ongoing on each endpoit  */
+	/*  1st field of structure avoid  giving knowledge of all structure to
+	 *  endpoint */
+	volatile uint32_t addr[MAX_ENDPOINT];
+	USBHALHost *inst;
+	void (USBHALHost::*deviceConnected)(int hub, int port, bool lowSpeed, USBHostHub * hub_parent);
+	void (USBHALHost::*deviceDisconnected)(int hub, int port, USBHostHub * hub_parent, volatile uint32_t addr);
+	void (USBHALHost::*transferCompleted)(volatile uint32_t addr);
+}USBHALHost_Private_t;
+
+/*  CONFIGURATION for USB_VBUS  
+ *  on 64 bits board PC_0 is used  (0  VBUS on,  1 VBUS off)
+ *  on 144 pins board PG_6 is used ( 1 VBUS on, 0 VBUS on)
+ */
+static gpio_t gpio_vbus;
+
+#if defined(USBHALHOST_64pins)
+#define  VBUS_OFF 1
+#define  VBUS_ON 0
+#define USB_VBUS_CONFIG \
+    do {__HAL_RCC_GPIOC_CLK_ENABLE();\
+		gpio_init_out_ex(&gpio_vbus, PC_0, VBUS_OFF);\
+	}while(0);
+#else
+#define  VBUS_OFF 0
+#define  VBUS_ON 1
+#define USB_VBUS_CONFIG \
+    do {__HAL_RCC_GPIOG_CLK_ENABLE();\
+		gpio_init_out_ex(&gpio_vbus, PG_6, VBUS_OFF);\
+	}while(0);
+#endif
+
+void  usb_vbus( uint8_t state)
+{
+    if(state == 0)
+    {
+        gpio_write(&gpio_vbus, VBUS_OFF);
+    }
+    else
+    {
+        gpio_write(&gpio_vbus, VBUS_ON);
+    }
+    wait(0.2);
+}
+
+USBHALHost::USBHALHost() {
+    instHost = this;
+    HCD_HandleTypeDef *hhcd;
+    USBHALHost_Private_t *HALPriv = new(USBHALHost_Private_t);
+    memset(HALPriv, 0, sizeof(USBHALHost_Private_t));
+    memInit();
+    memset((void*)usb_hcca, 0, HCCA_SIZE);
+    hhcd = (HCD_HandleTypeDef *)usb_hcca;
+    hhcd->Instance = USB_OTG_FS;
+    hhcd->pData = (void*)HALPriv;
+    hhcd->Init.Host_channels = 11;
+    hhcd->Init.speed = HCD_SPEED_FULL; 
+    hhcd->Init.phy_itface = HCD_PHY_EMBEDDED;
+    HALPriv->inst = this;
+    HALPriv->deviceConnected = &USBHALHost::deviceConnected;
+    HALPriv->deviceDisconnected = &USBHALHost::deviceDisconnected;
+    HALPriv->transferCompleted = &USBHALHost::transferCompleted;
+    for (int i = 0; i < MAX_ENDPOINT; i++) {
+        edBufAlloc[i] = false;
+        HALPriv->addr[i]=(uint32_t)-1;
+    }
+    for (int i = 0; i < MAX_TD; i++) {
+        tdBufAlloc[i] = false;
+    }
+    __HAL_RCC_PWR_CLK_ENABLE();
+#ifdef TARGET_STM32L4
+    HAL_PWREx_EnableVddUSB();
+#endif
+    /* Configure USB FS GPIOs */
+    __HAL_RCC_GPIOA_CLK_ENABLE();
+
+    /*USB DM and DP */
+    pin_function(PA_11, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF10_OTG_FS));
+    pin_function(PA_12, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF10_OTG_FS));
+    /*USB ID */
+    pin_function(PA_10, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_PULLUP, GPIO_AF10_OTG_FS));
+
+    __HAL_RCC_SYSCFG_CLK_ENABLE();
+    /* Configure POWER_SWITCH IO pin */
+    USB_VBUS_CONFIG;
+    /* Enable USB FS Clocks */
+    __HAL_RCC_USB_OTG_FS_CLK_ENABLE();
+
+    /* Set USBFS Interrupt priority */
+    HAL_NVIC_SetPriority(OTG_FS_IRQn, 6, 0);
+}
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/features/unsupported/USBHost/USBHost/TARGET_STM/USBHALHost_STM_TARGET.h	Fri Feb 10 11:48:44 2017 -0600
@@ -0,0 +1,39 @@
+/* Copyright (c) 2016 mbed.org, MIT License
+*
+* 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.
+*/
+
+/*  144 pins boards */
+#if defined(TARGET_NUCLEO_F429ZI) || defined(TARGET_NUCLEO_F446ZE)  || defined(TARGET_NUCLEO_F207ZG) \
+|| defined(TARGET_NUCLEO_F767ZI) || defined(TARGET_NUCLEO_F746ZG) || defined(TARGET_NUCLEO_F412ZG)
+#include "USBHALHost_STM_144_64pins.h"
+#endif
+
+/*  64 pins boards */
+#if defined(TARGET_NUCLEO_F401RE) || defined(TARGET_NUCLEO_L476RG) || defined(TARGET_NUCLEO_F411RE)
+#define USBHALHOST_64pins
+#include "USBHALHost_STM_144_64pins.h"
+#endif
+
+/*  DISCO board  */
+
+#ifdef TARGET_DISCO_F429ZI
+#include "USBHALHost_DISCOF429ZI.h"
+#endif
+
+#ifdef TARGET_DISCO_L476VG
+#include "USBHALHost_DISCOL476VG.h"
+#endif
--- a/targets/TARGET_STM/TARGET_STM32F1/TARGET_NUCLEO_F103RB/USBHAL_STM32F103RB.h	Thu Feb 09 10:05:54 2017 -0600
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,143 +0,0 @@
-/* Copyright (c) 2016 mbed.org, MIT License
-*
-* 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.
-*/
-#ifndef USBHAL_STM32F103RB
-#define USBHAL_STM32F103RB
-
-#define USBHAL_IRQn  USB_LP_CAN1_RX0_IRQn
-
-
-#define NB_ENDPOINT  8
-/*  must be multiple of 4 bytes */
-#define MAXTRANSFER_SIZE  0x200
-#define FIFO_USB_RAM_SIZE (MAXTRANSFER_SIZE+MAX_PACKET_SIZE_EP0+MAX_PACKET_SIZE_EP1+MAX_PACKET_SIZE_EP2+MAX_PACKET_SIZE_EP3)
-#if (FIFO_USB_RAM_SIZE > 0x500)
-#error "FIFO dimensioning incorrect"
-#endif
-
-typedef struct
-{
-    USBHAL *inst;
-    void (USBHAL::*bus_reset)(void);
-    void (USBHAL::*sof)(int frame);
-    void (USBHAL::*connect_change)(unsigned int  connected);
-    void (USBHAL::*suspend_change)(unsigned int suspended);
-    void (USBHAL::*ep0_setup)(void);
-    void (USBHAL::*ep0_in)(void);
-    void (USBHAL::*ep0_out)(void);
-    void (USBHAL::*ep0_read)(void);
-    bool (USBHAL::*ep_realise)(uint8_t endpoint, uint32_t maxPacket, uint32_t flags);
-    bool (USBHAL::*epCallback[2*NB_ENDPOINT-2])(void);
-    uint8_t epComplete[8];
-    /*  memorize dummy buffer used for reception */
-    uint32_t pBufRx[MAXTRANSFER_SIZE>>2];
-    uint32_t pBufRx0[MAX_PACKET_SIZE_EP0>>2];
-	gpio_t usb_switch;
-}USBHAL_Private_t;
-
-void HAL_PCDEx_SetConnectionState(PCD_HandleTypeDef *hpcd, uint8_t state){
-    USBHAL_Private_t *priv=((USBHAL_Private_t *)(hpcd->pData));
-    gpio_write(&(priv->usb_switch),!state);
-}
-
-uint32_t HAL_PCDEx_GetTxFiFo(PCD_HandleTypeDef *hpcd, uint8_t fifo)
-{
-    return 1024;
-}
-void HAL_PCD_SOFCallback(PCD_HandleTypeDef *hpcd) {
-    USBHAL_Private_t *priv=((USBHAL_Private_t *)(hpcd->pData));
-    USBHAL *obj= priv->inst;
-    uint32_t sofnum = (hpcd->Instance->FNR) & USB_FNR_FN;
-    void (USBHAL::*func)(int frame) = priv->sof;
-    /* fix me  call with same frame number */
-    (obj->*func)(sofnum);
-}
-
-USBHAL * USBHAL::instance;
-
-USBHAL::USBHAL(void) {
-    /*  init parameter  */
-    USBHAL_Private_t *HALPriv = new(USBHAL_Private_t);
-    /*  initialized all field of init including 0 field  */
-    /*  constructor does not fill with zero */
-    hpcd.Instance = USB;
-    /*  initialized all field of init including 0 field  */
-    /*  constructor does not fill with zero */
-    memset(&hpcd.Init, 0, sizeof(hpcd.Init));
-    hpcd.Init.dev_endpoints = NB_ENDPOINT;
-    hpcd.Init.ep0_mps =   MAX_PACKET_SIZE_EP0;
-    hpcd.Init.phy_itface = PCD_PHY_EMBEDDED;
-    hpcd.Init.Sof_enable = 1;
-    hpcd.Init.speed = PCD_SPEED_FULL;
-    /*  pass instance for usage inside call back */
-    HALPriv->inst = this;
-    HALPriv->bus_reset = &USBHAL::busReset;
-    HALPriv->suspend_change = &USBHAL::suspendStateChanged;
-    HALPriv->connect_change = &USBHAL::connectStateChanged;
-    HALPriv->sof = &USBHAL::SOF;
-    HALPriv->ep0_setup = &USBHAL::EP0setupCallback;
-    HALPriv->ep_realise = &USBHAL::realiseEndpoint;
-    HALPriv->ep0_in = &USBHAL::EP0in;
-    HALPriv->ep0_out = &USBHAL::EP0out;
-    HALPriv->ep0_read = &USBHAL::EP0read;
-    hpcd.pData = (void*)HALPriv;
-    HALPriv->epCallback[0] = &USBHAL::EP1_OUT_callback;
-    HALPriv->epCallback[1] = &USBHAL::EP1_IN_callback;
-    HALPriv->epCallback[2] = &USBHAL::EP2_OUT_callback;
-    HALPriv->epCallback[3] = &USBHAL::EP2_IN_callback;
-    HALPriv->epCallback[4] = &USBHAL::EP3_OUT_callback;
-    HALPriv->epCallback[5] = &USBHAL::EP3_IN_callback;
-    instance = this;
-
-
-    /* Configure USB VBUS GPIO */
-    gpio_init_out(&HALPriv->usb_switch,PB_14);
-	gpio_mode(&HALPriv->usb_switch,OpenDrain);
-    /* Configure USB FS GPIOs */
-
-    /* Configure DM DP Pins */
- /*   - USB-DP (D+ of the USB connector) <======> PA12 (Nucleo board)
-  Make sure to connect a 1.5KOhm pull up to USB-DP PA12 pin (permanent pull-up)
-     - USB-DM (D- of the USB connector) <======> PA11 (Nucleo board) */
-	
-    pin_function(PA_11, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_MODE_AF_INPUT));
-    pin_function(PA_12, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_MODE_AF_INPUT));
-
-     __HAL_RCC_USB_CLK_ENABLE();
-
-    hpcd.State = HAL_PCD_STATE_RESET;
-
-    HAL_PCD_Init(&hpcd);
-    /* hardcoded size of FIFO according definition*/
-    HAL_PCDEx_PMAConfig(&hpcd , 0x00 , PCD_SNG_BUF, 0x30);
-    HAL_PCDEx_PMAConfig(&hpcd , 0x80 , PCD_SNG_BUF, 0x70);
-	HAL_PCDEx_PMAConfig(&hpcd , 0x01 , PCD_SNG_BUF, 0x90);
-    HAL_PCDEx_PMAConfig(&hpcd , 0x81 , PCD_SNG_BUF, 0xb0);
-#if 0
-    HAL_PCDEx_PMAConfig(&hpcd , 0x2, PCD_DBL_BUF, 0x018000b0);
-#else
-    HAL_PCDEx_PMAConfig(&hpcd , 0x2, PCD_SNG_BUF, 0x100);
-#endif
-    HAL_PCDEx_PMAConfig(&hpcd , 0x82, PCD_SNG_BUF, 0x120);
-
-    NVIC_SetVector(USBHAL_IRQn,(uint32_t)&_usbisr);
-    NVIC_SetPriority( USBHAL_IRQn, 1);
-
-    HAL_PCD_Start(&hpcd);
-}
-
-#endif
--- a/targets/TARGET_STM/TARGET_STM32F1/TARGET_NUCLEO_F103RB/USBHAL_STM_TARGET.h	Thu Feb 09 10:05:54 2017 -0600
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,19 +0,0 @@
-/* Copyright (c) 2016 mbed.org, MIT License
-*
-* 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.
-*/
-#include "USBHAL_STM32F103RB.h"
-
--- a/targets/TARGET_STM/TARGET_STM32F2/TARGET_NUCLEO_F207ZG/USBHALHost_STM_TARGET.h	Thu Feb 09 10:05:54 2017 -0600
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,19 +0,0 @@
-/* Copyright (c) 2016 mbed.org, MIT License
-*
-* 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.
-*/
-#include "USBHALHost_STM_144_64pins.h"
-
--- a/targets/TARGET_STM/TARGET_STM32F2/TARGET_NUCLEO_F207ZG/USBHAL_STM_TARGET.h	Thu Feb 09 10:05:54 2017 -0600
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,19 +0,0 @@
-/* Copyright (c) 2016 mbed.org, MIT License
-*
-* 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.
-*/
-#include "USBHAL_STM_144_64pins.h"
-
--- a/targets/TARGET_STM/TARGET_STM32F3/TARGET_NUCLEO_F303ZE/USBHAL_STM32F303ZE.h	Thu Feb 09 10:05:54 2017 -0600
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,128 +0,0 @@
-/* Copyright (c) 2016 mbed.org, MIT License
-*
-* 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.
-*/
-#ifndef USBHAL_STM32F303ZE_H
-#define USBHAL_STM32F303ZE_H
-#define USBHAL_IRQn  USB_LP_CAN_RX0_IRQn
-/*  must be multiple of 4 bytes */
-#define NB_ENDPOINT 8
-#define MAXTRANSFER_SIZE  0x200
-#define FIFO_USB_RAM_SIZE (MAXTRANSFER_SIZE+MAX_PACKET_SIZE_EP0+MAX_PACKET_SIZE_EP1+MAX_PACKET_SIZE_EP2+MAX_PACKET_SIZE_EP3)
-#if (FIFO_USB_RAM_SIZE > 0x500)
-#error "FIFO dimensioning incorrect"
-#endif
-
-typedef struct
-{
-	USBHAL *inst;
-	void (USBHAL::*bus_reset)(void);
-	void (USBHAL::*sof)(int frame);
-	void (USBHAL::*connect_change)(unsigned int  connected);
-	void (USBHAL::*suspend_change)(unsigned int suspended);
-	void (USBHAL::*ep0_setup)(void);
-	void (USBHAL::*ep0_in)(void);
-	void (USBHAL::*ep0_out)(void);
-	void (USBHAL::*ep0_read)(void);
-	bool (USBHAL::*ep_realise)(uint8_t endpoint, uint32_t maxPacket, uint32_t flags);
-	bool (USBHAL::*epCallback[6])(void);
-	uint8_t epComplete[2*NB_ENDPOINT];
-	/*  memorize dummy buffer used for reception */
-	uint32_t pBufRx[MAXTRANSFER_SIZE>>2];
-	uint32_t pBufRx0[MAX_PACKET_SIZE_EP0>>2];
-    gpio_t usb_switch;
-}USBHAL_Private_t;
-
-uint32_t HAL_PCDEx_GetTxFiFo(PCD_HandleTypeDef *hpcd, uint8_t fifo)
-{
-        return 1024;
-}
-
-void HAL_PCDEx_SetConnectionState(PCD_HandleTypeDef *hpcd, uint8_t state){
-    USBHAL_Private_t *priv=((USBHAL_Private_t *)(hpcd->pData));
-    gpio_write(&(priv->usb_switch),state);
-}
-
-void HAL_PCD_SOFCallback(PCD_HandleTypeDef *hpcd) {
-    USBHAL_Private_t *priv=((USBHAL_Private_t *)(hpcd->pData));
-    USBHAL *obj= priv->inst;
-    uint32_t sofnum = (hpcd->Instance->FNR) & USB_FNR_FN;
-    void (USBHAL::*func)(int frame) = priv->sof;
-    /* fix me  call with same frame number */
-    (obj->*func)(sofnum);
-}
-
-USBHAL * USBHAL::instance;
-
-USBHAL::USBHAL(void) {
-    /*  init parameter  */
-    USBHAL_Private_t *HALPriv = new(USBHAL_Private_t);
-    hpcd.Instance = USB;
-    /*  initialized Init to zero (constructor does not zero initialized the
-     *  area */
-    /*  initialized all field of init including 0 field  */
-    /*  constructor does not fill with zero */
-    memset(&hpcd.Init, 0, sizeof(hpcd.Init));
-    hpcd.Init.dev_endpoints = NB_ENDPOINT;
-    hpcd.Init.ep0_mps =   MAX_PACKET_SIZE_EP0;
-    hpcd.Init.phy_itface = PCD_PHY_EMBEDDED;
-    hpcd.Init.Sof_enable = 1;
-    hpcd.Init.speed = PCD_SPEED_FULL;
-    /*  pass instance for usage inside call back */
-    HALPriv->inst = this;
-    HALPriv->bus_reset = &USBHAL::busReset;
-    HALPriv->suspend_change = &USBHAL::suspendStateChanged;
-    HALPriv->connect_change = &USBHAL::connectStateChanged;
-    HALPriv->sof = &USBHAL::SOF;
-    HALPriv->ep0_setup = &USBHAL::EP0setupCallback;
-    HALPriv->ep_realise = &USBHAL::realiseEndpoint;
-    HALPriv->ep0_in = &USBHAL::EP0in;
-    HALPriv->ep0_out = &USBHAL::EP0out;
-    HALPriv->ep0_read = &USBHAL::EP0read;
-    hpcd.pData = (void*)HALPriv;
-    HALPriv->epCallback[0] = &USBHAL::EP1_OUT_callback;
-    HALPriv->epCallback[1] = &USBHAL::EP1_IN_callback;
-    HALPriv->epCallback[2] = &USBHAL::EP2_OUT_callback;
-    HALPriv->epCallback[3] = &USBHAL::EP2_IN_callback;
-    HALPriv->epCallback[4] = &USBHAL::EP3_OUT_callback;
-    HALPriv->epCallback[5] = &USBHAL::EP3_IN_callback;
-    instance = this;
-    __HAL_RCC_GPIOA_CLK_ENABLE();
-    /* Configure USB DM pin. This is optional, and maintained only for user guidance. */
-    pin_function(PA_11, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF14_USB));
-    pin_function(PA_12, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF14_USB));
-    __HAL_RCC_GPIOG_CLK_ENABLE();
-    gpio_init_out(&HALPriv->usb_switch,PG_6);
-    /* Enable USB Clock */
-    __HAL_RCC_USB_CLK_ENABLE();
-    /* Enable SYSCFG Clock */
-    __HAL_RCC_SYSCFG_CLK_ENABLE();
-    hpcd.State = HAL_PCD_STATE_RESET;
-    HAL_PCD_Init(&hpcd);
-    /* hardcoded size of FIFO according definition*/
-    HAL_PCDEx_PMAConfig(&hpcd , 0x00 , PCD_SNG_BUF, 0x30);
-    HAL_PCDEx_PMAConfig(&hpcd , 0x80 , PCD_SNG_BUF, 0x70);
-#if 1
-    HAL_PCDEx_PMAConfig(&hpcd , 0x3, PCD_DBL_BUF, 0x018000b0);
-#else
-    HAL_PCDEx_PMAConfig(&hpcd , 0x3, PCD_SNG_BUF, 0x180);
-#endif
-    HAL_PCDEx_PMAConfig(&hpcd , 0x83, PCD_SNG_BUF, 0xb0);
-    NVIC_SetVector(USBHAL_IRQn,(uint32_t)&_usbisr);
-    NVIC_SetPriority(USBHAL_IRQn, 1);
-    HAL_PCD_Start(&hpcd);
-}
-#endif
--- a/targets/TARGET_STM/TARGET_STM32F3/TARGET_NUCLEO_F303ZE/USBHAL_STM_TARGET.h	Thu Feb 09 10:05:54 2017 -0600
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,18 +0,0 @@
-/* Copyright (c) 2016 mbed.org, MIT License
-*
-* 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.
-*/
-#include "USBHAL_STM32F303ZE.h"
--- a/targets/TARGET_STM/TARGET_STM32F4/TARGET_DISCO_F407VG/USBHAL_STM_TARGET.h	Thu Feb 09 10:05:54 2017 -0600
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,18 +0,0 @@
-/* Copyright (c) 2016 mbed.org, MIT License
-*
-* 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.
-*/
-#include "USBHAL_STM_144_64pins.h"
--- a/targets/TARGET_STM/TARGET_STM32F4/TARGET_DISCO_F429ZI/USBHALHost_DISCOF429ZI.h	Thu Feb 09 10:05:54 2017 -0600
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,112 +0,0 @@
-/* mbed USBHost Library
- * Copyright (c) 2006-2013 ARM Limited
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#ifndef USBHALHOST_DISCOF429ZI
-#define USBHALHOST_DISCOF429ZI
-
-#define USBHAL_IRQn  OTG_HS_IRQn
-
-#define HCCA_SIZE sizeof(HCD_HandleTypeDef)
-#define ED_SIZE  sizeof(HCED)
-#define TD_SIZE  sizeof(HCTD)
-
-#define TOTAL_SIZE (HCCA_SIZE + (MAX_ENDPOINT*ED_SIZE) + (MAX_TD*TD_SIZE))
-/* STM device FS have 11 channels  (definition is for 60 channels) */
-static volatile  uint8_t usb_buf[TOTAL_SIZE];
-typedef struct
-{
-    /* store the request ongoing on each endpoit  */
-    /*  1st field of structure avoid  giving knowledge of all structure to
-     *  endpoint */
-    volatile uint32_t addr[MAX_ENDPOINT];
-    USBHALHost *inst;
-    void (USBHALHost::*deviceConnected)(int hub, int port, bool lowSpeed, USBHostHub * hub_parent);
-    void (USBHALHost::*deviceDisconnected)(int hub, int port, USBHostHub * hub_parent, volatile uint32_t addr);
-    void (USBHALHost::*transferCompleted)(volatile uint32_t addr);
-}USBHALHost_Private_t;
-/*  CONFIGURATION for USB_VBUS  
- *  on 64 bits board PC_0 is used  (0  VBUS on,  1 VBUS off)
- *  on 144 pins board PG_6 is used ( 1 VBUS on, 0 VBUS on)
- */
-static gpio_t gpio_vbus;
-
-#define  VBUS_OFF 1
-#define  VBUS_ON 0
-#define USB_VBUS_CONFIG \
-    do {__HAL_RCC_GPIOC_CLK_ENABLE();\
-		gpio_init_out_ex(&gpio_vbus, PC_4, VBUS_OFF);\
-	}while(0);
-
-
-void  usb_vbus( uint8_t state)
-{
-    if(state == 0)
-    {
-        gpio_write(&gpio_vbus, VBUS_OFF);
-    }
-    else
-    {
-        gpio_write(&gpio_vbus, VBUS_ON);
-    }
-    wait(0.2);
-}
-
-
-USBHALHost::USBHALHost() {
-    gpio_t  pin_vbus;
-    instHost = this;
-    HCD_HandleTypeDef *hhcd;
-    USBHALHost_Private_t *HALPriv = new(USBHALHost_Private_t);
-    memset(HALPriv, 0, sizeof(USBHALHost_Private_t));
-    memInit();
-    memset((void*)usb_hcca, 0, HCCA_SIZE);
-    hhcd = (HCD_HandleTypeDef *)usb_hcca;
-    hhcd->Instance = USB_OTG_HS;
-    hhcd->pData = (void*)HALPriv;
-    hhcd->Init.Host_channels = 11;
-    /*   for now failed with dma */
-    hhcd->Init.dma_enable = 0;
-    hhcd->Init.speed = HCD_SPEED_HIGH;
-    hhcd->Init.phy_itface = HCD_PHY_EMBEDDED;
-    hhcd->Init.use_external_vbus = 1;
-    HALPriv->inst = this;
-    HALPriv->deviceConnected = &USBHALHost::deviceConnected;
-    HALPriv->deviceDisconnected = &USBHALHost::deviceDisconnected;
-    HALPriv->transferCompleted = &USBHALHost::transferCompleted;
-    for (int i = 0; i < MAX_ENDPOINT; i++) {
-        edBufAlloc[i] = false;
-        HALPriv->addr[i]=(uint32_t)-1;
-    }
-    for (int i = 0; i < MAX_TD; i++) {
-        tdBufAlloc[i] = false;
-    }
-    /* Configure USB HS GPIOs */
-    __HAL_RCC_GPIOB_CLK_ENABLE();
-
-    /*USB DM and DP */
-    pin_function(PB_14, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF12_OTG_HS_FS));
-    pin_function(PB_15, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF12_OTG_HS_FS));
-    /* Configure  VBUS Pin */
-    gpio_init_in(&pin_vbus, PB_13);
-    /* Configure POWER_SWITCH IO pin */
-    USB_VBUS_CONFIG;
-    /* Enable USB HS Clocks */
-    __HAL_RCC_USB_OTG_HS_CLK_ENABLE();
-
-    /* Set USBFS Interrupt priority */
-    HAL_NVIC_SetPriority(USBHAL_IRQn, 5, 0);
-    NVIC_SetVector(USBHAL_IRQn, (uint32_t)&_usbisr);
-}
-#endif
--- a/targets/TARGET_STM/TARGET_STM32F4/TARGET_DISCO_F429ZI/USBHALHost_STM_TARGET.h	Thu Feb 09 10:05:54 2017 -0600
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,18 +0,0 @@
-/* Copyright (c) 2016 mbed.org, MIT License
-*
-* 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.
-*/
-#include "USBHALHost_DISCOF429ZI.h"
--- a/targets/TARGET_STM/TARGET_STM32F4/TARGET_F429_F439/USBHALHost_STM_TARGET.h	Thu Feb 09 10:05:54 2017 -0600
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,18 +0,0 @@
-/* Copyright (c) 2016 mbed.org, MIT License
-*
-* 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.
-*/
-#include "USBHALHost_STM_144_64pins.h"
--- a/targets/TARGET_STM/TARGET_STM32F4/TARGET_F429_F439/USBHAL_STM_TARGET.h	Thu Feb 09 10:05:54 2017 -0600
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,18 +0,0 @@
-/* Copyright (c) 2016 mbed.org, MIT License
-*
-* 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.
-*/
-#include "USBHAL_STM_144_64pins.h"
--- a/targets/TARGET_STM/TARGET_STM32F4/TARGET_NUCLEO_F401RE/USBHALHost_STM_TARGET.h	Thu Feb 09 10:05:54 2017 -0600
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,20 +0,0 @@
-/* Copyright (c) 2016 mbed.org, MIT License
-*
-* 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.
-*/
-#define USBHALHOST_64pins
-#include "USBHALHost_STM_144_64pins.h"
-
--- a/targets/TARGET_STM/TARGET_STM32F4/TARGET_NUCLEO_F401RE/USBHAL_STM_TARGET.h	Thu Feb 09 10:05:54 2017 -0600
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,18 +0,0 @@
-/* Copyright (c) 2016 mbed.org, MIT License
-*
-* 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.
-*/
-#include "USBHAL_STM_144_64pins.h"
--- a/targets/TARGET_STM/TARGET_STM32F4/TARGET_NUCLEO_F411RE/USBHALHost_STM_TARGET.h	Thu Feb 09 10:05:54 2017 -0600
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,39 +0,0 @@
-/* Copyright (c) 2016 mbed.org, MIT License
-*
-* 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.
-*/
-
-/*  144 pins boards */
-#if defined(TARGET_NUCLEO_F429ZI) || defined(TARGET_NUCLEO_F446ZE)  || defined(TARGET_NUCLEO_F207ZG) \
-|| defined(TARGET_NUCLEO_F767ZI) || defined(TARGET_NUCLEO_F746ZG) || defined(TARGET_NUCLEO_F412ZG)
-#include "USBHALHost_STM_144_64pins.h"
-#endif
-
-/*  64 pins boards */
-#if defined(TARGET_NUCLEO_F401RE) || defined(TARGET_NUCLEO_L476RG) || defined(TARGET_NUCLEO_F411RE)
-#define USBHALHOST_64pins
-#include "USBHALHost_STM_144_64pins.h"
-#endif
-
-/*  DISCO board  */
-
-#ifdef TARGET_DISCO_F429ZI
-#include "USBHALHost_DISCOF429ZI.h"
-#endif
-
-#ifdef TARGET_DISCO_L476VG
-#include "USBHALHost_DISCOL476VG.h"
-#endif
--- a/targets/TARGET_STM/TARGET_STM32F4/TARGET_NUCLEO_F411RE/USBHAL_STM_TARGET.h	Thu Feb 09 10:05:54 2017 -0600
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,19 +0,0 @@
-/* Copyright (c) 2016 mbed.org, MIT License
-*
-* 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.
-*/
-
-#include "USBHAL_STM_144_64pins.h"
--- a/targets/TARGET_STM/TARGET_STM32F4/TARGET_NUCLEO_F412ZG/USBHALHost_STM_TARGET.h	Thu Feb 09 10:05:54 2017 -0600
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,19 +0,0 @@
-/* Copyright (c) 2016 mbed.org, MIT License
-*
-* 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.
-*/
-#include "USBHALHost_STM_144_64pins.h"
-
--- a/targets/TARGET_STM/TARGET_STM32F4/TARGET_NUCLEO_F412ZG/USBHAL_STM_TARGET.h	Thu Feb 09 10:05:54 2017 -0600
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,18 +0,0 @@
-/* Copyright (c) 2016 mbed.org, MIT License
-*
-* 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.
-*/
-#include "USBHAL_STM_144_64pins.h"
--- a/targets/TARGET_STM/TARGET_STM32F4/TARGET_NUCLEO_F446ZE/USBHALHost_STM_TARGET.h	Thu Feb 09 10:05:54 2017 -0600
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,19 +0,0 @@
-/* Copyright (c) 2016 mbed.org, MIT License
-*
-* 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.
-*/
-#include "USBHALHost_STM_144_64pins.h"
-
--- a/targets/TARGET_STM/TARGET_STM32F4/TARGET_NUCLEO_F446ZE/USBHAL_STM_TARGET.h	Thu Feb 09 10:05:54 2017 -0600
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,18 +0,0 @@
-/* Copyright (c) 2016 mbed.org, MIT License
-*
-* 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.
-*/
-#include "USBHAL_STM_144_64pins.h"
--- a/targets/TARGET_STM/TARGET_STM32F7/TARGET_DISCO_F769NI/USBHAL_STM32F769NI.h	Thu Feb 09 10:05:54 2017 -0600
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,147 +0,0 @@
-/* Copyright (c) 2016 mbed.org, MIT License
-*
-* 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.
-*/
-#ifndef USBHAL_STM32F769NI_H
-#define USBHAL_STM32F769NI_H
-#define USBHAL_IRQn  OTG_HS_IRQn
-/*  must be multiple of 4 bytes */
-#define NB_ENDPOINT 4
-#define MAXTRANSFER_SIZE  0x200
-#define FIFO_USB_RAM_SIZE (MAXTRANSFER_SIZE+MAX_PACKET_SIZE_EP0+MAX_PACKET_SIZE_EP1+MAX_PACKET_SIZE_EP2+MAX_PACKET_SIZE_EP3)
-#if (FIFO_USB_RAM_SIZE > 0x500)
-#error "FIFO dimensioning incorrect"
-#endif
-
-typedef struct
-{
-    USBHAL *inst;
-    void (USBHAL::*bus_reset)(void);
-    void (USBHAL::*sof)(int frame);
-    void (USBHAL::*connect_change)(unsigned int  connected);
-    void (USBHAL::*suspend_change)(unsigned int suspended);
-    void (USBHAL::*ep0_setup)(void);
-    void (USBHAL::*ep0_in)(void);
-    void (USBHAL::*ep0_out)(void);
-    void (USBHAL::*ep0_read)(void);
-    bool (USBHAL::*ep_realise)(uint8_t endpoint, uint32_t maxPacket, uint32_t flags);
-    bool (USBHAL::*epCallback[2*NB_ENDPOINT-2])(void);
-    /*  memorize dummy buffer used for reception */
-    uint32_t pBufRx[MAXTRANSFER_SIZE>>2];
-    uint32_t pBufRx0[MAX_PACKET_SIZE_EP0>>2];
-    uint8_t epComplete[2*NB_ENDPOINT];
-}USBHAL_Private_t;
-
-uint32_t HAL_PCDEx_GetTxFiFo(PCD_HandleTypeDef *hpcd, uint8_t fifo)
-{
-    uint32_t len;
-    if (fifo == 0) len = hpcd->Instance->DIEPTXF0_HNPTXFSIZ>>16;
-    else
-        len =  hpcd->Instance->DIEPTXF[fifo - 1] >> 16;
-    return len*4;
-}
-void HAL_PCD_SOFCallback(PCD_HandleTypeDef *hpcd) 
-{
-    USBHAL_Private_t *priv=((USBHAL_Private_t *)(hpcd->pData));
-    USBHAL *obj= priv->inst;
-    USB_OTG_GlobalTypeDef *USBx = hpcd->Instance;
-    uint32_t sofnum = (USBx_DEVICE->DSTS & USB_OTG_DSTS_FNSOF) >> 8;
-    void (USBHAL::*func)(int frame) = priv->sof;
-    /* fix me  call with same frame number */
-    (obj->*func)(sofnum);
-}
-
-
-USBHAL * USBHAL::instance;
-
-USBHAL::USBHAL(void) {
-    /*  init parameter  */
-    USBHAL_Private_t *HALPriv = new(USBHAL_Private_t);
-    hpcd.Instance = USB_OTG_HS;
-    memset(&hpcd.Init, 0, sizeof(hpcd.Init));
-    hpcd.Init.dev_endpoints = NB_ENDPOINT;
-    hpcd.Init.ep0_mps =   MAX_PACKET_SIZE_EP0;
-    hpcd.Init.phy_itface = PCD_PHY_ULPI;
-    hpcd.Init.Sof_enable = 0;
-
-    hpcd.Init.speed = PCD_SPEED_HIGH;
-    //hpcd.Init.vbus_sensing_enable = 0;
-    //hpcd.Init.lpm_enable = 0;
-    /*  pass instance for usage inside call back */
-    HALPriv->inst = this;
-    HALPriv->bus_reset = &USBHAL::busReset;
-    HALPriv->suspend_change = &USBHAL::suspendStateChanged;
-    HALPriv->connect_change = &USBHAL::connectStateChanged;
-    HALPriv->sof = &USBHAL::SOF;
-    HALPriv->ep0_setup = &USBHAL::EP0setupCallback;
-    HALPriv->ep_realise = &USBHAL::realiseEndpoint;
-    HALPriv->ep0_in = &USBHAL::EP0in;
-    HALPriv->ep0_out = &USBHAL::EP0out;
-    HALPriv->ep0_read = &USBHAL::EP0read;
-    hpcd.pData = (void*)HALPriv;
-    HALPriv->epCallback[0] = &USBHAL::EP1_OUT_callback;
-    HALPriv->epCallback[1] = &USBHAL::EP1_IN_callback;
-    HALPriv->epCallback[2] = &USBHAL::EP2_OUT_callback;
-    HALPriv->epCallback[3] = &USBHAL::EP2_IN_callback;
-    HALPriv->epCallback[4] = &USBHAL::EP3_OUT_callback;
-    HALPriv->epCallback[5] = &USBHAL::EP3_IN_callback;
-    instance = this;
-    /* Enable power and clocking */
-    __HAL_RCC_GPIOA_CLK_ENABLE();
-    __HAL_RCC_GPIOB_CLK_ENABLE();
-    __HAL_RCC_GPIOC_CLK_ENABLE();
-    __HAL_RCC_GPIOH_CLK_ENABLE();
-    __HAL_RCC_GPIOI_CLK_ENABLE();
-
-    pin_function(PA_5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF10_OTG_HS)); // CLK
-    pin_function(PA_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF10_OTG_HS)); // D0
-
-    pin_function(PB_0, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF10_OTG_HS)); // D1
-    pin_function(PB_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF10_OTG_HS)); // D2
-    pin_function(PB_5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF10_OTG_HS)); // D3
-    pin_function(PB_10, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF10_OTG_HS)); // D4
-    pin_function(PB_11, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF10_OTG_HS)); // D5
-    pin_function(PB_12, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF10_OTG_HS)); // D6
-    pin_function(PB_13, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF10_OTG_HS)); // D7
-
-    pin_function(PC_0, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF10_OTG_HS)); // STP
-    pin_function(PH_4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF10_OTG_HS)); // NXT
-    pin_function(PI_11, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF10_OTG_HS)); // DIR
-
-    __HAL_RCC_USB_OTG_HS_ULPI_CLK_ENABLE();
-    __HAL_RCC_USB_OTG_HS_CLK_ENABLE();
-
-    __HAL_RCC_SYSCFG_CLK_ENABLE();
-    hpcd.State = HAL_PCD_STATE_RESET;
-    HAL_PCD_Init(&hpcd);
-    /* 1.25kbytes */
-    /* min value 16 (= 16 x 4 bytes) */
-    /*  max value 256 (= 1K bytes ) */
-    /*  maximum sum is 0x140 */
-    HAL_PCDEx_SetRxFiFo(&hpcd, (MAXTRANSFER_SIZE/4));
-    /*  bulk/int 64 bytes in FS  */
-    HAL_PCDEx_SetTxFiFo(&hpcd, 0, (MAX_PACKET_SIZE_EP0/4)+1);
-    /*  bulk/int bytes in FS */
-    HAL_PCDEx_SetTxFiFo(&hpcd, 1, (MAX_PACKET_SIZE_EP1/4));
-    HAL_PCDEx_SetTxFiFo(&hpcd, 2, (MAX_PACKET_SIZE_EP2/4));
-    /* ISOchronous */
-    HAL_PCDEx_SetTxFiFo(&hpcd, 3, (MAX_PACKET_SIZE_EP3/4));
-    NVIC_SetVector(USBHAL_IRQn, (uint32_t)&_usbisr);
-    NVIC_SetPriority(USBHAL_IRQn, 1);
-    HAL_PCD_Start(&hpcd);
-}
-#endif
-
--- a/targets/TARGET_STM/TARGET_STM32F7/TARGET_DISCO_F769NI/USBHAL_STM_TARGET.h	Thu Feb 09 10:05:54 2017 -0600
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,19 +0,0 @@
-/* Copyright (c) 2016 mbed.org, MIT License
-*
-* 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.
-*/
-
-#include "USBHAL_STM32F769NI.h"
--- a/targets/TARGET_STM/TARGET_STM32F7/TARGET_F746_F756/USBHALHost_STM_TARGET.h	Thu Feb 09 10:05:54 2017 -0600
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,18 +0,0 @@
-/* Copyright (c) 2016 mbed.org, MIT License
-*
-* 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.
-*/
-#include "USBHALHost_STM_144_64pins.h"
--- a/targets/TARGET_STM/TARGET_STM32F7/TARGET_F746_F756/USBHAL_STM_TARGET.h	Thu Feb 09 10:05:54 2017 -0600
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,19 +0,0 @@
-/* Copyright (c) 2016 mbed.org, MIT License
-*
-* 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.
-*/
-#include "USBHAL_STM_144_64pins.h"
-
--- a/targets/TARGET_STM/TARGET_STM32F7/TARGET_NUCLEO_F767ZI/USBHALHost_STM_TARGET.h	Thu Feb 09 10:05:54 2017 -0600
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,19 +0,0 @@
-/* Copyright (c) 2016 mbed.org, MIT License
-*
-* 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.
-*/
-#include "USBHALHost_STM_144_64pins.h"
-
--- a/targets/TARGET_STM/TARGET_STM32F7/TARGET_NUCLEO_F767ZI/USBHAL_STM_TARGET.h	Thu Feb 09 10:05:54 2017 -0600
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,18 +0,0 @@
-/* Copyright (c) 2016 mbed.org, MIT License
-*
-* 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.
-*/
-#include "USBHAL_STM_144_64pins.h"
--- a/targets/TARGET_STM/TARGET_STM32L4/TARGET_DISCO_L476VG/USBHALHost_DISCOL476VG.h	Thu Feb 09 10:05:54 2017 -0600
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,118 +0,0 @@
-/* Copyright (c) 2016 mbed.org, MIT License
-*
-* 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.
-*/
-#ifndef USBHALHOST_DISCOL476VG
-#define USBHALHOST_DISCOL476VG
-
-#define USBHAL_IRQn  OTG_FS_IRQn
-
-#define HCCA_SIZE sizeof(HCD_HandleTypeDef)
-#define ED_SIZE  sizeof(HCED)
-#define TD_SIZE  sizeof(HCTD)
-
-#define TOTAL_SIZE (HCCA_SIZE + (MAX_ENDPOINT*ED_SIZE) + (MAX_TD*TD_SIZE))
-/* STM device FS have 11 channels  (definition is for 60 channels) */
-static volatile  uint8_t usb_buf[TOTAL_SIZE];
-typedef struct
-{
-    /* store the request ongoing on each endpoit  */
-    /*  1st field of structure avoid  giving knowledge of all structure to
-     *  endpoint */
-    volatile uint32_t addr[MAX_ENDPOINT];
-    USBHALHost *inst;
-    void (USBHALHost::*deviceConnected)(int hub, int port, bool lowSpeed, USBHostHub * hub_parent);
-    void (USBHALHost::*deviceDisconnected)(int hub, int port, USBHostHub * hub_parent, volatile uint32_t addr);
-    void (USBHALHost::*transferCompleted)(volatile uint32_t addr);
-}USBHALHost_Private_t;
-
-static gpio_t gpio_vbus;
-
-#define  VBUS_OFF 1
-#define  VBUS_ON 0
-#define USB_VBUS_CONFIG \
-    do {\
-		gpio_init_out_ex(&gpio_vbus, PC_9, VBUS_OFF);\
-	}while(0);
-
-
-void  usb_vbus( uint8_t state)
-{
-    if(state == 0)
-    {
-        gpio_write(&gpio_vbus, VBUS_OFF);
-    }
-    else
-    {
-        gpio_write(&gpio_vbus, VBUS_ON);
-    }
-    wait(0.2);
-}
-
-
-USBHALHost::USBHALHost() {
-    instHost = this;
-    HCD_HandleTypeDef *hhcd;
-    USBHALHost_Private_t *HALPriv = new(USBHALHost_Private_t);
-    memset(HALPriv, 0, sizeof(USBHALHost_Private_t));
-    memInit();
-    memset((void*)usb_hcca, 0, HCCA_SIZE);
-    hhcd = (HCD_HandleTypeDef *)usb_hcca;
-    hhcd->Instance = USB_OTG_FS;
-    hhcd->pData = (void*)HALPriv;
-    hhcd->Init.Host_channels = 11;
-    /*   for now failed with dma */
-    hhcd->Init.dma_enable = 0;
-    hhcd->Init.speed =  HCD_SPEED_FULL;
-    hhcd->Init.phy_itface = HCD_PHY_EMBEDDED;
-    hhcd->Init.use_external_vbus = 1;
-    HALPriv->inst = this;
-    HALPriv->deviceConnected = &USBHALHost::deviceConnected;
-    HALPriv->deviceDisconnected = &USBHALHost::deviceDisconnected;
-    HALPriv->transferCompleted = &USBHALHost::transferCompleted;
-    for (int i = 0; i < MAX_ENDPOINT; i++) {
-        edBufAlloc[i] = false;
-        HALPriv->addr[i]=(uint32_t)-1;
-    }
-    for (int i = 0; i < MAX_TD; i++) {
-        tdBufAlloc[i] = false;
-    }
-    __HAL_RCC_PWR_CLK_ENABLE();
-#ifdef TARGET_STM32L4
-    HAL_PWREx_EnableVddUSB();
-#endif
-
-    /* Configure USB HS GPIOs */
-    __HAL_RCC_GPIOA_CLK_ENABLE();
-
-    /*USB DM and DP */
-    pin_function(PA_11, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF10_OTG_FS));
-    pin_function(PA_12, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF10_OTG_FS));
-
-    /* Configure  VBUS Pin */
-    __HAL_RCC_GPIOC_CLK_ENABLE();
-    pin_function(PC_11, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF10_OTG_FS));
-    /* Configure POWER_SWITCH IO pin */
-    USB_VBUS_CONFIG;
-    __HAL_RCC_SYSCFG_CLK_ENABLE();
-
-    /* Enable USB FS Clocks */
-    __HAL_RCC_USB_OTG_FS_CLK_ENABLE();
-    /* Set USBFS Interrupt priority */
-    HAL_NVIC_SetPriority(USBHAL_IRQn, 5, 0);
-    NVIC_SetVector(USBHAL_IRQn, (uint32_t)&_usbisr);
-}
-#endif
--- a/targets/TARGET_STM/TARGET_STM32L4/TARGET_DISCO_L476VG/USBHALHost_STM_TARGET.h	Thu Feb 09 10:05:54 2017 -0600
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,18 +0,0 @@
-/* Copyright (c) 2016 mbed.org, MIT License
-*
-* 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.
-*/
-#include "USBHALHost_DISCOL476VG.h"
--- a/targets/TARGET_STM/TARGET_STM32L4/TARGET_DISCO_L476VG/USBHAL_STM32L476VG.h	Thu Feb 09 10:05:54 2017 -0600
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,145 +0,0 @@
-/* Copyright (c) 2016 mbed.org, MIT License
-*
-* 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.
-*/
-#ifndef USBHAL_STM32L476VG
-#define USBHAL_STM32L476VG
-
-#define USBHAL_IRQn  OTG_FS_IRQn
-
-
-#define NB_ENDPOINT  4
-/*  must be multiple of 4 bytes */
-#define MAXTRANSFER_SIZE  0x200
-#define FIFO_USB_RAM_SIZE (MAXTRANSFER_SIZE+MAX_PACKET_SIZE_EP0+MAX_PACKET_SIZE_EP1+MAX_PACKET_SIZE_EP2+MAX_PACKET_SIZE_EP3)
-#if (FIFO_USB_RAM_SIZE > 0x500)
-#error "FIFO dimensioning incorrect"
-#endif
-
-typedef struct
-{
-    USBHAL *inst;
-    void (USBHAL::*bus_reset)(void);
-    void (USBHAL::*sof)(int frame);
-    void (USBHAL::*connect_change)(unsigned int  connected);
-    void (USBHAL::*suspend_change)(unsigned int suspended);
-    void (USBHAL::*ep0_setup)(void);
-    void (USBHAL::*ep0_in)(void);
-    void (USBHAL::*ep0_out)(void);
-    void (USBHAL::*ep0_read)(void);
-    bool (USBHAL::*ep_realise)(uint8_t endpoint, uint32_t maxPacket, uint32_t flags);
-    bool (USBHAL::*epCallback[2*NB_ENDPOINT-2])(void);
-    uint8_t epComplete[8];
-    /*  memorize dummy buffer used for reception */
-    uint32_t pBufRx[MAXTRANSFER_SIZE>>2];
-    uint32_t pBufRx0[MAX_PACKET_SIZE_EP0>>2];
-}USBHAL_Private_t;
-
-uint32_t HAL_PCDEx_GetTxFiFo(PCD_HandleTypeDef *hpcd, uint8_t fifo)
-{
-    uint32_t len;
-    if (fifo == 0) len = hpcd->Instance->DIEPTXF0_HNPTXFSIZ>>16;
-    else
-        len =  hpcd->Instance->DIEPTXF[fifo - 1] >> 16;
-    return len*4;
-}
-void HAL_PCD_SOFCallback(PCD_HandleTypeDef *hpcd) {
-    USBHAL_Private_t *priv=((USBHAL_Private_t *)(hpcd->pData));
-    USBHAL *obj= priv->inst;
-    USB_OTG_GlobalTypeDef *USBx = hpcd->Instance;
-    uint32_t sofnum = (USBx_DEVICE->DSTS & USB_OTG_DSTS_FNSOF) >> 8;
-    void (USBHAL::*func)(int frame) = priv->sof;
-    /* fix me  call with same frame number */
-    (obj->*func)(sofnum);
-}
-
-USBHAL * USBHAL::instance;
-
-USBHAL::USBHAL(void) {
-    /*  init parameter  */
-    USBHAL_Private_t *HALPriv = new(USBHAL_Private_t);
-    /*  initialized all field of init including 0 field  */
-    /*  constructor does not fill with zero */
-    hpcd.Instance = USB_OTG_FS;
-    /*  initialized all field of init including 0 field  */
-    /*  constructor does not fill with zero */
-    memset(&hpcd.Init, 0, sizeof(hpcd.Init));
-    hpcd.Init.dev_endpoints = NB_ENDPOINT;
-    hpcd.Init.ep0_mps =   MAX_PACKET_SIZE_EP0;
-    hpcd.Init.phy_itface = PCD_PHY_EMBEDDED;
-    hpcd.Init.Sof_enable = 1;
-    hpcd.Init.speed = PCD_SPEED_FULL;
-    /*  pass instance for usage inside call back */
-    HALPriv->inst = this;
-    HALPriv->bus_reset = &USBHAL::busReset;
-    HALPriv->suspend_change = &USBHAL::suspendStateChanged;
-    HALPriv->connect_change = &USBHAL::connectStateChanged;
-    HALPriv->sof = &USBHAL::SOF;
-    HALPriv->ep0_setup = &USBHAL::EP0setupCallback;
-    HALPriv->ep_realise = &USBHAL::realiseEndpoint;
-    HALPriv->ep0_in = &USBHAL::EP0in;
-    HALPriv->ep0_out = &USBHAL::EP0out;
-    HALPriv->ep0_read = &USBHAL::EP0read;
-    hpcd.pData = (void*)HALPriv;
-    HALPriv->epCallback[0] = &USBHAL::EP1_OUT_callback;
-    HALPriv->epCallback[1] = &USBHAL::EP1_IN_callback;
-    HALPriv->epCallback[2] = &USBHAL::EP2_OUT_callback;
-    HALPriv->epCallback[3] = &USBHAL::EP2_IN_callback;
-    HALPriv->epCallback[4] = &USBHAL::EP3_OUT_callback;
-    HALPriv->epCallback[5] = &USBHAL::EP3_IN_callback;
-    instance = this;
-
-    __HAL_RCC_PWR_CLK_ENABLE();
-
-    HAL_PWREx_EnableVddUSB(); 
-    /* Configure USB VBUS GPIO */
-    __HAL_RCC_GPIOC_CLK_ENABLE();
-
-    /* Configure USB FS GPIOs */
-    __HAL_RCC_GPIOA_CLK_ENABLE();
-
-    /* Configure DM DP Pins */
-    pin_function(PA_11, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF10_OTG_FS));
-    pin_function(PA_12, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF10_OTG_FS));
-
-    /* Configure VBUS Pin */
-    pin_function(PC_11, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF10_OTG_FS));
-
-    __HAL_RCC_USB_OTG_FS_CLK_ENABLE();
-
-    hpcd.State = HAL_PCD_STATE_RESET;
-
-    HAL_PCD_Init(&hpcd);
-    /* 1.25kbytes */
-    /* min value 16 (= 16 x 4 bytes) */
-    /*  max value 256 (= 1K bytes ) */
-    /*  maximum sum is 0x140 */
-    HAL_PCDEx_SetRxFiFo(&hpcd, (MAXTRANSFER_SIZE/4));
-    /*  bulk/int 64 bytes in FS  */
-    HAL_PCDEx_SetTxFiFo(&hpcd, 0, (MAX_PACKET_SIZE_EP0/4)+1);
-    /*  bulk/int bytes in FS */
-    HAL_PCDEx_SetTxFiFo(&hpcd, 1, (MAX_PACKET_SIZE_EP1/4));
-    HAL_PCDEx_SetTxFiFo(&hpcd, 2, (MAX_PACKET_SIZE_EP2/4));
-    /* ISOchronous */
-    HAL_PCDEx_SetTxFiFo(&hpcd, 3, (MAX_PACKET_SIZE_EP3/4));
-
-    NVIC_SetVector(USBHAL_IRQn,(uint32_t)&_usbisr);
-    NVIC_SetPriority( USBHAL_IRQn, 1);
-
-    HAL_PCD_Start(&hpcd);
-}
-
-#endif
--- a/targets/TARGET_STM/TARGET_STM32L4/TARGET_DISCO_L476VG/USBHAL_STM_TARGET.h	Thu Feb 09 10:05:54 2017 -0600
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,18 +0,0 @@
-/* Copyright (c) 2016 mbed.org, MIT License
-*
-* 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.
-*/
-#include "USBHAL_STM32L476VG.h"
--- a/targets/TARGET_STM/TARGET_STM32L4/TARGET_L476_L486/TARGET_NUCLEO_L476RG/USBHALHost_STM_TARGET.h	Thu Feb 09 10:05:54 2017 -0600
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,19 +0,0 @@
-/* Copyright (c) 2016 mbed.org, MIT License
-*
-* 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.
-*/
-#define USBHALHOST_64pins
-#include "USBHALHost_STM_144_64pins.h"
--- a/targets/TARGET_STM/USBHALHost_STM_144_64pins.h	Thu Feb 09 10:05:54 2017 -0600
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,121 +0,0 @@
-/* mbed USBHost Library
- * Copyright (c) 2006-2013 ARM Limited
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#ifndef USBHALHOST_STM32_144_64
-#define USBHALHOST_STM32_144_64
-
-#define USBHAL_IRQn  OTG_FS_IRQn
-
-#define HCCA_SIZE sizeof(HCD_HandleTypeDef)
-#define ED_SIZE  sizeof(HCED)
-#define TD_SIZE  sizeof(HCTD)
-
-#define TOTAL_SIZE (HCCA_SIZE + (MAX_ENDPOINT*ED_SIZE) + (MAX_TD*TD_SIZE))
-/* STM device FS have 11 channels  (definition is for 60 channels) */
-static volatile  uint8_t usb_buf[TOTAL_SIZE];
-typedef struct
-{
-	/* store the request ongoing on each endpoit  */
-	/*  1st field of structure avoid  giving knowledge of all structure to
-	 *  endpoint */
-	volatile uint32_t addr[MAX_ENDPOINT];
-	USBHALHost *inst;
-	void (USBHALHost::*deviceConnected)(int hub, int port, bool lowSpeed, USBHostHub * hub_parent);
-	void (USBHALHost::*deviceDisconnected)(int hub, int port, USBHostHub * hub_parent, volatile uint32_t addr);
-	void (USBHALHost::*transferCompleted)(volatile uint32_t addr);
-}USBHALHost_Private_t;
-
-/*  CONFIGURATION for USB_VBUS  
- *  on 64 bits board PC_0 is used  (0  VBUS on,  1 VBUS off)
- *  on 144 pins board PG_6 is used ( 1 VBUS on, 0 VBUS on)
- */
-static gpio_t gpio_vbus;
-
-#if defined(USBHALHOST_64pins)
-#define  VBUS_OFF 1
-#define  VBUS_ON 0
-#define USB_VBUS_CONFIG \
-    do {__HAL_RCC_GPIOC_CLK_ENABLE();\
-		gpio_init_out_ex(&gpio_vbus, PC_0, VBUS_OFF);\
-	}while(0);
-#else
-#define  VBUS_OFF 0
-#define  VBUS_ON 1
-#define USB_VBUS_CONFIG \
-    do {__HAL_RCC_GPIOG_CLK_ENABLE();\
-		gpio_init_out_ex(&gpio_vbus, PG_6, VBUS_OFF);\
-	}while(0);
-#endif
-
-void  usb_vbus( uint8_t state)
-{
-    if(state == 0)
-    {
-        gpio_write(&gpio_vbus, VBUS_OFF);
-    }
-    else
-    {
-        gpio_write(&gpio_vbus, VBUS_ON);
-    }
-    wait(0.2);
-}
-
-USBHALHost::USBHALHost() {
-    instHost = this;
-    HCD_HandleTypeDef *hhcd;
-    USBHALHost_Private_t *HALPriv = new(USBHALHost_Private_t);
-    memset(HALPriv, 0, sizeof(USBHALHost_Private_t));
-    memInit();
-    memset((void*)usb_hcca, 0, HCCA_SIZE);
-    hhcd = (HCD_HandleTypeDef *)usb_hcca;
-    hhcd->Instance = USB_OTG_FS;
-    hhcd->pData = (void*)HALPriv;
-    hhcd->Init.Host_channels = 11;
-    hhcd->Init.speed = HCD_SPEED_FULL; 
-    hhcd->Init.phy_itface = HCD_PHY_EMBEDDED;
-    HALPriv->inst = this;
-    HALPriv->deviceConnected = &USBHALHost::deviceConnected;
-    HALPriv->deviceDisconnected = &USBHALHost::deviceDisconnected;
-    HALPriv->transferCompleted = &USBHALHost::transferCompleted;
-    for (int i = 0; i < MAX_ENDPOINT; i++) {
-        edBufAlloc[i] = false;
-        HALPriv->addr[i]=(uint32_t)-1;
-    }
-    for (int i = 0; i < MAX_TD; i++) {
-        tdBufAlloc[i] = false;
-    }
-    __HAL_RCC_PWR_CLK_ENABLE();
-#ifdef TARGET_STM32L4
-    HAL_PWREx_EnableVddUSB();
-#endif
-    /* Configure USB FS GPIOs */
-    __HAL_RCC_GPIOA_CLK_ENABLE();
-
-    /*USB DM and DP */
-    pin_function(PA_11, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF10_OTG_FS));
-    pin_function(PA_12, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF10_OTG_FS));
-    /*USB ID */
-    pin_function(PA_10, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_PULLUP, GPIO_AF10_OTG_FS));
-
-    __HAL_RCC_SYSCFG_CLK_ENABLE();
-    /* Configure POWER_SWITCH IO pin */
-    USB_VBUS_CONFIG;
-    /* Enable USB FS Clocks */
-    __HAL_RCC_USB_OTG_FS_CLK_ENABLE();
-
-    /* Set USBFS Interrupt priority */
-    HAL_NVIC_SetPriority(OTG_FS_IRQn, 6, 0);
-}
-#endif
--- a/targets/TARGET_STM/USBHAL_STM_144_64pins.h	Thu Feb 09 10:05:54 2017 -0600
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,133 +0,0 @@
-/* Copyright (c) 2016 mbed.org, MIT License
-*
-* 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.
-*/
-#ifndef USBHAL_STM32_144_64
-#define USBHAL_STM32_144_64
-
-#define USBHAL_IRQn  OTG_FS_IRQn
-/*  must be multiple of 4 bytes */
-#define NB_ENDPOINT 4
-#define MAXTRANSFER_SIZE  0x200
-#define FIFO_USB_RAM_SIZE (MAXTRANSFER_SIZE+MAX_PACKET_SIZE_EP0+MAX_PACKET_SIZE_EP1+MAX_PACKET_SIZE_EP2+MAX_PACKET_SIZE_EP3)
-#if (FIFO_USB_RAM_SIZE > 0x500)
-#error "FIFO dimensioning incorrect"
-#endif
-
-typedef struct
-{
-    USBHAL *inst;
-    void (USBHAL::*bus_reset)(void);
-    void (USBHAL::*sof)(int frame);
-    void (USBHAL::*connect_change)(unsigned int  connected);
-    void (USBHAL::*suspend_change)(unsigned int suspended);
-    void (USBHAL::*ep0_setup)(void);
-    void (USBHAL::*ep0_in)(void);
-    void (USBHAL::*ep0_out)(void);
-    void (USBHAL::*ep0_read)(void);
-    bool (USBHAL::*ep_realise)(uint8_t endpoint, uint32_t maxPacket, uint32_t flags);
-    bool (USBHAL::*epCallback[2*NB_ENDPOINT-2])(void);
-    /*  memorize dummy buffer used for reception */
-    uint32_t pBufRx[MAXTRANSFER_SIZE>>2];
-    uint32_t pBufRx0[MAX_PACKET_SIZE_EP0>>2];
-    uint8_t epComplete[2*NB_ENDPOINT];
-}USBHAL_Private_t;
-
-uint32_t HAL_PCDEx_GetTxFiFo(PCD_HandleTypeDef *hpcd, uint8_t fifo)
-{
-    uint32_t len;
-    if (fifo == 0) len = hpcd->Instance->DIEPTXF0_HNPTXFSIZ>>16;
-    else
-        len =  hpcd->Instance->DIEPTXF[fifo - 1] >> 16;
-    return len*4;
-}
-void HAL_PCD_SOFCallback(PCD_HandleTypeDef *hpcd) 
-{
-    USBHAL_Private_t *priv=((USBHAL_Private_t *)(hpcd->pData));
-    USBHAL *obj= priv->inst;
-    USB_OTG_GlobalTypeDef *USBx = hpcd->Instance;
-    uint32_t sofnum = (USBx_DEVICE->DSTS & USB_OTG_DSTS_FNSOF) >> 8;
-    void (USBHAL::*func)(int frame) = priv->sof;
-    /* fix me  call with same frame number */
-    (obj->*func)(sofnum);
-}
-
-
-USBHAL * USBHAL::instance;
-
-USBHAL::USBHAL(void) {
-    /*  init parameter  */
-    USBHAL_Private_t *HALPriv = new(USBHAL_Private_t);
-    hpcd.Instance = USB_OTG_FS;
-    memset(&hpcd.Init, 0, sizeof(hpcd.Init));
-    hpcd.Init.dev_endpoints = NB_ENDPOINT;
-    hpcd.Init.ep0_mps =   MAX_PACKET_SIZE_EP0;
-    hpcd.Init.phy_itface = PCD_PHY_EMBEDDED;
-    hpcd.Init.Sof_enable = 1;
-
-    hpcd.Init.speed = PCD_SPEED_FULL;
-    //hpcd.Init.vbus_sensing_enable = 0;
-    //hpcd.Init.lpm_enable = 0;
-    /*  pass instance for usage inside call back */
-    HALPriv->inst = this;
-    HALPriv->bus_reset = &USBHAL::busReset;
-    HALPriv->suspend_change = &USBHAL::suspendStateChanged;
-    HALPriv->connect_change = &USBHAL::connectStateChanged;
-    HALPriv->sof = &USBHAL::SOF;
-    HALPriv->ep0_setup = &USBHAL::EP0setupCallback;
-    HALPriv->ep_realise = &USBHAL::realiseEndpoint;
-    HALPriv->ep0_in = &USBHAL::EP0in;
-    HALPriv->ep0_out = &USBHAL::EP0out;
-    HALPriv->ep0_read = &USBHAL::EP0read;
-    hpcd.pData = (void*)HALPriv;
-    HALPriv->epCallback[0] = &USBHAL::EP1_OUT_callback;
-    HALPriv->epCallback[1] = &USBHAL::EP1_IN_callback;
-    HALPriv->epCallback[2] = &USBHAL::EP2_OUT_callback;
-    HALPriv->epCallback[3] = &USBHAL::EP2_IN_callback;
-    HALPriv->epCallback[4] = &USBHAL::EP3_OUT_callback;
-    HALPriv->epCallback[5] = &USBHAL::EP3_IN_callback;
-    instance = this;
-    // Enable power and clocking
-    /*  board 144 pin all similar  */
-    __HAL_RCC_GPIOA_CLK_ENABLE();
-    pin_function(PA_8, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF10_OTG_FS));
-    pin_function(PA_9, STM_PIN_DATA(STM_MODE_INPUT, GPIO_NOPULL, GPIO_AF10_OTG_FS));
-    pin_function(PA_10, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_PULLUP, GPIO_AF10_OTG_FS));
-    pin_function(PA_11, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF10_OTG_FS));
-    pin_function(PA_12, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF10_OTG_FS));
-
-    __HAL_RCC_USB_OTG_FS_CLK_ENABLE();
-    __HAL_RCC_SYSCFG_CLK_ENABLE();
-    hpcd.State = HAL_PCD_STATE_RESET;
-    HAL_PCD_Init(&hpcd);
-    /* 1.25kbytes */
-    /* min value 16 (= 16 x 4 bytes) */
-    /*  max value 256 (= 1K bytes ) */
-    /*  maximum sum is 0x140 */
-    HAL_PCDEx_SetRxFiFo(&hpcd, (MAXTRANSFER_SIZE/4));
-    /*  bulk/int 64 bytes in FS  */
-    HAL_PCDEx_SetTxFiFo(&hpcd, 0, (MAX_PACKET_SIZE_EP0/4)+1);
-    /*  bulk/int bytes in FS */
-    HAL_PCDEx_SetTxFiFo(&hpcd, 1, (MAX_PACKET_SIZE_EP1/4));
-    HAL_PCDEx_SetTxFiFo(&hpcd, 2, (MAX_PACKET_SIZE_EP2/4));
-    /* ISOchronous */
-    HAL_PCDEx_SetTxFiFo(&hpcd, 3, (MAX_PACKET_SIZE_EP3/4));
-    NVIC_SetVector(USBHAL_IRQn, (uint32_t)&_usbisr);
-    NVIC_SetPriority(USBHAL_IRQn, 1);
-    HAL_PCD_Start(&hpcd);
-}
-#endif
-
--- a/targets/targets.json	Thu Feb 09 10:05:54 2017 -0600
+++ b/targets/targets.json	Fri Feb 10 11:48:44 2017 -0600
@@ -899,7 +899,7 @@
         "extra_labels": ["STM", "STM32F4", "STM32F439", "STM32F439ZI", "STM32F439xx", "STM32F439xI"],
         "supported_toolchains": ["ARM", "uARM", "GCC_ARM", "IAR"],
         "progen": {"target": "nucleo-f439zi"},
-        "macros": ["TRANSACTION_QUEUE_SIZE_SPI=2", "USB_STM_HAL", "USBHOST_OTHER"],
+        "macros": ["TRANSACTION_QUEUE_SIZE_SPI=2"],
         "device_has": ["ANALOGIN", "ANALOGOUT", "CAN", "ERROR_RED", "I2C", "I2CSLAVE", "I2C_ASYNCH", "INTERRUPTIN", "LOWPOWERTIMER", "PORTIN", "PORTINOUT", "PORTOUT", "PWMOUT", "RTC", "SERIAL", "SERIAL_FC", "SLEEP", "SPI", "SPISLAVE", "SPI_ASYNCH", "STDIO_MESSAGES", "TRNG"],
         "detect_code": ["0797"],
         "features": ["LWIP"],