Added support for the DorkbotPDX Duce board.
[pub/USBasp.git] / LUFA / Drivers / USB / Class / Device / RNDISClassDevice.c
index 658ed19..e5aa40c 100644 (file)
@@ -7,7 +7,7 @@
 */
 
 /*
 */
 
 /*
-  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
 
   Permission to use, copy, modify, distribute, and sell this
   software and its documentation for any purpose is hereby granted
@@ -115,45 +115,18 @@ bool RNDIS_Device_ConfigureEndpoints(USB_ClassInfo_RNDIS_Device_t* const RNDISIn
 {
        memset(&RNDISInterfaceInfo->State, 0x00, sizeof(RNDISInterfaceInfo->State));
 
 {
        memset(&RNDISInterfaceInfo->State, 0x00, sizeof(RNDISInterfaceInfo->State));
 
-       for (uint8_t EndpointNum = 1; EndpointNum < ENDPOINT_TOTAL_ENDPOINTS; EndpointNum++)
-       {
-               uint16_t Size;
-               uint8_t  Type;
-               uint8_t  Direction;
-               bool     DoubleBanked;
-
-               if (EndpointNum == RNDISInterfaceInfo->Config.DataINEndpointNumber)
-               {
-                       Size         = RNDISInterfaceInfo->Config.DataINEndpointSize;
-                       Direction    = ENDPOINT_DIR_IN;
-                       Type         = EP_TYPE_BULK;
-                       DoubleBanked = RNDISInterfaceInfo->Config.DataINEndpointDoubleBank;
-               }
-               else if (EndpointNum == RNDISInterfaceInfo->Config.DataOUTEndpointNumber)
-               {
-                       Size         = RNDISInterfaceInfo->Config.DataOUTEndpointSize;
-                       Direction    = ENDPOINT_DIR_OUT;
-                       Type         = EP_TYPE_BULK;
-                       DoubleBanked = RNDISInterfaceInfo->Config.DataOUTEndpointDoubleBank;
-               }
-               else if (EndpointNum == RNDISInterfaceInfo->Config.NotificationEndpointNumber)
-               {
-                       Size         = RNDISInterfaceInfo->Config.NotificationEndpointSize;
-                       Direction    = ENDPOINT_DIR_IN;
-                       Type         = EP_TYPE_INTERRUPT;
-                       DoubleBanked = RNDISInterfaceInfo->Config.NotificationEndpointDoubleBank;
-               }
-               else
-               {
-                       continue;
-               }
-
-               if (!(Endpoint_ConfigureEndpoint(EndpointNum, Type, Direction, Size,
-                                                DoubleBanked ? ENDPOINT_BANK_DOUBLE : ENDPOINT_BANK_SINGLE)))
-               {
-                       return false;
-               }
-       }
+       RNDISInterfaceInfo->Config.DataINEndpoint.Type       = EP_TYPE_BULK;
+       RNDISInterfaceInfo->Config.DataOUTEndpoint.Type      = EP_TYPE_BULK;
+       RNDISInterfaceInfo->Config.NotificationEndpoint.Type = EP_TYPE_INTERRUPT;
+
+       if (!(Endpoint_ConfigureEndpointTable(&RNDISInterfaceInfo->Config.DataINEndpoint, 1)))
+         return false;
+
+       if (!(Endpoint_ConfigureEndpointTable(&RNDISInterfaceInfo->Config.DataOUTEndpoint, 1)))
+         return false;
+
+       if (!(Endpoint_ConfigureEndpointTable(&RNDISInterfaceInfo->Config.NotificationEndpoint, 1)))
+         return false;
 
        return true;
 }
 
        return true;
 }
@@ -163,7 +136,7 @@ void RNDIS_Device_USBTask(USB_ClassInfo_RNDIS_Device_t* const RNDISInterfaceInfo
        if (USB_DeviceState != DEVICE_STATE_Configured)
          return;
 
        if (USB_DeviceState != DEVICE_STATE_Configured)
          return;
 
-       Endpoint_SelectEndpoint(RNDISInterfaceInfo->Config.NotificationEndpointNumber);
+       Endpoint_SelectEndpoint(RNDISInterfaceInfo->Config.NotificationEndpoint.Address);
 
        if (Endpoint_IsINReady() && RNDISInterfaceInfo->State.ResponseReady)
        {
 
        if (Endpoint_IsINReady() && RNDISInterfaceInfo->State.ResponseReady)
        {
@@ -454,7 +427,7 @@ bool RNDIS_Device_IsPacketReceived(USB_ClassInfo_RNDIS_Device_t* const RNDISInte
                return false;
        }
 
                return false;
        }
 
-       Endpoint_SelectEndpoint(RNDISInterfaceInfo->Config.DataOUTEndpointNumber);
+       Endpoint_SelectEndpoint(RNDISInterfaceInfo->Config.DataOUTEndpoint.Address);
        return Endpoint_IsOUTReceived();
 }
 
        return Endpoint_IsOUTReceived();
 }
 
@@ -468,7 +441,7 @@ uint8_t RNDIS_Device_ReadPacket(USB_ClassInfo_RNDIS_Device_t* const RNDISInterfa
                return ENDPOINT_RWSTREAM_DeviceDisconnected;
        }
 
                return ENDPOINT_RWSTREAM_DeviceDisconnected;
        }
 
-       Endpoint_SelectEndpoint(RNDISInterfaceInfo->Config.DataOUTEndpointNumber);
+       Endpoint_SelectEndpoint(RNDISInterfaceInfo->Config.DataOUTEndpoint.Address);
 
        *PacketLength = 0;
 
 
        *PacketLength = 0;
 
@@ -505,7 +478,7 @@ uint8_t RNDIS_Device_SendPacket(USB_ClassInfo_RNDIS_Device_t* const RNDISInterfa
                return ENDPOINT_RWSTREAM_DeviceDisconnected;
        }
 
                return ENDPOINT_RWSTREAM_DeviceDisconnected;
        }
 
-       Endpoint_SelectEndpoint(RNDISInterfaceInfo->Config.DataINEndpointNumber);
+       Endpoint_SelectEndpoint(RNDISInterfaceInfo->Config.DataINEndpoint.Address);
 
        if ((ErrorCode = Endpoint_WaitUntilReady()) != ENDPOINT_READYWAIT_NoError)
          return ErrorCode;
 
        if ((ErrorCode = Endpoint_WaitUntilReady()) != ENDPOINT_READYWAIT_NoError)
          return ErrorCode;