Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
lufa
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Erik Strand
lufa
Commits
397c2f91
Commit
397c2f91
authored
May 27, 2011
by
Dean Camera
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Merge over trunk changes to the 110528 BETA to form the 110528 release.
parent
2b09c428
Changes
42
Hide whitespace changes
Inline
Side-by-side
Showing
42 changed files
with
390 additions
and
204 deletions
+390
-204
Bootloaders/CDC/BootloaderCDC.c
Bootloaders/CDC/BootloaderCDC.c
+17
-0
Bootloaders/CDC/BootloaderCDC.h
Bootloaders/CDC/BootloaderCDC.h
+1
-0
Bootloaders/DFU/BootloaderDFU.c
Bootloaders/DFU/BootloaderDFU.c
+21
-4
Bootloaders/DFU/BootloaderDFU.h
Bootloaders/DFU/BootloaderDFU.h
+1
-0
Bootloaders/HID/BootloaderHID.c
Bootloaders/HID/BootloaderHID.c
+8
-0
Demos/Device/ClassDriver/RNDISEthernet/Lib/DHCP.c
Demos/Device/ClassDriver/RNDISEthernet/Lib/DHCP.c
+1
-1
Demos/Device/ClassDriver/RNDISEthernet/Lib/Ethernet.c
Demos/Device/ClassDriver/RNDISEthernet/Lib/Ethernet.c
+1
-2
Demos/Device/ClassDriver/RNDISEthernet/Lib/TCP.c
Demos/Device/ClassDriver/RNDISEthernet/Lib/TCP.c
+3
-6
Demos/Device/ClassDriver/RNDISEthernet/Lib/TCP.h
Demos/Device/ClassDriver/RNDISEthernet/Lib/TCP.h
+2
-1
Demos/Device/ClassDriver/RNDISEthernet/RNDISEthernet.c
Demos/Device/ClassDriver/RNDISEthernet/RNDISEthernet.c
+17
-3
Demos/Device/LowLevel/RNDISEthernet/Lib/DHCP.c
Demos/Device/LowLevel/RNDISEthernet/Lib/DHCP.c
+1
-1
Demos/Device/LowLevel/RNDISEthernet/Lib/Ethernet.c
Demos/Device/LowLevel/RNDISEthernet/Lib/Ethernet.c
+1
-2
Demos/Device/LowLevel/RNDISEthernet/Lib/TCP.c
Demos/Device/LowLevel/RNDISEthernet/Lib/TCP.c
+1
-2
Demos/Device/LowLevel/RNDISEthernet/RNDISEthernet.c
Demos/Device/LowLevel/RNDISEthernet/RNDISEthernet.c
+4
-7
LUFA/CodeTemplates/makefile_template.uc3
LUFA/CodeTemplates/makefile_template.uc3
+1
-3
LUFA/Common/Common.h
LUFA/Common/Common.h
+4
-1
LUFA/Common/Endianness.h
LUFA/Common/Endianness.h
+3
-3
LUFA/Drivers/USB/Class/Common/CDC.h
LUFA/Drivers/USB/Class/Common/CDC.h
+2
-2
LUFA/Drivers/USB/Class/Common/RNDIS.h
LUFA/Drivers/USB/Class/Common/RNDIS.h
+13
-10
LUFA/Drivers/USB/Class/Device/RNDIS.c
LUFA/Drivers/USB/Class/Device/RNDIS.c
+80
-46
LUFA/Drivers/USB/Class/Device/RNDIS.h
LUFA/Drivers/USB/Class/Device/RNDIS.h
+42
-6
LUFA/Drivers/USB/Class/Host/RNDIS.c
LUFA/Drivers/USB/Class/Host/RNDIS.c
+5
-4
LUFA/Drivers/USB/Class/Host/RNDIS.h
LUFA/Drivers/USB/Class/Host/RNDIS.h
+7
-11
LUFA/Drivers/USB/Core/AVR8/Device_AVR8.h
LUFA/Drivers/USB/Core/AVR8/Device_AVR8.h
+15
-7
LUFA/Drivers/USB/Core/AVR8/USBController_AVR8.h
LUFA/Drivers/USB/Core/AVR8/USBController_AVR8.h
+3
-2
LUFA/Drivers/USB/Core/ConfigDescriptor.c
LUFA/Drivers/USB/Core/ConfigDescriptor.c
+7
-3
LUFA/Drivers/USB/Core/ConfigDescriptor.h
LUFA/Drivers/USB/Core/ConfigDescriptor.h
+9
-4
LUFA/Drivers/USB/Core/Device.h
LUFA/Drivers/USB/Core/Device.h
+7
-0
LUFA/Drivers/USB/Core/DeviceStandardReq.c
LUFA/Drivers/USB/Core/DeviceStandardReq.c
+1
-1
LUFA/Drivers/USB/Core/StdDescriptors.h
LUFA/Drivers/USB/Core/StdDescriptors.h
+15
-11
LUFA/Drivers/USB/Core/UC3/Device_UC3.h
LUFA/Drivers/USB/Core/UC3/Device_UC3.h
+16
-7
LUFA/Drivers/USB/Core/UC3/Endpoint_UC3.c
LUFA/Drivers/USB/Core/UC3/Endpoint_UC3.c
+1
-1
LUFA/Drivers/USB/Core/UC3/Pipe_UC3.c
LUFA/Drivers/USB/Core/UC3/Pipe_UC3.c
+1
-1
LUFA/Drivers/USB/Core/UC3/USBController_UC3.c
LUFA/Drivers/USB/Core/UC3/USBController_UC3.c
+2
-0
LUFA/Drivers/USB/Core/UC3/USBInterrupt_UC3.c
LUFA/Drivers/USB/Core/UC3/USBInterrupt_UC3.c
+4
-4
LUFA/ManPages/ChangeLog.txt
LUFA/ManPages/ChangeLog.txt
+4
-1
LUFA/ManPages/DeviceSupport.txt
LUFA/ManPages/DeviceSupport.txt
+42
-39
LUFA/ManPages/FutureChanges.txt
LUFA/ManPages/FutureChanges.txt
+4
-0
LUFA/ManPages/LUFAPoweredProjects.txt
LUFA/ManPages/LUFAPoweredProjects.txt
+9
-2
LUFA/ManPages/LibraryResources.txt
LUFA/ManPages/LibraryResources.txt
+1
-2
LUFA/ManPages/MigrationInformation.txt
LUFA/ManPages/MigrationInformation.txt
+3
-0
LUFA/makefile
LUFA/makefile
+10
-4
No files found.
Bootloaders/CDC/BootloaderCDC.c
View file @
397c2f91
...
...
@@ -66,6 +66,9 @@ int main(void)
/* Setup hardware required for the bootloader */
SetupHardware
();
/* Turn on first LED on the board to indicate that the bootloader has started */
LEDs_SetAllLEDs
(
LEDS_LED1
);
/* Enable global interrupts so that the USB stack can function */
sei
();
...
...
@@ -100,6 +103,17 @@ void SetupHardware(void)
/* Initialize USB Subsystem */
USB_Init
();
LEDs_Init
();
/* Bootloader active LED toggle timer initialization */
TIMSK1
=
(
1
<<
TOIE1
);
TCCR1B
=
((
1
<<
CS11
)
|
(
1
<<
CS10
));
}
/** ISR to periodically toggle the LEDs on the board to indicate that the bootloader is active. */
ISR
(
TIMER1_OVF_vect
,
ISR_BLOCK
)
{
LEDs_ToggleLEDs
(
LEDS_LED1
|
LEDS_LED2
);
}
/** Event handler for the USB_ConfigurationChanged event. This configures the device's endpoints ready
...
...
@@ -134,6 +148,9 @@ void EVENT_USB_Device_ControlRequest(void)
return
;
}
/* Activity - toggle indicator LEDs */
LEDs_ToggleLEDs
(
LEDS_LED1
|
LEDS_LED2
);
/* Process CDC specific control requests */
switch
(
USB_ControlRequest
.
bRequest
)
{
...
...
Bootloaders/CDC/BootloaderCDC.h
View file @
397c2f91
...
...
@@ -48,6 +48,7 @@
#include "Descriptors.h"
#include <LUFA/Drivers/USB/USB.h>
#include <LUFA/Drivers/Board/LEDs.h>
/* Macros: */
/** Version major of the CDC bootloader. */
...
...
Bootloaders/DFU/BootloaderDFU.c
View file @
397c2f91
...
...
@@ -119,6 +119,9 @@ int main(void)
MCUCR
&=
~
(
1
<<
JTD
);
#endif
/* Turn on first LED on the board to indicate that the bootloader has started */
LEDs_SetAllLEDs
(
LEDS_LED1
);
/* Enable global interrupts so that the USB stack can function */
sei
();
...
...
@@ -149,6 +152,11 @@ void SetupHardware(void)
/* Initialize the USB subsystem */
USB_Init
();
LEDs_Init
();
/* Bootloader active LED toggle timer initialization */
TIMSK1
=
(
1
<<
TOIE1
);
TCCR1B
=
((
1
<<
CS11
)
|
(
1
<<
CS10
));
}
/** Resets all configured hardware required for the bootloader back to their original states. */
...
...
@@ -162,15 +170,18 @@ void ResetHardware(void)
MCUCR
=
0
;
}
/** ISR to periodically toggle the LEDs on the board to indicate that the bootloader is active. */
ISR
(
TIMER1_OVF_vect
,
ISR_BLOCK
)
{
LEDs_ToggleLEDs
(
LEDS_LED1
|
LEDS_LED2
);
}
/** Event handler for the USB_ControlRequest event. This is used to catch and process control requests sent to
* the device from the USB host before passing along unhandled control requests to the library for processing
* internally.
*/
void
EVENT_USB_Device_ControlRequest
(
void
)
{
/* Get the size of the command and data from the wLength value */
SentCommand
.
DataSize
=
USB_ControlRequest
.
wLength
;
{
/* Ignore any requests that aren't directed to the DFU interface */
if
((
USB_ControlRequest
.
bmRequestType
&
(
CONTROL_REQTYPE_TYPE
|
CONTROL_REQTYPE_RECIPIENT
))
!=
(
REQTYPE_CLASS
|
REQREC_INTERFACE
))
...
...
@@ -178,6 +189,12 @@ void EVENT_USB_Device_ControlRequest(void)
return
;
}
/* Activity - toggle indicator LEDs */
LEDs_ToggleLEDs
(
LEDS_LED1
|
LEDS_LED2
);
/* Get the size of the command and data from the wLength value */
SentCommand
.
DataSize
=
USB_ControlRequest
.
wLength
;
switch
(
USB_ControlRequest
.
bRequest
)
{
case
DFU_REQ_DNLOAD
:
...
...
Bootloaders/DFU/BootloaderDFU.h
View file @
397c2f91
...
...
@@ -50,6 +50,7 @@
#include "Descriptors.h"
#include <LUFA/Drivers/USB/USB.h>
#include <LUFA/Drivers/Board/LEDs.h>
/* Macros: */
/** Configuration define. Define this token to true to case the bootloader to reject all memory commands
...
...
Bootloaders/HID/BootloaderHID.c
View file @
397c2f91
...
...
@@ -113,10 +113,18 @@ void EVENT_USB_Device_ControlRequest(void)
while
(
!
(
Endpoint_IsOUTReceived
()));
/* Read in the write destination address */
#if (FLASHEND > 0xFFFF)
uint32_t
PageAddress
=
((
uint32_t
)
Endpoint_Read_16_LE
()
<<
8
);
#else
uint16_t
PageAddress
=
Endpoint_Read_16_LE
();
#endif
/* Check if the command is a program page command, or a start application command */
#if (FLASHEND > 0xFFFF)
if
((
uint16_t
)(
PageAddress
>>
8
)
==
COMMAND_STARTAPPLICATION
)
#else
if
(
PageAddress
==
COMMAND_STARTAPPLICATION
)
#endif
{
RunBootloader
=
false
;
}
...
...
Demos/Device/ClassDriver/RNDISEthernet/Lib/DHCP.c
View file @
397c2f91
...
...
@@ -59,7 +59,7 @@ int16_t DHCP_ProcessDHCPPacket(void* IPHeaderInStart,
DecodeDHCPHeader
(
DHCPHeaderInStart
);
/* Zero out the response DHCP packet, as much of it legacy and left at 0 */
/* Zero out the response DHCP packet, as much of it
is
legacy and left at 0 */
memset
(
DHCPHeaderOUT
,
0
,
sizeof
(
DHCP_Header_t
));
/* Fill out the response DHCP packet */
...
...
Demos/Device/ClassDriver/RNDISEthernet/Lib/Ethernet.c
View file @
397c2f91
...
...
@@ -96,7 +96,6 @@ void Ethernet_ProcessPacket(Ethernet_Frame_Info_t* const FrameIN,
/* Set the response length in the buffer and indicate that a response is ready to be sent */
FrameOUT
->
FrameLength
=
(
sizeof
(
Ethernet_Frame_Header_t
)
+
RetSize
);
FrameOUT
->
FrameInBuffer
=
true
;
}
}
...
...
@@ -104,7 +103,7 @@ void Ethernet_ProcessPacket(Ethernet_Frame_Info_t* const FrameIN,
if
(
RetSize
!=
NO_PROCESS
)
{
/* Clear the frame buffer */
FrameIN
->
Frame
InBuffer
=
false
;
FrameIN
->
Frame
Length
=
0
;
}
}
...
...
Demos/Device/ClassDriver/RNDISEthernet/Lib/TCP.c
View file @
397c2f91
...
...
@@ -55,7 +55,8 @@ 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_Device_t
*
const
RNDISInterfaceInfo
)
void
TCP_TCPTask
(
USB_ClassInfo_RNDIS_Device_t
*
const
RNDISInterfaceInfo
,
Ethernet_Frame_Info_t
*
const
FrameOUT
)
{
/* Run each application in sequence, to process incoming and generate outgoing packets */
for
(
uint8_t
CSTableEntry
=
0
;
CSTableEntry
<
MAX_TCP_CONNECTIONS
;
CSTableEntry
++
)
...
...
@@ -73,11 +74,8 @@ void TCP_TCPTask(USB_ClassInfo_RNDIS_Device_t* const RNDISInterfaceInfo)
}
}
/* Get pointer to the output frame info struct for convenience */
Ethernet_Frame_Info_t
*
FrameOUT
=
&
RNDISInterfaceInfo
->
State
.
FrameOUT
;
/* Bail out early if there is already a frame waiting to be sent in the Ethernet OUT buffer */
if
(
FrameOUT
->
Frame
InBuffer
)
if
(
FrameOUT
->
Frame
Length
)
return
;
/* Send response packets from each application as the TCP packet buffers are filled by the applications */
...
...
@@ -147,7 +145,6 @@ void TCP_TCPTask(USB_ClassInfo_RNDIS_Device_t* const RNDISInterfaceInfo)
/* Set the response length in the buffer and indicate that a response is ready to be sent */
FrameOUT
->
FrameLength
=
PacketSize
;
FrameOUT
->
FrameInBuffer
=
true
;
ConnectionStateTable
[
CSTableEntry
].
Info
.
Buffer
.
Ready
=
false
;
...
...
Demos/Device/ClassDriver/RNDISEthernet/Lib/TCP.h
View file @
397c2f91
...
...
@@ -228,7 +228,8 @@
}
TCP_Header_t
;
/* Function Prototypes: */
void
TCP_TCPTask
(
USB_ClassInfo_RNDIS_Device_t
*
const
RNDISInterfaceInfo
);
void
TCP_TCPTask
(
USB_ClassInfo_RNDIS_Device_t
*
const
RNDISInterfaceInfo
,
Ethernet_Frame_Info_t
*
const
FrameOUT
);
void
TCP_Init
(
void
);
bool
TCP_SetPortState
(
const
uint16_t
Port
,
const
uint8_t
State
,
...
...
Demos/Device/ClassDriver/RNDISEthernet/RNDISEthernet.c
View file @
397c2f91
...
...
@@ -63,6 +63,11 @@ USB_ClassInfo_RNDIS_Device_t Ethernet_RNDIS_Interface =
},
};
/** Global to store the incoming frame from the host before it is processed by the device. */
static
Ethernet_Frame_Info_t
FrameIN
;
/** Global to store the outgoing frame created in the device before it is sent to the host. */
static
Ethernet_Frame_Info_t
FrameOUT
;
/** Main program entry point. This routine contains the overall program flow, including initial
* setup of all components and the main program loop.
...
...
@@ -79,14 +84,23 @@ int main(void)
for
(;;)
{
if
(
Ethernet_RNDIS_Interface
.
State
.
FrameIN
.
FrameInBuffer
)
if
(
RNDIS_Device_IsPacketReceived
(
&
Ethernet_RNDIS_Interface
)
)
{
LEDs_SetAllLEDs
(
LEDMASK_USB_BUSY
);
Ethernet_ProcessPacket
(
&
Ethernet_RNDIS_Interface
.
State
.
FrameIN
,
&
Ethernet_RNDIS_Interface
.
State
.
FrameOUT
);
RNDIS_Device_ReadPacket
(
&
Ethernet_RNDIS_Interface
,
&
FrameIN
.
FrameData
,
&
FrameIN
.
FrameLength
);
Ethernet_ProcessPacket
(
&
FrameIN
,
&
FrameOUT
);
if
(
FrameOUT
.
FrameLength
)
{
RNDIS_Device_SendPacket
(
&
Ethernet_RNDIS_Interface
,
&
FrameOUT
.
FrameData
,
FrameOUT
.
FrameLength
);
FrameOUT
.
FrameLength
=
0
;
}
LEDs_SetAllLEDs
(
LEDMASK_USB_READY
);
}
TCP_TCPTask
(
&
Ethernet_RNDIS_Interface
);
TCP_TCPTask
(
&
Ethernet_RNDIS_Interface
,
&
FrameOUT
);
RNDIS_Device_USBTask
(
&
Ethernet_RNDIS_Interface
);
USB_USBTask
();
...
...
Demos/Device/LowLevel/RNDISEthernet/Lib/DHCP.c
View file @
397c2f91
...
...
@@ -59,7 +59,7 @@ int16_t DHCP_ProcessDHCPPacket(void* IPHeaderInStart,
DecodeDHCPHeader
(
DHCPHeaderInStart
);
/* Zero out the response DHCP packet, as much of it legacy and left at 0 */
/* Zero out the response DHCP packet, as much of it
is
legacy and left at 0 */
memset
(
DHCPHeaderOUT
,
0
,
sizeof
(
DHCP_Header_t
));
/* Fill out the response DHCP packet */
...
...
Demos/Device/LowLevel/RNDISEthernet/Lib/Ethernet.c
View file @
397c2f91
...
...
@@ -100,7 +100,6 @@ void Ethernet_ProcessPacket(void)
/* Set the response length in the buffer and indicate that a response is ready to be sent */
FrameOUT
.
FrameLength
=
(
sizeof
(
Ethernet_Frame_Header_t
)
+
RetSize
);
FrameOUT
.
FrameInBuffer
=
true
;
}
}
...
...
@@ -108,7 +107,7 @@ void Ethernet_ProcessPacket(void)
if
(
RetSize
!=
NO_PROCESS
)
{
/* Clear the frame buffer */
FrameIN
.
Frame
InBuffer
=
false
;
FrameIN
.
Frame
Length
=
0
;
}
}
...
...
Demos/Device/LowLevel/RNDISEthernet/Lib/TCP.c
View file @
397c2f91
...
...
@@ -74,7 +74,7 @@ void TCP_Task(void)
}
/* Bail out early if there is already a frame waiting to be sent in the Ethernet OUT buffer */
if
(
FrameOUT
.
Frame
InBuffer
)
if
(
FrameOUT
.
Frame
Length
)
return
;
/* Send response packets from each application as the TCP packet buffers are filled by the applications */
...
...
@@ -144,7 +144,6 @@ void TCP_Task(void)
/* Set the response length in the buffer and indicate that a response is ready to be sent */
FrameOUT
.
FrameLength
=
PacketSize
;
FrameOUT
.
FrameInBuffer
=
true
;
ConnectionStateTable
[
CSTableEntry
].
Info
.
Buffer
.
Ready
=
false
;
...
...
Demos/Device/LowLevel/RNDISEthernet/RNDISEthernet.c
View file @
397c2f91
...
...
@@ -204,7 +204,7 @@ void RNDIS_Task(void)
Endpoint_SelectEndpoint
(
CDC_RX_EPNUM
);
/* Check if the data OUT endpoint contains data, and that the IN buffer is empty */
if
(
Endpoint_IsOUTReceived
()
&&
!
(
FrameIN
.
Frame
InBuffer
))
if
(
Endpoint_IsOUTReceived
()
&&
!
(
FrameIN
.
Frame
Length
))
{
/* Read in the packet message header */
Endpoint_Read_Stream_LE
(
&
RNDISPacketHeader
,
sizeof
(
RNDIS_Packet_Message_t
),
NULL
);
...
...
@@ -224,16 +224,13 @@ void RNDIS_Task(void)
/* Store the size of the Ethernet frame */
FrameIN
.
FrameLength
=
RNDISPacketHeader
.
DataLength
;
/* Indicate Ethernet IN buffer full */
FrameIN
.
FrameInBuffer
=
true
;
}
/* Select the data IN endpoint */
Endpoint_SelectEndpoint
(
CDC_TX_EPNUM
);
/* Check if the data IN endpoint is ready for more data, and that the IN buffer is full */
if
(
Endpoint_IsINReady
()
&&
FrameOUT
.
Frame
InBuffer
)
if
(
Endpoint_IsINReady
()
&&
FrameOUT
.
Frame
Length
)
{
/* Clear the packet header with all 0s so that the relevant fields can be filled */
memset
(
&
RNDISPacketHeader
,
0
,
sizeof
(
RNDIS_Packet_Message_t
));
...
...
@@ -254,7 +251,7 @@ void RNDIS_Task(void)
Endpoint_ClearIN
();
/* Indicate Ethernet OUT buffer no longer full */
FrameOUT
.
Frame
InBuffer
=
false
;
FrameOUT
.
Frame
Length
=
0
;
}
}
}
...
...
@@ -273,7 +270,7 @@ void Ethernet_Task(void)
return
;
/* Check if a frame has been written to the IN frame buffer */
if
(
FrameIN
.
Frame
InBuffer
)
if
(
FrameIN
.
Frame
Length
)
{
/* Indicate packet processing started */
LEDs_SetAllLEDs
(
LEDMASK_USB_BUSY
);
...
...
LUFA/CodeTemplates/makefile_template.uc3
View file @
397c2f91
...
...
@@ -236,9 +236,7 @@ ASFLAGS = $(ADEFS) -Wa,-adhlns=$(<:%.S=$(OBJDIR)/%.lst),-gstabs,--listing-cont-l
# -Map: create map file
# --cref: add cross reference to map file
LDFLAGS
=
-Wl
,-Map
=
$(TARGET)
.map,--cref
LDFLAGS
+=
-Wl
,--relax
LDFLAGS
+=
-Wl
,--gc-sections
LDFLAGS
+=
-Wl
,--rodata-writable
LDFLAGS
+=
-Wl
,--gc-sections
--rodata-writable
LDFLAGS
+=
-Wl
,--direct-data
#LDFLAGS += -T linker_script.x
...
...
LUFA/Common/Common.h
View file @
397c2f91
...
...
@@ -73,7 +73,10 @@
/* Architecture specific utility includes: */
#if defined(__DOXYGEN__)
/** Type define for an unsigned integer the same width as the selected architecture's machine register. */
/** Type define for an unsigned integer the same width as the selected architecture's machine register.
* This is distinct from the non-specific standard int data type, whose width is machine dependant but
* which may not reflect the actual machine register width on some targets (e.g. AVR8).
*/
typedef
MACHINE_REG_t
uint_reg_t
;
#elif (ARCH == ARCH_AVR8)
#include <avr/io.h>
...
...
LUFA/Common/Endianness.h
View file @
397c2f91
...
...
@@ -78,7 +78,7 @@
*
* \return Input value with the byte ordering reversed.
*/
#define SWAPENDIAN_16(x) ((((x) & 0xFF00) >> 8) | (((x) & 0x00FF) << 8))
#define SWAPENDIAN_16(x)
(uint16_t)
((((x) & 0xFF00) >> 8) | (((x) & 0x00FF) << 8))
/** Swaps the byte ordering of a 32-bit value at compile-time. Do not use this macro for swapping byte orderings
* of dynamic values computed at runtime- use \ref SwapEndian_32() instead. The result of this macro can be used
...
...
@@ -91,8 +91,8 @@
*
* \return Input value with the byte ordering reversed.
*/
#define SWAPENDIAN_32(x) ((((x) & 0xFF000000UL) >> 24UL) | (((x) & 0x00FF0000UL) >> 8UL) | \
(((
x
)
&
0x0000FF00UL
)
<<
8UL
)
|
(((
x
)
&
0x000000FFUL
)
<<
24UL
))
#define SWAPENDIAN_32(x)
(uint32_t)
((((x) & 0xFF000000UL) >> 24UL) | (((x) & 0x00FF0000UL) >> 8UL) | \
(((
x
)
&
0x0000FF00UL
)
<<
8UL
)
|
(((
x
)
&
0x000000FFUL
)
<<
24UL
))
#if defined(ARCH_BIG_ENDIAN) && !defined(le16_to_cpu)
#define le16_to_cpu(x) SwapEndian_16(x)
...
...
LUFA/Drivers/USB/Class/Common/CDC.h
View file @
397c2f91
...
...
@@ -145,10 +145,10 @@
CDC_CSCP_ATCommandProtocol
=
0x01
,
/**< Descriptor Protocol value indicating that the device or interface
* belongs to the AT Command protocol of the CDC class.
*/
CDC_CSCP_NoSpecificProtocol
=
0x00
,
/**< Descriptor
Class
value indicating that the device or interface
CDC_CSCP_NoSpecificProtocol
=
0x00
,
/**< Descriptor
Protocol
value indicating that the device or interface
* belongs to no specific protocol of the CDC class.
*/
CDC_CSCP_VendorSpecificProtocol
=
0xFF
,
/**< Descriptor
Class
value indicating that the device or interface
CDC_CSCP_VendorSpecificProtocol
=
0xFF
,
/**< Descriptor
Protocol
value indicating that the device or interface
* belongs to a vendor-specific protocol of the CDC class.
*/
CDC_CSCP_CDCDataClass
=
0x0A
,
/**< Descriptor Class value indicating that the device or interface
...
...
LUFA/Drivers/USB/Class/Common/RNDIS.h
View file @
397c2f91
...
...
@@ -68,6 +68,9 @@
#endif
/* Macros: */
/** Additional error code for RNDIS functions when a device returns a logical command failure. */
#define RNDIS_ERROR_LOGICAL_CMD_FAILED 0x80
/** Implemented RNDIS Version Major. */
#define REMOTE_NDIS_VERSION_MAJOR 0x01
...
...
@@ -205,25 +208,25 @@
};
/* Type Defines: */
/** \brief
MAC Address
Structure.
/** \brief
Ethernet Frame Packet Information
Structure.
*
* Type define for a physical MAC address of a device on a network.
* Type define for an Ethernet frame buffer data and information structure. This can be used to conveniently
* store both the size and data in an Ethernet frame.
*/
typedef
struct
{
uint8_t
Octets
[
6
];
/**< Individual bytes of a MAC address */
}
ATTR_PACKED
MAC_Address_t
;
uint8_t
FrameData
[
ETHERNET_FRAME_SIZE_MAX
];
/**< Ethernet frame contents. */
uint16_t
FrameLength
;
/**< Length in bytes of the Ethernet frame stored in the buffer. */
}
Ethernet_Frame_Info_t
;
/** \brief
RNDIS Ethernet Frame Packet Information
Structure.
/** \brief
MAC Address
Structure.
*
* Type define for a
n Ethernet frame buffer data and information structure
.
* Type define for a
physical MAC address of a device on a network
.
*/
typedef
struct
{
uint8_t
FrameData
[
ETHERNET_FRAME_SIZE_MAX
];
/**< Ethernet frame contents. */
uint16_t
FrameLength
;
/**< Length in bytes of the Ethernet frame stored in the buffer. */
bool
FrameInBuffer
;
/**< Indicates if a frame is currently stored in the buffer. */
}
ATTR_PACKED
Ethernet_Frame_Info_t
;
uint8_t
Octets
[
6
];
/**< Individual bytes of a MAC address */
}
ATTR_PACKED
MAC_Address_t
;
/** \brief RNDIS Common Message Header Structure.
*
...
...
LUFA/Drivers/USB/Class/Device/RNDIS.c
View file @
397c2f91
...
...
@@ -163,8 +163,6 @@ void RNDIS_Device_USBTask(USB_ClassInfo_RNDIS_Device_t* const RNDISInterfaceInfo
if
(
USB_DeviceState
!=
DEVICE_STATE_Configured
)
return
;
RNDIS_Message_Header_t
*
MessageHeader
=
(
RNDIS_Message_Header_t
*
)
&
RNDISInterfaceInfo
->
State
.
RNDISMessageBuffer
;
Endpoint_SelectEndpoint
(
RNDISInterfaceInfo
->
Config
.
NotificationEndpointNumber
);
if
(
Endpoint_IsINReady
()
&&
RNDISInterfaceInfo
->
State
.
ResponseReady
)
...
...
@@ -184,50 +182,6 @@ void RNDIS_Device_USBTask(USB_ClassInfo_RNDIS_Device_t* const RNDISInterfaceInfo
RNDISInterfaceInfo
->
State
.
ResponseReady
=
false
;
}
if
((
RNDISInterfaceInfo
->
State
.
CurrRNDISState
==
RNDIS_Data_Initialized
)
&&
!
(
MessageHeader
->
MessageLength
))
{
RNDIS_Packet_Message_t
RNDISPacketHeader
;
Endpoint_SelectEndpoint
(
RNDISInterfaceInfo
->
Config
.
DataOUTEndpointNumber
);
if
(
Endpoint_IsOUTReceived
()
&&
!
(
RNDISInterfaceInfo
->
State
.
FrameIN
.
FrameInBuffer
))
{
Endpoint_Read_Stream_LE
(
&
RNDISPacketHeader
,
sizeof
(
RNDIS_Packet_Message_t
),
NULL
);
if
(
RNDISPacketHeader
.
DataLength
>
ETHERNET_FRAME_SIZE_MAX
)
{
Endpoint_StallTransaction
();
return
;
}
Endpoint_Read_Stream_LE
(
RNDISInterfaceInfo
->
State
.
FrameIN
.
FrameData
,
RNDISPacketHeader
.
DataLength
,
NULL
);
Endpoint_ClearOUT
();
RNDISInterfaceInfo
->
State
.
FrameIN
.
FrameLength
=
RNDISPacketHeader
.
DataLength
;
RNDISInterfaceInfo
->
State
.
FrameIN
.
FrameInBuffer
=
true
;
}
Endpoint_SelectEndpoint
(
RNDISInterfaceInfo
->
Config
.
DataINEndpointNumber
);
if
(
Endpoint_IsINReady
()
&&
RNDISInterfaceInfo
->
State
.
FrameOUT
.
FrameInBuffer
)
{
memset
(
&
RNDISPacketHeader
,
0
,
sizeof
(
RNDIS_Packet_Message_t
));
RNDISPacketHeader
.
MessageType
=
REMOTE_NDIS_PACKET_MSG
;
RNDISPacketHeader
.
MessageLength
=
(
sizeof
(
RNDIS_Packet_Message_t
)
+
RNDISInterfaceInfo
->
State
.
FrameOUT
.
FrameLength
);
RNDISPacketHeader
.
DataOffset
=
(
sizeof
(
RNDIS_Packet_Message_t
)
-
sizeof
(
RNDIS_Message_Header_t
));
RNDISPacketHeader
.
DataLength
=
RNDISInterfaceInfo
->
State
.
FrameOUT
.
FrameLength
;
Endpoint_Write_Stream_LE
(
&
RNDISPacketHeader
,
sizeof
(
RNDIS_Packet_Message_t
),
NULL
);
Endpoint_Write_Stream_LE
(
RNDISInterfaceInfo
->
State
.
FrameOUT
.
FrameData
,
RNDISPacketHeader
.
DataLength
,
NULL
);
Endpoint_ClearIN
();
RNDISInterfaceInfo
->
State
.
FrameOUT
.
FrameInBuffer
=
false
;
}
}
}
void
RNDIS_Device_ProcessRNDISControlMessage
(
USB_ClassInfo_RNDIS_Device_t
*
const
RNDISInterfaceInfo
)
...
...
@@ -493,5 +447,85 @@ static bool RNDIS_Device_ProcessNDISSet(USB_ClassInfo_RNDIS_Device_t* const RNDI
}
}
bool
RNDIS_Device_IsPacketReceived
(
USB_ClassInfo_RNDIS_Device_t
*
const
RNDISInterfaceInfo
)
{
if
((
USB_DeviceState
!=
DEVICE_STATE_Configured
)
||
(
RNDISInterfaceInfo
->
State
.
CurrRNDISState
!=
RNDIS_Data_Initialized
))
{
return
false
;
}
Endpoint_SelectEndpoint
(
RNDISInterfaceInfo
->
Config
.
DataOUTEndpointNumber
);
return
Endpoint_IsOUTReceived
();
}
uint8_t
RNDIS_Device_ReadPacket
(
USB_ClassInfo_RNDIS_Device_t
*
const
RNDISInterfaceInfo
,
void
*
Buffer
,
uint16_t
*
const
PacketLength
)
{
if
((
USB_DeviceState
!=
DEVICE_STATE_Configured
)
||
(
RNDISInterfaceInfo
->
State
.
CurrRNDISState
!=
RNDIS_Data_Initialized
))
{
return
ENDPOINT_RWSTREAM_DeviceDisconnected
;
}
Endpoint_SelectEndpoint
(
RNDISInterfaceInfo
->
Config
.
DataOUTEndpointNumber
);
*
PacketLength
=
0
;
if
(
!
(
Endpoint_IsOUTReceived
()))
return
ENDPOINT_RWSTREAM_NoError
;
RNDIS_Packet_Message_t
RNDISPacketHeader
;
Endpoint_Read_Stream_LE
(
&
RNDISPacketHeader
,
sizeof
(
RNDIS_Packet_Message_t
),
NULL
);
if
(
RNDISPacketHeader
.
DataLength
>
ETHERNET_FRAME_SIZE_MAX
)
{
Endpoint_StallTransaction
();
return
RNDIS_ERROR_LOGICAL_CMD_FAILED
;
}
*
PacketLength
=
(
uint16_t
)
RNDISPacketHeader
.
DataLength
;
Endpoint_Read_Stream_LE
(
Buffer
,
RNDISPacketHeader
.
DataLength
,
NULL
);
Endpoint_ClearOUT
();
return
ENDPOINT_RWSTREAM_NoError
;
}
uint8_t
RNDIS_Device_SendPacket
(
USB_ClassInfo_RNDIS_Device_t
*
const
RNDISInterfaceInfo
,
void
*
Buffer
,
const
uint16_t
PacketLength
)
{
uint8_t
ErrorCode
;
if
((
USB_DeviceState
!=
DEVICE_STATE_Configured
)
||
(
RNDISInterfaceInfo
->
State
.
CurrRNDISState
!=
RNDIS_Data_Initialized
))
{
return
ENDPOINT_RWSTREAM_DeviceDisconnected
;
}
Endpoint_SelectEndpoint
(
RNDISInterfaceInfo
->
Config
.
DataINEndpointNumber
);
if
((
ErrorCode
=
Endpoint_WaitUntilReady
())
!=
ENDPOINT_READYWAIT_NoError
)
return
ErrorCode
;
RNDIS_Packet_Message_t
RNDISPacketHeader
;
memset
(
&
RNDISPacketHeader
,
0
,
sizeof
(
RNDIS_Packet_Message_t
));
RNDISPacketHeader
.
MessageType
=
REMOTE_NDIS_PACKET_MSG
;
RNDISPacketHeader
.
MessageLength
=
(
sizeof
(
RNDIS_Packet_Message_t
)
+
PacketLength
);
RNDISPacketHeader
.
DataOffset
=
(
sizeof
(
RNDIS_Packet_Message_t
)
-
sizeof
(
RNDIS_Message_Header_t
));
RNDISPacketHeader
.
DataLength
=
PacketLength
;
Endpoint_Write_Stream_LE
(
&
RNDISPacketHeader
,
sizeof
(
RNDIS_Packet_Message_t
),
NULL
);
Endpoint_Write_Stream_LE
(
Buffer
,
PacketLength
,
NULL
);
Endpoint_ClearIN
();
return
ENDPOINT_RWSTREAM_NoError
;
}
#endif
LUFA/Drivers/USB/Class/Device/RNDIS.h
View file @
397c2f91
...
...
@@ -106,12 +106,6 @@
bool
ResponseReady
;
/**< Internal flag indicating if a RNDIS message is waiting to be returned to the host. */
uint8_t
CurrRNDISState
;
/**< Current RNDIS state of the adapter, a value from the \ref RNDIS_States_t enum. */
uint32_t
CurrPacketFilter
;
/**< Current packet filter mode, used internally by the class driver. */
Ethernet_Frame_Info_t
FrameIN
;
/**< Structure holding the last received Ethernet frame from the host, for user
* processing.
*/
Ethernet_Frame_Info_t
FrameOUT
;
/**< Structure holding the next Ethernet frame to send to the host, populated by the
* user application.
*/
}
State
;
/**< State data for the USB class interface within the device. All elements in this section
* are reset to their defaults when the interface is enumerated.
*/
...
...
@@ -146,6 +140,48 @@
*/
void
RNDIS_Device_USBTask
(
USB_ClassInfo_RNDIS_Device_t
*
const
RNDISInterfaceInfo
)
ATTR_NON_NULL_PTR_ARG
(
1
);
/** Determines if a packet is currently waiting for the device to read in and process.
*
* \pre This function must only be called when the Device state machine is in the \ref DEVICE_STATE_Configured state or the
* call will fail.
*
* \param[in,out] RNDISInterfaceInfo Pointer to a structure containing an RNDIS Class configuration and state.
*
* \return Boolean \c true if a packet is waiting to be read in by the host, \c false otherwise.
*/
bool
RNDIS_Device_IsPacketReceived
(
USB_ClassInfo_RNDIS_Device_t
*
const
RNDISInterfaceInfo
);