Use immediate variable expansion in the second-deepest level makefile scripts to...
[pub/USBasp.git] / Demos / Device / LowLevel / DualVirtualSerial / DualVirtualSerial.c
index bf80749..2db6f4e 100644 (file)
@@ -1,13 +1,13 @@
 /*
              LUFA Library
-     Copyright (C) Dean Camera, 2011.
+     Copyright (C) Dean Camera, 2012.
 
   dean [at] fourwalledcubicle [dot] com
            www.lufa-lib.org
 */
 
 /*
-  Copyright 2011  Dean Camera (dean [at] fourwalledcubicle [dot] com)
+  Copyright 2012  Dean Camera (dean [at] fourwalledcubicle [dot] com)
 
   Permission to use, copy, modify, distribute, and sell this
   software and its documentation for any purpose is hereby granted
  *  It is possible to completely ignore these value or use other settings as the host is completely unaware of the physical
  *  serial link characteristics and instead sends and receives data in endpoint streams.
  */
-CDC_LineEncoding_t LineEncoding1 = { .BaudRateBPS = 0,
-                                     .CharFormat  = CDC_LINEENCODING_OneStopBit,
-                                     .ParityType  = CDC_PARITY_None,
-                                     .DataBits    = 8                            };
+static CDC_LineEncoding_t LineEncoding1 = { .BaudRateBPS = 0,
+                                            .CharFormat  = CDC_LINEENCODING_OneStopBit,
+                                            .ParityType  = CDC_PARITY_None,
+                                            .DataBits    = 8                            };
 
 /** Contains the current baud rate and other settings of the second virtual serial port. While this demo does not use
  *  the physical USART and thus does not use these settings, they must still be retained and returned to the host
@@ -57,10 +57,10 @@ CDC_LineEncoding_t LineEncoding1 = { .BaudRateBPS = 0,
  *  It is possible to completely ignore these value or use other settings as the host is completely unaware of the physical
  *  serial link characteristics and instead sends and receives data in endpoint streams.
  */
-CDC_LineEncoding_t LineEncoding2 = { .BaudRateBPS = 0,
-                                     .CharFormat  = CDC_LINEENCODING_OneStopBit,
-                                     .ParityType  = CDC_PARITY_None,
-                                     .DataBits    = 8                            };
+static CDC_LineEncoding_t LineEncoding2 = { .BaudRateBPS = 0,
+                                            .CharFormat  = CDC_LINEENCODING_OneStopBit,
+                                            .ParityType  = CDC_PARITY_None,
+                                            .DataBits    = 8                            };
 
 
 /** Main program entry point. This routine configures the hardware required by the application, then
@@ -123,20 +123,14 @@ void EVENT_USB_Device_ConfigurationChanged(void)
        bool ConfigSuccess = true;
 
        /* Setup first CDC Interface's Endpoints */
-       ConfigSuccess &= Endpoint_ConfigureEndpoint(CDC1_TX_EPNUM, EP_TYPE_BULK, ENDPOINT_DIR_IN,
-                                                   CDC_TXRX_EPSIZE, ENDPOINT_BANK_SINGLE);
-       ConfigSuccess &= Endpoint_ConfigureEndpoint(CDC1_RX_EPNUM, EP_TYPE_BULK, ENDPOINT_DIR_OUT,
-                                                   CDC_TXRX_EPSIZE, ENDPOINT_BANK_SINGLE);
-       ConfigSuccess &= Endpoint_ConfigureEndpoint(CDC1_NOTIFICATION_EPNUM, EP_TYPE_INTERRUPT, ENDPOINT_DIR_IN,
-                                                   CDC_NOTIFICATION_EPSIZE, ENDPOINT_BANK_SINGLE);
+       ConfigSuccess &= Endpoint_ConfigureEndpoint(CDC1_TX_EPADDR, EP_TYPE_BULK, CDC_TXRX_EPSIZE, 1);
+       ConfigSuccess &= Endpoint_ConfigureEndpoint(CDC1_RX_EPADDR, EP_TYPE_BULK, CDC_TXRX_EPSIZE, 1);
+       ConfigSuccess &= Endpoint_ConfigureEndpoint(CDC1_NOTIFICATION_EPADDR, EP_TYPE_INTERRUPT, CDC_NOTIFICATION_EPSIZE, 1);
 
        /* Setup second CDC Interface's Endpoints */
-       ConfigSuccess &= Endpoint_ConfigureEndpoint(CDC2_TX_EPNUM, EP_TYPE_BULK, ENDPOINT_DIR_IN,
-                                                   CDC_TXRX_EPSIZE, ENDPOINT_BANK_SINGLE);
-       ConfigSuccess &= Endpoint_ConfigureEndpoint(CDC2_RX_EPNUM, EP_TYPE_BULK, ENDPOINT_DIR_OUT,
-                                                   CDC_TXRX_EPSIZE, ENDPOINT_BANK_SINGLE);
-       ConfigSuccess &= Endpoint_ConfigureEndpoint(CDC2_NOTIFICATION_EPNUM, EP_TYPE_INTERRUPT, ENDPOINT_DIR_IN,
-                                                   CDC_NOTIFICATION_EPSIZE, ENDPOINT_BANK_SINGLE);
+       ConfigSuccess &= Endpoint_ConfigureEndpoint(CDC2_TX_EPADDR, EP_TYPE_BULK, CDC_TXRX_EPSIZE, 1);
+       ConfigSuccess &= Endpoint_ConfigureEndpoint(CDC2_RX_EPADDR, EP_TYPE_BULK, CDC_TXRX_EPSIZE, 1);
+       ConfigSuccess &= Endpoint_ConfigureEndpoint(CDC2_NOTIFICATION_EPADDR, EP_TYPE_INTERRUPT, CDC_NOTIFICATION_EPSIZE, 1);
 
        /* Reset line encoding baud rates so that the host knows to send new values */
        LineEncoding1.BaudRateBPS = 0;
@@ -224,10 +218,10 @@ void CDC1_Task(void)
                ActionSent = true;
 
                /* Select the Serial Tx Endpoint */
-               Endpoint_SelectEndpoint(CDC1_TX_EPNUM);
+               Endpoint_SelectEndpoint(CDC1_TX_EPADDR);
 
                /* Write the String to the Endpoint */
-               Endpoint_Write_Stream_LE(ReportString, strlen(ReportString));
+               Endpoint_Write_Stream_LE(ReportString, strlen(ReportString), NULL);
 
                /* Finalize the stream transfer to send the last packet */
                Endpoint_ClearIN();
@@ -240,7 +234,7 @@ void CDC1_Task(void)
        }
 
        /* Select the Serial Rx Endpoint */
-       Endpoint_SelectEndpoint(CDC1_RX_EPNUM);
+       Endpoint_SelectEndpoint(CDC1_RX_EPADDR);
 
        /* Throw away any received data from the host */
        if (Endpoint_IsOUTReceived())
@@ -257,7 +251,7 @@ void CDC2_Task(void)
          return;
 
        /* Select the Serial Rx Endpoint */
-       Endpoint_SelectEndpoint(CDC2_RX_EPNUM);
+       Endpoint_SelectEndpoint(CDC2_RX_EPADDR);
 
        /* Check to see if any data has been received */
        if (Endpoint_IsOUTReceived())
@@ -269,16 +263,16 @@ void CDC2_Task(void)
                uint16_t DataLength = Endpoint_BytesInEndpoint();
 
                /* Read in the incoming packet into the buffer */
-               Endpoint_Read_Stream_LE(&Buffer, DataLength);
+               Endpoint_Read_Stream_LE(&Buffer, DataLength, NULL);
 
                /* Finalize the stream transfer to send the last packet */
                Endpoint_ClearOUT();
 
                /* Select the Serial Tx Endpoint */
-               Endpoint_SelectEndpoint(CDC2_TX_EPNUM);
+               Endpoint_SelectEndpoint(CDC2_TX_EPADDR);
 
                /* Write the received data to the endpoint */
-               Endpoint_Write_Stream_LE(&Buffer, DataLength);
+               Endpoint_Write_Stream_LE(&Buffer, DataLength, NULL);
 
                /* Finalize the stream transfer to send the last packet */
                Endpoint_ClearIN();