aboutsummaryrefslogtreecommitdiffstats
path: root/os
diff options
context:
space:
mode:
authorGiovanni Di Sirio <gdisirio@gmail.com>2015-12-31 10:26:34 +0000
committerGiovanni Di Sirio <gdisirio@gmail.com>2015-12-31 10:26:34 +0000
commitba2c8ab2164f76a70bc333b6988427d8acf2bf8a (patch)
treedb13ec72ce742d5a3a36d0b6d34c667ff5ec26f5 /os
parent271176de36b36784b51e5dac2379547e92a2f415 (diff)
downloadChibiOS-ba2c8ab2164f76a70bc333b6988427d8acf2bf8a.tar.gz
ChibiOS-ba2c8ab2164f76a70bc333b6988427d8acf2bf8a.tar.bz2
ChibiOS-ba2c8ab2164f76a70bc333b6988427d8acf2bf8a.zip
Added switch to disable isochronous support in USBv1 because code size concerns on small devices.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@8662 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os')
-rw-r--r--os/hal/ports/STM32/LLD/USBv1/usb_lld.c82
-rw-r--r--os/hal/ports/STM32/LLD/USBv1/usb_lld.h9
2 files changed, 62 insertions, 29 deletions
diff --git a/os/hal/ports/STM32/LLD/USBv1/usb_lld.c b/os/hal/ports/STM32/LLD/USBv1/usb_lld.c
index c23dadac5..76e5f8665 100644
--- a/os/hal/ports/STM32/LLD/USBv1/usb_lld.c
+++ b/os/hal/ports/STM32/LLD/USBv1/usb_lld.c
@@ -130,6 +130,7 @@ static size_t usb_packet_read_to_buffer(usbep_t ep, uint8_t *buf) {
size_t i, n;
stm32_usb_descriptor_t *udp = USB_GET_DESCRIPTOR(ep);
stm32_usb_pma_t *pmap = USB_ADDR2PTR(udp->RXADDR0);
+#if STM32_USB_USE_ISOCHRONOUS
uint32_t epr = STM32_USB->EPR[ep];
/* Double buffering is always enabled for isochronous endpoints, and
@@ -143,6 +144,9 @@ static size_t usb_packet_read_to_buffer(usbep_t ep, uint8_t *buf) {
n = (size_t)udp->RXCOUNT1 & RXCOUNT_COUNT_MASK;
else
n = (size_t)udp->RXCOUNT0 & RXCOUNT_COUNT_MASK;
+#else
+ n = (size_t)udp->RXCOUNT0 & RXCOUNT_COUNT_MASK;
+#endif
i = n;
@@ -210,9 +214,11 @@ static void usb_packet_write_from_buffer(usbep_t ep,
size_t n) {
stm32_usb_descriptor_t *udp = USB_GET_DESCRIPTOR(ep);
stm32_usb_pma_t *pmap = USB_ADDR2PTR(udp->TXADDR0);
- uint32_t epr = STM32_USB->EPR[ep];
int i = (int)n;
+#if STM32_USB_USE_ISOCHRONOUS
+ uint32_t epr = STM32_USB->EPR[ep];
+
/* Double buffering is always enabled for isochronous endpoints, and
although we overlap the two buffers for simplicity, we still need
to write to the right counter. The DTOG_TX bit indicates the buffer
@@ -223,6 +229,9 @@ static void usb_packet_write_from_buffer(usbep_t ep,
udp->TXCOUNT1 = (stm32_usb_pma_t)n;
else
udp->TXCOUNT0 = (stm32_usb_pma_t)n;
+#else
+ udp->TXCOUNT0 = (stm32_usb_pma_t)n;
+#endif
#if STM32_USB_USE_FAST_COPY
while (i >= 16) {
@@ -350,6 +359,7 @@ static void usb_serve_endpoints(USBDriver *usbp, uint32_t ep) {
#if STM32_USB_USE_USB1 || defined(__DOXYGEN__)
#if STM32_USB1_HP_NUMBER != STM32_USB1_LP_NUMBER
+#if STM32_USB_USE_ISOCHRONOUS
/**
* @brief USB high priority interrupt handler.
*
@@ -370,6 +380,7 @@ OSAL_IRQ_HANDLER(STM32_USB1_HP_HANDLER) {
OSAL_IRQ_EPILOGUE();
}
+#endif /* STM32_USB_USE_ISOCHRONOUS */
#endif /* STM32_USB1_LP_NUMBER != STM32_USB1_HP_NUMBER */
/**
@@ -570,7 +581,7 @@ void usb_lld_set_address(USBDriver *usbp) {
* @notapi
*/
void usb_lld_init_endpoint(USBDriver *usbp, usbep_t ep) {
- uint16_t nblocks, epr;
+ uint16_t epr;
stm32_usb_descriptor_t *dp;
const USBEndpointConfig *epcp = usbp->epc[ep];
@@ -579,10 +590,14 @@ void usb_lld_init_endpoint(USBDriver *usbp, usbep_t ep) {
receive descriptor fields are used for either direction.*/
switch (epcp->ep_mode & USB_EP_MODE_TYPE) {
case USB_EP_MODE_TYPE_ISOC:
+#if STM32_USB_USE_ISOCHRONOUS
osalDbgAssert((epcp->in_state == NULL) || (epcp->out_state == NULL),
"isochronous EP cannot be IN and OUT");
epr = EPR_EP_TYPE_ISO;
break;
+#else
+ osalDbgAssert(false, "isochronous support disabled");
+#endif
case USB_EP_MODE_TYPE_BULK:
epr = EPR_EP_TYPE_BULK;
break;
@@ -593,43 +608,52 @@ void usb_lld_init_endpoint(USBDriver *usbp, usbep_t ep) {
epr = EPR_EP_TYPE_CONTROL;
}
- /* Endpoint size and address initialization.*/
- if (epcp->out_maxsize > 62)
- nblocks = (((((epcp->out_maxsize - 1) | 0x1f) + 1) / 32) << 10) |
- 0x8000;
- else
- nblocks = ((((epcp->out_maxsize - 1) | 1) + 1) / 2) << 10;
-
dp = USB_GET_DESCRIPTOR(ep);
- dp->TXCOUNT0 = 0;
- dp->RXCOUNT0 = nblocks;
- dp->TXADDR0 = usb_pm_alloc(usbp, epcp->in_maxsize);
- dp->RXADDR0 = usb_pm_alloc(usbp, epcp->out_maxsize);
-
- /* Initial status for isochronous enpoints is valid because disabled and
- valid are the only legal values. Also since double buffering is used
- we need to initialize both count/address sets depending on the direction,
- but since we are not taking advantage of the double buffering, we set both
- addresses to point to the same PMA.*/
- if ((epcp->ep_mode & USB_EP_MODE_TYPE) == USB_EP_MODE_TYPE_ISOC) {
- if (epcp->in_state != NULL) {
+
+ /* IN endpoint handling.*/
+ if (epcp->in_state != NULL) {
+ dp->TXCOUNT0 = 0;
+ dp->TXADDR0 = usb_pm_alloc(usbp, epcp->in_maxsize);
+
+#if STM32_USB_USE_ISOCHRONOUS
+ if (epr == EPR_EP_TYPE_ISO) {
epr |= EPR_STAT_TX_VALID;
dp->TXCOUNT1 = dp->TXCOUNT0;
dp->TXADDR1 = dp->TXADDR0; /* Both buffers overlapped.*/
}
- if (epcp->out_state != NULL) {
+ else {
+ epr |= EPR_STAT_TX_NAK;
+ }
+#else
+ epr |= EPR_STAT_TX_NAK;
+#endif
+ }
+
+ /* OUT endpoint handling.*/
+ if (epcp->out_state != NULL) {
+ uint16_t nblocks;
+
+ /* Endpoint size and address initialization.*/
+ if (epcp->out_maxsize > 62)
+ nblocks = (((((epcp->out_maxsize - 1) | 0x1f) + 1) / 32) << 10) |
+ 0x8000;
+ else
+ nblocks = ((((epcp->out_maxsize - 1) | 1) + 1) / 2) << 10;
+ dp->RXCOUNT0 = nblocks;
+ dp->RXADDR0 = usb_pm_alloc(usbp, epcp->out_maxsize);
+
+#if STM32_USB_USE_ISOCHRONOUS
+ if (epr == EPR_EP_TYPE_ISO) {
epr |= EPR_STAT_RX_VALID;
dp->RXCOUNT1 = dp->RXCOUNT0;
dp->RXADDR1 = dp->RXADDR0; /* Both buffers overlapped.*/
}
- }
- else {
- /* Initial status for other endpoint types is NAK.*/
- if (epcp->in_state != NULL)
- epr |= EPR_STAT_TX_NAK;
-
- if (epcp->out_state != NULL)
+ else {
epr |= EPR_STAT_RX_NAK;
+ }
+#else
+ epr |= EPR_STAT_RX_NAK;
+#endif
}
/* EPxR register setup.*/
diff --git a/os/hal/ports/STM32/LLD/USBv1/usb_lld.h b/os/hal/ports/STM32/LLD/USBv1/usb_lld.h
index 64cf395b8..6214e5ff4 100644
--- a/os/hal/ports/STM32/LLD/USBv1/usb_lld.h
+++ b/os/hal/ports/STM32/LLD/USBv1/usb_lld.h
@@ -89,6 +89,15 @@
#endif
/**
+ * @brief Enables isochronous support.
+ * @note Isochronous support requires special handling and this makes the
+ * code size increase significantly.
+ */
+#if !defined(STM32_USB_USE_ISOCHRONOUS) || defined(__DOXYGEN__)
+#define STM32_USB_USE_ISOCHRONOUS FALSE
+#endif
+
+/**
* @brief Use faster copy for packets.
* @note Makes the driver larger.
*/