summaryrefslogtreecommitdiff
path: root/tinyusb
diff options
context:
space:
mode:
authorhathach <[email protected]>2013-06-16 15:32:08 +0700
committerhathach <[email protected]>2013-06-16 15:32:08 +0700
commit4d6121d44aee5056a8d8ac69c8f3445d59530dca (patch)
tree8f4707d5ec1265e251f76971d118981b6f411edf /tinyusb
parent357e8d32ec2c0a32cab79466131e38a103591975 (diff)
refractor set endpoint max packet size
Diffstat (limited to 'tinyusb')
-rw-r--r--tinyusb/device/dcd_lpc175x_6x.c21
1 files changed, 11 insertions, 10 deletions
diff --git a/tinyusb/device/dcd_lpc175x_6x.c b/tinyusb/device/dcd_lpc175x_6x.c
index 70f895efa..e93f2c631 100644
--- a/tinyusb/device/dcd_lpc175x_6x.c
+++ b/tinyusb/device/dcd_lpc175x_6x.c
@@ -61,8 +61,19 @@ STATIC_ dcd_dma_descriptor_t dcd_dd[DCD_MAX_DD];
static inline void endpoint_set_max_packet_size(uint8_t endpoint_idx, uint16_t max_packet_size) ATTR_ALWAYS_INLINE;
static inline void endpoint_set_max_packet_size(uint8_t endpoint_idx, uint16_t max_packet_size)
{
+ LPC_USB->USBReEp |= BIT_(endpoint_idx);
+
LPC_USB->USBEpInd = endpoint_idx; // select index before setting packet size
LPC_USB->USBMaxPSize = max_packet_size;
+
+#ifndef _TEST_
+ if( endpoint_idx > 2) // endpoint control is always realized
+ {
+ while ((LPC_USB->USBDevIntSt & DEV_INT_ENDPOINT_REALIZED_MASK) == 0) {} // TODO can be omitted, or move to set max packet size
+ LPC_USB->USBDevIntClr = DEV_INT_ENDPOINT_REALIZED_MASK;
+ }
+#endif
+
}
static inline void sie_commamd_code (uint8_t phase, uint8_t code_data) ATTR_ALWAYS_INLINE;
@@ -180,10 +191,6 @@ tusb_error_t dcd_init(void)
endpoint_set_max_packet_size(0, TUSB_CFG_DEVICE_CONTROL_PACKET_SIZE);
endpoint_set_max_packet_size(1, TUSB_CFG_DEVICE_CONTROL_PACKET_SIZE);
-#ifndef _TEST_
- while ((LPC_USB->USBDevIntSt & DEV_INT_ENDPOINT_REALIZED_MASK) == 0);
-#endif
-
// step 7 : slave mode set up
LPC_USB->USBEpIntEn = (uint32_t) BIN8(11); // control endpoint cannot use DMA, non-control all use DMA
@@ -296,14 +303,8 @@ tusb_error_t dcd_endpoint_configure(uint8_t coreid, tusb_descriptor_endpoint_t c
uint8_t phy_ep = endpoint_address_to_physical_index( p_endpoint_desc->bEndpointAddress );
//------------- Realize Endpoint with Max Packet Size -------------//
- LPC_USB->USBReEp |= BIT_(phy_ep);
endpoint_set_max_packet_size(phy_ep, p_endpoint_desc->wMaxPacketSize.size);
-#ifndef _TEST_
- while ((LPC_USB->USBDevIntSt & DEV_INT_ENDPOINT_REALIZED_MASK) == 0) {} // TODO can be omitted, or move to set max packet size
- LPC_USB->USBDevIntClr = DEV_INT_ENDPOINT_REALIZED_MASK;
-#endif
-
//------------- DMA set up -------------//
memclr_(dcd_dd + phy_ep, sizeof(dcd_dma_descriptor_t));
dcd_dd[phy_ep].is_isochronous = (p_endpoint_desc->bmAttributes.xfer == TUSB_XFER_ISOCHRONOUS) ? 1 : 0;