]> rtime.felk.cvut.cz Git - fpga/lx-cpu1/lx-dad.git/commitdiff
USB CDC ACM use maximal packet length - 64 bytes.
authorPavel Pisa <pisa@cmp.felk.cvut.cz>
Tue, 28 Jul 2015 17:29:18 +0000 (19:29 +0200)
committerPavel Pisa <pisa@cmp.felk.cvut.cz>
Thu, 30 Jul 2015 20:52:51 +0000 (22:52 +0200)
Signed-off-by: Pavel Pisa <ppisa@pikron.com>
sw/app/lx_dad/appl_usb.c
sw/app/lx_dad/usb/usb_defs.h

index 2f3d72474b19314d27427130235f06f865bc6930..cbeece550b1962de44ea30682be0c2376489ecab 100644 (file)
@@ -53,8 +53,8 @@ usb_ep_t eps[NUM_ENDPOINTS];
 #define CDC0_MASK_EP_RXD     (1<<CDC0_EPIDX_RXD)
 #define CDC0_MASK_EP_TXD     (1<<CDC0_EPIDX_TXD)
 
-unsigned char cdc0_ep_tx_buff[USB_MAX_PACKET] __attribute__ ((aligned (8)));
-unsigned char cdc0_ep_rx_buff[USB_MAX_PACKET] __attribute__ ((aligned (8)));
+unsigned char cdc0_ep_tx_buff[CDC0_MAX_PACKET] __attribute__ ((aligned (8)));
+unsigned char cdc0_ep_rx_buff[CDC0_MAX_PACKET] __attribute__ ((aligned (8)));
 unsigned char ep0_buffer[USB_MAX_PACKET0] __attribute__ ((aligned (8)));
 int cdc0_tx_index = 0, cdc0_tx_ready = 1;
 int cdc0_tx_flush_required;
@@ -383,8 +383,8 @@ int usb_app_init(void)
   memset(&usb_device, 0, sizeof(usb_device));
 
   eps[CDC0_EPIDX_NOTIFY].max_packet_size = USB_MAX_PACKET;
-  eps[CDC0_EPIDX_RXD].max_packet_size = USB_MAX_PACKET;
-  eps[CDC0_EPIDX_TXD].max_packet_size = USB_MAX_PACKET;
+  eps[CDC0_EPIDX_RXD].max_packet_size = CDC0_MAX_PACKET;
+  eps[CDC0_EPIDX_TXD].max_packet_size = CDC0_MAX_PACKET;
   eps[CDC0_EPIDX_NOTIFY].epnum = CDC0_EP_NOTIFY;
   eps[CDC0_EPIDX_RXD].epnum = CDC0_EP_RXD;
   eps[CDC0_EPIDX_TXD].epnum = CDC0_EP_TXD;
@@ -423,7 +423,7 @@ int cdc0_txd_check_ep(void)
   if (cdc0_tx_ready && ((cdc0_tx_index != 0) || cdc0_tx_flush_required))
   {
     usb_udev_write_endpoint(&eps[CDC0_EPIDX_TXD], cdc0_ep_tx_buff, cdc0_tx_index);
-    cdc0_tx_flush_required = (cdc0_tx_index == USB_MAX_PACKET);
+    cdc0_tx_flush_required = (cdc0_tx_index == CDC0_MAX_PACKET);
     cdc0_tx_index = 0;
     cdc0_tx_ready = 0;
     hal_gpio_set_value(LED2_PIN, 0);
@@ -452,7 +452,7 @@ int usb_app_poll(void)
   /* Check RXD/OUT endpoint */
   if (usb_device.ep_events & CDC0_MASK_EP_RXD)
   {
-    cdc0_rx_chars = usb_udev_read_endpoint(&eps[CDC0_EPIDX_RXD], cdc0_ep_rx_buff, USB_MAX_PACKET);
+    cdc0_rx_chars = usb_udev_read_endpoint(&eps[CDC0_EPIDX_RXD], cdc0_ep_rx_buff, CDC0_MAX_PACKET);
     cdc0_rx_index = 0;
     usb_device.ep_events &= ~CDC0_MASK_EP_RXD;
     hal_gpio_set_value(LED2_PIN, 0);
@@ -483,14 +483,14 @@ int cmd_io_getc_usbcon(struct cmd_io *cmd_io)
 
 int cmd_io_putc_usbcon(struct cmd_io *cmd_io, int ch)
 {
-  if (cdc0_tx_index >= USB_MAX_PACKET)
+  if (cdc0_tx_index >= CDC0_MAX_PACKET)
   {
     /* Check EP1 status and return -1 if unavailable */
     usb_check_events(&usb_device);
     cdc0_txd_check_ep();
 
     /* Check again if it wasn't emptied */
-    if (cdc0_tx_index >= USB_MAX_PACKET)
+    if (cdc0_tx_index >= CDC0_MAX_PACKET)
       return -1;
   }
 
index eecc8de88ac5bc8b0e81e2bcea0a37b13b11c41e..5e112a4c3e4319eb42714753c3d7cbe9c7b9cfaf 100644 (file)
@@ -36,6 +36,7 @@
 #define CDC0_EP_NOTIFY      0x81
 #define CDC0_EP_RXD         0x02
 #define CDC0_EP_TXD         0x82
+#define CDC0_MAX_PACKET     64
 
 #define CONFIG_DESCRIPTOR_LENGTH \
   sizeof(USB_CONFIGURATION_DESCRIPTOR) \
@@ -161,7 +162,7 @@ CODE const struct
     USB_DESCRIPTOR_TYPE_ENDPOINT,
     CDC0_EP_RXD,                      /* bEndpointAddress */
     USB_ENDPOINT_TYPE_BULK,
-    SWAP(USB_MAX_PACKET),
+    SWAP(CDC0_MAX_PACKET),
     0,                                /* bInterval (polling interval: 50ms) */
   },
   {
@@ -170,7 +171,7 @@ CODE const struct
     USB_DESCRIPTOR_TYPE_ENDPOINT,
     CDC0_EP_TXD,                      /* bEndpointAddress */
     USB_ENDPOINT_TYPE_BULK,
-    SWAP(USB_MAX_PACKET),
+    SWAP(CDC0_MAX_PACKET),
     0,                                /* bInterval (polling interval: 50ms) */
   }
 };