aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorgdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2012-06-16 06:22:39 +0000
committergdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2012-06-16 06:22:39 +0000
commit166d6bf8b5e5a9e39efd0458feee04be4d1674d6 (patch)
treec45f3d1fd901d0f2a0d880cee9cef387a883936a
parent2b1173e29246cbc82f45490d0b1b1443d7bf897a (diff)
downloadChibiOS-166d6bf8b5e5a9e39efd0458feee04be4d1674d6.tar.gz
ChibiOS-166d6bf8b5e5a9e39efd0458feee04be4d1674d6.tar.bz2
ChibiOS-166d6bf8b5e5a9e39efd0458feee04be4d1674d6.zip
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@4277 35acf78f-673a-0410-8e92-d51de3d6d3f4
-rw-r--r--demos/ARMCM3-STM32F100-DISCOVERY/mcuconf.h2
-rw-r--r--demos/ARMCM3-STM32F103-FATFS/mcuconf.h2
-rw-r--r--demos/ARMCM3-STM32F103-G++/mcuconf.h2
-rw-r--r--demos/ARMCM3-STM32F103/mcuconf.h2
-rw-r--r--demos/ARMCM3-STM32F103ZG-FATFS/mcuconf.h2
-rw-r--r--demos/ARMCM3-STM32F107-LWIP/mcuconf.h2
-rw-r--r--demos/ARMCM3-STM32F107/mcuconf.h2
-rw-r--r--demos/ARMCM3-STM32L152-DISCOVERY/mcuconf.h2
-rw-r--r--os/hal/platforms/STM32/OTGv1/usb_lld.c67
-rw-r--r--os/hal/platforms/STM32/OTGv1/usb_lld.h2
-rw-r--r--os/hal/platforms/STM32/USBv1/usb_lld.c305
-rw-r--r--os/hal/platforms/STM32/USBv1/usb_lld.h74
-rw-r--r--testhal/STM32F1xx/ADC/mcuconf.h2
-rw-r--r--testhal/STM32F1xx/CAN/mcuconf.h2
-rw-r--r--testhal/STM32F1xx/EXT/mcuconf.h2
-rw-r--r--testhal/STM32F1xx/EXT_WAKEUP/mcuconf.h2
-rw-r--r--testhal/STM32F1xx/GPT/mcuconf.h2
-rw-r--r--testhal/STM32F1xx/I2C/mcuconf.h2
-rw-r--r--testhal/STM32F1xx/IRQ_STORM/mcuconf.h2
-rw-r--r--testhal/STM32F1xx/MAC/mcuconf.h2
-rw-r--r--testhal/STM32F1xx/PVD/mcuconf.h2
-rw-r--r--testhal/STM32F1xx/PWM-ICU/mcuconf.h2
-rw-r--r--testhal/STM32F1xx/RTC/mcuconf.h2
-rw-r--r--testhal/STM32F1xx/SDC/mcuconf.h2
-rw-r--r--testhal/STM32F1xx/SPI/mcuconf.h2
-rw-r--r--testhal/STM32F1xx/UART/mcuconf.h2
-rw-r--r--testhal/STM32F1xx/USB_CDC/main.c24
-rw-r--r--testhal/STM32F1xx/USB_CDC/mcuconf.h2
-rw-r--r--testhal/STM32F1xx/USB_MSC/mcuconf.h2
-rw-r--r--testhal/STM32F4xx/USB_CDC/main.c10
-rw-r--r--testhal/STM32L1xx/ADC/mcuconf.h2
-rw-r--r--testhal/STM32L1xx/EXT/mcuconf.h2
-rw-r--r--testhal/STM32L1xx/GPT/mcuconf.h2
-rw-r--r--testhal/STM32L1xx/IRQ_STORM/mcuconf.h2
-rw-r--r--testhal/STM32L1xx/PVD/mcuconf.h2
-rw-r--r--testhal/STM32L1xx/PWM-ICU/mcuconf.h2
-rw-r--r--testhal/STM32L1xx/SPI/mcuconf.h2
-rw-r--r--testhal/STM32L1xx/UART/mcuconf.h2
38 files changed, 338 insertions, 208 deletions
diff --git a/demos/ARMCM3-STM32F100-DISCOVERY/mcuconf.h b/demos/ARMCM3-STM32F100-DISCOVERY/mcuconf.h
index 0c6269480..a57920fd1 100644
--- a/demos/ARMCM3-STM32F100-DISCOVERY/mcuconf.h
+++ b/demos/ARMCM3-STM32F100-DISCOVERY/mcuconf.h
@@ -200,5 +200,5 @@
*/
#define STM32_USB_USE_USB1 TRUE
#define STM32_USB_LOW_POWER_ON_SUSPEND FALSE
-#define STM32_USB_USB1_HP_IRQ_PRIORITY 6
+#define STM32_USB_USB1_HP_IRQ_PRIORITY 13
#define STM32_USB_USB1_LP_IRQ_PRIORITY 14
diff --git a/demos/ARMCM3-STM32F103-FATFS/mcuconf.h b/demos/ARMCM3-STM32F103-FATFS/mcuconf.h
index 8f57ef9bd..8638acca5 100644
--- a/demos/ARMCM3-STM32F103-FATFS/mcuconf.h
+++ b/demos/ARMCM3-STM32F103-FATFS/mcuconf.h
@@ -202,5 +202,5 @@
*/
#define STM32_USB_USE_USB1 TRUE
#define STM32_USB_LOW_POWER_ON_SUSPEND FALSE
-#define STM32_USB_USB1_HP_IRQ_PRIORITY 6
+#define STM32_USB_USB1_HP_IRQ_PRIORITY 13
#define STM32_USB_USB1_LP_IRQ_PRIORITY 14
diff --git a/demos/ARMCM3-STM32F103-G++/mcuconf.h b/demos/ARMCM3-STM32F103-G++/mcuconf.h
index e87bba983..637d4b26f 100644
--- a/demos/ARMCM3-STM32F103-G++/mcuconf.h
+++ b/demos/ARMCM3-STM32F103-G++/mcuconf.h
@@ -202,5 +202,5 @@
*/
#define STM32_USB_USE_USB1 TRUE
#define STM32_USB_LOW_POWER_ON_SUSPEND FALSE
-#define STM32_USB_USB1_HP_IRQ_PRIORITY 6
+#define STM32_USB_USB1_HP_IRQ_PRIORITY 13
#define STM32_USB_USB1_LP_IRQ_PRIORITY 14
diff --git a/demos/ARMCM3-STM32F103/mcuconf.h b/demos/ARMCM3-STM32F103/mcuconf.h
index e87bba983..637d4b26f 100644
--- a/demos/ARMCM3-STM32F103/mcuconf.h
+++ b/demos/ARMCM3-STM32F103/mcuconf.h
@@ -202,5 +202,5 @@
*/
#define STM32_USB_USE_USB1 TRUE
#define STM32_USB_LOW_POWER_ON_SUSPEND FALSE
-#define STM32_USB_USB1_HP_IRQ_PRIORITY 6
+#define STM32_USB_USB1_HP_IRQ_PRIORITY 13
#define STM32_USB_USB1_LP_IRQ_PRIORITY 14
diff --git a/demos/ARMCM3-STM32F103ZG-FATFS/mcuconf.h b/demos/ARMCM3-STM32F103ZG-FATFS/mcuconf.h
index 5fe9b07d6..d13f2ad3c 100644
--- a/demos/ARMCM3-STM32F103ZG-FATFS/mcuconf.h
+++ b/demos/ARMCM3-STM32F103ZG-FATFS/mcuconf.h
@@ -202,5 +202,5 @@
*/
#define STM32_USB_USE_USB1 TRUE
#define STM32_USB_LOW_POWER_ON_SUSPEND FALSE
-#define STM32_USB_USB1_HP_IRQ_PRIORITY 6
+#define STM32_USB_USB1_HP_IRQ_PRIORITY 13
#define STM32_USB_USB1_LP_IRQ_PRIORITY 14
diff --git a/demos/ARMCM3-STM32F107-LWIP/mcuconf.h b/demos/ARMCM3-STM32F107-LWIP/mcuconf.h
index 9fdef0029..46336b962 100644
--- a/demos/ARMCM3-STM32F107-LWIP/mcuconf.h
+++ b/demos/ARMCM3-STM32F107-LWIP/mcuconf.h
@@ -207,5 +207,5 @@
*/
#define STM32_USB_USE_USB1 TRUE
#define STM32_USB_LOW_POWER_ON_SUSPEND FALSE
-#define STM32_USB_USB1_HP_IRQ_PRIORITY 6
+#define STM32_USB_USB1_HP_IRQ_PRIORITY 13
#define STM32_USB_USB1_LP_IRQ_PRIORITY 14
diff --git a/demos/ARMCM3-STM32F107/mcuconf.h b/demos/ARMCM3-STM32F107/mcuconf.h
index 9fdef0029..46336b962 100644
--- a/demos/ARMCM3-STM32F107/mcuconf.h
+++ b/demos/ARMCM3-STM32F107/mcuconf.h
@@ -207,5 +207,5 @@
*/
#define STM32_USB_USE_USB1 TRUE
#define STM32_USB_LOW_POWER_ON_SUSPEND FALSE
-#define STM32_USB_USB1_HP_IRQ_PRIORITY 6
+#define STM32_USB_USB1_HP_IRQ_PRIORITY 13
#define STM32_USB_USB1_LP_IRQ_PRIORITY 14
diff --git a/demos/ARMCM3-STM32L152-DISCOVERY/mcuconf.h b/demos/ARMCM3-STM32L152-DISCOVERY/mcuconf.h
index aefc3506a..3caecfd80 100644
--- a/demos/ARMCM3-STM32L152-DISCOVERY/mcuconf.h
+++ b/demos/ARMCM3-STM32L152-DISCOVERY/mcuconf.h
@@ -185,5 +185,5 @@
*/
#define STM32_USB_USE_USB1 TRUE
#define STM32_USB_LOW_POWER_ON_SUSPEND FALSE
-#define STM32_USB_USB1_HP_IRQ_PRIORITY 6
+#define STM32_USB_USB1_HP_IRQ_PRIORITY 13
#define STM32_USB_USB1_LP_IRQ_PRIORITY 14
diff --git a/os/hal/platforms/STM32/OTGv1/usb_lld.c b/os/hal/platforms/STM32/OTGv1/usb_lld.c
index 2efd4dfea..70d985e69 100644
--- a/os/hal/platforms/STM32/OTGv1/usb_lld.c
+++ b/os/hal/platforms/STM32/OTGv1/usb_lld.c
@@ -186,6 +186,30 @@ static uint32_t otg_ram_alloc(USBDriver *usbp, size_t size) {
"otg_fifo_alloc(), #1", "FIFO memory overflow");
return next;
}
+
+/**
+ * @brief Prepares for a receive transaction on an OUT endpoint.
+ * @post The endpoint is ready for @p usbStartReceiveI().
+ *
+ * @param[in] usbp pointer to the @p USBDriver object
+ * @param[in] ep endpoint number
+ * @param[in] n maximum number of bytes to copy
+ *
+ * @special
+ */
+static void otg_prepare_receive(USBDriver *usbp, usbep_t ep, size_t n) {
+ uint32_t pcnt;
+ USBOutEndpointState *osp = usbp->epc[ep]->out_state;
+
+ osp->rxsize = n;
+ osp->rxcnt = 0;
+
+ /* Transfer initialization.*/
+ pcnt = (n + usbp->epc[ep]->out_maxsize - 1) / usbp->epc[ep]->out_maxsize;
+ OTG->oe[ep].DOEPTSIZ = DOEPTSIZ_STUPCNT(3) | DOEPTSIZ_PKTCNT(pcnt) |
+ DOEPTSIZ_XFRSIZ(usbp->epc[ep]->out_maxsize);
+}
+
/**
* @brief Prepares for a transmit transaction on an IN endpoint.
* @post The endpoint is ready for @p usbStartTransmitI().
@@ -219,29 +243,6 @@ static void otg_prepare_transmit(USBDriver *usbp, usbep_t ep, size_t n) {
}
/**
- * @brief Prepares for a receive transaction on an OUT endpoint.
- * @post The endpoint is ready for @p usbStartReceiveI().
- *
- * @param[in] usbp pointer to the @p USBDriver object
- * @param[in] ep endpoint number
- * @param[in] n maximum number of bytes to copy
- *
- * @special
- */
-static void otg_prepare_receive(USBDriver *usbp, usbep_t ep, size_t n) {
- uint32_t pcnt;
- USBOutEndpointState *osp = usbp->epc[ep]->out_state;
-
- osp->rxsize = n;
- osp->rxcnt = 0;
-
- /* Transfer initialization.*/
- pcnt = (n + usbp->epc[ep]->out_maxsize - 1) / usbp->epc[ep]->out_maxsize;
- OTG->oe[ep].DOEPTSIZ = DOEPTSIZ_STUPCNT(3) | DOEPTSIZ_PKTCNT(pcnt) |
- DOEPTSIZ_XFRSIZ(usbp->epc[ep]->out_maxsize);
-}
-
-/**
* @brief Pushes a series of words into a FIFO.
*
* @param[in] fifop pointer to the FIFO register
@@ -666,7 +667,7 @@ void usb_lld_init(void) {
/**
* @brief Configures and activates the USB peripheral.
- * @note Starting the ORG cell can be a slow operation carried out with
+ * @note Starting the OTG cell can be a slow operation carried out with
* interrupts disabled, perform it before starting time-critical
* operations.
*
@@ -901,11 +902,16 @@ void usb_lld_disable_endpoints(USBDriver *usbp) {
* @notapi
*/
usbepstatus_t usb_lld_get_status_out(USBDriver *usbp, usbep_t ep) {
+ uint32_t ctl;
(void)usbp;
- (void)ep;
- return 0;
+ ctl = OTG->oe[ep].DOEPCTL;
+ if (!(ctl & DOEPCTL_USBAEP))
+ return EP_STATUS_DISABLED;
+ if (ctl & DOEPCTL_STALL)
+ return EP_STATUS_STALLED;
+ return EP_STATUS_ACTIVE;
}
/**
@@ -921,11 +927,16 @@ usbepstatus_t usb_lld_get_status_out(USBDriver *usbp, usbep_t ep) {
* @notapi
*/
usbepstatus_t usb_lld_get_status_in(USBDriver *usbp, usbep_t ep) {
+ uint32_t ctl;
(void)usbp;
- (void)ep;
- return 0;
+ ctl = OTG->ie[ep].DIEPCTL;
+ if (!(ctl & DIEPCTL_USBAEP))
+ return EP_STATUS_DISABLED;
+ if (ctl & DIEPCTL_STALL)
+ return EP_STATUS_STALLED;
+ return EP_STATUS_ACTIVE;
}
/**
diff --git a/os/hal/platforms/STM32/OTGv1/usb_lld.h b/os/hal/platforms/STM32/OTGv1/usb_lld.h
index 9dc2a0eec..d9b013976 100644
--- a/os/hal/platforms/STM32/OTGv1/usb_lld.h
+++ b/os/hal/platforms/STM32/OTGv1/usb_lld.h
@@ -64,7 +64,7 @@
* @brief OTG1 interrupt priority level setting.
*/
#if !defined(STM32_USB_OTG1_IRQ_PRIORITY) || defined(__DOXYGEN__)
-#define STM32_USB_OTG1_IRQ_PRIORITY 6
+#define STM32_USB_OTG1_IRQ_PRIORITY 14
#endif
/**
diff --git a/os/hal/platforms/STM32/USBv1/usb_lld.c b/os/hal/platforms/STM32/USBv1/usb_lld.c
index bd0c1a6e2..a719780bc 100644
--- a/os/hal/platforms/STM32/USBv1/usb_lld.c
+++ b/os/hal/platforms/STM32/USBv1/usb_lld.c
@@ -65,17 +65,23 @@ static union {
} ep0_state;
/**
+ * @brief Buffer for the EP0 setup packets.
+ */
+static uint8_t ep0setup_buffer[8];
+
+/**
* @brief EP0 initialization structure.
*/
static const USBEndpointConfig ep0config = {
- USB_EP_MODE_TYPE_CTRL | USB_EP_MODE_TRANSACTION,
+ USB_EP_MODE_TYPE_CTRL,
_usb_ep0setup,
_usb_ep0in,
_usb_ep0out,
0x40,
0x40,
&ep0_state.in,
- &ep0_state.out
+ &ep0_state.out,
+ ep0setup_buffer
};
/*===========================================================================*/
@@ -109,6 +115,117 @@ static uint32_t pm_alloc(USBDriver *usbp, size_t size) {
return next;
}
+/**
+ * @brief Reads from a dedicated packet buffer.
+ *
+ * @param[in] usbp pointer to the @p USBDriver object
+ * @param[in] ep endpoint number
+ * @param[out] buf buffer where to copy the packet data
+ * @param[in] n maximum number of bytes to copy. This value must
+ * not exceed the maximum packet size for this endpoint.
+ * @return The received packet size regardless the specified
+ * @p n parameter.
+ * @retval 0 Zero size packet received.
+ *
+ * @notapi
+ */
+static size_t usb_read_packet_buffer(USBDriver *usbp, usbep_t ep,
+ uint8_t *buf, size_t n) {
+ uint32_t *pmap;
+ stm32_usb_descriptor_t *udp;
+ size_t count;
+
+ (void)usbp;
+ udp = USB_GET_DESCRIPTOR(ep);
+ pmap = USB_ADDR2PTR(udp->RXADDR0);
+ count = (size_t)udp->RXCOUNT0 & RXCOUNT_COUNT_MASK;
+ if (n > count)
+ n = count;
+ n = (n + 1) / 2;
+ while (n > 0) {
+ *(uint16_t *)buf = (uint16_t)*pmap++;
+ buf += 2;
+ n--;
+ }
+ return count;
+}
+
+/**
+ * @brief Writes to a dedicated packet buffer.
+ *
+ * @param[in] usbp pointer to the @p USBDriver object
+ * @param[in] ep endpoint number
+ * @param[in] buf buffer where to fetch the packet data
+ * @param[in] n maximum number of bytes to copy. This value must
+ * not exceed the maximum packet size for this endpoint.
+ *
+ * @notapi
+ */
+static void usb_write_packet_buffer(USBDriver *usbp, usbep_t ep,
+ const uint8_t *buf, size_t n) {
+ uint32_t *pmap;
+ stm32_usb_descriptor_t *udp;
+
+ (void)usbp;
+ udp = USB_GET_DESCRIPTOR(ep);
+ pmap = USB_ADDR2PTR(udp->TXADDR0);
+ udp->TXCOUNT0 = (uint16_t)n;
+ n = (n + 1) / 2;
+ while (n > 0) {
+ *pmap++ = *(uint16_t *)buf;
+ buf += 2;
+ n--;
+ }
+}
+
+/**
+ * @brief Prepares for a receive transaction on an OUT endpoint.
+ * @post The endpoint is ready for @p usbStartReceiveI().
+ *
+ * @param[in] usbp pointer to the @p USBDriver object
+ * @param[in] ep endpoint number
+ * @param[in] n maximum number of bytes to copy
+ *
+ * @special
+ */
+static void usb_prepare_receive(USBDriver *usbp, usbep_t ep, size_t n) {
+ USBOutEndpointState *osp = usbp->epc[ep]->out_state;
+
+ osp->rxsize = n;
+ osp->rxcnt = 0;
+
+ /* Transfer initialization.*/
+ if (osp->rxsize == 0) /* Special case for zero sized packets.*/
+ osp->rxpkts = 1;
+ else
+ osp->rxpkts = (uint16_t)((n + usbp->epc[ep]->out_maxsize - 1) /
+ usbp->epc[ep]->out_maxsize);
+}
+
+/**
+ * @brief Prepares for a transmit transaction on an IN endpoint.
+ * @post The endpoint is ready for @p usbStartTransmitI().
+ * @note The transmit transaction size is equal to the data contained
+ * in the queue.
+ *
+ * @param[in] usbp pointer to the @p USBDriver object
+ * @param[in] ep endpoint number
+ * @param[in] n maximum number of bytes to copy
+ *
+ * @special
+ */
+static void usb_prepare_transmit(USBDriver *usbp, usbep_t ep, size_t n) {
+ USBInEndpointState *isp = usbp->epc[ep]->in_state;
+
+ isp->txsize = n;
+ isp->txcnt = 0;
+
+ /* Transfer initialization.*/
+ if (n > (size_t)usbp->epc[ep]->in_maxsize)
+ n = (size_t)usbp->epc[ep]->in_maxsize;
+ usb_write_packet_buffer(usbp, ep, isp->mode.linear.txbuf, n);
+}
+
/*===========================================================================*/
/* Driver interrupt handlers. */
/*===========================================================================*/
@@ -189,29 +306,24 @@ CH_IRQ_HANDLER(Vector90) {
if (epr & EPR_CTR_TX) {
/* IN endpoint, transmission.*/
EPR_CLEAR_CTR_TX(ep);
- if (epcp->ep_mode & USB_EP_MODE_PACKET) {
- /* Packet mode, just invokes the callback.*/
- _usb_isr_invoke_in_cb(usbp, ep);
+
+ n = (size_t)USB_GET_DESCRIPTOR(ep)->TXCOUNT0;
+ epcp->in_state->mode.linear.txbuf += n;
+ epcp->in_state->txcnt += n;
+ epcp->in_state->txsize -= n;
+ if (epcp->in_state->txsize > 0) {
+ /* Transfer not completed, there are more packets to send.*/
+ if (epcp->in_state->txsize > epcp->in_maxsize)
+ n = epcp->in_maxsize;
+ else
+ n = epcp->in_state->txsize;
+ usb_write_packet_buffer(usbp, ep,
+ epcp->in_state->mode.linear.txbuf, n);
+ usb_lld_start_in(usbp, ep);
}
else {
- /* Transaction mode.*/
- n = (size_t)USB_GET_DESCRIPTOR(ep)->TXCOUNT0;
- epcp->in_state->txbuf += n;
- epcp->in_state->txcnt += n;
- epcp->in_state->txsize -= n;
- if (epcp->in_state->txsize > 0) {
- /* Transfer not completed, there are more packets to send.*/
- if (epcp->in_state->txsize > epcp->in_maxsize)
- n = epcp->in_maxsize;
- else
- n = epcp->in_state->txsize;
- usb_lld_write_packet_buffer(usbp, ep, epcp->in_state->txbuf, n);
- usb_lld_start_in(usbp, ep);
- }
- else {
- /* Transfer completed, invokes the callback.*/
- _usb_isr_invoke_in_cb(usbp, ep);
- }
+ /* Transfer completed, invokes the callback.*/
+ _usb_isr_invoke_in_cb(usbp, ep);
}
}
if (epr & EPR_CTR_RX) {
@@ -222,20 +334,15 @@ CH_IRQ_HANDLER(Vector90) {
specific callback.*/
_usb_isr_invoke_setup_cb(usbp, ep);
}
- else if (epcp->ep_mode & USB_EP_MODE_PACKET) {
- /* Packet mode, just invokes the callback.*/
- _usb_isr_invoke_out_cb(usbp, ep);
- }
else {
- /* Transaction mode.*/
- n = usb_lld_read_packet_buffer(usbp, ep,
- epcp->out_state->rxbuf,
+ n = usb_read_packet_buffer(usbp, ep,
+ epcp->out_state->mode.linear.rxbuf,
epcp->out_state->rxsize);
usb_lld_start_out(usbp, ep);
- epcp->out_state->rxbuf += n;
- epcp->out_state->rxcnt += n;
- epcp->out_state->rxsize -= n;
- epcp->out_state->rxpkts -= 1;
+ epcp->out_state->mode.linear.rxbuf += n;
+ epcp->out_state->rxcnt += n;
+ epcp->out_state->rxsize -= n;
+ epcp->out_state->rxpkts -= 1;
if (epcp->out_state->rxpkts > 0) {
/* Transfer not completed, there are more packets to receive.*/
EPR_SET_STAT_RX(ep, EPR_STAT_RX_VALID);
@@ -393,20 +500,13 @@ void usb_lld_init_endpoint(USBDriver *usbp, usbep_t ep) {
epr = EPR_EP_TYPE_CONTROL;
}
- /* IN endpoint settings, always in NAK mode initially.*/
+ /* IN endpoint initially in NAK mode.*/
if (epcp->in_cb != NULL)
epr |= EPR_STAT_TX_NAK;
- /* OUT endpoint settings. If the endpoint is in packet mode then it must
- start ready to accept data else it must start in NAK mode.*/
- if (epcp->out_cb != NULL) {
- if (epcp->ep_mode & USB_EP_MODE_PACKET) {
- usbp->receiving |= (1 << ep);
- epr |= EPR_STAT_RX_VALID;
- }
- else
- epr |= EPR_STAT_RX_NAK;
- }
+ /* OUT endpoint initially in NAK mode.*/
+ if (epcp->out_cb != NULL)
+ epr |= EPR_STAT_RX_NAK;
/* EPxR register setup.*/
EPR_SET(ep, epr | ep);
@@ -524,118 +624,87 @@ void usb_lld_read_setup(USBDriver *usbp, usbep_t ep, uint8_t *buf) {
}
/**
- * @brief Reads from a dedicated packet buffer.
- * @pre In order to use this function he endpoint must have been
- * initialized in packet mode.
- * @note This function can be invoked both in thread and IRQ context.
+ * @brief Prepares for a receive operation.
*
* @param[in] usbp pointer to the @p USBDriver object
* @param[in] ep endpoint number
- * @param[out] buf buffer where to copy the packet data
- * @param[in] n maximum number of bytes to copy. This value must
- * not exceed the maximum packet size for this endpoint.
- * @return The received packet size regardless the specified
- * @p n parameter.
- * @retval 0 Zero size packet received.
+ * @param[out] buf buffer where to copy the received data
+ * @param[in] n maximum number of bytes to copy
*
* @notapi
*/
-size_t usb_lld_read_packet_buffer(USBDriver *usbp, usbep_t ep,
- uint8_t *buf, size_t n) {
- uint32_t *pmap;
- stm32_usb_descriptor_t *udp;
- size_t count;
+void usb_lld_prepare_receive(USBDriver *usbp, usbep_t ep,
+ uint8_t *buf, size_t n) {
+ USBOutEndpointState *osp = usbp->epc[ep]->out_state;
- (void)usbp;
- udp = USB_GET_DESCRIPTOR(ep);
- pmap = USB_ADDR2PTR(udp->RXADDR0);
- count = (size_t)udp->RXCOUNT0 & RXCOUNT_COUNT_MASK;
- if (n > count)
- n = count;
- n = (n + 1) / 2;
- while (n > 0) {
- *(uint16_t *)buf = (uint16_t)*pmap++;
- buf += 2;
- n--;
- }
- return count;
+ osp->rxqueued = FALSE;
+ osp->mode.linear.rxbuf = buf;
+ usb_prepare_receive(usbp, ep, n);
}
/**
- * @brief Writes to a dedicated packet buffer.
- * @pre In order to use this function he endpoint must have been
- * initialized in packet mode.
- * @note This function can be invoked both in thread and IRQ context.
+ * @brief Prepares for a transmit operation.
*
* @param[in] usbp pointer to the @p USBDriver object
* @param[in] ep endpoint number
- * @param[in] buf buffer where to fetch the packet data
- * @param[in] n maximum number of bytes to copy. This value must
- * not exceed the maximum packet size for this endpoint.
+ * @param[in] buf buffer where to fetch the data to be transmitted
+ * @param[in] n maximum number of bytes to copy
*
* @notapi
*/
-void usb_lld_write_packet_buffer(USBDriver *usbp, usbep_t ep,
- const uint8_t *buf, size_t n) {
- uint32_t *pmap;
- stm32_usb_descriptor_t *udp;
+void usb_lld_prepare_transmit(USBDriver *usbp, usbep_t ep,
+ const uint8_t *buf, size_t n) {
+ USBInEndpointState *isp = usbp->epc[ep]->in_state;
- (void)usbp;
- udp = USB_GET_DESCRIPTOR(ep);
- pmap = USB_ADDR2PTR(udp->TXADDR0);
- udp->TXCOUNT0 = (uint16_t)n;
- n = (n + 1) / 2;
- while (n > 0) {
- *pmap++ = *(uint16_t *)buf;
- buf += 2;
- n--;
- }
+ isp->txqueued = FALSE;
+ isp->mode.linear.txbuf = buf;
+ usb_prepare_transmit(usbp, ep, n);
}
/**
- * @brief Prepares for a receive operation.
+ * @brief Prepares for a receive transaction on an OUT endpoint.
+ * @post The endpoint is ready for @p usbStartReceiveI().
+ * @note The receive transaction size is equal to the space in the queue
+ * rounded to the lower multiple of a packet size. Make sure there
+ * is room for at least one packet in the queue before starting
+ * the receive operation.
*
* @param[in] usbp pointer to the @p USBDriver object
* @param[in] ep endpoint number
- * @param[out] buf buffer where to copy the received data
+ * @param[in] iq input queue to be filled with incoming data
* @param[in] n maximum number of bytes to copy
*
- * @notapi
+ * @special
*/
-void usb_lld_prepare_receive(USBDriver *usbp, usbep_t ep,
- uint8_t *buf, size_t n) {
+void usb_lld_prepare_queued_receive(USBDriver *usbp, usbep_t ep,
+ InputQueue *iq, size_t n) {
USBOutEndpointState *osp = usbp->epc[ep]->out_state;
- osp->rxbuf = buf;
- osp->rxsize = n;
- osp->rxcnt = 0;
- if (osp->rxsize == 0) /* Special case for zero sized packets.*/
- osp->rxpkts = 1;
- else
- osp->rxpkts = (uint16_t)((n + usbp->epc[ep]->out_maxsize - 1) /
- usbp->epc[ep]->out_maxsize);
+ osp->rxqueued = TRUE;
+ osp->mode.queue.rxqueue = iq;
+ usb_prepare_receive(usbp, ep, n);
}
/**
- * @brief Prepares for a transmit operation.
+ * @brief Prepares for a transmit transaction on an IN endpoint.
+ * @post The endpoint is ready for @p usbStartTransmitI().
+ * @note The transmit transaction size is equal to the data contained
+ * in the queue.
*
* @param[in] usbp pointer to the @p USBDriver object
* @param[in] ep endpoint number
- * @param[in] buf buffer where to fetch the data to be transmitted
+ * @param[in] oq output queue to be fetched for outgoing data
* @param[in] n maximum number of bytes to copy
*
- * @notapi
+ * @special
*/
-void usb_lld_prepare_transmit(USBDriver *usbp, usbep_t ep,
- const uint8_t *buf, size_t n) {
+void usb_lld_prepare_queued_transmit(USBDriver *usbp, usbep_t ep,
+ OutputQueue *oq, size_t n) {
USBInEndpointState *isp = usbp->epc[ep]->in_state;
- isp->txbuf = buf;
- isp->txsize = n;
- isp->txcnt = 0;
- if (n > (size_t)usbp->epc[ep]->in_maxsize)
- n = (size_t)usbp->epc[ep]->in_maxsize;
- usb_lld_write_packet_buffer(usbp, ep, buf, n);
+ isp->txqueued = TRUE;
+ isp->mode.queue.txqueue = oq;
+ usb_prepare_transmit(usbp, ep, n);
}
/**
diff --git a/os/hal/platforms/STM32/USBv1/usb_lld.h b/os/hal/platforms/STM32/USBv1/usb_lld.h
index fb1e38bd6..1520e97c6 100644
--- a/os/hal/platforms/STM32/USBv1/usb_lld.h
+++ b/os/hal/platforms/STM32/USBv1/usb_lld.h
@@ -71,7 +71,7 @@
* @brief USB1 interrupt priority level setting.
*/
#if !defined(STM32_USB_USB1_HP_IRQ_PRIORITY) || defined(__DOXYGEN__)
-#define STM32_USB_USB1_HP_IRQ_PRIORITY 6
+#define STM32_USB_USB1_HP_IRQ_PRIORITY 13
#endif
/**
@@ -102,13 +102,13 @@
/*===========================================================================*/
/**
- * @brief Type of an endpoint state structure.
+ * @brief Type of an IN endpoint state structure.
*/
typedef struct {
/**
- * @brief Pointer to the transmission buffer.
+ * @brief Buffer mode, queue or linear.
*/
- const uint8_t *txbuf;
+ bool_t txqueued;
/**
* @brief Requested transmit transfer size.
*/
@@ -117,20 +117,31 @@ typedef struct {
* @brief Transmitted bytes so far.
*/
size_t txcnt;
+ union {
+ struct {
+ /**
+ * @brief Pointer to the transmission linear buffer.
+ */
+ const uint8_t *txbuf;
+ } linear;
+ struct {
+ /**
+ * @brief Pointer to the output queue.
+ */
+ OutputQueue *txqueue;
+ } queue;
+ /* End of the mandatory fields.*/
+ } mode;
} USBInEndpointState;
/**
- * @brief Type of an endpoint state structure.
+ * @brief Type of an OUT endpoint state structure.
*/
typedef struct {
/**
- * @brief Number of packets to receive.
- */
- uint16_t rxpkts;
- /**
- * @brief Pointer to the receive buffer.
+ * @brief Buffer mode, queue or linear.
*/
- uint8_t *rxbuf;
+ bool_t rxqueued;
/**
* @brief Requested receive transfer size.
*/
@@ -139,6 +150,25 @@ typedef struct {
* @brief Received bytes so far.
*/
size_t rxcnt;
+ union {
+ struct {
+ /**
+ * @brief Pointer to the receive linear buffer.
+ */
+ uint8_t *rxbuf;
+ } linear;
+ struct {
+ /**
+ * @brief Pointer to the input queue.
+ */
+ InputQueue *rxqueue;
+ } queue;
+ } mode;
+ /* End of the mandatory fields.*/
+ /**
+ * @brief Number of packets to receive.
+ */
+ uint16_t rxpkts;
} USBOutEndpointState;
/**
@@ -187,19 +217,21 @@ typedef struct {
uint16_t out_maxsize;
/**
* @brief @p USBEndpointState associated to the IN endpoint.
- * @details This structure maintains the state of the IN endpoint when
- * the endpoint is not in packet mode. Endpoints configured in
- * packet mode must set this field to @p NULL.
+ * @details This structure maintains the state of the IN endpoint.
*/
USBInEndpointState *in_state;
/**
* @brief @p USBEndpointState associated to the OUT endpoint.
- * @details This structure maintains the state of the OUT endpoint when
- * the endpoint is not in packet mode. Endpoints configured in
- * packet mode must set this field to @p NULL.
+ * @details This structure maintains the state of the OUT endpoint.
*/
USBOutEndpointState *out_state;
/* End of the mandatory fields.*/
+ /**
+ * @brief Pointer to a buffer for setup packets.
+ * @details Setup packets require a dedicated 8-bytes buffer, set this
+ * field to @p NULL for non-control endpoints.
+ */
+ uint8_t *setup_buf;
} USBEndpointConfig;
/**
@@ -375,14 +407,14 @@ extern "C" {
usbepstatus_t usb_lld_get_status_in(USBDriver *usbp, usbep_t ep);
usbepstatus_t usb_lld_get_status_out(USBDriver *usbp, usbep_t ep);
void usb_lld_read_setup(USBDriver *usbp, usbep_t ep, uint8_t *buf);
- size_t usb_lld_read_packet_buffer(USBDriver *usbp, usbep_t ep,
- uint8_t *buf, size_t n);
- void usb_lld_write_packet_buffer(USBDriver *usbp, usbep_t ep,
- const uint8_t *buf, size_t n);
void usb_lld_prepare_receive(USBDriver *usbp, usbep_t ep,
uint8_t *buf, size_t n);
void usb_lld_prepare_transmit(USBDriver *usbp, usbep_t ep,
const uint8_t *buf, size_t n);
+ void usb_lld_prepare_queued_receive(USBDriver *usbp, usbep_t ep,
+ InputQueue *iq, size_t n);
+ void usb_lld_prepare_queued_transmit(USBDriver *usbp, usbep_t ep,
+ OutputQueue *oq, size_t n);
void usb_lld_start_out(USBDriver *usbp, usbep_t ep);
void usb_lld_start_in(USBDriver *usbp, usbep_t ep);
void usb_lld_stall_out(USBDriver *usbp, usbep_t ep);
diff --git a/testhal/STM32F1xx/ADC/mcuconf.h b/testhal/STM32F1xx/ADC/mcuconf.h
index e87bba983..637d4b26f 100644
--- a/testhal/STM32F1xx/ADC/mcuconf.h
+++ b/testhal/STM32F1xx/ADC/mcuconf.h
@@ -202,5 +202,5 @@
*/
#define STM32_USB_USE_USB1 TRUE
#define STM32_USB_LOW_POWER_ON_SUSPEND FALSE
-#define STM32_USB_USB1_HP_IRQ_PRIORITY 6
+#define STM32_USB_USB1_HP_IRQ_PRIORITY 13
#define STM32_USB_USB1_LP_IRQ_PRIORITY 14
diff --git a/testhal/STM32F1xx/CAN/mcuconf.h b/testhal/STM32F1xx/CAN/mcuconf.h
index e87bba983..637d4b26f 100644
--- a/testhal/STM32F1xx/CAN/mcuconf.h
+++ b/testhal/STM32F1xx/CAN/mcuconf.h
@@ -202,5 +202,5 @@
*/
#define STM32_USB_USE_USB1 TRUE
#define STM32_USB_LOW_POWER_ON_SUSPEND FALSE
-#define STM32_USB_USB1_HP_IRQ_PRIORITY 6
+#define STM32_USB_USB1_HP_IRQ_PRIORITY 13
#define STM32_USB_USB1_LP_IRQ_PRIORITY 14
diff --git a/testhal/STM32F1xx/EXT/mcuconf.h b/testhal/STM32F1xx/EXT/mcuconf.h
index e87bba983..637d4b26f 100644
--- a/testhal/STM32F1xx/EXT/mcuconf.h
+++ b/testhal/STM32F1xx/EXT/mcuconf.h
@@ -202,5 +202,5 @@
*/
#define STM32_USB_USE_USB1 TRUE
#define STM32_USB_LOW_POWER_ON_SUSPEND FALSE
-#define STM32_USB_USB1_HP_IRQ_PRIORITY 6
+#define STM32_USB_USB1_HP_IRQ_PRIORITY 13
#define STM32_USB_USB1_LP_IRQ_PRIORITY 14
diff --git a/testhal/STM32F1xx/EXT_WAKEUP/mcuconf.h b/testhal/STM32F1xx/EXT_WAKEUP/mcuconf.h
index 5fe9b07d6..d13f2ad3c 100644
--- a/testhal/STM32F1xx/EXT_WAKEUP/mcuconf.h
+++ b/testhal/STM32F1xx/EXT_WAKEUP/mcuconf.h
@@ -202,5 +202,5 @@
*/
#define STM32_USB_USE_USB1 TRUE
#define STM32_USB_LOW_POWER_ON_SUSPEND FALSE
-#define STM32_USB_USB1_HP_IRQ_PRIORITY 6
+#define STM32_USB_USB1_HP_IRQ_PRIORITY 13
#define STM32_USB_USB1_LP_IRQ_PRIORITY 14
diff --git a/testhal/STM32F1xx/GPT/mcuconf.h b/testhal/STM32F1xx/GPT/mcuconf.h
index a096ea1b2..b676befa3 100644
--- a/testhal/STM32F1xx/GPT/mcuconf.h
+++ b/testhal/STM32F1xx/GPT/mcuconf.h
@@ -202,5 +202,5 @@
*/
#define STM32_USB_USE_USB1 TRUE
#define STM32_USB_LOW_POWER_ON_SUSPEND FALSE
-#define STM32_USB_USB1_HP_IRQ_PRIORITY 6
+#define STM32_USB_USB1_HP_IRQ_PRIORITY 13
#define STM32_USB_USB1_LP_IRQ_PRIORITY 14
diff --git a/testhal/STM32F1xx/I2C/mcuconf.h b/testhal/STM32F1xx/I2C/mcuconf.h
index dd127bb50..67c11c072 100644
--- a/testhal/STM32F1xx/I2C/mcuconf.h
+++ b/testhal/STM32F1xx/I2C/mcuconf.h
@@ -202,5 +202,5 @@
*/
#define STM32_USB_USE_USB1 TRUE
#define STM32_USB_LOW_POWER_ON_SUSPEND FALSE
-#define STM32_USB_USB1_HP_IRQ_PRIORITY 6
+#define STM32_USB_USB1_HP_IRQ_PRIORITY 13
#define STM32_USB_USB1_LP_IRQ_PRIORITY 14
diff --git a/testhal/STM32F1xx/IRQ_STORM/mcuconf.h b/testhal/STM32F1xx/IRQ_STORM/mcuconf.h
index 2f9654626..08c964954 100644
--- a/testhal/STM32F1xx/IRQ_STORM/mcuconf.h
+++ b/testhal/STM32F1xx/IRQ_STORM/mcuconf.h
@@ -202,5 +202,5 @@
*/
#define STM32_USB_USE_USB1 TRUE
#define STM32_USB_LOW_POWER_ON_SUSPEND FALSE
-#define STM32_USB_USB1_HP_IRQ_PRIORITY 6
+#define STM32_USB_USB1_HP_IRQ_PRIORITY 13
#define STM32_USB_USB1_LP_IRQ_PRIORITY 14
diff --git a/testhal/STM32F1xx/MAC/mcuconf.h b/testhal/STM32F1xx/MAC/mcuconf.h
index b790e4f2a..f6cafb56e 100644
--- a/testhal/STM32F1xx/MAC/mcuconf.h
+++ b/testhal/STM32F1xx/MAC/mcuconf.h
@@ -207,5 +207,5 @@
*/
#define STM32_USB_USE_USB1 TRUE
#define STM32_USB_LOW_POWER_ON_SUSPEND FALSE
-#define STM32_USB_USB1_HP_IRQ_PRIORITY 6
+#define STM32_USB_USB1_HP_IRQ_PRIORITY 13
#define STM32_USB_USB1_LP_IRQ_PRIORITY 14
diff --git a/testhal/STM32F1xx/PVD/mcuconf.h b/testhal/STM32F1xx/PVD/mcuconf.h
index e87bba983..637d4b26f 100644
--- a/testhal/STM32F1xx/PVD/mcuconf.h
+++ b/testhal/STM32F1xx/PVD/mcuconf.h
@@ -202,5 +202,5 @@
*/
#define STM32_USB_USE_USB1 TRUE
#define STM32_USB_LOW_POWER_ON_SUSPEND FALSE
-#define STM32_USB_USB1_HP_IRQ_PRIORITY 6
+#define STM32_USB_USB1_HP_IRQ_PRIORITY 13
#define STM32_USB_USB1_LP_IRQ_PRIORITY 14
diff --git a/testhal/STM32F1xx/PWM-ICU/mcuconf.h b/testhal/STM32F1xx/PWM-ICU/mcuconf.h
index 2dc784db0..f728d5a33 100644
--- a/testhal/STM32F1xx/PWM-ICU/mcuconf.h
+++ b/testhal/STM32F1xx/PWM-ICU/mcuconf.h
@@ -202,5 +202,5 @@
*/
#define STM32_USB_USE_USB1 TRUE
#define STM32_USB_LOW_POWER_ON_SUSPEND FALSE
-#define STM32_USB_USB1_HP_IRQ_PRIORITY 6
+#define STM32_USB_USB1_HP_IRQ_PRIORITY 13
#define STM32_USB_USB1_LP_IRQ_PRIORITY 14
diff --git a/testhal/STM32F1xx/RTC/mcuconf.h b/testhal/STM32F1xx/RTC/mcuconf.h
index 575fda978..6220d2140 100644
--- a/testhal/STM32F1xx/RTC/mcuconf.h
+++ b/testhal/STM32F1xx/RTC/mcuconf.h
@@ -202,5 +202,5 @@
*/
#define STM32_USB_USE_USB1 TRUE
#define STM32_USB_LOW_POWER_ON_SUSPEND FALSE
-#define STM32_USB_USB1_HP_IRQ_PRIORITY 6
+#define STM32_USB_USB1_HP_IRQ_PRIORITY 13
#define STM32_USB_USB1_LP_IRQ_PRIORITY 14
diff --git a/testhal/STM32F1xx/SDC/mcuconf.h b/testhal/STM32F1xx/SDC/mcuconf.h
index e87bba983..637d4b26f 100644
--- a/testhal/STM32F1xx/SDC/mcuconf.h
+++ b/testhal/STM32F1xx/SDC/mcuconf.h
@@ -202,5 +202,5 @@
*/
#define STM32_USB_USE_USB1 TRUE
#define STM32_USB_LOW_POWER_ON_SUSPEND FALSE
-#define STM32_USB_USB1_HP_IRQ_PRIORITY 6
+#define STM32_USB_USB1_HP_IRQ_PRIORITY 13
#define STM32_USB_USB1_LP_IRQ_PRIORITY 14
diff --git a/testhal/STM32F1xx/SPI/mcuconf.h b/testhal/STM32F1xx/SPI/mcuconf.h
index 0aad454d2..b5079e96b 100644
--- a/testhal/STM32F1xx/SPI/mcuconf.h
+++ b/testhal/STM32F1xx/SPI/mcuconf.h
@@ -202,5 +202,5 @@
*/
#define STM32_USB_USE_USB1 TRUE
#define STM32_USB_LOW_POWER_ON_SUSPEND FALSE
-#define STM32_USB_USB1_HP_IRQ_PRIORITY 6
+#define STM32_USB_USB1_HP_IRQ_PRIORITY 13
#define STM32_USB_USB1_LP_IRQ_PRIORITY 14
diff --git a/testhal/STM32F1xx/UART/mcuconf.h b/testhal/STM32F1xx/UART/mcuconf.h
index 1b9968d1b..05dff0cdd 100644
--- a/testhal/STM32F1xx/UART/mcuconf.h
+++ b/testhal/STM32F1xx/UART/mcuconf.h
@@ -202,5 +202,5 @@
*/
#define STM32_USB_USE_USB1 TRUE
#define STM32_USB_LOW_POWER_ON_SUSPEND FALSE
-#define STM32_USB_USB1_HP_IRQ_PRIORITY 6
+#define STM32_USB_USB1_HP_IRQ_PRIORITY 13
#define STM32_USB_USB1_LP_IRQ_PRIORITY 14
diff --git a/testhal/STM32F1xx/USB_CDC/main.c b/testhal/STM32F1xx/USB_CDC/main.c
index 24ba77987..d4625066f 100644
--- a/testhal/STM32F1xx/USB_CDC/main.c
+++ b/testhal/STM32F1xx/USB_CDC/main.c
@@ -226,44 +226,62 @@ static const USBDescriptor *get_descriptor(USBDriver *usbp,
}
/**
+ * @brief IN EP1 state.
+ */
+static USBInEndpointState ep1instate;
+
+/**
* @brief EP1 initialization structure (IN only).
*/
static const USBEndpointConfig ep1config = {
- USB_EP_MODE_TYPE_BULK | USB_EP_MODE_PACKET,
+ USB_EP_MODE_TYPE_BULK,
NULL,
sduDataTransmitted,
NULL,
0x0040,
0x0000,
+ &ep1instate,
NULL,
NULL
};
/**
+ * @brief OUT EP2 state.
+ */
+USBOutEndpointState ep2outstate;
+
+/**
* @brief EP2 initialization structure (IN only).
*/
static const USBEndpointConfig ep2config = {
- USB_EP_MODE_TYPE_INTR | USB_EP_MODE_PACKET,
+ USB_EP_MODE_TYPE_INTR,
NULL,
sduInterruptTransmitted,
NULL,
0x0010,
0x0000,
NULL,
+ &ep2outstate,
NULL
};
/**
+ * @brief OUT EP3 state.
+ */
+USBOutEndpointState ep3outstate;
+
+/**
* @brief EP3 initialization structure (OUT only).
*/
static const USBEndpointConfig ep3config = {
- USB_EP_MODE_TYPE_BULK | USB_EP_MODE_PACKET,
+ USB_EP_MODE_TYPE_BULK,
NULL,
NULL,
sduDataReceived,
0x0000,
0x0040,
NULL,
+ &ep3outstate,
NULL
};
diff --git a/testhal/STM32F1xx/USB_CDC/mcuconf.h b/testhal/STM32F1xx/USB_CDC/mcuconf.h
index e87bba983..637d4b26f 100644
--- a/testhal/STM32F1xx/USB_CDC/mcuconf.h
+++ b/testhal/STM32F1xx/USB_CDC/mcuconf.h
@@ -202,5 +202,5 @@
*/
#define STM32_USB_USE_USB1 TRUE
#define STM32_USB_LOW_POWER_ON_SUSPEND FALSE
-#define STM32_USB_USB1_HP_IRQ_PRIORITY 6
+#define STM32_USB_USB1_HP_IRQ_PRIORITY 13
#define STM32_USB_USB1_LP_IRQ_PRIORITY 14
diff --git a/testhal/STM32F1xx/USB_MSC/mcuconf.h b/testhal/STM32F1xx/USB_MSC/mcuconf.h
index e87bba983..637d4b26f 100644
--- a/testhal/STM32F1xx/USB_MSC/mcuconf.h
+++ b/testhal/STM32F1xx/USB_MSC/mcuconf.h
@@ -202,5 +202,5 @@
*/
#define STM32_USB_USE_USB1 TRUE
#define STM32_USB_LOW_POWER_ON_SUSPEND FALSE
-#define STM32_USB_USB1_HP_IRQ_PRIORITY 6
+#define STM32_USB_USB1_HP_IRQ_PRIORITY 13
#define STM32_USB_USB1_LP_IRQ_PRIORITY 14
diff --git a/testhal/STM32F4xx/USB_CDC/main.c b/testhal/STM32F4xx/USB_CDC/main.c
index 99acdc894..a122591e4 100644
--- a/testhal/STM32F4xx/USB_CDC/main.c
+++ b/testhal/STM32F4xx/USB_CDC/main.c
@@ -246,9 +246,9 @@ static const USBEndpointConfig ep1config = {
};
/**
- * @brief OUT EP1 state.
+ * @brief OUT EP2 state.
*/
-USBOutEndpointState ep1outstate;
+USBOutEndpointState ep2outstate;
/**
* @brief EP2 initialization structure (IN only).
@@ -261,14 +261,14 @@ static const USBEndpointConfig ep2config = {
0x0010,
0x0000,
NULL,
- &ep1outstate,
+ &ep2outstate,
NULL
};
/**
* @brief OUT EP2 state.
*/
-USBOutEndpointState ep2outstate;
+USBOutEndpointState ep3outstate;
/**
* @brief EP3 initialization structure (OUT only).
@@ -281,7 +281,7 @@ static const USBEndpointConfig ep3config = {
0x0000,
0x0040,
NULL,
- &ep2outstate,
+ &ep3outstate,
NULL
};
diff --git a/testhal/STM32L1xx/ADC/mcuconf.h b/testhal/STM32L1xx/ADC/mcuconf.h
index 8b2565209..4769b314d 100644
--- a/testhal/STM32L1xx/ADC/mcuconf.h
+++ b/testhal/STM32L1xx/ADC/mcuconf.h
@@ -185,5 +185,5 @@
*/
#define STM32_USB_USE_USB1 TRUE
#define STM32_USB_LOW_POWER_ON_SUSPEND FALSE
-#define STM32_USB_USB1_HP_IRQ_PRIORITY 6
+#define STM32_USB_USB1_HP_IRQ_PRIORITY 13
#define STM32_USB_USB1_LP_IRQ_PRIORITY 14
diff --git a/testhal/STM32L1xx/EXT/mcuconf.h b/testhal/STM32L1xx/EXT/mcuconf.h
index 8b2565209..4769b314d 100644
--- a/testhal/STM32L1xx/EXT/mcuconf.h
+++ b/testhal/STM32L1xx/EXT/mcuconf.h
@@ -185,5 +185,5 @@
*/
#define STM32_USB_USE_USB1 TRUE
#define STM32_USB_LOW_POWER_ON_SUSPEND FALSE
-#define STM32_USB_USB1_HP_IRQ_PRIORITY 6
+#define STM32_USB_USB1_HP_IRQ_PRIORITY 13
#define STM32_USB_USB1_LP_IRQ_PRIORITY 14
diff --git a/testhal/STM32L1xx/GPT/mcuconf.h b/testhal/STM32L1xx/GPT/mcuconf.h
index 8b2565209..4769b314d 100644
--- a/testhal/STM32L1xx/GPT/mcuconf.h
+++ b/testhal/STM32L1xx/GPT/mcuconf.h
@@ -185,5 +185,5 @@
*/
#define STM32_USB_USE_USB1 TRUE
#define STM32_USB_LOW_POWER_ON_SUSPEND FALSE
-#define STM32_USB_USB1_HP_IRQ_PRIORITY 6
+#define STM32_USB_USB1_HP_IRQ_PRIORITY 13
#define STM32_USB_USB1_LP_IRQ_PRIORITY 14
diff --git a/testhal/STM32L1xx/IRQ_STORM/mcuconf.h b/testhal/STM32L1xx/IRQ_STORM/mcuconf.h
index 2b9e92bf8..bdab543ae 100644
--- a/testhal/STM32L1xx/IRQ_STORM/mcuconf.h
+++ b/testhal/STM32L1xx/IRQ_STORM/mcuconf.h
@@ -185,5 +185,5 @@
*/
#define STM32_USB_USE_USB1 TRUE
#define STM32_USB_LOW_POWER_ON_SUSPEND FALSE
-#define STM32_USB_USB1_HP_IRQ_PRIORITY 6
+#define STM32_USB_USB1_HP_IRQ_PRIORITY 13
#define STM32_USB_USB1_LP_IRQ_PRIORITY 14
diff --git a/testhal/STM32L1xx/PVD/mcuconf.h b/testhal/STM32L1xx/PVD/mcuconf.h
index 660580a8b..ef25eab0a 100644
--- a/testhal/STM32L1xx/PVD/mcuconf.h
+++ b/testhal/STM32L1xx/PVD/mcuconf.h
@@ -185,5 +185,5 @@
*/
#define STM32_USB_USE_USB1 TRUE
#define STM32_USB_LOW_POWER_ON_SUSPEND FALSE
-#define STM32_USB_USB1_HP_IRQ_PRIORITY 6
+#define STM32_USB_USB1_HP_IRQ_PRIORITY 13
#define STM32_USB_USB1_LP_IRQ_PRIORITY 14
diff --git a/testhal/STM32L1xx/PWM-ICU/mcuconf.h b/testhal/STM32L1xx/PWM-ICU/mcuconf.h
index 40bb8dfcd..f86f9caa1 100644
--- a/testhal/STM32L1xx/PWM-ICU/mcuconf.h
+++ b/testhal/STM32L1xx/PWM-ICU/mcuconf.h
@@ -185,5 +185,5 @@
*/
#define STM32_USB_USE_USB1 TRUE
#define STM32_USB_LOW_POWER_ON_SUSPEND FALSE
-#define STM32_USB_USB1_HP_IRQ_PRIORITY 6
+#define STM32_USB_USB1_HP_IRQ_PRIORITY 13
#define STM32_USB_USB1_LP_IRQ_PRIORITY 14
diff --git a/testhal/STM32L1xx/SPI/mcuconf.h b/testhal/STM32L1xx/SPI/mcuconf.h
index d22b6df0d..e0c087b19 100644
--- a/testhal/STM32L1xx/SPI/mcuconf.h
+++ b/testhal/STM32L1xx/SPI/mcuconf.h
@@ -185,5 +185,5 @@
*/
#define STM32_USB_USE_USB1 TRUE
#define STM32_USB_LOW_POWER_ON_SUSPEND FALSE
-#define STM32_USB_USB1_HP_IRQ_PRIORITY 6
+#define STM32_USB_USB1_HP_IRQ_PRIORITY 13
#define STM32_USB_USB1_LP_IRQ_PRIORITY 14
diff --git a/testhal/STM32L1xx/UART/mcuconf.h b/testhal/STM32L1xx/UART/mcuconf.h
index 8d0d117bc..1df13289f 100644
--- a/testhal/STM32L1xx/UART/mcuconf.h
+++ b/testhal/STM32L1xx/UART/mcuconf.h
@@ -185,5 +185,5 @@
*/
#define STM32_USB_USE_USB1 TRUE
#define STM32_USB_LOW_POWER_ON_SUSPEND FALSE
-#define STM32_USB_USB1_HP_IRQ_PRIORITY 6
+#define STM32_USB_USB1_HP_IRQ_PRIORITY 13
#define STM32_USB_USB1_LP_IRQ_PRIORITY 14