aboutsummaryrefslogtreecommitdiffstats
path: root/Demos/Device/ClassDriver/RNDISEthernet
diff options
context:
space:
mode:
authorDean Camera <dean@fourwalledcubicle.com>2009-06-18 10:31:55 +0000
committerDean Camera <dean@fourwalledcubicle.com>2009-06-18 10:31:55 +0000
commitf896c00c48f04fb9273555ab8d9b1af99f865d25 (patch)
treeb76827a0467c77ddeb30e11748c02a4f53779a14 /Demos/Device/ClassDriver/RNDISEthernet
parente338cb6f329d6bf948abad88637f81436ee90daf (diff)
downloadlufa-f896c00c48f04fb9273555ab8d9b1af99f865d25.tar.gz
lufa-f896c00c48f04fb9273555ab8d9b1af99f865d25.tar.bz2
lufa-f896c00c48f04fb9273555ab8d9b1af99f865d25.zip
Break device mode class driver interfaces into seperate config and state structs which are then combined, for clarity. Move device mode class driver interfaces back into the device mode class driver headers from the common class headers to make room for host class interfaces.
Diffstat (limited to 'Demos/Device/ClassDriver/RNDISEthernet')
-rw-r--r--Demos/Device/ClassDriver/RNDISEthernet/Lib/TCP.c16
-rw-r--r--Demos/Device/ClassDriver/RNDISEthernet/Lib/TCP.h2
-rw-r--r--Demos/Device/ClassDriver/RNDISEthernet/RNDISEthernet.c40
3 files changed, 33 insertions, 25 deletions
diff --git a/Demos/Device/ClassDriver/RNDISEthernet/Lib/TCP.c b/Demos/Device/ClassDriver/RNDISEthernet/Lib/TCP.c
index 44a32ea51..652714985 100644
--- a/Demos/Device/ClassDriver/RNDISEthernet/Lib/TCP.c
+++ b/Demos/Device/ClassDriver/RNDISEthernet/Lib/TCP.c
@@ -56,7 +56,7 @@ TCP_ConnectionState_t ConnectionStateTable[MAX_TCP_CONNECTIONS];
* level. If an application produces a response, this task constructs the appropriate Ethernet frame and places it into the Ethernet OUT
* buffer for later transmission.
*/
-void TCP_TCPTask(USB_ClassInfo_RNDIS_t* RNDISInterfaceInfo)
+void TCP_TCPTask(USB_ClassInfo_RNDIS_Device_t* RNDISInterfaceInfo)
{
/* Task to hand off TCP packets to and from the listening applications. */
@@ -76,7 +76,7 @@ void TCP_TCPTask(USB_ClassInfo_RNDIS_t* RNDISInterfaceInfo)
}
/* Bail out early if there is already a frame waiting to be sent in the Ethernet OUT buffer */
- if (RNDISInterfaceInfo->FrameOUT.FrameInBuffer)
+ if (RNDISInterfaceInfo->State.FrameOUT.FrameInBuffer)
return;
/* Send response packets from each application as the TCP packet buffers are filled by the applications */
@@ -86,11 +86,11 @@ void TCP_TCPTask(USB_ClassInfo_RNDIS_t* RNDISInterfaceInfo)
if ((ConnectionStateTable[CSTableEntry].Info.Buffer.Direction == TCP_PACKETDIR_OUT) &&
(ConnectionStateTable[CSTableEntry].Info.Buffer.Ready))
{
- Ethernet_Frame_Header_t* FrameOUTHeader = (Ethernet_Frame_Header_t*)&RNDISInterfaceInfo->FrameOUT.FrameData;
- IP_Header_t* IPHeaderOUT = (IP_Header_t*)&RNDISInterfaceInfo->FrameOUT.FrameData[sizeof(Ethernet_Frame_Header_t)];
- TCP_Header_t* TCPHeaderOUT = (TCP_Header_t*)&RNDISInterfaceInfo->FrameOUT.FrameData[sizeof(Ethernet_Frame_Header_t) +
+ Ethernet_Frame_Header_t* FrameOUTHeader = (Ethernet_Frame_Header_t*)&RNDISInterfaceInfo->State.FrameOUT.FrameData;
+ IP_Header_t* IPHeaderOUT = (IP_Header_t*)&RNDISInterfaceInfo->State.FrameOUT.FrameData[sizeof(Ethernet_Frame_Header_t)];
+ TCP_Header_t* TCPHeaderOUT = (TCP_Header_t*)&RNDISInterfaceInfo->State.FrameOUT.FrameData[sizeof(Ethernet_Frame_Header_t) +
sizeof(IP_Header_t)];
- void* TCPDataOUT = &RNDISInterfaceInfo->FrameOUT.FrameData[sizeof(Ethernet_Frame_Header_t) +
+ void* TCPDataOUT = &RNDISInterfaceInfo->State.FrameOUT.FrameData[sizeof(Ethernet_Frame_Header_t) +
sizeof(IP_Header_t) +
sizeof(TCP_Header_t)];
@@ -145,8 +145,8 @@ void TCP_TCPTask(USB_ClassInfo_RNDIS_t* RNDISInterfaceInfo)
PacketSize += sizeof(Ethernet_Frame_Header_t);
/* Set the response length in the buffer and indicate that a response is ready to be sent */
- RNDISInterfaceInfo->FrameOUT.FrameLength = PacketSize;
- RNDISInterfaceInfo->FrameOUT.FrameInBuffer = true;
+ RNDISInterfaceInfo->State.FrameOUT.FrameLength = PacketSize;
+ RNDISInterfaceInfo->State.FrameOUT.FrameInBuffer = true;
ConnectionStateTable[CSTableEntry].Info.Buffer.Ready = false;
diff --git a/Demos/Device/ClassDriver/RNDISEthernet/Lib/TCP.h b/Demos/Device/ClassDriver/RNDISEthernet/Lib/TCP.h
index 3448245ed..919245a0d 100644
--- a/Demos/Device/ClassDriver/RNDISEthernet/Lib/TCP.h
+++ b/Demos/Device/ClassDriver/RNDISEthernet/Lib/TCP.h
@@ -232,7 +232,7 @@
TCP_PortState_t PortStateTable[MAX_OPEN_TCP_PORTS];
/* Function Prototypes: */
- void TCP_TCPTask(USB_ClassInfo_RNDIS_t* RNDISInterfaceInfo);
+ void TCP_TCPTask(USB_ClassInfo_RNDIS_Device_t* RNDISInterfaceInfo);
void TCP_Init(void);
bool TCP_SetPortState(uint16_t Port, uint8_t State, void (*Handler)(TCP_ConnectionState_t*, TCP_ConnectionBuffer_t*));
uint8_t TCP_GetPortState(uint16_t Port);
diff --git a/Demos/Device/ClassDriver/RNDISEthernet/RNDISEthernet.c b/Demos/Device/ClassDriver/RNDISEthernet/RNDISEthernet.c
index 3c9fddfd4..ed0718455 100644
--- a/Demos/Device/ClassDriver/RNDISEthernet/RNDISEthernet.c
+++ b/Demos/Device/ClassDriver/RNDISEthernet/RNDISEthernet.c
@@ -40,21 +40,29 @@
* passed to all RNDIS Class driver functions, so that multiple instances of the same class
* within a device can be differentiated from one another.
*/
-USB_ClassInfo_RNDIS_t Ethernet_RNDIS_Interface =
+USB_ClassInfo_RNDIS_Device_t Ethernet_RNDIS_Interface =
{
- .ControlInterfaceNumber = 0,
-
- .DataINEndpointNumber = CDC_TX_EPNUM,
- .DataINEndpointSize = CDC_TXRX_EPSIZE,
-
- .DataOUTEndpointNumber = CDC_RX_EPNUM,
- .DataOUTEndpointSize = CDC_TXRX_EPSIZE,
-
- .NotificationEndpointNumber = CDC_NOTIFICATION_EPNUM,
- .NotificationEndpointSize = CDC_NOTIFICATION_EPSIZE,
-
- .AdapterVendorDescription = "LUFA RNDIS Demo Adapter",
- .AdapterMACAddress = {ADAPTER_MAC_ADDRESS},
+ .Config =
+ {
+ .ControlInterfaceNumber = 0,
+
+ .DataINEndpointNumber = CDC_TX_EPNUM,
+ .DataINEndpointSize = CDC_TXRX_EPSIZE,
+
+ .DataOUTEndpointNumber = CDC_RX_EPNUM,
+ .DataOUTEndpointSize = CDC_TXRX_EPSIZE,
+
+ .NotificationEndpointNumber = CDC_NOTIFICATION_EPNUM,
+ .NotificationEndpointSize = CDC_NOTIFICATION_EPSIZE,
+
+ .AdapterVendorDescription = "LUFA RNDIS Demo Adapter",
+ .AdapterMACAddress = {ADAPTER_MAC_ADDRESS},
+ },
+
+ .State =
+ {
+ // Leave all state values to their defaults
+ }
};
/** Main program entry point. This routine contains the overall program flow, including initial
@@ -73,10 +81,10 @@ int main(void)
for (;;)
{
- if (Ethernet_RNDIS_Interface.FrameIN.FrameInBuffer)
+ if (Ethernet_RNDIS_Interface.State.FrameIN.FrameInBuffer)
{
LEDs_SetAllLEDs(LEDMASK_USB_BUSY);
- Ethernet_ProcessPacket(&Ethernet_RNDIS_Interface.FrameIN, &Ethernet_RNDIS_Interface.FrameOUT);
+ Ethernet_ProcessPacket(&Ethernet_RNDIS_Interface.State.FrameIN, &Ethernet_RNDIS_Interface.State.FrameOUT);
LEDs_SetAllLEDs(LEDMASK_USB_READY);
}