Fixed GenericHIDHost demo report write routine incorrect for control type requests (thanks to Andrei Krainev).

Removed Endpoint_ClearCurrentBank() and Pipe_ClearCurrentBank() in favour of new Endpoint_ClearIN(), Endpoint_ClearOUT(), Endpoint_ClearControlIN(), Endpoint_ClearControlOUT(), Pipe_ClearIN(), Pipe_ClearOUT(), Pipe_ClearControlIN() and Pipe_ClearControlOUT() macros (done to allow for the detection of packets of zero length).

Renamed *_ReadWriteAllowed() macros to *_IsReadWriteAllowed() to remain consistent with the rest of the LUFA API.

Endpoint_IsSetupReceived() macro has been renamed to Endpoint_IsSETUPReceived(), Endpoint_ClearSetupReceived() macro has been renamed to Endpoint_ClearControlSETUP(), the Pipe_IsSetupSent() macro has been renamed to Pipe_IsSETUPSent() and the Pipe_ClearSetupSent() macro is no longer applicable and should be removed - changes made to compliment the new endpoint and pipe bank management API.

Updated all demos, bootloaders and projects to use the new endpoint and pipe management APIs (thanks to Roman Thiel).

Updated library doxygen documentation, added groups, changed documentation macro functions to real functions for clarity.

Removed old endpoint and pipe aliased read/write/discard routines which did not have an explicit endian specifier for clarity.

Removed the ButtLoadTag.h header file, as no one used for its intended purpose anyway.
pull/1469/head
Dean Camera 16 years ago
parent ef06bfd1c0
commit 8f6b4ddf76

@ -90,7 +90,7 @@ int main(void)
Endpoint_SelectEndpoint(CDC_TX_EPNUM); Endpoint_SelectEndpoint(CDC_TX_EPNUM);
/* Wait until any pending transmissions have completed before shutting down */ /* Wait until any pending transmissions have completed before shutting down */
while (!(Endpoint_ReadWriteAllowed())); while (!(Endpoint_IsINReady()));
/* Shut down the USB subsystem */ /* Shut down the USB subsystem */
USB_ShutDown(); USB_ShutDown();
@ -160,45 +160,45 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
case REQ_GetLineEncoding: case REQ_GetLineEncoding:
if (bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE)) if (bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE))
{ {
Endpoint_ClearSetupReceived(); Endpoint_ClearControlSETUP();
for (uint8_t i = 0; i < sizeof(LineCoding); i++) for (uint8_t i = 0; i < sizeof(LineCoding); i++)
Endpoint_Write_Byte(*(LineCodingData++)); Endpoint_Write_Byte(*(LineCodingData++));
Endpoint_ClearSetupIN(); Endpoint_ClearControlIN();
/* Acknowledge status stage */ /* Acknowledge status stage */
while (!(Endpoint_IsSetupOUTReceived())); while (!(Endpoint_IsOUTReceived()));
Endpoint_ClearSetupOUT(); Endpoint_ClearControlOUT();
} }
break; break;
case REQ_SetLineEncoding: case REQ_SetLineEncoding:
if (bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE)) if (bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE))
{ {
Endpoint_ClearSetupReceived(); Endpoint_ClearControlSETUP();
while (!(Endpoint_IsSetupOUTReceived())); while (!(Endpoint_IsOUTReceived()));
for (uint8_t i = 0; i < sizeof(LineCoding); i++) for (uint8_t i = 0; i < sizeof(LineCoding); i++)
*(LineCodingData++) = Endpoint_Read_Byte(); *(LineCodingData++) = Endpoint_Read_Byte();
Endpoint_ClearSetupOUT(); Endpoint_ClearControlOUT();
/* Acknowledge status stage */ /* Acknowledge status stage */
while (!(Endpoint_IsSetupINReady())); while (!(Endpoint_IsINReady()));
Endpoint_ClearSetupIN(); Endpoint_ClearControlIN();
} }
break; break;
case REQ_SetControlLineState: case REQ_SetControlLineState:
if (bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE)) if (bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE))
{ {
Endpoint_ClearSetupReceived(); Endpoint_ClearControlSETUP();
/* Acknowledge status stage */ /* Acknowledge status stage */
while (!(Endpoint_IsSetupINReady())); while (!(Endpoint_IsINReady()));
Endpoint_ClearSetupIN(); Endpoint_ClearControlIN();
} }
break; break;
@ -332,10 +332,10 @@ static uint8_t FetchNextCommandByte(void)
Endpoint_SelectEndpoint(CDC_RX_EPNUM); Endpoint_SelectEndpoint(CDC_RX_EPNUM);
/* If OUT endpoint empty, clear it and wait for the next packet from the host */ /* If OUT endpoint empty, clear it and wait for the next packet from the host */
if (!(Endpoint_ReadWriteAllowed())) while (!(Endpoint_IsReadWriteAllowed()))
{ {
Endpoint_ClearCurrentBank(); Endpoint_ClearOUT();
while (!(Endpoint_ReadWriteAllowed())); while (!(Endpoint_IsOUTReceived()));
} }
/* Fetch the next byte from the OUT endpoint */ /* Fetch the next byte from the OUT endpoint */
@ -353,10 +353,10 @@ static void WriteNextResponseByte(const uint8_t Response)
Endpoint_SelectEndpoint(CDC_TX_EPNUM); Endpoint_SelectEndpoint(CDC_TX_EPNUM);
/* If OUT endpoint empty, clear it and wait for the next packet from the host */ /* If OUT endpoint empty, clear it and wait for the next packet from the host */
if (!(Endpoint_ReadWriteAllowed())) if (!(Endpoint_IsReadWriteAllowed()))
{ {
Endpoint_ClearCurrentBank(); Endpoint_ClearIN();
while (!(Endpoint_ReadWriteAllowed())); while (!(Endpoint_IsINReady()));
} }
/* Write the next byte to the OUT endpoint */ /* Write the next byte to the OUT endpoint */
@ -372,7 +372,7 @@ TASK(CDC_Task)
Endpoint_SelectEndpoint(CDC_RX_EPNUM); Endpoint_SelectEndpoint(CDC_RX_EPNUM);
/* Check if endpoint has a command in it sent from the host */ /* Check if endpoint has a command in it sent from the host */
if (Endpoint_ReadWriteAllowed()) if (Endpoint_IsOUTReceived())
{ {
/* Read in the bootloader command (first byte sent from host) */ /* Read in the bootloader command (first byte sent from host) */
uint8_t Command = FetchNextCommandByte(); uint8_t Command = FetchNextCommandByte();
@ -557,22 +557,22 @@ TASK(CDC_Task)
Endpoint_SelectEndpoint(CDC_TX_EPNUM); Endpoint_SelectEndpoint(CDC_TX_EPNUM);
/* Remember if the endpoint is completely full before clearing it */ /* Remember if the endpoint is completely full before clearing it */
bool IsEndpointFull = !(Endpoint_ReadWriteAllowed()); bool IsEndpointFull = !(Endpoint_IsReadWriteAllowed());
/* Send the endpoint data to the host */ /* Send the endpoint data to the host */
Endpoint_ClearCurrentBank(); Endpoint_ClearIN();
/* If a full endpoint's worth of data was sent, we need to send an empty packet afterwards to signal end of transfer */ /* If a full endpoint's worth of data was sent, we need to send an empty packet afterwards to signal end of transfer */
if (IsEndpointFull) if (IsEndpointFull)
{ {
while (!(Endpoint_ReadWriteAllowed())); while (!(Endpoint_IsINReady()));
Endpoint_ClearCurrentBank(); Endpoint_ClearIN();
} }
/* Select the OUT endpoint */ /* Select the OUT endpoint */
Endpoint_SelectEndpoint(CDC_RX_EPNUM); Endpoint_SelectEndpoint(CDC_RX_EPNUM);
/* Acknowledge the command from the host */ /* Acknowledge the command from the host */
Endpoint_ClearCurrentBank(); Endpoint_ClearOUT();
} }
} }

@ -163,7 +163,7 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
switch (bRequest) switch (bRequest)
{ {
case DFU_DNLOAD: case DFU_DNLOAD:
Endpoint_ClearSetupReceived(); Endpoint_ClearControlSETUP();
/* Check if bootloader is waiting to terminate */ /* Check if bootloader is waiting to terminate */
if (WaitForExit) if (WaitForExit)
@ -178,7 +178,7 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
/* If the request has a data stage, load it into the command struct */ /* If the request has a data stage, load it into the command struct */
if (SentCommand.DataSize) if (SentCommand.DataSize)
{ {
while (!(Endpoint_IsSetupOUTReceived())); while (!(Endpoint_IsOUTReceived()));
/* First byte of the data stage is the DNLOAD request's command */ /* First byte of the data stage is the DNLOAD request's command */
SentCommand.Command = Endpoint_Read_Byte(); SentCommand.Command = Endpoint_Read_Byte();
@ -235,8 +235,8 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
/* Check if endpoint is empty - if so clear it and wait until ready for next packet */ /* Check if endpoint is empty - if so clear it and wait until ready for next packet */
if (!(Endpoint_BytesInEndpoint())) if (!(Endpoint_BytesInEndpoint()))
{ {
Endpoint_ClearSetupOUT(); Endpoint_ClearControlOUT();
while (!(Endpoint_IsSetupOUTReceived())); while (!(Endpoint_IsOUTReceived()));
} }
/* Write the next word into the current flash page */ /* Write the next word into the current flash page */
@ -279,8 +279,8 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
/* Check if endpoint is empty - if so clear it and wait until ready for next packet */ /* Check if endpoint is empty - if so clear it and wait until ready for next packet */
if (!(Endpoint_BytesInEndpoint())) if (!(Endpoint_BytesInEndpoint()))
{ {
Endpoint_ClearSetupOUT(); Endpoint_ClearControlOUT();
while (!(Endpoint_IsSetupOUTReceived())); while (!(Endpoint_IsOUTReceived()));
} }
/* Read the byte from the USB interface and write to to the EEPROM */ /* Read the byte from the USB interface and write to to the EEPROM */
@ -296,17 +296,17 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
} }
} }
Endpoint_ClearSetupOUT(); Endpoint_ClearControlOUT();
/* Acknowledge status stage */ /* Acknowledge status stage */
while (!(Endpoint_IsSetupINReady())); while (!(Endpoint_IsINReady()));
Endpoint_ClearSetupIN(); Endpoint_ClearControlIN();
break; break;
case DFU_UPLOAD: case DFU_UPLOAD:
Endpoint_ClearSetupReceived(); Endpoint_ClearControlSETUP();
while (!(Endpoint_IsSetupINReady())); while (!(Endpoint_IsINReady()));
if (DFU_State != dfuUPLOAD_IDLE) if (DFU_State != dfuUPLOAD_IDLE)
{ {
@ -343,8 +343,8 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
/* Check if endpoint is full - if so clear it and wait until ready for next packet */ /* Check if endpoint is full - if so clear it and wait until ready for next packet */
if (Endpoint_BytesInEndpoint() == FIXED_CONTROL_ENDPOINT_SIZE) if (Endpoint_BytesInEndpoint() == FIXED_CONTROL_ENDPOINT_SIZE)
{ {
Endpoint_ClearSetupIN(); Endpoint_ClearControlIN();
while (!(Endpoint_IsSetupINReady())); while (!(Endpoint_IsINReady()));
} }
/* Read the flash word and send it via USB to the host */ /* Read the flash word and send it via USB to the host */
@ -368,8 +368,8 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
/* Check if endpoint is full - if so clear it and wait until ready for next packet */ /* Check if endpoint is full - if so clear it and wait until ready for next packet */
if (Endpoint_BytesInEndpoint() == FIXED_CONTROL_ENDPOINT_SIZE) if (Endpoint_BytesInEndpoint() == FIXED_CONTROL_ENDPOINT_SIZE)
{ {
Endpoint_ClearSetupIN(); Endpoint_ClearControlIN();
while (!(Endpoint_IsSetupINReady())); while (!(Endpoint_IsINReady()));
} }
/* Read the EEPROM byte and send it via USB to the host */ /* Read the EEPROM byte and send it via USB to the host */
@ -384,15 +384,15 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
DFU_State = dfuIDLE; DFU_State = dfuIDLE;
} }
Endpoint_ClearSetupIN(); Endpoint_ClearControlIN();
/* Acknowledge status stage */ /* Acknowledge status stage */
while (!(Endpoint_IsSetupOUTReceived())); while (!(Endpoint_IsOUTReceived()));
Endpoint_ClearSetupOUT(); Endpoint_ClearControlOUT();
break; break;
case DFU_GETSTATUS: case DFU_GETSTATUS:
Endpoint_ClearSetupReceived(); Endpoint_ClearControlSETUP();
/* Write 8-bit status value */ /* Write 8-bit status value */
Endpoint_Write_Byte(DFU_Status); Endpoint_Write_Byte(DFU_Status);
@ -407,46 +407,46 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
/* Write 8-bit state string ID number */ /* Write 8-bit state string ID number */
Endpoint_Write_Byte(0); Endpoint_Write_Byte(0);
Endpoint_ClearSetupIN(); Endpoint_ClearControlIN();
/* Acknowledge status stage */ /* Acknowledge status stage */
while (!(Endpoint_IsSetupOUTReceived())); while (!(Endpoint_IsOUTReceived()));
Endpoint_ClearSetupOUT(); Endpoint_ClearControlOUT();
break; break;
case DFU_CLRSTATUS: case DFU_CLRSTATUS:
Endpoint_ClearSetupReceived(); Endpoint_ClearControlSETUP();
/* Reset the status value variable to the default OK status */ /* Reset the status value variable to the default OK status */
DFU_Status = OK; DFU_Status = OK;
/* Acknowledge status stage */ /* Acknowledge status stage */
while (!(Endpoint_IsSetupINReady())); while (!(Endpoint_IsINReady()));
Endpoint_ClearSetupIN(); Endpoint_ClearControlIN();
break; break;
case DFU_GETSTATE: case DFU_GETSTATE:
Endpoint_ClearSetupReceived(); Endpoint_ClearControlSETUP();
/* Write the current device state to the endpoint */ /* Write the current device state to the endpoint */
Endpoint_Write_Byte(DFU_State); Endpoint_Write_Byte(DFU_State);
Endpoint_ClearSetupIN(); Endpoint_ClearControlIN();
/* Acknowledge status stage */ /* Acknowledge status stage */
while (!(Endpoint_IsSetupOUTReceived())); while (!(Endpoint_IsOUTReceived()));
Endpoint_ClearSetupOUT(); Endpoint_ClearControlOUT();
break; break;
case DFU_ABORT: case DFU_ABORT:
Endpoint_ClearSetupReceived(); Endpoint_ClearControlSETUP();
/* Reset the current state variable to the default idle state */ /* Reset the current state variable to the default idle state */
DFU_State = dfuIDLE; DFU_State = dfuIDLE;
/* Acknowledge status stage */ /* Acknowledge status stage */
while (!(Endpoint_IsSetupINReady())); while (!(Endpoint_IsINReady()));
Endpoint_ClearSetupIN(); Endpoint_ClearControlIN();
break; break;
} }
@ -463,10 +463,10 @@ static void DiscardFillerBytes(uint8_t NumberOfBytes)
{ {
if (!(Endpoint_BytesInEndpoint())) if (!(Endpoint_BytesInEndpoint()))
{ {
Endpoint_ClearSetupOUT(); Endpoint_ClearControlOUT();
/* Wait until next data packet received */ /* Wait until next data packet received */
while (!(Endpoint_IsSetupOUTReceived())); while (!(Endpoint_IsOUTReceived()));
} }
Endpoint_Discard_Byte(); Endpoint_Discard_Byte();

@ -101,10 +101,10 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
case REQ_SetReport: case REQ_SetReport:
if (bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE)) if (bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE))
{ {
Endpoint_ClearSetupReceived(); Endpoint_ClearControlSETUP();
/* Wait until the command (report) has been sent by the host */ /* Wait until the command (report) has been sent by the host */
while (!(Endpoint_IsSetupOUTReceived())); while (!(Endpoint_IsOUTReceived()));
/* Read in the write destination address */ /* Read in the write destination address */
uint16_t PageAddress = Endpoint_Read_Word_LE(); uint16_t PageAddress = Endpoint_Read_Word_LE();
@ -126,8 +126,8 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
/* Check if endpoint is empty - if so clear it and wait until ready for next packet */ /* Check if endpoint is empty - if so clear it and wait until ready for next packet */
if (!(Endpoint_BytesInEndpoint())) if (!(Endpoint_BytesInEndpoint()))
{ {
Endpoint_ClearSetupOUT(); Endpoint_ClearControlOUT();
while (!(Endpoint_IsSetupOUTReceived())); while (!(Endpoint_IsOUTReceived()));
} }
/* Write the next data word to the FLASH page */ /* Write the next data word to the FLASH page */
@ -142,11 +142,11 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
boot_rww_enable(); boot_rww_enable();
} }
Endpoint_ClearSetupOUT(); Endpoint_ClearControlOUT();
/* Acknowledge status stage */ /* Acknowledge status stage */
while (!(Endpoint_IsSetupINReady())); while (!(Endpoint_IsINReady()));
Endpoint_ClearSetupIN(); Endpoint_ClearControlIN();
} }
break; break;

@ -36,12 +36,6 @@
#include "AudioInput.h" #include "AudioInput.h"
/* Project Tags, for reading out using the ButtLoad project */
BUTTLOADTAG(ProjName, "LUFA AudioIn App");
BUTTLOADTAG(BuildTime, __TIME__);
BUTTLOADTAG(BuildDate, __DATE__);
BUTTLOADTAG(LUFAVersion, "LUFA V" LUFA_VERSION_STRING);
/* Scheduler Task List */ /* Scheduler Task List */
TASK_LIST TASK_LIST
{ {
@ -145,7 +139,7 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
{ {
uint16_t wValue = Endpoint_Read_Word_LE(); uint16_t wValue = Endpoint_Read_Word_LE();
Endpoint_ClearSetupReceived(); Endpoint_ClearControlSETUP();
/* Check if the host is enabling the audio interface (setting AlternateSetting to 1) */ /* Check if the host is enabling the audio interface (setting AlternateSetting to 1) */
if (wValue) if (wValue)
@ -160,8 +154,8 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
} }
/* Acknowledge status stage */ /* Acknowledge status stage */
while (!(Endpoint_IsSetupINReady())); while (!(Endpoint_IsINReady()));
Endpoint_ClearSetupIN(); Endpoint_ClearControlIN();
} }
break; break;
@ -201,8 +195,8 @@ TASK(USB_Audio_Task)
/* Select the audio stream endpoint */ /* Select the audio stream endpoint */
Endpoint_SelectEndpoint(AUDIO_STREAM_EPNUM); Endpoint_SelectEndpoint(AUDIO_STREAM_EPNUM);
/* Check if the current endpoint can be read from (contains a packet) and that the next sample should be stored */ /* Check if the current endpoint can be written to and that the next sample should be stored */
if (Endpoint_ReadWriteAllowed() && (TIFR0 & (1 << OCF0A))) if (Endpoint_IsINReady() && (TIFR0 & (1 << OCF0A)))
{ {
/* Clear the sample reload timer */ /* Clear the sample reload timer */
TIFR0 |= (1 << OCF0A); TIFR0 |= (1 << OCF0A);
@ -219,10 +213,10 @@ TASK(USB_Audio_Task)
Endpoint_Write_Word_LE(AudioSample); Endpoint_Write_Word_LE(AudioSample);
/* Check to see if the bank is now full */ /* Check to see if the bank is now full */
if (!(Endpoint_ReadWriteAllowed())) if (!(Endpoint_IsReadWriteAllowed()))
{ {
/* Send the full packet to the host */ /* Send the full packet to the host */
Endpoint_ClearCurrentBank(); Endpoint_ClearIN();
} }
} }
} }

@ -44,7 +44,6 @@
#include "Descriptors.h" #include "Descriptors.h"
#include <LUFA/Version.h> // Library Version Information #include <LUFA/Version.h> // Library Version Information
#include <LUFA/Common/ButtLoadTag.h> // PROGMEM tags readable by the ButtLoad project
#include <LUFA/Drivers/USB/USB.h> // USB Functionality #include <LUFA/Drivers/USB/USB.h> // USB Functionality
#include <LUFA/Drivers/Board/LEDs.h> // LEDs driver #include <LUFA/Drivers/Board/LEDs.h> // LEDs driver
#include <LUFA/Drivers/AT90USBXXX/ADC.h> // ADC driver #include <LUFA/Drivers/AT90USBXXX/ADC.h> // ADC driver

@ -36,12 +36,6 @@
#include "AudioOutput.h" #include "AudioOutput.h"
/* Project Tags, for reading out using the ButtLoad project */
BUTTLOADTAG(ProjName, "LUFA AudioOut App");
BUTTLOADTAG(BuildTime, __TIME__);
BUTTLOADTAG(BuildDate, __DATE__);
BUTTLOADTAG(LUFAVersion, "LUFA V" LUFA_VERSION_STRING);
/* Scheduler Task List */ /* Scheduler Task List */
TASK_LIST TASK_LIST
{ {
@ -172,7 +166,7 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
{ {
uint16_t wValue = Endpoint_Read_Word_LE(); uint16_t wValue = Endpoint_Read_Word_LE();
Endpoint_ClearSetupReceived(); Endpoint_ClearControlSETUP();
/* Check if the host is enabling the audio interface (setting AlternateSetting to 1) */ /* Check if the host is enabling the audio interface (setting AlternateSetting to 1) */
if (wValue) if (wValue)
@ -187,8 +181,8 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
} }
/* Acknowledge status stage */ /* Acknowledge status stage */
while (!(Endpoint_IsSetupINReady())); while (!(Endpoint_IsINReady()));
Endpoint_ClearSetupIN(); Endpoint_ClearControlIN();
} }
break; break;
@ -231,7 +225,7 @@ TASK(USB_Audio_Task)
Endpoint_SelectEndpoint(AUDIO_STREAM_EPNUM); Endpoint_SelectEndpoint(AUDIO_STREAM_EPNUM);
/* Check if the current endpoint can be read from (contains a packet) and that the next sample should be read */ /* Check if the current endpoint can be read from (contains a packet) and that the next sample should be read */
if (Endpoint_ReadWriteAllowed() && (TIFR0 & (1 << OCF0A))) if (Endpoint_IsOUTReceived() && (TIFR0 & (1 << OCF0A)))
{ {
/* Clear the sample reload timer */ /* Clear the sample reload timer */
TIFR0 |= (1 << OCF0A); TIFR0 |= (1 << OCF0A);
@ -241,10 +235,10 @@ TASK(USB_Audio_Task)
int16_t RightSample_16Bit = (int16_t)Endpoint_Read_Word_LE(); int16_t RightSample_16Bit = (int16_t)Endpoint_Read_Word_LE();
/* Check to see if the bank is now empty */ /* Check to see if the bank is now empty */
if (!(Endpoint_ReadWriteAllowed())) if (!(Endpoint_IsReadWriteAllowed()))
{ {
/* Acknowledge the packet, clear the bank ready for the next packet */ /* Acknowledge the packet, clear the bank ready for the next packet */
Endpoint_ClearCurrentBank(); Endpoint_ClearOUT();
} }
/* Massage signed 16-bit left and right audio samples into signed 8-bit */ /* Massage signed 16-bit left and right audio samples into signed 8-bit */

@ -44,7 +44,6 @@
#include "Descriptors.h" #include "Descriptors.h"
#include <LUFA/Version.h> // Library Version Information #include <LUFA/Version.h> // Library Version Information
#include <LUFA/Common/ButtLoadTag.h> // PROGMEM tags readable by the ButtLoad project
#include <LUFA/Drivers/USB/USB.h> // USB Functionality #include <LUFA/Drivers/USB/USB.h> // USB Functionality
#include <LUFA/Drivers/Board/LEDs.h> // LEDs driver #include <LUFA/Drivers/Board/LEDs.h> // LEDs driver
#include <LUFA/Scheduler/Scheduler.h> // Simple scheduler for task management #include <LUFA/Scheduler/Scheduler.h> // Simple scheduler for task management

@ -36,12 +36,6 @@
#include "CDC.h" #include "CDC.h"
/* Project Tags, for reading out using the ButtLoad project */
BUTTLOADTAG(ProjName, "LUFA CDC App");
BUTTLOADTAG(BuildTime, __TIME__);
BUTTLOADTAG(BuildDate, __DATE__);
BUTTLOADTAG(LUFAVersion, "LUFA V" LUFA_VERSION_STRING);
/* Scheduler Task List */ /* Scheduler Task List */
TASK_LIST TASK_LIST
{ {
@ -172,13 +166,13 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
if (bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE)) if (bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE))
{ {
/* Acknowledge the SETUP packet, ready for data transfer */ /* Acknowledge the SETUP packet, ready for data transfer */
Endpoint_ClearSetupReceived(); Endpoint_ClearControlSETUP();
/* Write the line coding data to the control endpoint */ /* Write the line coding data to the control endpoint */
Endpoint_Write_Control_Stream_LE(LineCodingData, sizeof(CDC_Line_Coding_t)); Endpoint_Write_Control_Stream_LE(LineCodingData, sizeof(CDC_Line_Coding_t));
/* Finalize the stream transfer to send the last packet or clear the host abort */ /* Finalize the stream transfer to send the last packet or clear the host abort */
Endpoint_ClearSetupOUT(); Endpoint_ClearControlOUT();
} }
break; break;
@ -186,13 +180,13 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
if (bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE)) if (bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE))
{ {
/* Acknowledge the SETUP packet, ready for data transfer */ /* Acknowledge the SETUP packet, ready for data transfer */
Endpoint_ClearSetupReceived(); Endpoint_ClearControlSETUP();
/* Read the line coding data in from the host into the global struct */ /* Read the line coding data in from the host into the global struct */
Endpoint_Read_Control_Stream_LE(LineCodingData, sizeof(CDC_Line_Coding_t)); Endpoint_Read_Control_Stream_LE(LineCodingData, sizeof(CDC_Line_Coding_t));
/* Finalize the stream transfer to clear the last packet from the host */ /* Finalize the stream transfer to clear the last packet from the host */
Endpoint_ClearSetupIN(); Endpoint_ClearControlIN();
} }
break; break;
@ -211,11 +205,11 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
#endif #endif
/* Acknowledge the SETUP packet, ready for data transfer */ /* Acknowledge the SETUP packet, ready for data transfer */
Endpoint_ClearSetupReceived(); Endpoint_ClearControlSETUP();
/* Acknowledge status stage */ /* Acknowledge status stage */
while (!(Endpoint_IsSetupINReady())); while (!(Endpoint_IsINReady()));
Endpoint_ClearSetupIN(); Endpoint_ClearControlIN();
} }
break; break;
@ -276,7 +270,7 @@ TASK(CDC_Task)
Endpoint_SelectEndpoint(CDC_NOTIFICATION_EPNUM); Endpoint_SelectEndpoint(CDC_NOTIFICATION_EPNUM);
Endpoint_Write_Stream_LE(&Notification, sizeof(Notification)); Endpoint_Write_Stream_LE(&Notification, sizeof(Notification));
Endpoint_Write_Stream_LE(&LineStateMask, sizeof(LineStateMask)); Endpoint_Write_Stream_LE(&LineStateMask, sizeof(LineStateMask));
Endpoint_ClearCurrentBank(); Endpoint_ClearIN();
#endif #endif
/* Determine if a joystick action has occurred */ /* Determine if a joystick action has occurred */
@ -307,19 +301,19 @@ TASK(CDC_Task)
Endpoint_Write_Stream_LE(ReportString, strlen(ReportString)); Endpoint_Write_Stream_LE(ReportString, strlen(ReportString));
/* Finalize the stream transfer to send the last packet */ /* Finalize the stream transfer to send the last packet */
Endpoint_ClearCurrentBank(); Endpoint_ClearIN();
/* Wait until the endpoint is ready for another packet */ /* Wait until the endpoint is ready for another packet */
while (!(Endpoint_ReadWriteAllowed())); while (!(Endpoint_IsINReady()));
/* Send an empty packet to ensure that the host does not buffer data sent to it */ /* Send an empty packet to ensure that the host does not buffer data sent to it */
Endpoint_ClearCurrentBank(); Endpoint_ClearIN();
} }
/* Select the Serial Rx Endpoint */ /* Select the Serial Rx Endpoint */
Endpoint_SelectEndpoint(CDC_RX_EPNUM); Endpoint_SelectEndpoint(CDC_RX_EPNUM);
/* Throw away any received data from the host */ /* Throw away any received data from the host */
if (Endpoint_ReadWriteAllowed()) if (Endpoint_IsOUTReceived())
Endpoint_ClearCurrentBank(); Endpoint_ClearOUT();
} }

@ -45,7 +45,6 @@
#include "Descriptors.h" #include "Descriptors.h"
#include <LUFA/Version.h> // Library Version Information #include <LUFA/Version.h> // Library Version Information
#include <LUFA/Common/ButtLoadTag.h> // PROGMEM tags readable by the ButtLoad project
#include <LUFA/Drivers/USB/USB.h> // USB Functionality #include <LUFA/Drivers/USB/USB.h> // USB Functionality
#include <LUFA/Drivers/Board/Joystick.h> // Joystick driver #include <LUFA/Drivers/Board/Joystick.h> // Joystick driver
#include <LUFA/Drivers/Board/LEDs.h> // LEDs driver #include <LUFA/Drivers/Board/LEDs.h> // LEDs driver

@ -36,12 +36,6 @@
#include "DualCDC.h" #include "DualCDC.h"
/* Project Tags, for reading out using the ButtLoad project */
BUTTLOADTAG(ProjName, "LUFA DualCDC App");
BUTTLOADTAG(BuildTime, __TIME__);
BUTTLOADTAG(BuildDate, __DATE__);
BUTTLOADTAG(LUFAVersion, "LUFA V" LUFA_VERSION_STRING);
/* Scheduler Task List */ /* Scheduler Task List */
TASK_LIST TASK_LIST
{ {
@ -195,7 +189,7 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
uint8_t* LineCodingData; uint8_t* LineCodingData;
/* Discard the unused wValue parameter */ /* Discard the unused wValue parameter */
Endpoint_Ignore_Word(); Endpoint_Discard_Word();
/* wIndex indicates the interface being controlled */ /* wIndex indicates the interface being controlled */
uint16_t wIndex = Endpoint_Read_Word_LE(); uint16_t wIndex = Endpoint_Read_Word_LE();
@ -210,13 +204,13 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
if (bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE)) if (bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE))
{ {
/* Acknowledge the SETUP packet, ready for data transfer */ /* Acknowledge the SETUP packet, ready for data transfer */
Endpoint_ClearSetupReceived(); Endpoint_ClearControlSETUP();
/* Write the line coding data to the control endpoint */ /* Write the line coding data to the control endpoint */
Endpoint_Write_Control_Stream_LE(LineCodingData, sizeof(CDC_Line_Coding_t)); Endpoint_Write_Control_Stream_LE(LineCodingData, sizeof(CDC_Line_Coding_t));
/* Finalize the stream transfer to send the last packet or clear the host abort */ /* Finalize the stream transfer to send the last packet or clear the host abort */
Endpoint_ClearSetupOUT(); Endpoint_ClearControlOUT();
} }
break; break;
@ -224,13 +218,13 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
if (bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE)) if (bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE))
{ {
/* Acknowledge the SETUP packet, ready for data transfer */ /* Acknowledge the SETUP packet, ready for data transfer */
Endpoint_ClearSetupReceived(); Endpoint_ClearControlSETUP();
/* Read the line coding data in from the host into the global struct */ /* Read the line coding data in from the host into the global struct */
Endpoint_Read_Control_Stream_LE(LineCodingData, sizeof(CDC_Line_Coding_t)); Endpoint_Read_Control_Stream_LE(LineCodingData, sizeof(CDC_Line_Coding_t));
/* Finalize the stream transfer to clear the last packet from the host */ /* Finalize the stream transfer to clear the last packet from the host */
Endpoint_ClearSetupIN(); Endpoint_ClearControlIN();
} }
break; break;
@ -238,11 +232,11 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
if (bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE)) if (bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE))
{ {
/* Acknowledge the SETUP packet, ready for data transfer */ /* Acknowledge the SETUP packet, ready for data transfer */
Endpoint_ClearSetupReceived(); Endpoint_ClearControlSETUP();
/* Acknowledge status stage */ /* Acknowledge status stage */
while (!(Endpoint_IsSetupINReady())); while (!(Endpoint_IsINReady()));
Endpoint_ClearSetupIN(); Endpoint_ClearControlIN();
} }
break; break;
@ -313,15 +307,21 @@ TASK(CDC1_Task)
Endpoint_Write_Stream_LE(ReportString, strlen(ReportString)); Endpoint_Write_Stream_LE(ReportString, strlen(ReportString));
/* Finalize the stream transfer to send the last packet */ /* Finalize the stream transfer to send the last packet */
Endpoint_ClearCurrentBank(); Endpoint_ClearIN();
/* Wait until the endpoint is ready for another packet */
while (!(Endpoint_IsINReady()));
/* Send an empty packet to ensure that the host does not buffer data sent to it */
Endpoint_ClearIN();
} }
/* Select the Serial Rx Endpoint */ /* Select the Serial Rx Endpoint */
Endpoint_SelectEndpoint(CDC1_RX_EPNUM); Endpoint_SelectEndpoint(CDC1_RX_EPNUM);
/* Throw away any received data from the host */ /* Throw away any received data from the host */
if (Endpoint_ReadWriteAllowed()) if (Endpoint_IsOUTReceived())
Endpoint_ClearCurrentBank(); Endpoint_ClearOUT();
} }
/** Function to manage CDC data transmission and reception to and from the host for the second CDC interface, which echoes back /** Function to manage CDC data transmission and reception to and from the host for the second CDC interface, which echoes back
@ -333,7 +333,7 @@ TASK(CDC2_Task)
Endpoint_SelectEndpoint(CDC2_RX_EPNUM); Endpoint_SelectEndpoint(CDC2_RX_EPNUM);
/* Check to see if any data has been received */ /* Check to see if any data has been received */
if (Endpoint_ReadWriteAllowed()) if (Endpoint_IsOUTReceived())
{ {
/* Create a temp buffer big enough to hold the incoming endpoint packet */ /* Create a temp buffer big enough to hold the incoming endpoint packet */
uint8_t Buffer[Endpoint_BytesInEndpoint()]; uint8_t Buffer[Endpoint_BytesInEndpoint()];
@ -345,7 +345,7 @@ TASK(CDC2_Task)
Endpoint_Read_Stream_LE(&Buffer, DataLength); Endpoint_Read_Stream_LE(&Buffer, DataLength);
/* Finalize the stream transfer to send the last packet */ /* Finalize the stream transfer to send the last packet */
Endpoint_ClearCurrentBank(); Endpoint_ClearOUT();
/* Select the Serial Tx Endpoint */ /* Select the Serial Tx Endpoint */
Endpoint_SelectEndpoint(CDC2_TX_EPNUM); Endpoint_SelectEndpoint(CDC2_TX_EPNUM);
@ -354,6 +354,12 @@ TASK(CDC2_Task)
Endpoint_Write_Stream_LE(&Buffer, DataLength); Endpoint_Write_Stream_LE(&Buffer, DataLength);
/* Finalize the stream transfer to send the last packet */ /* Finalize the stream transfer to send the last packet */
Endpoint_ClearCurrentBank(); Endpoint_ClearIN();
/* Wait until the endpoint is ready for the next packet */
while (!(Endpoint_IsINReady()));
/* Send an empty packet to prevent host buffering */
Endpoint_ClearIN();
} }
} }

@ -45,7 +45,6 @@
#include "Descriptors.h" #include "Descriptors.h"
#include <LUFA/Version.h> // Library Version Information #include <LUFA/Version.h> // Library Version Information
#include <LUFA/Common/ButtLoadTag.h> // PROGMEM tags readable by the ButtLoad project
#include <LUFA/Drivers/USB/USB.h> // USB Functionality #include <LUFA/Drivers/USB/USB.h> // USB Functionality
#include <LUFA/Drivers/Board/Joystick.h> // Joystick driver #include <LUFA/Drivers/Board/Joystick.h> // Joystick driver
#include <LUFA/Drivers/Board/LEDs.h> // LEDs driver #include <LUFA/Drivers/Board/LEDs.h> // LEDs driver

@ -36,12 +36,6 @@
#include "GenericHID.h" #include "GenericHID.h"
/* Project Tags, for reading out using the ButtLoad project */
BUTTLOADTAG(ProjName, "LUFA GenHID App");
BUTTLOADTAG(BuildTime, __TIME__);
BUTTLOADTAG(BuildDate, __DATE__);
BUTTLOADTAG(LUFAVersion, "LUFA V" LUFA_VERSION_STRING);
/* Scheduler Task List */ /* Scheduler Task List */
TASK_LIST TASK_LIST
{ {
@ -171,7 +165,7 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
case REQ_GetReport: case REQ_GetReport:
if (bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE)) if (bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE))
{ {
Endpoint_ClearSetupReceived(); Endpoint_ClearControlSETUP();
uint8_t GenericData[GENERIC_REPORT_SIZE]; uint8_t GenericData[GENERIC_REPORT_SIZE];
@ -181,32 +175,32 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
Endpoint_Write_Control_Stream_LE(&GenericData, sizeof(GenericData)); Endpoint_Write_Control_Stream_LE(&GenericData, sizeof(GenericData));
/* Finalize the stream transfer to send the last packet or clear the host abort */ /* Finalize the stream transfer to send the last packet or clear the host abort */
Endpoint_ClearSetupOUT(); Endpoint_ClearControlOUT();
} }
break; break;
case REQ_SetReport: case REQ_SetReport:
if (bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE)) if (bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE))
{ {
Endpoint_ClearSetupReceived(); Endpoint_ClearControlSETUP();
/* Wait until the generic report has been sent by the host */ /* Wait until the generic report has been sent by the host */
while (!(Endpoint_IsSetupOUTReceived())); while (!(Endpoint_IsOUTReceived()));
uint8_t GenericData[GENERIC_REPORT_SIZE]; uint8_t GenericData[GENERIC_REPORT_SIZE];
Endpoint_Read_Control_Stream(&GenericData, sizeof(GenericData)); Endpoint_Read_Control_Stream_LE(&GenericData, sizeof(GenericData));
ProcessGenericHIDReport(GenericData); ProcessGenericHIDReport(GenericData);
/* Clear the endpoint data */ /* Clear the endpoint data */
Endpoint_ClearSetupOUT(); Endpoint_ClearControlOUT();
/* Wait until the host is ready to receive the request confirmation */ /* Wait until the host is ready to receive the request confirmation */
while (!(Endpoint_IsSetupINReady())); while (!(Endpoint_IsINReady()));
/* Handshake the request by sending an empty IN packet */ /* Handshake the request by sending an empty IN packet */
Endpoint_ClearSetupIN(); Endpoint_ClearControlIN();
} }
break; break;
@ -280,7 +274,11 @@ TASK(USB_HID_Report)
{ {
Endpoint_SelectEndpoint(GENERIC_OUT_EPNUM); Endpoint_SelectEndpoint(GENERIC_OUT_EPNUM);
if (Endpoint_ReadWriteAllowed()) /* Check to see if a packet has been sent from the host */
if (Endpoint_IsOUTReceived())
{
/* Check to see if the packet contains data */
if (Endpoint_IsReadWriteAllowed())
{ {
/* Create a temporary buffer to hold the read in report from the host */ /* Create a temporary buffer to hold the read in report from the host */
uint8_t GenericData[GENERIC_REPORT_SIZE]; uint8_t GenericData[GENERIC_REPORT_SIZE];
@ -290,14 +288,16 @@ TASK(USB_HID_Report)
/* Process Generic Report Data */ /* Process Generic Report Data */
ProcessGenericHIDReport(GenericData); ProcessGenericHIDReport(GenericData);
}
/* Finalize the stream transfer to send the last packet */ /* Finalize the stream transfer to send the last packet */
Endpoint_ClearCurrentBank(); Endpoint_ClearOUT();
} }
Endpoint_SelectEndpoint(GENERIC_IN_EPNUM); Endpoint_SelectEndpoint(GENERIC_IN_EPNUM);
if (Endpoint_ReadWriteAllowed()) /* Check to see if the host is ready to accept another packet */
if (Endpoint_IsINReady())
{ {
/* Create a temporary buffer to hold the report to send to the host */ /* Create a temporary buffer to hold the report to send to the host */
uint8_t GenericData[GENERIC_REPORT_SIZE]; uint8_t GenericData[GENERIC_REPORT_SIZE];
@ -309,7 +309,7 @@ TASK(USB_HID_Report)
Endpoint_Write_Stream_LE(&GenericData, sizeof(GenericData)); Endpoint_Write_Stream_LE(&GenericData, sizeof(GenericData));
/* Finalize the stream transfer to send the last packet */ /* Finalize the stream transfer to send the last packet */
Endpoint_ClearCurrentBank(); Endpoint_ClearIN();
} }
} }
} }
@ -363,7 +363,7 @@ ISR(ENDPOINT_PIPE_vect, ISR_BLOCK)
Endpoint_Write_Stream_LE(&GenericData, sizeof(GenericData)); Endpoint_Write_Stream_LE(&GenericData, sizeof(GenericData));
/* Finalize the stream transfer to send the last packet */ /* Finalize the stream transfer to send the last packet */
Endpoint_ClearCurrentBank(); Endpoint_ClearIN();
} }
/* Check if Generic OUT endpoint has interrupted */ /* Check if Generic OUT endpoint has interrupted */
@ -388,7 +388,7 @@ ISR(ENDPOINT_PIPE_vect, ISR_BLOCK)
ProcessGenericHIDReport(GenericData); ProcessGenericHIDReport(GenericData);
/* Finalize the stream transfer to send the last packet */ /* Finalize the stream transfer to send the last packet */
Endpoint_ClearCurrentBank(); Endpoint_ClearOUT();
} }
#endif #endif

@ -48,7 +48,6 @@
#include <LUFA/Version.h> // Library Version Information #include <LUFA/Version.h> // Library Version Information
#include <LUFA/Scheduler/Scheduler.h> // Simple scheduler for task management #include <LUFA/Scheduler/Scheduler.h> // Simple scheduler for task management
#include <LUFA/Common/ButtLoadTag.h> // PROGMEM tags readable by the ButtLoad project
#include <LUFA/Drivers/USB/USB.h> // USB Functionality #include <LUFA/Drivers/USB/USB.h> // USB Functionality
#include <LUFA/Drivers/Board/LEDs.h> // LEDs driver #include <LUFA/Drivers/Board/LEDs.h> // LEDs driver

@ -36,12 +36,6 @@
#include "Joystick.h" #include "Joystick.h"
/* Project Tags, for reading out using the ButtLoad project */
BUTTLOADTAG(ProjName, "LUFA Joystick App");
BUTTLOADTAG(BuildTime, __TIME__);
BUTTLOADTAG(BuildDate, __DATE__);
BUTTLOADTAG(LUFAVersion, "LUFA V" LUFA_VERSION_STRING);
/* Scheduler Task List */ /* Scheduler Task List */
TASK_LIST TASK_LIST
{ {
@ -151,13 +145,13 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
if (wLength > sizeof(JoystickReportData)) if (wLength > sizeof(JoystickReportData))
wLength = sizeof(JoystickReportData); wLength = sizeof(JoystickReportData);
Endpoint_ClearSetupReceived(); Endpoint_ClearControlSETUP();
/* Write the report data to the control endpoint */ /* Write the report data to the control endpoint */
Endpoint_Write_Control_Stream_LE(&JoystickReportData, wLength); Endpoint_Write_Control_Stream_LE(&JoystickReportData, wLength);
/* Finalize the stream transfer to send the last packet or clear the host abort */ /* Finalize the stream transfer to send the last packet or clear the host abort */
Endpoint_ClearSetupOUT(); Endpoint_ClearControlOUT();
} }
break; break;
@ -241,8 +235,8 @@ TASK(USB_Joystick_Report)
/* Select the Joystick Report Endpoint */ /* Select the Joystick Report Endpoint */
Endpoint_SelectEndpoint(JOYSTICK_EPNUM); Endpoint_SelectEndpoint(JOYSTICK_EPNUM);
/* Check if Joystick Endpoint Ready for Read/Write */ /* Check to see if the host is ready for another packet */
if (Endpoint_ReadWriteAllowed()) if (Endpoint_IsINReady())
{ {
USB_JoystickReport_Data_t JoystickReportData; USB_JoystickReport_Data_t JoystickReportData;
@ -253,12 +247,10 @@ TASK(USB_Joystick_Report)
Endpoint_Write_Stream_LE(&JoystickReportData, sizeof(JoystickReportData)); Endpoint_Write_Stream_LE(&JoystickReportData, sizeof(JoystickReportData));
/* Finalize the stream transfer to send the last packet */ /* Finalize the stream transfer to send the last packet */
Endpoint_ClearCurrentBank(); Endpoint_ClearIN();
/* Clear the report data afterwards */ /* Clear the report data afterwards */
JoystickReportData.X = 0; memset(&JoystickReportData, 0, sizeof(JoystickReportData));
JoystickReportData.Y = 0;
JoystickReportData.Button = 0;
} }
} }
} }

@ -45,7 +45,6 @@
#include "Descriptors.h" #include "Descriptors.h"
#include <LUFA/Version.h> // Library Version Information #include <LUFA/Version.h> // Library Version Information
#include <LUFA/Common/ButtLoadTag.h> // PROGMEM tags readable by the ButtLoad project
#include <LUFA/Drivers/USB/USB.h> // USB Functionality #include <LUFA/Drivers/USB/USB.h> // USB Functionality
#include <LUFA/Drivers/Board/Joystick.h> // Joystick driver #include <LUFA/Drivers/Board/Joystick.h> // Joystick driver
#include <LUFA/Drivers/Board/LEDs.h> // LEDs driver #include <LUFA/Drivers/Board/LEDs.h> // LEDs driver

@ -37,12 +37,6 @@
#include "Keyboard.h" #include "Keyboard.h"
/* Project Tags, for reading out using the ButtLoad project */
BUTTLOADTAG(ProjName, "LUFA Keyboard App");
BUTTLOADTAG(BuildTime, __TIME__);
BUTTLOADTAG(BuildDate, __DATE__);
BUTTLOADTAG(LUFAVersion, "LUFA V" LUFA_VERSION_STRING);
/* Scheduler Task List */ /* Scheduler Task List */
TASK_LIST TASK_LIST
{ {
@ -222,23 +216,23 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
if (wLength > sizeof(KeyboardReportData)) if (wLength > sizeof(KeyboardReportData))
wLength = sizeof(KeyboardReportData); wLength = sizeof(KeyboardReportData);
Endpoint_ClearSetupReceived(); Endpoint_ClearControlSETUP();
/* Write the report data to the control endpoint */ /* Write the report data to the control endpoint */
Endpoint_Write_Control_Stream_LE(&KeyboardReportData, wLength); Endpoint_Write_Control_Stream_LE(&KeyboardReportData, wLength);
/* Finalize the stream transfer to send the last packet or clear the host abort */ /* Finalize the stream transfer to send the last packet or clear the host abort */
Endpoint_ClearSetupOUT(); Endpoint_ClearControlOUT();
} }
break; break;
case REQ_SetReport: case REQ_SetReport:
if (bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE)) if (bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE))
{ {
Endpoint_ClearSetupReceived(); Endpoint_ClearControlSETUP();
/* Wait until the LED report has been sent by the host */ /* Wait until the LED report has been sent by the host */
while (!(Endpoint_IsSetupOUTReceived())); while (!(Endpoint_IsOUTReceived()));
/* Read in the LED report from the host */ /* Read in the LED report from the host */
uint8_t LEDStatus = Endpoint_Read_Byte(); uint8_t LEDStatus = Endpoint_Read_Byte();
@ -247,28 +241,28 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
ProcessLEDReport(LEDStatus); ProcessLEDReport(LEDStatus);
/* Clear the endpoint data */ /* Clear the endpoint data */
Endpoint_ClearSetupOUT(); Endpoint_ClearControlOUT();
/* Acknowledge status stage */ /* Acknowledge status stage */
while (!(Endpoint_IsSetupINReady())); while (!(Endpoint_IsINReady()));
Endpoint_ClearSetupIN(); Endpoint_ClearControlIN();
} }
break; break;
case REQ_GetProtocol: case REQ_GetProtocol:
if (bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE)) if (bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE))
{ {
Endpoint_ClearSetupReceived(); Endpoint_ClearControlSETUP();
/* Write the current protocol flag to the host */ /* Write the current protocol flag to the host */
Endpoint_Write_Byte(UsingReportProtocol); Endpoint_Write_Byte(UsingReportProtocol);
/* Send the flag to the host */ /* Send the flag to the host */
Endpoint_ClearSetupIN(); Endpoint_ClearControlIN();
/* Acknowledge status stage */ /* Acknowledge status stage */
while (!(Endpoint_IsSetupOUTReceived())); while (!(Endpoint_IsOUTReceived()));
Endpoint_ClearSetupOUT(); Endpoint_ClearControlOUT();
} }
break; break;
@ -278,14 +272,14 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
/* Read in the wValue parameter containing the new protocol mode */ /* Read in the wValue parameter containing the new protocol mode */
uint16_t wValue = Endpoint_Read_Word_LE(); uint16_t wValue = Endpoint_Read_Word_LE();
Endpoint_ClearSetupReceived(); Endpoint_ClearControlSETUP();
/* Set or clear the flag depending on what the host indicates that the current Protocol should be */ /* Set or clear the flag depending on what the host indicates that the current Protocol should be */
UsingReportProtocol = (wValue != 0x0000); UsingReportProtocol = (wValue != 0x0000);
/* Acknowledge status stage */ /* Acknowledge status stage */
while (!(Endpoint_IsSetupINReady())); while (!(Endpoint_IsINReady()));
Endpoint_ClearSetupIN(); Endpoint_ClearControlIN();
} }
break; break;
@ -295,31 +289,31 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
/* Read in the wValue parameter containing the idle period */ /* Read in the wValue parameter containing the idle period */
uint16_t wValue = Endpoint_Read_Word_LE(); uint16_t wValue = Endpoint_Read_Word_LE();
Endpoint_ClearSetupReceived(); Endpoint_ClearControlSETUP();
/* Get idle period in MSB */ /* Get idle period in MSB */
IdleCount = (wValue >> 8); IdleCount = (wValue >> 8);
/* Acknowledge status stage */ /* Acknowledge status stage */
while (!(Endpoint_IsSetupINReady())); while (!(Endpoint_IsINReady()));
Endpoint_ClearSetupIN(); Endpoint_ClearControlIN();
} }
break; break;
case REQ_GetIdle: case REQ_GetIdle:
if (bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE)) if (bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE))
{ {
Endpoint_ClearSetupReceived(); Endpoint_ClearControlSETUP();
/* Write the current idle duration to the host */ /* Write the current idle duration to the host */
Endpoint_Write_Byte(IdleCount); Endpoint_Write_Byte(IdleCount);
/* Send the flag to the host */ /* Send the flag to the host */
Endpoint_ClearSetupIN(); Endpoint_ClearControlIN();
/* Acknowledge status stage */ /* Acknowledge status stage */
while (!(Endpoint_IsSetupOUTReceived())); while (!(Endpoint_IsOUTReceived()));
Endpoint_ClearSetupOUT(); Endpoint_ClearControlOUT();
} }
break; break;
@ -415,13 +409,13 @@ static inline void SendNextReport(void)
Endpoint_SelectEndpoint(KEYBOARD_EPNUM); Endpoint_SelectEndpoint(KEYBOARD_EPNUM);
/* Check if Keyboard Endpoint Ready for Read/Write, and if we should send a report */ /* Check if Keyboard Endpoint Ready for Read/Write, and if we should send a report */
if (Endpoint_ReadWriteAllowed() && SendReport) if (Endpoint_IsReadWriteAllowed() && SendReport)
{ {
/* Write Keyboard Report Data */ /* Write Keyboard Report Data */
Endpoint_Write_Stream_LE(&KeyboardReportData, sizeof(KeyboardReportData)); Endpoint_Write_Stream_LE(&KeyboardReportData, sizeof(KeyboardReportData));
/* Finalize the stream transfer to send the last packet */ /* Finalize the stream transfer to send the last packet */
Endpoint_ClearCurrentBank(); Endpoint_ClearIN();
} }
} }
@ -431,20 +425,24 @@ static inline void ReceiveNextReport(void)
/* Select the Keyboard LED Report Endpoint */ /* Select the Keyboard LED Report Endpoint */
Endpoint_SelectEndpoint(KEYBOARD_LEDS_EPNUM); Endpoint_SelectEndpoint(KEYBOARD_LEDS_EPNUM);
/* Check if Keyboard LED Endpoint Ready for Read/Write */ /* Check if Keyboard LED Endpoint contains a packet */
if (!(Endpoint_ReadWriteAllowed())) if (Endpoint_IsOUTReceived())
return; {
/* Check to see if the packet contains data */
if (Endpoint_IsReadWriteAllowed())
{
/* Read in the LED report from the host */ /* Read in the LED report from the host */
uint8_t LEDReport = Endpoint_Read_Byte(); uint8_t LEDReport = Endpoint_Read_Byte();
/* Handshake the OUT Endpoint - clear endpoint and ready for next report */
Endpoint_ClearCurrentBank();
/* Process the read LED report from the host */ /* Process the read LED report from the host */
ProcessLEDReport(LEDReport); ProcessLEDReport(LEDReport);
} }
/* Handshake the OUT Endpoint - clear endpoint and ready for next report */
Endpoint_ClearOUT();
}
}
/** Function to manage status updates to the user. This is done via LEDs on the given board, if available, but may be changed to /** Function to manage status updates to the user. This is done via LEDs on the given board, if available, but may be changed to
* log to a serial port, or anything else that is suitable for status updates. * log to a serial port, or anything else that is suitable for status updates.
* *

@ -49,7 +49,6 @@
#include <LUFA/Version.h> // Library Version Information #include <LUFA/Version.h> // Library Version Information
#include <LUFA/Scheduler/Scheduler.h> // Simple scheduler for task management #include <LUFA/Scheduler/Scheduler.h> // Simple scheduler for task management
#include <LUFA/Common/ButtLoadTag.h> // PROGMEM tags readable by the ButtLoad project
#include <LUFA/Drivers/USB/USB.h> // USB Functionality #include <LUFA/Drivers/USB/USB.h> // USB Functionality
#include <LUFA/Drivers/Board/Joystick.h> // Joystick driver #include <LUFA/Drivers/Board/Joystick.h> // Joystick driver
#include <LUFA/Drivers/Board/LEDs.h> // LEDs driver #include <LUFA/Drivers/Board/LEDs.h> // LEDs driver

@ -37,12 +37,6 @@
#include "KeyboardMouse.h" #include "KeyboardMouse.h"
/* Project Tags, for reading out using the ButtLoad project */
BUTTLOADTAG(ProjName, "LUFA MouseKBD App");
BUTTLOADTAG(BuildTime, __TIME__);
BUTTLOADTAG(BuildDate, __DATE__);
BUTTLOADTAG(LUFAVersion, "LUFA V" LUFA_VERSION_STRING);
/* Scheduler Task List */ /* Scheduler Task List */
TASK_LIST TASK_LIST
{ {
@ -150,7 +144,7 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
case REQ_GetReport: case REQ_GetReport:
if (bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE)) if (bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE))
{ {
Endpoint_Ignore_Word(); Endpoint_Discard_Word();
uint16_t wIndex = Endpoint_Read_Word_LE(); uint16_t wIndex = Endpoint_Read_Word_LE();
@ -173,7 +167,7 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
if (wLength > ReportSize) if (wLength > ReportSize)
wLength = ReportSize; wLength = ReportSize;
Endpoint_ClearSetupReceived(); Endpoint_ClearControlSETUP();
/* Write the report data to the control endpoint */ /* Write the report data to the control endpoint */
Endpoint_Write_Control_Stream_LE(ReportData, wLength); Endpoint_Write_Control_Stream_LE(ReportData, wLength);
@ -182,17 +176,17 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
memset(ReportData, 0, ReportSize); memset(ReportData, 0, ReportSize);
/* Finalize the stream transfer to send the last packet or clear the host abort */ /* Finalize the stream transfer to send the last packet or clear the host abort */
Endpoint_ClearSetupOUT(); Endpoint_ClearControlOUT();
} }
break; break;
case REQ_SetReport: case REQ_SetReport:
if (bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE)) if (bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE))
{ {
Endpoint_ClearSetupReceived(); Endpoint_ClearControlSETUP();
/* Wait until the LED report has been sent by the host */ /* Wait until the LED report has been sent by the host */
while (!(Endpoint_IsSetupOUTReceived())); while (!(Endpoint_IsOUTReceived()));
/* Read in the LED report from the host */ /* Read in the LED report from the host */
uint8_t LEDStatus = Endpoint_Read_Byte(); uint8_t LEDStatus = Endpoint_Read_Byte();
@ -211,11 +205,11 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
LEDs_SetAllLEDs(LEDMask); LEDs_SetAllLEDs(LEDMask);
/* Clear the endpoint data */ /* Clear the endpoint data */
Endpoint_ClearSetupOUT(); Endpoint_ClearControlOUT();
/* Acknowledge status stage */ /* Acknowledge status stage */
while (!(Endpoint_IsSetupINReady())); while (!(Endpoint_IsINReady()));
Endpoint_ClearSetupIN(); Endpoint_ClearControlIN();
} }
break; break;
@ -281,13 +275,13 @@ TASK(USB_Keyboard)
Endpoint_SelectEndpoint(KEYBOARD_IN_EPNUM); Endpoint_SelectEndpoint(KEYBOARD_IN_EPNUM);
/* Check if Keyboard Endpoint Ready for Read/Write */ /* Check if Keyboard Endpoint Ready for Read/Write */
if (Endpoint_ReadWriteAllowed()) if (Endpoint_IsReadWriteAllowed())
{ {
/* Write Keyboard Report Data */ /* Write Keyboard Report Data */
Endpoint_Write_Stream_LE(&KeyboardReportData, sizeof(KeyboardReportData)); Endpoint_Write_Stream_LE(&KeyboardReportData, sizeof(KeyboardReportData));
/* Finalize the stream transfer to send the last packet */ /* Finalize the stream transfer to send the last packet */
Endpoint_ClearCurrentBank(); Endpoint_ClearIN();
/* Clear the report data afterwards */ /* Clear the report data afterwards */
memset(&KeyboardReportData, 0, sizeof(KeyboardReportData)); memset(&KeyboardReportData, 0, sizeof(KeyboardReportData));
@ -297,7 +291,7 @@ TASK(USB_Keyboard)
Endpoint_SelectEndpoint(KEYBOARD_OUT_EPNUM); Endpoint_SelectEndpoint(KEYBOARD_OUT_EPNUM);
/* Check if Keyboard LED Endpoint Ready for Read/Write */ /* Check if Keyboard LED Endpoint Ready for Read/Write */
if (Endpoint_ReadWriteAllowed()) if (Endpoint_IsReadWriteAllowed())
{ {
/* Read in the LED report from the host */ /* Read in the LED report from the host */
uint8_t LEDStatus = Endpoint_Read_Byte(); uint8_t LEDStatus = Endpoint_Read_Byte();
@ -316,7 +310,7 @@ TASK(USB_Keyboard)
LEDs_SetAllLEDs(LEDMask); LEDs_SetAllLEDs(LEDMask);
/* Handshake the OUT Endpoint - clear endpoint and ready for next report */ /* Handshake the OUT Endpoint - clear endpoint and ready for next report */
Endpoint_ClearCurrentBank(); Endpoint_ClearOUT();
} }
} }
} }
@ -352,13 +346,13 @@ TASK(USB_Mouse)
Endpoint_SelectEndpoint(MOUSE_IN_EPNUM); Endpoint_SelectEndpoint(MOUSE_IN_EPNUM);
/* Check if Mouse Endpoint Ready for Read/Write */ /* Check if Mouse Endpoint Ready for Read/Write */
if (Endpoint_ReadWriteAllowed()) if (Endpoint_IsReadWriteAllowed())
{ {
/* Write Mouse Report Data */ /* Write Mouse Report Data */
Endpoint_Write_Stream_LE(&MouseReportData, sizeof(MouseReportData)); Endpoint_Write_Stream_LE(&MouseReportData, sizeof(MouseReportData));
/* Finalize the stream transfer to send the last packet */ /* Finalize the stream transfer to send the last packet */
Endpoint_ClearCurrentBank(); Endpoint_ClearIN();
/* Clear the report data afterwards */ /* Clear the report data afterwards */
memset(&MouseReportData, 0, sizeof(MouseReportData)); memset(&MouseReportData, 0, sizeof(MouseReportData));

@ -42,7 +42,6 @@
#include "Descriptors.h" #include "Descriptors.h"
#include <LUFA/Version.h> // Library Version Information #include <LUFA/Version.h> // Library Version Information
#include <LUFA/Common/ButtLoadTag.h> // PROGMEM tags readable by the ButtLoad project
#include <LUFA/Drivers/USB/USB.h> // USB Functionality #include <LUFA/Drivers/USB/USB.h> // USB Functionality
#include <LUFA/Drivers/Board/Joystick.h> // Joystick driver #include <LUFA/Drivers/Board/Joystick.h> // Joystick driver
#include <LUFA/Drivers/Board/LEDs.h> // LEDs driver #include <LUFA/Drivers/Board/LEDs.h> // LEDs driver

@ -36,12 +36,6 @@
#include "MIDI.h" #include "MIDI.h"
/* Project Tags, for reading out using the ButtLoad project */
BUTTLOADTAG(ProjName, "LUFA MIDI App");
BUTTLOADTAG(BuildTime, __TIME__);
BUTTLOADTAG(BuildDate, __DATE__);
BUTTLOADTAG(LUFAVersion, "LUFA V" LUFA_VERSION_STRING);
/* Scheduler Task List */ /* Scheduler Task List */
TASK_LIST TASK_LIST
{ {
@ -134,7 +128,7 @@ TASK(USB_MIDI_Task)
Endpoint_SelectEndpoint(MIDI_STREAM_IN_EPNUM); Endpoint_SelectEndpoint(MIDI_STREAM_IN_EPNUM);
/* Check if endpoint is ready to be written to */ /* Check if endpoint is ready to be written to */
if (Endpoint_ReadWriteAllowed()) if (Endpoint_IsINReady())
{ {
/* Get current joystick mask, XOR with previous to detect joystick changes */ /* Get current joystick mask, XOR with previous to detect joystick changes */
uint8_t JoystickStatus = Joystick_GetStatus(); uint8_t JoystickStatus = Joystick_GetStatus();
@ -166,8 +160,8 @@ TASK(USB_MIDI_Task)
Endpoint_SelectEndpoint(MIDI_STREAM_OUT_EPNUM); Endpoint_SelectEndpoint(MIDI_STREAM_OUT_EPNUM);
/* Check if endpoint is ready to be read from, if so discard its (unused) data */ /* Check if endpoint is ready to be read from, if so discard its (unused) data */
if (Endpoint_ReadWriteAllowed()) if (Endpoint_IsOUTReceived())
Endpoint_ClearCurrentBank(); Endpoint_ClearOUT();
} }
/** Function to manage status updates to the user. This is done via LEDs on the given board, if available, but may be changed to /** Function to manage status updates to the user. This is done via LEDs on the given board, if available, but may be changed to
@ -207,7 +201,7 @@ void UpdateStatus(uint8_t CurrentStatus)
void SendMIDINoteChange(const uint8_t Pitch, const bool OnOff, const uint8_t CableID, const uint8_t Channel) void SendMIDINoteChange(const uint8_t Pitch, const bool OnOff, const uint8_t CableID, const uint8_t Channel)
{ {
/* Wait until endpoint ready for more data */ /* Wait until endpoint ready for more data */
while (!(Endpoint_ReadWriteAllowed())); while (!(Endpoint_IsReadWriteAllowed()));
/* Check if the message should be a Note On or Note Off command */ /* Check if the message should be a Note On or Note Off command */
uint8_t Command = ((OnOff)? MIDI_COMMAND_NOTE_ON : MIDI_COMMAND_NOTE_OFF); uint8_t Command = ((OnOff)? MIDI_COMMAND_NOTE_ON : MIDI_COMMAND_NOTE_OFF);
@ -221,5 +215,5 @@ void SendMIDINoteChange(const uint8_t Pitch, const bool OnOff, const uint8_t Cab
Endpoint_Write_Byte(MIDI_STANDARD_VELOCITY); Endpoint_Write_Byte(MIDI_STANDARD_VELOCITY);
/* Send the data in the endpoint to the host */ /* Send the data in the endpoint to the host */
Endpoint_ClearCurrentBank(); Endpoint_ClearIN();
} }

@ -45,7 +45,6 @@
#include "Descriptors.h" #include "Descriptors.h"
#include <LUFA/Version.h> // Library Version Information #include <LUFA/Version.h> // Library Version Information
#include <LUFA/Common/ButtLoadTag.h> // PROGMEM tags readable by the ButtLoad project
#include <LUFA/Drivers/USB/USB.h> // USB Functionality #include <LUFA/Drivers/USB/USB.h> // USB Functionality
#include <LUFA/Drivers/Board/Joystick.h> // Joystick driver #include <LUFA/Drivers/Board/Joystick.h> // Joystick driver
#include <LUFA/Drivers/Board/LEDs.h> // LEDs driver #include <LUFA/Drivers/Board/LEDs.h> // LEDs driver

@ -64,7 +64,7 @@ void DataflashManager_WriteBlocks(const uint32_t BlockAddress, uint16_t TotalBlo
Dataflash_SendAddressBytes(0, CurrDFPageByte); Dataflash_SendAddressBytes(0, CurrDFPageByte);
/* Wait until endpoint is ready before continuing */ /* Wait until endpoint is ready before continuing */
while (!(Endpoint_ReadWriteAllowed())); while (!(Endpoint_IsReadWriteAllowed()));
while (TotalBlocks) while (TotalBlocks)
{ {
@ -74,13 +74,13 @@ void DataflashManager_WriteBlocks(const uint32_t BlockAddress, uint16_t TotalBlo
while (BytesInBlockDiv16 < (VIRTUAL_MEMORY_BLOCK_SIZE >> 4)) while (BytesInBlockDiv16 < (VIRTUAL_MEMORY_BLOCK_SIZE >> 4))
{ {
/* Check if the endpoint is currently empty */ /* Check if the endpoint is currently empty */
if (!(Endpoint_ReadWriteAllowed())) if (!(Endpoint_IsReadWriteAllowed()))
{ {
/* Clear the current endpoint bank */ /* Clear the current endpoint bank */
Endpoint_ClearCurrentBank(); Endpoint_ClearOUT();
/* Wait until the host has sent another packet */ /* Wait until the host has sent another packet */
while (!(Endpoint_ReadWriteAllowed())); while (!(Endpoint_IsReadWriteAllowed()));
} }
/* Check if end of dataflash page reached */ /* Check if end of dataflash page reached */
@ -157,8 +157,8 @@ void DataflashManager_WriteBlocks(const uint32_t BlockAddress, uint16_t TotalBlo
Dataflash_WaitWhileBusy(); Dataflash_WaitWhileBusy();
/* If the endpoint is empty, clear it ready for the next packet from the host */ /* If the endpoint is empty, clear it ready for the next packet from the host */
if (!(Endpoint_ReadWriteAllowed())) if (!(Endpoint_IsReadWriteAllowed()))
Endpoint_ClearCurrentBank(); Endpoint_ClearOUT();
/* Deselect all dataflash chips */ /* Deselect all dataflash chips */
Dataflash_DeselectChip(); Dataflash_DeselectChip();
@ -187,7 +187,7 @@ void DataflashManager_ReadBlocks(const uint32_t BlockAddress, uint16_t TotalBloc
Dataflash_SendByte(0x00); Dataflash_SendByte(0x00);
/* Wait until endpoint is ready before continuing */ /* Wait until endpoint is ready before continuing */
while (!(Endpoint_ReadWriteAllowed())); while (!(Endpoint_IsReadWriteAllowed()));
while (TotalBlocks) while (TotalBlocks)
{ {
@ -197,13 +197,13 @@ void DataflashManager_ReadBlocks(const uint32_t BlockAddress, uint16_t TotalBloc
while (BytesInBlockDiv16 < (VIRTUAL_MEMORY_BLOCK_SIZE >> 4)) while (BytesInBlockDiv16 < (VIRTUAL_MEMORY_BLOCK_SIZE >> 4))
{ {
/* Check if the endpoint is currently full */ /* Check if the endpoint is currently full */
if (!(Endpoint_ReadWriteAllowed())) if (!(Endpoint_IsReadWriteAllowed()))
{ {
/* Clear the endpoint bank to send its contents to the host */ /* Clear the endpoint bank to send its contents to the host */
Endpoint_ClearCurrentBank(); Endpoint_ClearIN();
/* Wait until the endpoint is ready for more data */ /* Wait until the endpoint is ready for more data */
while (!(Endpoint_ReadWriteAllowed())); while (!(Endpoint_IsReadWriteAllowed()));
} }
/* Check if end of dataflash page reached */ /* Check if end of dataflash page reached */
@ -259,8 +259,8 @@ void DataflashManager_ReadBlocks(const uint32_t BlockAddress, uint16_t TotalBloc
} }
/* If the endpoint is full, send its contents to the host */ /* If the endpoint is full, send its contents to the host */
if (!(Endpoint_ReadWriteAllowed())) if (!(Endpoint_IsReadWriteAllowed()))
Endpoint_ClearCurrentBank(); Endpoint_ClearIN();
/* Deselect all dataflash chips */ /* Deselect all dataflash chips */
Dataflash_DeselectChip(); Dataflash_DeselectChip();

@ -37,12 +37,6 @@
#define INCLUDE_FROM_MASSSTORAGE_C #define INCLUDE_FROM_MASSSTORAGE_C
#include "MassStorage.h" #include "MassStorage.h"
/* Project Tags, for reading out using the ButtLoad project */
BUTTLOADTAG(ProjName, "LUFA MassStore App");
BUTTLOADTAG(BuildTime, __TIME__);
BUTTLOADTAG(BuildDate, __DATE__);
BUTTLOADTAG(LUFAVersion, "LUFA V" LUFA_VERSION_STRING);
/* Scheduler Task List */ /* Scheduler Task List */
TASK_LIST TASK_LIST
{ {
@ -159,30 +153,30 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
case REQ_MassStorageReset: case REQ_MassStorageReset:
if (bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE)) if (bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE))
{ {
Endpoint_ClearSetupReceived(); Endpoint_ClearControlSETUP();
/* Indicate that the current transfer should be aborted */ /* Indicate that the current transfer should be aborted */
IsMassStoreReset = true; IsMassStoreReset = true;
/* Acknowledge status stage */ /* Acknowledge status stage */
while (!(Endpoint_IsSetupINReady())); while (!(Endpoint_IsINReady()));
Endpoint_ClearSetupIN(); Endpoint_ClearControlIN();
} }
break; break;
case REQ_GetMaxLUN: case REQ_GetMaxLUN:
if (bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE)) if (bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE))
{ {
/* Indicate to the host the number of supported LUNs (virtual disks) on the device */ Endpoint_ClearControlSETUP();
Endpoint_ClearSetupReceived();
/* Indicate to the host the number of supported LUNs (virtual disks) on the device */
Endpoint_Write_Byte(TOTAL_LUNS - 1); Endpoint_Write_Byte(TOTAL_LUNS - 1);
Endpoint_ClearSetupIN(); Endpoint_ClearControlIN();
/* Acknowledge status stage */ /* Acknowledge status stage */
while (!(Endpoint_IsSetupOUTReceived())); while (!(Endpoint_IsOUTReceived()));
Endpoint_ClearSetupOUT(); Endpoint_ClearControlOUT();
} }
break; break;
@ -234,7 +228,7 @@ TASK(USB_MassStorage)
Endpoint_SelectEndpoint(MASS_STORAGE_OUT_EPNUM); Endpoint_SelectEndpoint(MASS_STORAGE_OUT_EPNUM);
/* Check to see if a command from the host has been issued */ /* Check to see if a command from the host has been issued */
if (Endpoint_ReadWriteAllowed()) if (Endpoint_IsReadWriteAllowed())
{ {
/* Indicate busy */ /* Indicate busy */
UpdateStatus(Status_ProcessingCommandBlock); UpdateStatus(Status_ProcessingCommandBlock);
@ -326,7 +320,7 @@ static bool ReadInCommandBlock(void)
return false; return false;
/* Finalize the stream transfer to send the last packet */ /* Finalize the stream transfer to send the last packet */
Endpoint_ClearCurrentBank(); Endpoint_ClearOUT();
return true; return true;
} }
@ -367,7 +361,7 @@ static void ReturnCommandStatus(void)
return; return;
/* Finalize the stream transfer to send the last packet */ /* Finalize the stream transfer to send the last packet */
Endpoint_ClearCurrentBank(); Endpoint_ClearIN();
} }
/** Stream callback function for the Endpoint stream read and write functions. This callback will abort the current stream transfer /** Stream callback function for the Endpoint stream read and write functions. This callback will abort the current stream transfer

@ -46,7 +46,6 @@
#include "DataflashManager.h" #include "DataflashManager.h"
#include <LUFA/Version.h> // Library Version Information #include <LUFA/Version.h> // Library Version Information
#include <LUFA/Common/ButtLoadTag.h> // PROGMEM tags readable by the ButtLoad project
#include <LUFA/Drivers/USB/USB.h> // USB Functionality #include <LUFA/Drivers/USB/USB.h> // USB Functionality
#include <LUFA/Drivers/Board/LEDs.h> // LEDs driver #include <LUFA/Drivers/Board/LEDs.h> // LEDs driver
#include <LUFA/Drivers/Board/Dataflash.h> // Dataflash chip driver #include <LUFA/Drivers/Board/Dataflash.h> // Dataflash chip driver

@ -174,7 +174,7 @@ static bool SCSI_Command_Inquiry(void)
Endpoint_Write_Stream_LE(&PadBytes, (AllocationLength - BytesTransferred), AbortOnMassStoreReset); Endpoint_Write_Stream_LE(&PadBytes, (AllocationLength - BytesTransferred), AbortOnMassStoreReset);
/* Finalize the stream transfer to send the last packet */ /* Finalize the stream transfer to send the last packet */
Endpoint_ClearCurrentBank(); Endpoint_ClearIN();
/* Succeed the command and update the bytes transferred counter */ /* Succeed the command and update the bytes transferred counter */
CommandBlock.DataTransferLength -= BytesTransferred; CommandBlock.DataTransferLength -= BytesTransferred;
@ -201,7 +201,7 @@ static bool SCSI_Command_Request_Sense(void)
Endpoint_Write_Stream_LE(&PadBytes, (AllocationLength - BytesTransferred), AbortOnMassStoreReset); Endpoint_Write_Stream_LE(&PadBytes, (AllocationLength - BytesTransferred), AbortOnMassStoreReset);
/* Finalize the stream transfer to send the last packet */ /* Finalize the stream transfer to send the last packet */
Endpoint_ClearCurrentBank(); Endpoint_ClearIN();
/* Succeed the command and update the bytes transferred counter */ /* Succeed the command and update the bytes transferred counter */
CommandBlock.DataTransferLength -= BytesTransferred; CommandBlock.DataTransferLength -= BytesTransferred;
@ -227,7 +227,7 @@ static bool SCSI_Command_Read_Capacity_10(void)
return false; return false;
/* Send the endpoint data packet to the host */ /* Send the endpoint data packet to the host */
Endpoint_ClearCurrentBank(); Endpoint_ClearIN();
/* Succeed the command and update the bytes transferred counter */ /* Succeed the command and update the bytes transferred counter */
CommandBlock.DataTransferLength -= 8; CommandBlock.DataTransferLength -= 8;

@ -36,12 +36,6 @@
#include "Mouse.h" #include "Mouse.h"
/* Project Tags, for reading out using the ButtLoad project */
BUTTLOADTAG(ProjName, "LUFA Mouse App");
BUTTLOADTAG(BuildTime, __TIME__);
BUTTLOADTAG(BuildDate, __DATE__);
BUTTLOADTAG(LUFAVersion, "LUFA V" LUFA_VERSION_STRING);
/* Scheduler Task List */ /* Scheduler Task List */
TASK_LIST TASK_LIST
{ {
@ -212,7 +206,7 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
if (wLength > sizeof(MouseReportData)) if (wLength > sizeof(MouseReportData))
wLength = sizeof(MouseReportData); wLength = sizeof(MouseReportData);
Endpoint_ClearSetupReceived(); Endpoint_ClearControlSETUP();
/* Write the report data to the control endpoint */ /* Write the report data to the control endpoint */
Endpoint_Write_Control_Stream_LE(&MouseReportData, wLength); Endpoint_Write_Control_Stream_LE(&MouseReportData, wLength);
@ -221,24 +215,24 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
memset(&MouseReportData, 0, sizeof(MouseReportData)); memset(&MouseReportData, 0, sizeof(MouseReportData));
/* Finalize the stream transfer to send the last packet or clear the host abort */ /* Finalize the stream transfer to send the last packet or clear the host abort */
Endpoint_ClearSetupOUT(); Endpoint_ClearControlOUT();
} }
break; break;
case REQ_GetProtocol: case REQ_GetProtocol:
if (bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE)) if (bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE))
{ {
Endpoint_ClearSetupReceived(); Endpoint_ClearControlSETUP();
/* Write the current protocol flag to the host */ /* Write the current protocol flag to the host */
Endpoint_Write_Byte(UsingReportProtocol); Endpoint_Write_Byte(UsingReportProtocol);
/* Send the flag to the host */ /* Send the flag to the host */
Endpoint_ClearSetupIN(); Endpoint_ClearControlIN();
/* Acknowledge status stage */ /* Acknowledge status stage */
while (!(Endpoint_IsSetupOUTReceived())); while (!(Endpoint_IsOUTReceived()));
Endpoint_ClearSetupOUT(); Endpoint_ClearControlOUT();
} }
break; break;
@ -248,14 +242,14 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
/* Read in the wValue parameter containing the new protocol mode */ /* Read in the wValue parameter containing the new protocol mode */
uint16_t wValue = Endpoint_Read_Word_LE(); uint16_t wValue = Endpoint_Read_Word_LE();
Endpoint_ClearSetupReceived(); Endpoint_ClearControlSETUP();
/* Set or clear the flag depending on what the host indicates that the current Protocol should be */ /* Set or clear the flag depending on what the host indicates that the current Protocol should be */
UsingReportProtocol = (wValue != 0x0000); UsingReportProtocol = (wValue != 0x0000);
/* Acknowledge status stage */ /* Acknowledge status stage */
while (!(Endpoint_IsSetupINReady())); while (!(Endpoint_IsINReady()));
Endpoint_ClearSetupIN(); Endpoint_ClearControlIN();
} }
break; break;
@ -265,31 +259,31 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
/* Read in the wValue parameter containing the idle period */ /* Read in the wValue parameter containing the idle period */
uint16_t wValue = Endpoint_Read_Word_LE(); uint16_t wValue = Endpoint_Read_Word_LE();
Endpoint_ClearSetupReceived(); Endpoint_ClearControlSETUP();
/* Get idle period in MSB */ /* Get idle period in MSB */
IdleCount = (wValue >> 8); IdleCount = (wValue >> 8);
/* Acknowledge status stage */ /* Acknowledge status stage */
while (!(Endpoint_IsSetupINReady())); while (!(Endpoint_IsINReady()));
Endpoint_ClearSetupIN(); Endpoint_ClearControlIN();
} }
break; break;
case REQ_GetIdle: case REQ_GetIdle:
if (bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE)) if (bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE))
{ {
Endpoint_ClearSetupReceived(); Endpoint_ClearControlSETUP();
/* Write the current idle duration to the host */ /* Write the current idle duration to the host */
Endpoint_Write_Byte(IdleCount); Endpoint_Write_Byte(IdleCount);
/* Send the flag to the host */ /* Send the flag to the host */
Endpoint_ClearSetupIN(); Endpoint_ClearControlIN();
/* Acknowledge status stage */ /* Acknowledge status stage */
while (!(Endpoint_IsSetupOUTReceived())); while (!(Endpoint_IsOUTReceived()));
Endpoint_ClearSetupOUT(); Endpoint_ClearControlOUT();
} }
break; break;
@ -367,13 +361,13 @@ static inline void SendNextReport(void)
Endpoint_SelectEndpoint(MOUSE_EPNUM); Endpoint_SelectEndpoint(MOUSE_EPNUM);
/* Check if Mouse Endpoint Ready for Read/Write and if we should send a new report */ /* Check if Mouse Endpoint Ready for Read/Write and if we should send a new report */
if (Endpoint_ReadWriteAllowed() && SendReport) if (Endpoint_IsReadWriteAllowed() && SendReport)
{ {
/* Write Mouse Report Data */ /* Write Mouse Report Data */
Endpoint_Write_Stream_LE(&MouseReportData, sizeof(MouseReportData)); Endpoint_Write_Stream_LE(&MouseReportData, sizeof(MouseReportData));
/* Finalize the stream transfer to send the last packet */ /* Finalize the stream transfer to send the last packet */
Endpoint_ClearCurrentBank(); Endpoint_ClearIN();
} }
} }

@ -47,7 +47,6 @@
#include "Descriptors.h" #include "Descriptors.h"
#include <LUFA/Version.h> // Library Version Information #include <LUFA/Version.h> // Library Version Information
#include <LUFA/Common/ButtLoadTag.h> // PROGMEM tags readable by the ButtLoad project
#include <LUFA/Drivers/USB/USB.h> // USB Functionality #include <LUFA/Drivers/USB/USB.h> // USB Functionality
#include <LUFA/Drivers/Board/Joystick.h> // Joystick driver #include <LUFA/Drivers/Board/Joystick.h> // Joystick driver
#include <LUFA/Drivers/Board/LEDs.h> // LEDs driver #include <LUFA/Drivers/Board/LEDs.h> // LEDs driver

@ -36,12 +36,6 @@
#include "RNDISEthernet.h" #include "RNDISEthernet.h"
/* Project Tags, for reading out using the ButtLoad project */
BUTTLOADTAG(ProjName, "LUFA RNDIS App");
BUTTLOADTAG(BuildTime, __TIME__);
BUTTLOADTAG(BuildDate, __DATE__);
BUTTLOADTAG(LUFAVersion, "LUFA V" LUFA_VERSION_STRING);
/* Scheduler Task List */ /* Scheduler Task List */
TASK_LIST TASK_LIST
{ {
@ -162,13 +156,13 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
if (bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE)) if (bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE))
{ {
/* Clear the SETUP packet, ready for data transfer */ /* Clear the SETUP packet, ready for data transfer */
Endpoint_ClearSetupReceived(); Endpoint_ClearControlSETUP();
/* Read in the RNDIS message into the message buffer */ /* Read in the RNDIS message into the message buffer */
Endpoint_Read_Control_Stream_LE(RNDISMessageBuffer, wLength); Endpoint_Read_Control_Stream_LE(RNDISMessageBuffer, wLength);
/* Finalize the stream transfer to clear the last packet from the host */ /* Finalize the stream transfer to clear the last packet from the host */
Endpoint_ClearSetupIN(); Endpoint_ClearControlIN();
/* Process the RNDIS message */ /* Process the RNDIS message */
ProcessRNDISControlMessage(); ProcessRNDISControlMessage();
@ -191,13 +185,13 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
wLength = MessageHeader->MessageLength; wLength = MessageHeader->MessageLength;
/* Clear the SETUP packet, ready for data transfer */ /* Clear the SETUP packet, ready for data transfer */
Endpoint_ClearSetupReceived(); Endpoint_ClearControlSETUP();
/* Write the message response data to the endpoint */ /* Write the message response data to the endpoint */
Endpoint_Write_Control_Stream_LE(RNDISMessageBuffer, wLength); Endpoint_Write_Control_Stream_LE(RNDISMessageBuffer, wLength);
/* Finalize the stream transfer to send the last packet or clear the host abort */ /* Finalize the stream transfer to send the last packet or clear the host abort */
Endpoint_ClearSetupOUT(); Endpoint_ClearControlOUT();
/* Reset the message header once again after transmission */ /* Reset the message header once again after transmission */
MessageHeader->MessageLength = 0; MessageHeader->MessageLength = 0;
@ -247,7 +241,7 @@ TASK(RNDIS_Task)
Endpoint_SelectEndpoint(CDC_NOTIFICATION_EPNUM); Endpoint_SelectEndpoint(CDC_NOTIFICATION_EPNUM);
/* Check if a message response is ready for the host */ /* Check if a message response is ready for the host */
if (Endpoint_ReadWriteAllowed() && ResponseReady) if (Endpoint_IsINReady() && ResponseReady)
{ {
USB_Notification_t Notification = (USB_Notification_t) USB_Notification_t Notification = (USB_Notification_t)
{ {
@ -262,7 +256,7 @@ TASK(RNDIS_Task)
Endpoint_Write_Stream_LE(&Notification, sizeof(Notification)); Endpoint_Write_Stream_LE(&Notification, sizeof(Notification));
/* Finalize the stream transfer to send the last packet */ /* Finalize the stream transfer to send the last packet */
Endpoint_ClearCurrentBank(); Endpoint_ClearIN();
/* Indicate a response is no longer ready */ /* Indicate a response is no longer ready */
ResponseReady = false; ResponseReady = false;
@ -278,7 +272,7 @@ TASK(RNDIS_Task)
Endpoint_SelectEndpoint(CDC_RX_EPNUM); Endpoint_SelectEndpoint(CDC_RX_EPNUM);
/* Check if the data OUT endpoint contains data, and that the IN buffer is empty */ /* Check if the data OUT endpoint contains data, and that the IN buffer is empty */
if (Endpoint_ReadWriteAllowed() && !(FrameIN.FrameInBuffer)) if (Endpoint_IsOUTReceived() && !(FrameIN.FrameInBuffer))
{ {
/* Read in the packet message header */ /* Read in the packet message header */
Endpoint_Read_Stream_LE(&RNDISPacketHeader, sizeof(RNDIS_PACKET_MSG_t)); Endpoint_Read_Stream_LE(&RNDISPacketHeader, sizeof(RNDIS_PACKET_MSG_t));
@ -294,7 +288,7 @@ TASK(RNDIS_Task)
Endpoint_Read_Stream_LE(FrameIN.FrameData, RNDISPacketHeader.DataLength); Endpoint_Read_Stream_LE(FrameIN.FrameData, RNDISPacketHeader.DataLength);
/* Finalize the stream transfer to send the last packet */ /* Finalize the stream transfer to send the last packet */
Endpoint_ClearCurrentBank(); Endpoint_ClearOUT();
/* Store the size of the Ethernet frame */ /* Store the size of the Ethernet frame */
FrameIN.FrameLength = RNDISPacketHeader.DataLength; FrameIN.FrameLength = RNDISPacketHeader.DataLength;
@ -307,7 +301,7 @@ TASK(RNDIS_Task)
Endpoint_SelectEndpoint(CDC_TX_EPNUM); Endpoint_SelectEndpoint(CDC_TX_EPNUM);
/* Check if the data IN endpoint is ready for more data, and that the IN buffer is full */ /* Check if the data IN endpoint is ready for more data, and that the IN buffer is full */
if (Endpoint_ReadWriteAllowed() && FrameOUT.FrameInBuffer) if (Endpoint_IsINReady() && FrameOUT.FrameInBuffer)
{ {
/* Clear the packet header with all 0s so that the relevant fields can be filled */ /* Clear the packet header with all 0s so that the relevant fields can be filled */
memset(&RNDISPacketHeader, 0, sizeof(RNDIS_PACKET_MSG_t)); memset(&RNDISPacketHeader, 0, sizeof(RNDIS_PACKET_MSG_t));
@ -325,7 +319,7 @@ TASK(RNDIS_Task)
Endpoint_Write_Stream_LE(FrameOUT.FrameData, RNDISPacketHeader.DataLength); Endpoint_Write_Stream_LE(FrameOUT.FrameData, RNDISPacketHeader.DataLength);
/* Finalize the stream transfer to send the last packet */ /* Finalize the stream transfer to send the last packet */
Endpoint_ClearCurrentBank(); Endpoint_ClearIN();
/* Indicate Ethernet OUT buffer no longer full */ /* Indicate Ethernet OUT buffer no longer full */
FrameOUT.FrameInBuffer = false; FrameOUT.FrameInBuffer = false;

@ -52,7 +52,6 @@
#include "Webserver.h" #include "Webserver.h"
#include <LUFA/Version.h> // Library Version Information #include <LUFA/Version.h> // Library Version Information
#include <LUFA/Common/ButtLoadTag.h> // PROGMEM tags readable by the ButtLoad project
#include <LUFA/Drivers/USB/USB.h> // USB Functionality #include <LUFA/Drivers/USB/USB.h> // USB Functionality
#include <LUFA/Drivers/Board/LEDs.h> // LEDs driver #include <LUFA/Drivers/Board/LEDs.h> // LEDs driver
#include <LUFA/Scheduler/Scheduler.h> // Simple scheduler for task management #include <LUFA/Scheduler/Scheduler.h> // Simple scheduler for task management

@ -30,12 +30,6 @@
#include "USBtoSerial.h" #include "USBtoSerial.h"
/* Project Tags, for reading out using the ButtLoad project */
BUTTLOADTAG(ProjName, "LUFA USB RS232 App");
BUTTLOADTAG(BuildTime, __TIME__);
BUTTLOADTAG(BuildDate, __DATE__);
BUTTLOADTAG(LUFAVersion, "LUFA V" LUFA_VERSION_STRING);
/* Scheduler Task List */ /* Scheduler Task List */
TASK_LIST TASK_LIST
{ {
@ -165,13 +159,13 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
if (bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE)) if (bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE))
{ {
/* Acknowledge the SETUP packet, ready for data transfer */ /* Acknowledge the SETUP packet, ready for data transfer */
Endpoint_ClearSetupReceived(); Endpoint_ClearControlSETUP();
/* Write the line coding data to the control endpoint */ /* Write the line coding data to the control endpoint */
Endpoint_Write_Control_Stream_LE(LineCodingData, sizeof(LineCoding)); Endpoint_Write_Control_Stream_LE(LineCodingData, sizeof(LineCoding));
/* Finalize the stream transfer to send the last packet or clear the host abort */ /* Finalize the stream transfer to send the last packet or clear the host abort */
Endpoint_ClearSetupOUT(); Endpoint_ClearControlOUT();
} }
break; break;
@ -179,13 +173,13 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
if (bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE)) if (bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE))
{ {
/* Acknowledge the SETUP packet, ready for data transfer */ /* Acknowledge the SETUP packet, ready for data transfer */
Endpoint_ClearSetupReceived(); Endpoint_ClearControlSETUP();
/* Read the line coding data in from the host into the global struct */ /* Read the line coding data in from the host into the global struct */
Endpoint_Read_Control_Stream_LE(LineCodingData, sizeof(LineCoding)); Endpoint_Read_Control_Stream_LE(LineCodingData, sizeof(LineCoding));
/* Finalize the stream transfer to clear the last packet from the host */ /* Finalize the stream transfer to clear the last packet from the host */
Endpoint_ClearSetupIN(); Endpoint_ClearControlIN();
/* Reconfigure the USART with the new settings */ /* Reconfigure the USART with the new settings */
ReconfigureUSART(); ReconfigureUSART();
@ -207,11 +201,11 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
#endif #endif
/* Acknowledge the SETUP packet, ready for data transfer */ /* Acknowledge the SETUP packet, ready for data transfer */
Endpoint_ClearSetupReceived(); Endpoint_ClearControlSETUP();
/* Acknowledge status stage */ /* Acknowledge status stage */
while (!(Endpoint_IsSetupINReady())); while (!(Endpoint_IsINReady()));
Endpoint_ClearSetupIN(); Endpoint_ClearControlIN();
} }
break; break;
@ -244,13 +238,13 @@ TASK(CDC_Task)
Endpoint_SelectEndpoint(CDC_NOTIFICATION_EPNUM); Endpoint_SelectEndpoint(CDC_NOTIFICATION_EPNUM);
Endpoint_Write_Stream_LE(&Notification, sizeof(Notification)); Endpoint_Write_Stream_LE(&Notification, sizeof(Notification));
Endpoint_Write_Stream_LE(&LineStateMask, sizeof(LineStateMask)); Endpoint_Write_Stream_LE(&LineStateMask, sizeof(LineStateMask));
Endpoint_ClearCurrentBank(); Endpoint_ClearIN();
#endif #endif
/* Select the Serial Rx Endpoint */ /* Select the Serial Rx Endpoint */
Endpoint_SelectEndpoint(CDC_RX_EPNUM); Endpoint_SelectEndpoint(CDC_RX_EPNUM);
if (Endpoint_ReadWriteAllowed()) if (Endpoint_IsOUTReceived())
{ {
/* Read the received data endpoint into the transmission buffer */ /* Read the received data endpoint into the transmission buffer */
while (Endpoint_BytesInEndpoint()) while (Endpoint_BytesInEndpoint())
@ -263,7 +257,7 @@ TASK(CDC_Task)
} }
/* Clear the endpoint buffer */ /* Clear the endpoint buffer */
Endpoint_ClearCurrentBank(); Endpoint_ClearOUT();
} }
/* Check if Rx buffer contains data */ /* Check if Rx buffer contains data */
@ -284,27 +278,20 @@ TASK(CDC_Task)
if (Tx_Buffer.Elements) if (Tx_Buffer.Elements)
{ {
/* Wait until Serial Tx Endpoint Ready for Read/Write */ /* Wait until Serial Tx Endpoint Ready for Read/Write */
while (!(Endpoint_ReadWriteAllowed())); while (!(Endpoint_IsReadWriteAllowed()));
/* Check before sending the data if the endpoint is completely full */
bool IsFull = (Endpoint_BytesInEndpoint() == CDC_TXRX_EPSIZE);
/* Write the transmission buffer contents to the received data endpoint */ /* Write the transmission buffer contents to the received data endpoint */
while (Tx_Buffer.Elements && (Endpoint_BytesInEndpoint() < CDC_TXRX_EPSIZE)) while (Tx_Buffer.Elements && (Endpoint_BytesInEndpoint() < CDC_TXRX_EPSIZE))
Endpoint_Write_Byte(Buffer_GetElement(&Tx_Buffer)); Endpoint_Write_Byte(Buffer_GetElement(&Tx_Buffer));
/* Send the data */ /* Send the data */
Endpoint_ClearCurrentBank(); Endpoint_ClearIN();
/* If a full endpoint was sent, we need to send an empty packet afterwards to terminate the transfer */
if (IsFull)
{
/* Wait until Serial Tx Endpoint Ready for Read/Write */ /* Wait until Serial Tx Endpoint Ready for Read/Write */
while (!(Endpoint_ReadWriteAllowed())); while (!(Endpoint_IsReadWriteAllowed()));
/* Send an empty packet to terminate the transfer */ /* Send an empty packet to terminate the transfer */
Endpoint_ClearCurrentBank(); Endpoint_ClearIN();
}
} }
} }
} }

@ -46,7 +46,6 @@
#include "RingBuff.h" #include "RingBuff.h"
#include <LUFA/Version.h> // Library Version Information #include <LUFA/Version.h> // Library Version Information
#include <LUFA/Common/ButtLoadTag.h> // PROGMEM tags readable by the ButtLoad project
#include <LUFA/Drivers/USB/USB.h> // USB Functionality #include <LUFA/Drivers/USB/USB.h> // USB Functionality
#include <LUFA/Drivers/AT90USBXXX/Serial.h> // USART driver #include <LUFA/Drivers/AT90USBXXX/Serial.h> // USART driver
#include <LUFA/Drivers/Board/LEDs.h> // LEDs driver #include <LUFA/Drivers/Board/LEDs.h> // LEDs driver

@ -36,12 +36,6 @@
#include "CDCHost.h" #include "CDCHost.h"
/* Project Tags, for reading out using the ButtLoad project */
BUTTLOADTAG(ProjName, "LUFA CDC Host App");
BUTTLOADTAG(BuildTime, __TIME__);
BUTTLOADTAG(BuildDate, __DATE__);
BUTTLOADTAG(LUFAVersion, "LUFA V" LUFA_VERSION_STRING);
/* Scheduler Task List */ /* Scheduler Task List */
TASK_LIST TASK_LIST
{ {
@ -244,8 +238,11 @@ TASK(USB_CDC_Host)
/* Select and the data IN pipe */ /* Select and the data IN pipe */
Pipe_SelectPipe(CDC_DATAPIPE_IN); Pipe_SelectPipe(CDC_DATAPIPE_IN);
/* Check to see if a packet has been received */
if (Pipe_IsINReceived())
{
/* Check if data is in the pipe */ /* Check if data is in the pipe */
if (Pipe_ReadWriteAllowed()) if (Pipe_IsReadWriteAllowed())
{ {
/* Get the length of the pipe data, and create a new buffer to hold it */ /* Get the length of the pipe data, and create a new buffer to hold it */
uint16_t BufferLength = Pipe_BytesInPipe(); uint16_t BufferLength = Pipe_BytesInPipe();
@ -254,23 +251,24 @@ TASK(USB_CDC_Host)
/* Read in the pipe data to the temporary buffer */ /* Read in the pipe data to the temporary buffer */
Pipe_Read_Stream_LE(Buffer, BufferLength); Pipe_Read_Stream_LE(Buffer, BufferLength);
/* Clear the pipe after it is read, ready for the next packet */
Pipe_ClearCurrentBank();
/* Print out the buffer contents to the USART */ /* Print out the buffer contents to the USART */
for (uint16_t BufferByte = 0; BufferByte < BufferLength; BufferByte++) for (uint16_t BufferByte = 0; BufferByte < BufferLength; BufferByte++)
putchar(Buffer[BufferByte]); putchar(Buffer[BufferByte]);
} }
/* Clear the pipe after it is read, ready for the next packet */
Pipe_ClearIN();
}
/* Select and unfreeze the notification pipe */ /* Select and unfreeze the notification pipe */
Pipe_SelectPipe(CDC_NOTIFICATIONPIPE); Pipe_SelectPipe(CDC_NOTIFICATIONPIPE);
Pipe_Unfreeze(); Pipe_Unfreeze();
/* Check if data is in the pipe */ /* Check if a packet has been received */
if (Pipe_ReadWriteAllowed()) if (Pipe_IsINReceived())
{ {
/* Discard the event notification */ /* Discard the event notification */
Pipe_ClearCurrentBank(); Pipe_ClearIN();
} }
/* Freeze notification IN pipe after use */ /* Freeze notification IN pipe after use */

@ -44,7 +44,6 @@
#include <stdio.h> #include <stdio.h>
#include <LUFA/Version.h> // Library Version Information #include <LUFA/Version.h> // Library Version Information
#include <LUFA/Common/ButtLoadTag.h> // PROGMEM tags readable by the ButtLoad project
#include <LUFA/Drivers/Misc/TerminalCodes.h> // ANSI Terminal Escape Codes #include <LUFA/Drivers/Misc/TerminalCodes.h> // ANSI Terminal Escape Codes
#include <LUFA/Drivers/USB/USB.h> // USB Functionality #include <LUFA/Drivers/USB/USB.h> // USB Functionality
#include <LUFA/Drivers/AT90USBXXX/Serial_Stream.h> // Serial stream driver #include <LUFA/Drivers/AT90USBXXX/Serial_Stream.h> // Serial stream driver

@ -38,7 +38,6 @@
/* Includes: */ /* Includes: */
#include <LUFA/Drivers/USB/USB.h> // USB Functionality #include <LUFA/Drivers/USB/USB.h> // USB Functionality
#include <LUFA/Drivers/USB/Class/ConfigDescriptor.h> // Configuration Descriptor Parser
#include "CDCHost.h" #include "CDCHost.h"

@ -38,7 +38,6 @@
/* Includes: */ /* Includes: */
#include <LUFA/Drivers/USB/USB.h> // USB Functionality #include <LUFA/Drivers/USB/USB.h> // USB Functionality
#include <LUFA/Drivers/USB/Class/ConfigDescriptor.h> // Configuration Descriptor Parser
#include "GenericHIDHost.h" #include "GenericHIDHost.h"

@ -36,12 +36,6 @@
#include "GenericHIDHost.h" #include "GenericHIDHost.h"
/* Project Tags, for reading out using the ButtLoad project */
BUTTLOADTAG(ProjName, "LUFA GenHid Host App");
BUTTLOADTAG(BuildTime, __TIME__);
BUTTLOADTAG(BuildDate, __DATE__);
BUTTLOADTAG(LUFAVersion, "LUFA V" LUFA_VERSION_STRING);
/* Scheduler Task List */ /* Scheduler Task List */
TASK_LIST TASK_LIST
{ {
@ -185,8 +179,8 @@ void ReadNextReport(void)
Pipe_SelectPipe(HID_DATA_IN_PIPE); Pipe_SelectPipe(HID_DATA_IN_PIPE);
Pipe_Unfreeze(); Pipe_Unfreeze();
/* Ensure pipe contains data and is ready to be read before continuing */ /* Check to see if a packet has been received */
if (!(Pipe_ReadWriteAllowed())) if (!(Pipe_IsINReceived()))
{ {
#if !defined(INTERRUPT_DATA_PIPE) #if !defined(INTERRUPT_DATA_PIPE)
/* Refreeze HID data IN pipe */ /* Refreeze HID data IN pipe */
@ -196,19 +190,23 @@ void ReadNextReport(void)
return; return;
} }
/* Ensure pipe contains data before trying to read from it */
if (Pipe_IsReadWriteAllowed())
{
uint8_t ReportINData[Pipe_BytesInPipe()]; uint8_t ReportINData[Pipe_BytesInPipe()];
/* Read in HID report data */ /* Read in HID report data */
Pipe_Read_Stream_LE(&ReportINData, sizeof(ReportINData)); Pipe_Read_Stream_LE(&ReportINData, sizeof(ReportINData));
/* Clear the IN endpoint, ready for next data packet */
Pipe_ClearCurrentBank();
/* Print report data through the serial port */ /* Print report data through the serial port */
for (uint16_t CurrByte = 0; CurrByte < sizeof(ReportINData); CurrByte++) for (uint16_t CurrByte = 0; CurrByte < sizeof(ReportINData); CurrByte++)
printf_P(PSTR("0x%02X "), ReportINData[CurrByte]); printf_P(PSTR("0x%02X "), ReportINData[CurrByte]);
puts_P(PSTR("\r\n")); puts_P(PSTR("\r\n"));
}
/* Clear the IN endpoint, ready for next data packet */
Pipe_ClearIN();
#if !defined(INTERRUPT_DATA_PIPE) #if !defined(INTERRUPT_DATA_PIPE)
/* Refreeze HID data IN pipe */ /* Refreeze HID data IN pipe */
@ -235,7 +233,7 @@ void WriteNextReport(uint8_t* ReportOUTData, uint8_t ReportIndex, uint8_t Report
Pipe_Unfreeze(); Pipe_Unfreeze();
/* Ensure pipe is ready to be written to before continuing */ /* Ensure pipe is ready to be written to before continuing */
if (!(Pipe_ReadWriteAllowed())) if (!(Pipe_IsOUTReady()))
{ {
/* Refreeze the data OUT pipe */ /* Refreeze the data OUT pipe */
Pipe_Freeze(); Pipe_Freeze();
@ -251,7 +249,7 @@ void WriteNextReport(uint8_t* ReportOUTData, uint8_t ReportIndex, uint8_t Report
Pipe_Write_Stream_LE(ReportOUTData, ReportLength); Pipe_Write_Stream_LE(ReportOUTData, ReportLength);
/* Clear the OUT endpoint, send last data packet */ /* Clear the OUT endpoint, send last data packet */
Pipe_ClearCurrentBank(); Pipe_ClearOUT();
/* Refreeze the data OUT pipe */ /* Refreeze the data OUT pipe */
Pipe_Freeze(); Pipe_Freeze();

@ -45,7 +45,6 @@
#include <stdio.h> #include <stdio.h>
#include <LUFA/Version.h> // Library Version Information #include <LUFA/Version.h> // Library Version Information
#include <LUFA/Common/ButtLoadTag.h> // PROGMEM tags readable by the ButtLoad project
#include <LUFA/Drivers/Misc/TerminalCodes.h> // ANSI Terminal Escape Codes #include <LUFA/Drivers/Misc/TerminalCodes.h> // ANSI Terminal Escape Codes
#include <LUFA/Drivers/USB/USB.h> // USB Functionality #include <LUFA/Drivers/USB/USB.h> // USB Functionality
#include <LUFA/Drivers/AT90USBXXX/Serial_Stream.h> // Serial stream driver #include <LUFA/Drivers/AT90USBXXX/Serial_Stream.h> // Serial stream driver
@ -94,6 +93,6 @@
/* Function Prototypes: */ /* Function Prototypes: */
void UpdateStatus(uint8_t CurrentStatus); void UpdateStatus(uint8_t CurrentStatus);
void ReadNextReport(void); void ReadNextReport(void);
void WriteNextReport(uint8_t* ReportOUTData, uint16_t ReportLength); void WriteNextReport(uint8_t* ReportOUTData, uint8_t ReportIndex, uint8_t ReportType, uint16_t ReportLength);
#endif #endif

@ -38,7 +38,6 @@
/* Includes: */ /* Includes: */
#include <LUFA/Drivers/USB/USB.h> // USB Functionality #include <LUFA/Drivers/USB/USB.h> // USB Functionality
#include <LUFA/Drivers/USB/Class/ConfigDescriptor.h> // Configuration Descriptor Parser
#include "KeyboardHost.h" #include "KeyboardHost.h"

@ -36,12 +36,6 @@
#include "KeyboardHost.h" #include "KeyboardHost.h"
/* Project Tags, for reading out using the ButtLoad project */
BUTTLOADTAG(ProjName, "LUFA KBD Host App");
BUTTLOADTAG(BuildTime, __TIME__);
BUTTLOADTAG(BuildDate, __DATE__);
BUTTLOADTAG(LUFAVersion, "LUFA V" LUFA_VERSION_STRING);
/* Scheduler Task List */ /* Scheduler Task List */
TASK_LIST TASK_LIST
{ {
@ -191,23 +185,23 @@ void ReadNextReport(void)
Pipe_Unfreeze(); Pipe_Unfreeze();
#endif #endif
/* Ensure pipe contains data and is ready to be read before continuing */ /* Check to see if a packet has been received */
if (!(Pipe_ReadWriteAllowed())) if (!(Pipe_IsINReceived()))
{ {
#if !defined(INTERRUPT_DATA_PIPE) #if !defined(INTERRUPT_DATA_PIPE)
/* Refreeze keyboard data pipe */ /* Refreeze HID data IN pipe */
Pipe_Freeze(); Pipe_Freeze();
#endif #endif
return; return;
} }
/* Ensure pipe contains data before trying to read from it */
if (Pipe_IsReadWriteAllowed())
{
/* Read in keyboard report data */ /* Read in keyboard report data */
Pipe_Read_Stream_LE(&KeyboardReport, sizeof(KeyboardReport)); Pipe_Read_Stream_LE(&KeyboardReport, sizeof(KeyboardReport));
/* Clear the IN endpoint, ready for next data packet */
Pipe_ClearCurrentBank();
/* Indicate if the modifier byte is non-zero (special key such as shift is being pressed) */ /* Indicate if the modifier byte is non-zero (special key such as shift is being pressed) */
LEDs_ChangeLEDs(LEDS_LED1, (KeyboardReport.Modifier) ? LEDS_LED1 : 0); LEDs_ChangeLEDs(LEDS_LED1, (KeyboardReport.Modifier) ? LEDS_LED1 : 0);
@ -236,6 +230,11 @@ void ReadNextReport(void)
if (PressedKey) if (PressedKey)
putchar(PressedKey); putchar(PressedKey);
} }
}
/* Clear the IN endpoint, ready for next data packet */
Pipe_ClearIN();
#if !defined(INTERRUPT_DATA_PIPE) #if !defined(INTERRUPT_DATA_PIPE)
/* Refreeze keyboard data pipe */ /* Refreeze keyboard data pipe */

@ -45,7 +45,6 @@
#include <stdio.h> #include <stdio.h>
#include <LUFA/Version.h> // Library Version Information #include <LUFA/Version.h> // Library Version Information
#include <LUFA/Common/ButtLoadTag.h> // PROGMEM tags readable by the ButtLoad project
#include <LUFA/Drivers/Misc/TerminalCodes.h> // ANSI Terminal Escape Codes #include <LUFA/Drivers/Misc/TerminalCodes.h> // ANSI Terminal Escape Codes
#include <LUFA/Drivers/USB/USB.h> // USB Functionality #include <LUFA/Drivers/USB/USB.h> // USB Functionality
#include <LUFA/Drivers/AT90USBXXX/Serial_Stream.h> // Serial stream driver #include <LUFA/Drivers/AT90USBXXX/Serial_Stream.h> // Serial stream driver

@ -38,7 +38,6 @@
/* Includes: */ /* Includes: */
#include <LUFA/Drivers/USB/USB.h> // USB Functionality #include <LUFA/Drivers/USB/USB.h> // USB Functionality
#include <LUFA/Drivers/USB/Class/ConfigDescriptor.h> // Configuration Descriptor Parser
#include "HIDReport.h" #include "HIDReport.h"

@ -37,7 +37,7 @@
#define _HID_REPORT_H_ #define _HID_REPORT_H_
/* Includes: */ /* Includes: */
#include <LUFA/Drivers/USB/Class/HIDParser.h> // HID Class Report Parser #include <LUFA/Drivers/USB/USB.h> // USB Functionality
#include "KeyboardHostWithParser.h" #include "KeyboardHostWithParser.h"

@ -36,12 +36,6 @@
#include "KeyboardHostWithParser.h" #include "KeyboardHostWithParser.h"
/* Project Tags, for reading out using the ButtLoad project */
BUTTLOADTAG(ProjName, "LUFA KBD Host App");
BUTTLOADTAG(BuildTime, __TIME__);
BUTTLOADTAG(BuildDate, __DATE__);
BUTTLOADTAG(LUFAVersion, "LUFA V" LUFA_VERSION_STRING);
/* Scheduler Task List */ /* Scheduler Task List */
TASK_LIST TASK_LIST
{ {
@ -270,8 +264,11 @@ TASK(USB_Keyboard_Host)
Pipe_SelectPipe(KEYBOARD_DATAPIPE); Pipe_SelectPipe(KEYBOARD_DATAPIPE);
Pipe_Unfreeze(); Pipe_Unfreeze();
/* Check to see if a packet has been received */
if (Pipe_IsINReceived())
{
/* Check if data has been received from the attached keyboard */ /* Check if data has been received from the attached keyboard */
if (Pipe_ReadWriteAllowed()) if (Pipe_IsReadWriteAllowed())
{ {
/* Create buffer big enough for the report */ /* Create buffer big enough for the report */
uint8_t KeyboardReport[Pipe_BytesInPipe()]; uint8_t KeyboardReport[Pipe_BytesInPipe()];
@ -279,9 +276,27 @@ TASK(USB_Keyboard_Host)
/* Load in the keyboard report */ /* Load in the keyboard report */
Pipe_Read_Stream_LE(KeyboardReport, Pipe_BytesInPipe()); Pipe_Read_Stream_LE(KeyboardReport, Pipe_BytesInPipe());
/* Process the read in keyboard report from the device */
ProcessKeyboardReport(KeyboardReport);
}
/* Clear the IN endpoint, ready for next data packet */ /* Clear the IN endpoint, ready for next data packet */
Pipe_ClearCurrentBank(); Pipe_ClearIN();
}
/* Freeze keyboard data pipe */
Pipe_Freeze();
break;
}
}
/** Processes a read HID report from an attached keyboard, extracting out elements via the HID parser results
* as required and prints pressed characters to the serial port. Each time a key is typed, a board LED is toggled.
*
* \param KeyboardReport Pointer to a HID report from an attached keyboard device
*/
void ProcessKeyboardReport(uint8_t* KeyboardReport)
{
/* Check each HID report item in turn, looking for keyboard scan code reports */ /* Check each HID report item in turn, looking for keyboard scan code reports */
for (uint8_t ReportNumber = 0; ReportNumber < HIDReportInfo.TotalReportItems; ReportNumber++) for (uint8_t ReportNumber = 0; ReportNumber < HIDReportInfo.TotalReportItems; ReportNumber++)
{ {
@ -335,9 +350,3 @@ TASK(USB_Keyboard_Host)
} }
} }
} }
/* Freeze keyboard data pipe */
Pipe_Freeze();
break;
}
}

@ -39,7 +39,6 @@
#include <stdio.h> #include <stdio.h>
#include <LUFA/Version.h> // Library Version Information #include <LUFA/Version.h> // Library Version Information
#include <LUFA/Common/ButtLoadTag.h> // PROGMEM tags readable by the ButtLoad project
#include <LUFA/Drivers/Misc/TerminalCodes.h> // ANSI Terminal Escape Codes #include <LUFA/Drivers/Misc/TerminalCodes.h> // ANSI Terminal Escape Codes
#include <LUFA/Drivers/USB/USB.h> // USB Functionality #include <LUFA/Drivers/USB/USB.h> // USB Functionality
#include <LUFA/Drivers/AT90USBXXX/Serial_Stream.h> // Serial stream driver #include <LUFA/Drivers/AT90USBXXX/Serial_Stream.h> // Serial stream driver
@ -77,5 +76,6 @@
/* Function Prototypes: */ /* Function Prototypes: */
void UpdateStatus(uint8_t CurrentStatus); void UpdateStatus(uint8_t CurrentStatus);
void ProcessKeyboardReport(uint8_t* KeyboardReport);
#endif #endif

@ -38,7 +38,6 @@
/* Includes: */ /* Includes: */
#include <LUFA/Drivers/USB/USB.h> // USB Functionality #include <LUFA/Drivers/USB/USB.h> // USB Functionality
#include <LUFA/Drivers/USB/Class/ConfigDescriptor.h> // Configuration Descriptor Parser
#include "MassStorageHost.h" #include "MassStorageHost.h"

@ -36,12 +36,6 @@
#include "MassStorageHost.h" #include "MassStorageHost.h"
/* Project Tags, for reading out using the ButtLoad project */
BUTTLOADTAG(ProjName, "LUFA MS Host App");
BUTTLOADTAG(BuildTime, __TIME__);
BUTTLOADTAG(BuildDate, __DATE__);
BUTTLOADTAG(LUFAVersion, "LUFA V" LUFA_VERSION_STRING);
/* Scheduler Task List */ /* Scheduler Task List */
TASK_LIST TASK_LIST
{ {

@ -48,7 +48,6 @@
#include "MassStoreCommands.h" #include "MassStoreCommands.h"
#include <LUFA/Version.h> // Library Version Information #include <LUFA/Version.h> // Library Version Information
#include <LUFA/Common/ButtLoadTag.h> // PROGMEM tags readable by the ButtLoad project
#include <LUFA/Drivers/Misc/TerminalCodes.h> // ANSI Terminal Escape Codes #include <LUFA/Drivers/Misc/TerminalCodes.h> // ANSI Terminal Escape Codes
#include <LUFA/Drivers/USB/USB.h> // USB Functionality #include <LUFA/Drivers/USB/USB.h> // USB Functionality
#include <LUFA/Drivers/AT90USBXXX/Serial_Stream.h> // Serial stream driver #include <LUFA/Drivers/AT90USBXXX/Serial_Stream.h> // Serial stream driver

@ -88,7 +88,7 @@ static uint8_t MassStore_SendCommand(void)
return ErrorCode; return ErrorCode;
/* Send the data in the OUT pipe to the attached device */ /* Send the data in the OUT pipe to the attached device */
Pipe_ClearCurrentBank(); Pipe_ClearOUT();
/* Some buggy devices require a delay here before the pipe freezing or they will lock up */ /* Some buggy devices require a delay here before the pipe freezing or they will lock up */
USB_Host_WaitMS(1); USB_Host_WaitMS(1);
@ -117,7 +117,7 @@ static uint8_t MassStore_WaitForDataReceived(void)
Pipe_Unfreeze(); Pipe_Unfreeze();
/* Wait until data received in the IN pipe */ /* Wait until data received in the IN pipe */
while (!(Pipe_ReadWriteAllowed())) while (!(Pipe_IsINReceived()))
{ {
/* Check to see if a new frame has been issued (1ms elapsed) */ /* Check to see if a new frame has been issued (1ms elapsed) */
if (USB_INT_HasOccurred(USB_INT_HSOFI)) if (USB_INT_HasOccurred(USB_INT_HSOFI))
@ -183,6 +183,9 @@ static uint8_t MassStore_SendReceiveData(void* BufferPtr)
/* Read in the block data from the pipe */ /* Read in the block data from the pipe */
if ((ErrorCode = Pipe_Read_Stream_LE(BufferPtr, BytesRem)) != PIPE_RWSTREAM_ERROR_NoError) if ((ErrorCode = Pipe_Read_Stream_LE(BufferPtr, BytesRem)) != PIPE_RWSTREAM_ERROR_NoError)
return ErrorCode; return ErrorCode;
/* Acknowledge the packet */
Pipe_ClearIN();
} }
else else
{ {
@ -193,10 +196,10 @@ static uint8_t MassStore_SendReceiveData(void* BufferPtr)
/* Write the block data to the pipe */ /* Write the block data to the pipe */
if ((ErrorCode = Pipe_Write_Stream_LE(BufferPtr, BytesRem)) != PIPE_RWSTREAM_ERROR_NoError) if ((ErrorCode = Pipe_Write_Stream_LE(BufferPtr, BytesRem)) != PIPE_RWSTREAM_ERROR_NoError)
return ErrorCode; return ErrorCode;
}
/* Acknowledge the packet */ /* Acknowledge the packet */
Pipe_ClearCurrentBank(); Pipe_ClearOUT();
}
/* Some buggy devices require a delay here before the pipe freezing or they will lock up */ /* Some buggy devices require a delay here before the pipe freezing or they will lock up */
USB_Host_WaitMS(1); USB_Host_WaitMS(1);
@ -216,8 +219,8 @@ static uint8_t MassStore_GetReturnedStatus(void)
uint8_t ErrorCode = PIPE_RWSTREAM_ERROR_NoError; uint8_t ErrorCode = PIPE_RWSTREAM_ERROR_NoError;
/* If an error in the command ocurred, abort */ /* If an error in the command ocurred, abort */
if (MassStore_WaitForDataReceived() != NoError) if ((ErrorCode == MassStore_WaitForDataReceived()) != PIPE_RWSTREAM_ERROR_NoError)
return; return ErrorCode;
/* Select the IN data pipe for data reception */ /* Select the IN data pipe for data reception */
Pipe_SelectPipe(MASS_STORE_DATA_IN_PIPE); Pipe_SelectPipe(MASS_STORE_DATA_IN_PIPE);
@ -228,7 +231,7 @@ static uint8_t MassStore_GetReturnedStatus(void)
return ErrorCode; return ErrorCode;
/* Clear the data ready for next reception */ /* Clear the data ready for next reception */
Pipe_ClearCurrentBank(); Pipe_ClearIN();
/* Some buggy devices require a delay here before the pipe freezing or they will lock up */ /* Some buggy devices require a delay here before the pipe freezing or they will lock up */
USB_Host_WaitMS(1); USB_Host_WaitMS(1);

@ -38,7 +38,6 @@
/* Includes: */ /* Includes: */
#include <LUFA/Drivers/USB/USB.h> // USB Functionality #include <LUFA/Drivers/USB/USB.h> // USB Functionality
#include <LUFA/Drivers/USB/Class/ConfigDescriptor.h> // Configuration Descriptor Parser
#include "MouseHost.h" #include "MouseHost.h"

@ -36,12 +36,6 @@
#include "MouseHost.h" #include "MouseHost.h"
/* Project Tags, for reading out using the ButtLoad project */
BUTTLOADTAG(ProjName, "LUFA Mouse Host App");
BUTTLOADTAG(BuildTime, __TIME__);
BUTTLOADTAG(BuildDate, __DATE__);
BUTTLOADTAG(LUFAVersion, "LUFA V" LUFA_VERSION_STRING);
/* Scheduler Task List */ /* Scheduler Task List */
TASK_LIST TASK_LIST
{ {
@ -188,27 +182,27 @@ void ReadNextReport(void)
Pipe_SelectPipe(MOUSE_DATAPIPE); Pipe_SelectPipe(MOUSE_DATAPIPE);
#if !defined(INTERRUPT_DATA_PIPE) #if !defined(INTERRUPT_DATA_PIPE)
/* Unfreeze mouse data pipe */ /* Unfreeze keyboard data pipe */
Pipe_Unfreeze(); Pipe_Unfreeze();
#endif #endif
/* Ensure pipe contains data and is ready to be read before continuing */ /* Check to see if a packet has been received */
if (!(Pipe_ReadWriteAllowed())) if (!(Pipe_IsINReceived()))
{ {
#if !defined(INTERRUPT_DATA_PIPE) #if !defined(INTERRUPT_DATA_PIPE)
/* Refreeze mouse data pipe */ /* Refreeze HID data IN pipe */
Pipe_Freeze(); Pipe_Freeze();
#endif #endif
return; return;
} }
/* Ensure pipe contains data before trying to read from it */
if (Pipe_IsReadWriteAllowed())
{
/* Read in mouse report data */ /* Read in mouse report data */
Pipe_Read_Stream_LE(&MouseReport, sizeof(MouseReport)); Pipe_Read_Stream_LE(&MouseReport, sizeof(MouseReport));
/* Clear the IN endpoint, ready for next data packet */
Pipe_ClearCurrentBank();
/* Alter status LEDs according to mouse X movement */ /* Alter status LEDs according to mouse X movement */
if (MouseReport.X > 0) if (MouseReport.X > 0)
LEDMask |= LEDS_LED1; LEDMask |= LEDS_LED1;
@ -231,6 +225,10 @@ void ReadNextReport(void)
printf_P(PSTR("dX:%2d dY:%2d Button:%d\r\n"), MouseReport.X, printf_P(PSTR("dX:%2d dY:%2d Button:%d\r\n"), MouseReport.X,
MouseReport.Y, MouseReport.Y,
MouseReport.Button); MouseReport.Button);
}
/* Clear the IN endpoint, ready for next data packet */
Pipe_ClearIN();
#if !defined(INTERRUPT_DATA_PIPE) #if !defined(INTERRUPT_DATA_PIPE)
/* Refreeze mouse data pipe */ /* Refreeze mouse data pipe */

@ -45,7 +45,6 @@
#include <stdio.h> #include <stdio.h>
#include <LUFA/Version.h> // Library Version Information #include <LUFA/Version.h> // Library Version Information
#include <LUFA/Common/ButtLoadTag.h> // PROGMEM tags readable by the ButtLoad project
#include <LUFA/Drivers/Misc/TerminalCodes.h> // ANSI Terminal Escape Codes #include <LUFA/Drivers/Misc/TerminalCodes.h> // ANSI Terminal Escape Codes
#include <LUFA/Drivers/USB/USB.h> // USB Functionality #include <LUFA/Drivers/USB/USB.h> // USB Functionality
#include <LUFA/Drivers/AT90USBXXX/Serial_Stream.h> // Serial stream driver #include <LUFA/Drivers/AT90USBXXX/Serial_Stream.h> // Serial stream driver

@ -38,7 +38,6 @@
/* Includes: */ /* Includes: */
#include <LUFA/Drivers/USB/USB.h> // USB Functionality #include <LUFA/Drivers/USB/USB.h> // USB Functionality
#include <LUFA/Drivers/USB/Class/ConfigDescriptor.h> // Configuration Descriptor Parser
#include "HIDReport.h" #include "HIDReport.h"

@ -37,7 +37,7 @@
#define _HID_REPORT_H_ #define _HID_REPORT_H_
/* Includes: */ /* Includes: */
#include <LUFA/Drivers/USB/Class/HIDParser.h> // HID Class Report Parser #include <LUFA/Drivers/USB/USB.h> // HID Class Report Parser
#include "MouseHostWithParser.h" #include "MouseHostWithParser.h"

@ -36,12 +36,6 @@
#include "MouseHostWithParser.h" #include "MouseHostWithParser.h"
/* Project Tags, for reading out using the ButtLoad project */
BUTTLOADTAG(ProjName, "LUFA Mouse Host App");
BUTTLOADTAG(BuildTime, __TIME__);
BUTTLOADTAG(BuildDate, __DATE__);
BUTTLOADTAG(LUFAVersion, "LUFA V" LUFA_VERSION_STRING);
/* Scheduler Task List */ /* Scheduler Task List */
TASK_LIST TASK_LIST
{ {
@ -271,19 +265,40 @@ TASK(USB_Mouse_Host)
Pipe_SelectPipe(MOUSE_DATAPIPE); Pipe_SelectPipe(MOUSE_DATAPIPE);
Pipe_Unfreeze(); Pipe_Unfreeze();
/* Check to see if a packet has been received */
if (Pipe_IsINReceived())
{
/* Check if data has been received from the attached mouse */ /* Check if data has been received from the attached mouse */
if (Pipe_ReadWriteAllowed()) if (Pipe_IsReadWriteAllowed())
{ {
uint8_t LEDMask = LEDS_NO_LEDS;
/* Create buffer big enough for the report */ /* Create buffer big enough for the report */
uint8_t MouseReport[Pipe_BytesInPipe()]; uint8_t MouseReport[Pipe_BytesInPipe()];
/* Load in the mouse report */ /* Load in the mouse report */
Pipe_Read_Stream_LE(MouseReport, Pipe_BytesInPipe()); Pipe_Read_Stream_LE(MouseReport, Pipe_BytesInPipe());
/* Process the read in mouse report from the device */
ProcessMouseReport(MouseReport);
}
/* Clear the IN endpoint, ready for next data packet */ /* Clear the IN endpoint, ready for next data packet */
Pipe_ClearCurrentBank(); Pipe_ClearIN();
}
/* Freeze mouse data pipe */
Pipe_Freeze();
break;
}
}
/** Processes a read HID report from an attached mouse, extracting out elements via the HID parser results
* as required and displays movement and button presses on the board LEDs.
*
* \param MouseReport Pointer to a HID report from an attached mouse device
*/
void ProcessMouseReport(uint8_t* MouseReport)
{
uint8_t LEDMask = LEDS_NO_LEDS;
/* Check each HID report item in turn, looking for mouse X/Y/button reports */ /* Check each HID report item in turn, looking for mouse X/Y/button reports */
for (uint8_t ReportNumber = 0; ReportNumber < HIDReportInfo.TotalReportItems; ReportNumber++) for (uint8_t ReportNumber = 0; ReportNumber < HIDReportInfo.TotalReportItems; ReportNumber++)
@ -345,10 +360,3 @@ TASK(USB_Mouse_Host)
/* Display the button information on the board LEDs */ /* Display the button information on the board LEDs */
LEDs_SetAllLEDs(LEDMask); LEDs_SetAllLEDs(LEDMask);
} }
/* Freeze mouse data pipe */
Pipe_Freeze();
break;
}
}

@ -39,7 +39,6 @@
#include <stdio.h> #include <stdio.h>
#include <LUFA/Version.h> // Library Version Information #include <LUFA/Version.h> // Library Version Information
#include <LUFA/Common/ButtLoadTag.h> // PROGMEM tags readable by the ButtLoad project
#include <LUFA/Drivers/Misc/TerminalCodes.h> // ANSI Terminal Escape Codes #include <LUFA/Drivers/Misc/TerminalCodes.h> // ANSI Terminal Escape Codes
#include <LUFA/Drivers/USB/USB.h> // USB Functionality #include <LUFA/Drivers/USB/USB.h> // USB Functionality
#include <LUFA/Drivers/AT90USBXXX/Serial_Stream.h> // Serial stream driver #include <LUFA/Drivers/AT90USBXXX/Serial_Stream.h> // Serial stream driver
@ -77,5 +76,6 @@
/* Function Prototypes: */ /* Function Prototypes: */
void UpdateStatus(uint8_t CurrentStatus); void UpdateStatus(uint8_t CurrentStatus);
void ProcessMouseReport(uint8_t* MouseReport);
#endif #endif

@ -38,7 +38,6 @@
/* Includes: */ /* Includes: */
#include <LUFA/Drivers/USB/USB.h> // USB Functionality #include <LUFA/Drivers/USB/USB.h> // USB Functionality
#include <LUFA/Drivers/USB/Class/ConfigDescriptor.h> // Configuration Descriptor Parser
#include "StillImageHost.h" #include "StillImageHost.h"

@ -72,7 +72,7 @@ void SImage_SendBlockHeader(void)
} }
/* Send the PIMA command block to the attached device */ /* Send the PIMA command block to the attached device */
Pipe_ClearCurrentBank(); Pipe_ClearOUT();
} }
/* Freeze pipe after use */ /* Freeze pipe after use */
@ -90,7 +90,7 @@ void SImage_RecieveEventHeader(void)
Pipe_Read_Stream_LE(&PIMA_EventBlock, sizeof(PIMA_EventBlock)); Pipe_Read_Stream_LE(&PIMA_EventBlock, sizeof(PIMA_EventBlock));
/* Clear the pipe after read complete to prepare for next event */ /* Clear the pipe after read complete to prepare for next event */
Pipe_ClearCurrentBank(); Pipe_ClearIN();
/* Freeze the event pipe again after use */ /* Freeze the event pipe again after use */
Pipe_Freeze(); Pipe_Freeze();
@ -106,7 +106,7 @@ uint8_t SImage_RecieveBlockHeader(void)
Pipe_Unfreeze(); Pipe_Unfreeze();
/* Wait until data received on the IN pipe */ /* Wait until data received on the IN pipe */
while (!(Pipe_ReadWriteAllowed())) while (!(Pipe_IsReadWriteAllowed()))
{ {
/* Check to see if a new frame has been issued (1ms elapsed) */ /* Check to see if a new frame has been issued (1ms elapsed) */
if (USB_INT_HasOccurred(USB_INT_HSOFI)) if (USB_INT_HasOccurred(USB_INT_HSOFI))
@ -179,7 +179,7 @@ uint8_t SImage_RecieveBlockHeader(void)
} }
/* Clear pipe bank after use */ /* Clear pipe bank after use */
Pipe_ClearCurrentBank(); Pipe_ClearIN();
} }
/* Freeze the IN pipe after use */ /* Freeze the IN pipe after use */
@ -203,7 +203,7 @@ void SImage_SendData(void* Buffer, uint16_t Bytes)
Pipe_Write_Stream_LE(Buffer, Bytes); Pipe_Write_Stream_LE(Buffer, Bytes);
/* Send the last packet to the attached device */ /* Send the last packet to the attached device */
Pipe_ClearCurrentBank(); Pipe_ClearOUT();
/* Freeze the pipe again after use */ /* Freeze the pipe again after use */
Pipe_Freeze(); Pipe_Freeze();

@ -36,11 +36,6 @@
#include "StillImageHost.h" #include "StillImageHost.h"
/* Project Tags, for reading out using the ButtLoad project */
BUTTLOADTAG(ProjName, "LUFA SIMG Host App");
BUTTLOADTAG(BuildTime, __TIME__);
BUTTLOADTAG(BuildDate, __DATE__);
/* Scheduler Task List */ /* Scheduler Task List */
TASK_LIST TASK_LIST
{ {
@ -243,7 +238,7 @@ TASK(USB_SImage_Host)
SImage_ReadData(DeviceInfo, DeviceInfoSize); SImage_ReadData(DeviceInfo, DeviceInfoSize);
/* Once all the data has been read, the pipe must be cleared before the response can be sent */ /* Once all the data has been read, the pipe must be cleared before the response can be sent */
Pipe_ClearCurrentBank(); Pipe_ClearIN();
/* Create a pointer for walking through the info dataset */ /* Create a pointer for walking through the info dataset */
uint8_t* DeviceInfoPos = DeviceInfo; uint8_t* DeviceInfoPos = DeviceInfo;

@ -46,7 +46,6 @@
#include "PIMACodes.h" #include "PIMACodes.h"
#include "StillImageCommands.h" #include "StillImageCommands.h"
#include <LUFA/Common/ButtLoadTag.h> // PROGMEM tags readable by the ButtLoad project
#include <LUFA/Drivers/Misc/TerminalCodes.h> // ANSI Terminal Escape Codes #include <LUFA/Drivers/Misc/TerminalCodes.h> // ANSI Terminal Escape Codes
#include <LUFA/Drivers/USB/USB.h> // USB Functionality #include <LUFA/Drivers/USB/USB.h> // USB Functionality
#include <LUFA/Drivers/AT90USBXXX/Serial_Stream.h> // Serial stream driver #include <LUFA/Drivers/AT90USBXXX/Serial_Stream.h> // Serial stream driver

@ -36,12 +36,6 @@
#include "TestApp.h" #include "TestApp.h"
/* Project Tags, for reading out using the ButtLoad project */
BUTTLOADTAG(ProjName, "LUFA Test App");
BUTTLOADTAG(BuildTime, __TIME__);
BUTTLOADTAG(BuildDate, __DATE__);
BUTTLOADTAG(LUFAVersion, "LUFA V" LUFA_VERSION_STRING);
/* Scheduler Task List */ /* Scheduler Task List */
TASK_LIST TASK_LIST
{ {

@ -46,7 +46,6 @@
#include <LUFA/Drivers/USB/USB.h> // USB Functionality #include <LUFA/Drivers/USB/USB.h> // USB Functionality
#include <LUFA/Scheduler/Scheduler.h> // Simple scheduler for task management #include <LUFA/Scheduler/Scheduler.h> // Simple scheduler for task management
#include <LUFA/MemoryAllocator/DynAlloc.h> // Auto-defragmenting Dynamic Memory allocation #include <LUFA/MemoryAllocator/DynAlloc.h> // Auto-defragmenting Dynamic Memory allocation
#include <LUFA/Common/ButtLoadTag.h> // PROGMEM tags readable by the ButtLoad project
#include <LUFA/Drivers/Misc/TerminalCodes.h> // ANSI Terminal Escape Codes #include <LUFA/Drivers/Misc/TerminalCodes.h> // ANSI Terminal Escape Codes
#include <LUFA/Drivers/AT90USBXXX/ADC.h> // ADC driver #include <LUFA/Drivers/AT90USBXXX/ADC.h> // ADC driver
#include <LUFA/Drivers/AT90USBXXX/Serial_Stream.h> // USART Stream driver #include <LUFA/Drivers/AT90USBXXX/Serial_Stream.h> // USART Stream driver

File diff suppressed because one or more lines are too long

@ -34,7 +34,20 @@
* - The USB_Host_SendControlRequest() function no longer automatically selects the Control pipe (pipe 0), so that other control type * - The USB_Host_SendControlRequest() function no longer automatically selects the Control pipe (pipe 0), so that other control type
* pipes can be used with the function * pipes can be used with the function
* - The USB Host management task now saves and restores the currently selected pipe before and after the task completes * - The USB Host management task now saves and restores the currently selected pipe before and after the task completes
* - Fixed GenericHIDHost demo report write routine incorrect for control type requests (thanks to Andrei) * - Fixed GenericHIDHost demo report write routine incorrect for control type requests (thanks to Andrei Krainev)
* - Removed Endpoint_ClearCurrentBank() and Pipe_ClearCurrentBank() in favour of new Endpoint_ClearIN(), Endpoint_ClearOUT(),
* Endpoint_ClearControlIN(), Endpoint_ClearControlOUT(), Pipe_ClearIN(), Pipe_ClearOUT(), Pipe_ClearControlIN() and
* Pipe_ClearControlOUT() macros (done to allow for the detection of packets of zero length)
* - Renamed *_ReadWriteAllowed() macros to *_IsReadWriteAllowed() to remain consistent with the rest of the LUFA API
* - Endpoint_IsSetupReceived() macro has been renamed to Endpoint_IsSETUPReceived(), Endpoint_ClearSetupReceived() macro has been
* renamed to Endpoint_ClearControlSETUP(), the Pipe_IsSetupSent() macro has been renamed to Pipe_IsSETUPSent() and the
* Pipe_ClearSetupSent() macro is no longer applicable and should be removed - changes made to compliment the new endpoint and pipe
* bank management API
* - Updated all demos, bootloaders and projects to use the new endpoint and pipe management APIs (thanks to Roman Thiel)
* - Updated library doxygen documentation, added groups, changed documentation macro functions to real functions for clarity
* - Removed old endpoint and pipe aliased read/write/discard routines which did not have an explicit endian specifier for clarity
* - Removed the ButtLoadTag.h header file, as no one used for its intended purpose anyway
*
* *
* \section Sec_ChangeLog090401 Version 090401 * \section Sec_ChangeLog090401 Version 090401
* *

@ -37,6 +37,15 @@
* functionality. * functionality.
*/ */
/** \ingroup Group_Common
* @defgroup Group_BoardTypes Board Types
*
* Macros for indicating the chosen physical board hardware to the library. These macros should be used when
* defining the BOARD token to the chosen hardware via the -D switch in the project makefile.
*
* @{
*/
#ifndef __BOARDTYPES_H__ #ifndef __BOARDTYPES_H__
#define __BOARDTYPES_H__ #define __BOARDTYPES_H__
@ -70,3 +79,5 @@
#define BOARD_USER 5 #define BOARD_USER 5
#endif #endif
/** @} */

@ -1,77 +0,0 @@
/*
LUFA Library
Copyright (C) Dean Camera, 2009.
dean [at] fourwalledcubicle [dot] com
www.fourwalledcubicle.com
*/
/*
Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)
Permission to use, copy, modify, and distribute this software
and its documentation for any purpose and without fee is hereby
granted, provided that the above copyright notice appear in all
copies and that both that the copyright notice and this
permission notice and warranty disclaimer appear in supporting
documentation, and that the name of the author not be used in
advertising or publicity pertaining to distribution of the
software without specific, written prior permission.
The author disclaim all warranties with regard to this
software, including all implied warranties of merchantability
and fitness. In no event shall the author be liable for any
special, indirect or consequential damages or any damages
whatsoever resulting from loss of use, data or profits, whether
in an action of contract, negligence or other tortious action,
arising out of or in connection with the use or performance of
this software.
*/
/** \file
*
* This file contains macros for the embedding of compile-time strings into the resultant project binary for
* identification purposes. It is designed to prefix "tags" with the magic string of "@(#)" so that the tags
* can easily be identified in the binary data.
*
* These tags are compatible with the ButtLoad project at http://www.fourwalledcubicle.com/ButtLoad.php .
*/
#ifndef __BUTTLOADTAG_H__
#define __BUTTLOADTAG_H__
/* Includes: */
#include <avr/io.h>
#include <avr/pgmspace.h>
/* Public Interface - May be used in end-application: */
/* Macros: */
/** Creates a new tag in the resultant binary, containing the specified data array. The macro id
* parameter is only for identification purposes (so that the tag data can be referenced in code)
* and is not visible in the compiled binary.
*/
#define BUTTLOADTAG(id, data) const struct ButtLoadTagData BUTTTAG_##id \
PROGMEM __attribute__((used, externally_visible)) = \
{MagicString: BT_TAGHEADER, TagData: data}
/** Macro for retrieving a reference to the specified tag's contents. The tag data is located in
* the program memory (FLASH) space, and so must be read out with the macros in avr-libc which
* deal with embedded data.
*/
#define BUTTLOADTAG_DATA(id) BUTTTAG_##id.TagData
/* Structures: */
/** Structure for ButtLoad compatible binary tags. */
struct ButtLoadTagData
{
char MagicString[4]; /**< Magic tag header, containing the string "@(#)". */
char TagData[]; /**< Tag contents as a char array. */
};
/* Private Interface - For use in library only: */
#if !defined(__DOXYGEN__)
/* Macros: */
#define BT_TAGHEADER {'@','(','#',')'}
#endif
#endif

@ -34,6 +34,24 @@
* also includes other common headers, such as Atomic.h, FunctionAttributes.h and BoardTypes.h. * also includes other common headers, such as Atomic.h, FunctionAttributes.h and BoardTypes.h.
*/ */
/** @defgroup Group_Common Common Utility Headers - LUFA/Drivers/Common/Common.h
*
* Common utility headers containing macros, functions, enums and types which are common to all
* aspects of the library.
*
* @{
*/
/** @defgroup Group_Debugging Debugging Macros
*
* Macros for debugging use.
*/
/** @defgroup Group_BitManip Endian and Bit Macros
*
* Functions for swapping endianness and reversing bit orders.
*/
#ifndef __COMMON_H__ #ifndef __COMMON_H__
#define __COMMON_H__ #define __COMMON_H__
@ -66,14 +84,22 @@
/** Defines a volatile NOP statement which cannot be optimized out by the compiler, and thus can always /** Defines a volatile NOP statement which cannot be optimized out by the compiler, and thus can always
* be set as a breakpoint in the resulting code. Useful for debugging purposes, where the optimizer * be set as a breakpoint in the resulting code. Useful for debugging purposes, where the optimizer
* removes/reorders code to the point where break points cannot reliably be set. * removes/reorders code to the point where break points cannot reliably be set.
*
* \ingroup Group_Debugging
*/ */
#define JTAG_DEBUG_POINT() asm volatile ("NOP" ::) #define JTAG_DEBUG_POINT() asm volatile ("NOP" ::)
/** Defines an explicit JTAG break point in the resulting binary via the ASM BREAK statement. When /** Defines an explicit JTAG break point in the resulting binary via the ASM BREAK statement. When
* a JTAG is used, this causes the program execution to halt when reached until manually resumed. */ * a JTAG is used, this causes the program execution to halt when reached until manually resumed.
*
* \ingroup Group_Debugging
*/
#define JTAG_DEBUG_BREAK() asm volatile ("BREAK" ::) #define JTAG_DEBUG_BREAK() asm volatile ("BREAK" ::)
/** Macro for testing condition "x" and breaking via JTAG_DEBUG_BREAK() if the condition is false. */ /** Macro for testing condition "x" and breaking via JTAG_DEBUG_BREAK() if the condition is false.
*
* \ingroup Group_Debugging
*/
#define JTAG_DEBUG_ASSERT(x) MACROS{ if (!(x)) { JTAG_DEBUG_BREAK(); } }MACROE #define JTAG_DEBUG_ASSERT(x) MACROS{ if (!(x)) { JTAG_DEBUG_BREAK(); } }MACROE
/** Macro for testing condition "x" and writing debug data to the serial stream if false. As a /** Macro for testing condition "x" and writing debug data to the serial stream if false. As a
@ -81,6 +107,8 @@
* *
* The serial output takes the form "{FILENAME}: Function {FUNCTION NAME}, Line {LINE NUMBER}: Assertion * The serial output takes the form "{FILENAME}: Function {FUNCTION NAME}, Line {LINE NUMBER}: Assertion
* {x} failed." * {x} failed."
*
* \ingroup Group_Debugging
*/ */
#define SERIAL_STREAM_ASSERT(x) MACROS{ if (!(x)) { printf_P(PSTR("%s: Function \"%s\", Line %d: " \ #define SERIAL_STREAM_ASSERT(x) MACROS{ if (!(x)) { printf_P(PSTR("%s: Function \"%s\", Line %d: " \
"Assertion \"%s\" failed.\r\n"), \ "Assertion \"%s\" failed.\r\n"), \
@ -91,6 +119,8 @@
/** Function to reverse the individual bits in a byte - i.e. bit 7 is moved to bit 0, bit 6 to bit 1, /** Function to reverse the individual bits in a byte - i.e. bit 7 is moved to bit 0, bit 6 to bit 1,
* etc. * etc.
* *
* \ingroup Group_BitManip
*
* \param Byte Byte of data whose bits are to be reversed * \param Byte Byte of data whose bits are to be reversed
*/ */
static inline uint8_t BitReverse(uint8_t Byte) ATTR_WARN_UNUSED_RESULT ATTR_CONST; static inline uint8_t BitReverse(uint8_t Byte) ATTR_WARN_UNUSED_RESULT ATTR_CONST;
@ -104,6 +134,8 @@
} }
/** Function to reverse the byte ordering of the individual bytes in a 16 bit number. /** Function to reverse the byte ordering of the individual bytes in a 16 bit number.
*
* \ingroup Group_BitManip
* *
* \param Word Word of data whose bytes are to be swapped * \param Word Word of data whose bytes are to be swapped
*/ */
@ -114,6 +146,8 @@
} }
/** Function to reverse the byte ordering of the individual bytes in a 32 bit number. /** Function to reverse the byte ordering of the individual bytes in a 32 bit number.
*
* \ingroup Group_BitManip
* *
* \param DWord Double word of data whose bytes are to be swapped * \param DWord Double word of data whose bytes are to be swapped
*/ */
@ -127,6 +161,8 @@
} }
/** Function to reverse the byte ordering of the individual bytes in a n byte number. /** Function to reverse the byte ordering of the individual bytes in a n byte number.
*
* \ingroup Group_BitManip
* *
* \param Data Pointer to a number containing an even number of bytes to be reversed * \param Data Pointer to a number containing an even number of bytes to be reversed
* \param Bytes Length of the data in bytes * \param Bytes Length of the data in bytes
@ -148,3 +184,5 @@
} }
#endif #endif
/** @} */

@ -38,6 +38,14 @@
* functionality. * functionality.
*/ */
/** \ingroup Group_Common
* @defgroup Group_FuncAttr Function Attributes
*
* Macros for easy access GCC function attributes, which can be applied to function prototypes.
*
* @{
*/
#ifndef __FUNCATTR_H__ #ifndef __FUNCATTR_H__
#define __FUNCATTR_H__ #define __FUNCATTR_H__
@ -108,3 +116,5 @@
#define ATTR_ALIAS(x) __attribute__ ((alias( #x ))) #define ATTR_ALIAS(x) __attribute__ ((alias( #x )))
#endif #endif
/** @} */

@ -408,7 +408,7 @@ SORT_BRIEF_DOCS = NO
# hierarchy of group names into alphabetical order. If set to NO (the default) # hierarchy of group names into alphabetical order. If set to NO (the default)
# the group names will appear in their defined order. # the group names will appear in their defined order.
SORT_GROUP_NAMES = NO SORT_GROUP_NAMES = YES
# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be # If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be
# sorted by fully-qualified names, including namespaces. If set to # sorted by fully-qualified names, including namespaces. If set to
@ -607,7 +607,7 @@ EXCLUDE_SYMLINKS = NO
# against the file with absolute path, so to exclude all test directories # against the file with absolute path, so to exclude all test directories
# for example use the pattern */test/* # for example use the pattern */test/*
EXCLUDE_PATTERNS = */LowLevel/USBMode.h EXCLUDE_PATTERNS =
# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names # The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names
# (namespaces, classes, functions, etc.) that should be excluded from the # (namespaces, classes, functions, etc.) that should be excluded from the
@ -936,7 +936,7 @@ GENERATE_TREEVIEW = YES
# used to set the initial width (in pixels) of the frame in which the tree # used to set the initial width (in pixels) of the frame in which the tree
# is shown. # is shown.
TREEVIEW_WIDTH = 250 TREEVIEW_WIDTH = 300
# Use this tag to change the font size of Latex formulas included # Use this tag to change the font size of Latex formulas included
# as images in the HTML documentation. The default is 10. Note that # as images in the HTML documentation. The default is 10. Note that
@ -1228,7 +1228,7 @@ PREDEFINED = __DOXYGEN__
# The macro definition that is found in the sources will be used. # The macro definition that is found in the sources will be used.
# Use the PREDEFINED tag if you want to use a different macro definition. # Use the PREDEFINED tag if you want to use a different macro definition.
EXPAND_AS_DEFINED = BUTTLOADTAG EXPAND_AS_DEFINED =
# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then # If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then
# doxygen's preprocessor will remove all function-like macros that are alone # doxygen's preprocessor will remove all function-like macros that are alone
@ -1356,7 +1356,7 @@ COLLABORATION_GRAPH = NO
# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen # If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen
# will generate a graph for groups, showing the direct groups dependencies # will generate a graph for groups, showing the direct groups dependencies
GROUP_GRAPHS = NO GROUP_GRAPHS = YES
# If the UML_LOOK tag is set to YES doxygen will generate inheritance and # If the UML_LOOK tag is set to YES doxygen will generate inheritance and
# collaboration diagrams in a style similar to the OMG's Unified Modeling # collaboration diagrams in a style similar to the OMG's Unified Modeling
@ -1374,14 +1374,14 @@ TEMPLATE_RELATIONS = NO
# file showing the direct and indirect include dependencies of the file with # file showing the direct and indirect include dependencies of the file with
# other documented files. # other documented files.
INCLUDE_GRAPH = NO INCLUDE_GRAPH = YES
# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and # If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and
# HAVE_DOT tags are set to YES then doxygen will generate a graph for each # HAVE_DOT tags are set to YES then doxygen will generate a graph for each
# documented header file showing the documented files that directly or # documented header file showing the documented files that directly or
# indirectly include this file. # indirectly include this file.
INCLUDED_BY_GRAPH = NO INCLUDED_BY_GRAPH = YES
# If the CALL_GRAPH and HAVE_DOT options are set to YES then # If the CALL_GRAPH and HAVE_DOT options are set to YES then
# doxygen will generate a call dependency graph for every global function # doxygen will generate a call dependency graph for every global function
@ -1389,7 +1389,7 @@ INCLUDED_BY_GRAPH = NO
# the time of a run. So in most cases it will be better to enable call graphs # the time of a run. So in most cases it will be better to enable call graphs
# for selected functions only using the \callgraph command. # for selected functions only using the \callgraph command.
CALL_GRAPH = NO CALL_GRAPH = YES
# If the CALLER_GRAPH and HAVE_DOT tags are set to YES then # If the CALLER_GRAPH and HAVE_DOT tags are set to YES then
# doxygen will generate a caller dependency graph for every global function # doxygen will generate a caller dependency graph for every global function
@ -1409,7 +1409,7 @@ GRAPHICAL_HIERARCHY = NO
# in a graphical way. The dependency relations are determined by the #include # in a graphical way. The dependency relations are determined by the #include
# relations between the files in the directories. # relations between the files in the directories.
DIRECTORY_GRAPH = NO DIRECTORY_GRAPH = YES
# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images # The DOT_IMAGE_FORMAT tag can be used to set the image format of the images
# generated by dot. Possible values are png, jpg, or gif # generated by dot. Possible values are png, jpg, or gif

@ -36,6 +36,10 @@
* currently selected AVR model. * currently selected AVR model.
*/ */
/** \ingroup Group_SubsystemDrivers
* @defgroup Group_ADC ADC Driver - LUFA/Drivers/AT90USBXXX/ADC.h
*/
#ifndef __ADC_H__ #ifndef __ADC_H__
#define __ADC_H__ #define __ADC_H__
@ -55,4 +59,29 @@
#error "ADC is not available for the currently selected AVR model." #error "ADC is not available for the currently selected AVR model."
#endif #endif
/* Public Interface - May be used in end-application: */
/* Inline Functions: */
/** Starts the reading of the given channel, but does not wait until the conversion has completed.
* Once executed, the conversion status can be determined via the ADC_IsReadingComplete() macro and
* the result read via the ADC_GetResult() macro.
*
* \param MUXMask Mask comprising of an ADC channel number, reference mask and adjustment mask
*/
static inline void ADC_StartReading(const uint8_t MUXMask);
/** Performs a complete single reading from channel, including a polling spinloop to wait for the
* conversion to complete, and the returning of the converted value.
*
* \param MUXMask Mask comprising of an ADC channel number, reference mask and adjustment mask
*/
static inline uint16_t ADC_GetChannelReading(const uint8_t MUXMask) ATTR_WARN_UNUSED_RESULT;
/** Configures the given ADC channel, ready for ADC conversions. This function sets the
* associated port pin as an input and disables the digital portion of the I/O to reduce
* power consumption.
*
* \param Channel ADC channel number to set up for conversions
*/
static inline void ADC_SetupChannel(const uint8_t Channel);
#endif #endif

@ -36,15 +36,21 @@
* dispatch header located in LUFA/Drivers/AT90USBXXX/ADC.h. * dispatch header located in LUFA/Drivers/AT90USBXXX/ADC.h.
*/ */
/** \ingroup Group_ADC
* @defgroup Group_ADC_AT90USBXXX67 AT90USBXXX6 and AT90USBXXX7 Models
*
* @{
*/
#ifndef __ADC_AT90USBXXX67_H__ #ifndef __ADC_AT90USBXXX67_H__
#define __ADC_AT90USBXXX67_H__ #define __ADC_AT90USBXXX67_H__
/* Includes: */ /* Includes: */
#include "../../../Common/Common.h"
#include <avr/io.h> #include <avr/io.h>
#include <stdbool.h> #include <stdbool.h>
#include "../../../Common/Common.h"
/* Enable C linkage for C++ Compilers: */ /* Enable C linkage for C++ Compilers: */
#if defined(__cplusplus) #if defined(__cplusplus)
extern "C" { extern "C" {
@ -175,3 +181,5 @@
#endif #endif
#endif #endif
/** @} */

@ -33,6 +33,14 @@
* Hardware SPI subsystem driver for the supported USB AVRs models. * Hardware SPI subsystem driver for the supported USB AVRs models.
*/ */
/** \ingroup Group_SubsystemDrivers
* @defgroup Group_SPI SPI Driver - LUFA/Drivers/AT90USBXXX/SPI.h
*
* Functions, macros, variables, enums and types related to the setup of a the SPI port.
*
* @{
*/
#ifndef __SPI_H__ #ifndef __SPI_H__
#define __SPI_H__ #define __SPI_H__
@ -137,3 +145,5 @@
#endif #endif
#endif #endif
/** @} */

@ -33,6 +33,14 @@
* Driver for the USART subsystem on supported USB AVRs. * Driver for the USART subsystem on supported USB AVRs.
*/ */
/** \ingroup Group_SubsystemDrivers
* @defgroup Group_Serial Serial USART Driver - LUFA/Drivers/AT90USBXXX/Serial.h
*
* Functions, macros, variables, enums and types related to the setup of the USART for serial communications.
*
* @{
*/
#ifndef __SERIAL_H__ #ifndef __SERIAL_H__
#define __SERIAL_H__ #define __SERIAL_H__
@ -113,3 +121,5 @@
#endif #endif
#endif #endif
/** @} */

@ -35,6 +35,15 @@
* USART. * USART.
**/ **/
/** \ingroup Group_SubsystemDrivers
* @defgroup Group_SerialStream Serial Stream Driver - LUFA/Drivers/AT90USBXXX/Serial_Stream.h
*
* Functions, macros, variables, enums and types related to the setup of a serial stream, so that standard printf and other
* C stream functions can be used on the serial port.
*
* @{
*/
#ifndef __SERIAL_STREAM_H__ #ifndef __SERIAL_STREAM_H__
#define __SERIAL_STREAM_H__ #define __SERIAL_STREAM_H__
@ -80,3 +89,5 @@
#endif #endif
#endif #endif
/** @} */

@ -36,6 +36,12 @@
* dispatch header located in LUFA/Drivers/Board/HWB.h. * dispatch header located in LUFA/Drivers/Board/HWB.h.
*/ */
/** \ingroup Group_HWB
* @defgroup Group_HWB_ATAVRUSBRF01 ATAVRUSBRF01
*
* @{
*/
#ifndef __HWB_ATAVRUSBRF01_H__ #ifndef __HWB_ATAVRUSBRF01_H__
#define __HWB_ATAVRUSBRF01_H__ #define __HWB_ATAVRUSBRF01_H__
@ -77,3 +83,5 @@
#endif #endif
#endif #endif
/** @} */

@ -36,6 +36,12 @@
* dispatch header located in LUFA/Drivers/Board/LEDs.h. * dispatch header located in LUFA/Drivers/Board/LEDs.h.
*/ */
/** \ingroup Group_LEDs
* @defgroup Group_LEDs_ATAVRUSBRF01 ATAVRUSBRF01
*
* @{
*/
#ifndef __LEDS_ATAVRUSBRF01_H__ #ifndef __LEDS_ATAVRUSBRF01_H__
#define __LEDS_ATAVRUSBRF01_H__ #define __LEDS_ATAVRUSBRF01_H__
@ -118,3 +124,5 @@
#endif #endif
#endif #endif
/** @} */

@ -40,6 +40,14 @@
* directory. * directory.
*/ */
/** \ingroup Group_BoardDrivers
* @defgroup Group_Dataflash Dataflash Driver - LUFA/Drivers/Board/Dataflash.h
*
* Functions, macros, variables, enums and types related to the control of board Dataflash ICs.
*
* @{
*/
#ifndef __DATAFLASH_H__ #ifndef __DATAFLASH_H__
#define __DATAFLASH_H__ #define __DATAFLASH_H__
@ -59,20 +67,32 @@
#endif #endif
/* Public Interface - May be used in end-application: */ /* Public Interface - May be used in end-application: */
/* Macros: */ /* Psuedo-Function Macros: */
/** Returns the mask of the currently selected Dataflash chip, either DATAFLASH_NO_CHIP or a #if defined(__DOXYGEN__)
* DATAFLASH_CHIPn mask (where n is the chip number). /** Determines the currently selected dataflash chip.
*
* \return Mask of the currently selected Dataflash chip, either DATAFLASH_NO_CHIP if no chip is selected
* or a DATAFLASH_CHIPn mask (where n is the chip number).
*/ */
#define Dataflash_GetSelectedChip() (DATAFLASH_CHIPCS_PORT & DATAFLASH_CHIPCS_MASK) static inline uint8_t Dataflash_GetSelectedChip(void);
/** Selects the dataflash chip given as a chip mask, in the form of DATAFLASH_CHIPn (where n /** Selects the given dataflash chip.
* is the chip number). *
* \param ChipMask Mask of the Dataflash IC to select, in the form of DATAFLASH_CHIPn mask (where n is
* the chip number).
*/ */
static inline void Dataflash_SelectChip(uint8_t ChipMask);
/** Deselects the current dataflash chip, so that no dataflash is selected. */
static inline void Dataflash_DeselectChip(void);
#else
#define Dataflash_GetSelectedChip() (DATAFLASH_CHIPCS_PORT & DATAFLASH_CHIPCS_MASK)
#define Dataflash_SelectChip(mask) MACROS{ DATAFLASH_CHIPCS_PORT = ((DATAFLASH_CHIPCS_PORT \ #define Dataflash_SelectChip(mask) MACROS{ DATAFLASH_CHIPCS_PORT = ((DATAFLASH_CHIPCS_PORT \
& ~DATAFLASH_CHIPCS_MASK) | mask); }MACROE & ~DATAFLASH_CHIPCS_MASK) | mask); }MACROE
/** Deselects the current dataflash chip, so that no dataflash is selected. */
#define Dataflash_DeselectChip() Dataflash_SelectChip(DATAFLASH_NO_CHIP) #define Dataflash_DeselectChip() Dataflash_SelectChip(DATAFLASH_NO_CHIP)
#endif
/* Inline Functions: */ /* Inline Functions: */
/** Sends a byte to the currently selected dataflash IC, and returns a byte from the dataflash. /** Sends a byte to the currently selected dataflash IC, and returns a byte from the dataflash.
@ -182,3 +202,5 @@
#endif #endif
#endif #endif
/** @} */

@ -40,6 +40,14 @@
* directory. * directory.
*/ */
/** \ingroup Group_BoardDrivers
* @defgroup Group_HWB HWB Driver - LUFA/Drivers/Board/HWB.h
*
* Functions, macros, variables, enums and types related to the control of board HWB.
*
* @{
*/
#ifndef __HWB_H__ #ifndef __HWB_H__
#define __HWB_H__ #define __HWB_H__
@ -85,3 +93,5 @@
#endif #endif
#endif #endif
/** @} */

@ -40,6 +40,14 @@
* directory. * directory.
*/ */
/** \ingroup Group_BoardDrivers
* @defgroup Group_Joystick Joystick Driver - LUFA/Drivers/Board/Joystick.h
*
* Functions, macros, variables, enums and types related to the control of board joystick.
*
* @{
*/
#ifndef __JOYSTICK_H__ #ifndef __JOYSTICK_H__
#define __JOYSTICK_H__ #define __JOYSTICK_H__
@ -83,3 +91,5 @@
#endif #endif
#endif #endif
/** @} */

@ -40,6 +40,14 @@
* directory. * directory.
*/ */
/** \ingroup Group_BoardDrivers
* @defgroup Group_LEDs LEDs Driver - LUFA/Drivers/Board/LEDs.h
*
* Functions, macros, variables, enums and types related to the control of board LEDs.
*
* @{
*/
#ifndef __LEDS_H__ #ifndef __LEDS_H__
#define __LEDS_H__ #define __LEDS_H__
@ -111,3 +119,5 @@
#endif #endif
#endif #endif
/** @} */

@ -36,6 +36,12 @@
* dispatch header located in LUFA/Drivers/Board/LEDs.h. * dispatch header located in LUFA/Drivers/Board/LEDs.h.
*/ */
/** \ingroup Group_LEDs
* @defgroup Group_LEDs_RZUSBSTICK RZUSBSTICK
*
* @{
*/
#ifndef __LEDS_RZUSBSTICK_H__ #ifndef __LEDS_RZUSBSTICK_H__
#define __LEDS_RZUSBSTICK_H__ #define __LEDS_RZUSBSTICK_H__
@ -139,3 +145,5 @@
#endif #endif
#endif #endif
/** @} */

@ -36,6 +36,12 @@
* dispatch header located in LUFA/Drivers/Board/Dataflash.h. * dispatch header located in LUFA/Drivers/Board/Dataflash.h.
*/ */
/** \ingroup Group_Dataflash_STK525
* @defgroup Group_Dataflash_STK525_AT45DB321C AT45DB321C
*
* @{
*/
#ifndef __DATAFLASH_CMDS_H__ #ifndef __DATAFLASH_CMDS_H__
#define __DATAFLASH_CMDS_H__ #define __DATAFLASH_CMDS_H__
@ -82,3 +88,5 @@
#define DF_CMD_READMANUFACTURERDEVICEINFO 0x9F #define DF_CMD_READMANUFACTURERDEVICEINFO 0x9F
#endif #endif
/** @} */

@ -36,6 +36,12 @@
* dispatch header located in LUFA/Drivers/Board/Dataflash.h. * dispatch header located in LUFA/Drivers/Board/Dataflash.h.
*/ */
/** \ingroup Group_Dataflash
* @defgroup Group_Dataflash_STK525 STK525
*
* @{
*/
#ifndef __DATAFLASH_STK525_H__ #ifndef __DATAFLASH_STK525_H__
#define __DATAFLASH_STK525_H__ #define __DATAFLASH_STK525_H__
@ -106,3 +112,5 @@
} }
#endif #endif
/** @} */

@ -36,6 +36,12 @@
* dispatch header located in LUFA/Drivers/Board/HWB.h. * dispatch header located in LUFA/Drivers/Board/HWB.h.
*/ */
/** \ingroup Group_HWB
* @defgroup Group_HWB_STK525 STK525
*
* @{
*/
#ifndef __HWB_STK525_H__ #ifndef __HWB_STK525_H__
#define __HWB_STK525_H__ #define __HWB_STK525_H__
@ -77,3 +83,5 @@
#endif #endif
#endif #endif
/** @} */

@ -36,6 +36,12 @@
* dispatch header located in LUFA/Drivers/Board/Joystick.h. * dispatch header located in LUFA/Drivers/Board/Joystick.h.
*/ */
/** \ingroup Group_Joystick
* @defgroup Group_Joystick_STK525 STK525
*
* @{
*/
#ifndef __JOYSTICK_STK525_H__ #ifndef __JOYSTICK_STK525_H__
#define __JOYSTICK_STK525_H__ #define __JOYSTICK_STK525_H__
@ -102,3 +108,5 @@
#endif #endif
#endif #endif
/** @} */

@ -36,6 +36,12 @@
* dispatch header located in LUFA/Drivers/Board/LEDs.h. * dispatch header located in LUFA/Drivers/Board/LEDs.h.
*/ */
/** \ingroup Group_LEDs
* @defgroup Group_LEDs_STK525 STK525
*
* @{
*/
#ifndef __LEDS_STK525_H__ #ifndef __LEDS_STK525_H__
#define __LEDS_STK525_H__ #define __LEDS_STK525_H__
@ -115,3 +121,5 @@
#endif #endif
#endif #endif
/** @} */

@ -36,6 +36,12 @@
* dispatch header located in LUFA/Drivers/Board/Dataflash.h. * dispatch header located in LUFA/Drivers/Board/Dataflash.h.
*/ */
/** \ingroup Group_Dataflash_STK526
* @defgroup Group_Dataflash_STK526_AT45DB642D AT45DB642D
*
* @{
*/
#ifndef __DATAFLASH_CMDS_H__ #ifndef __DATAFLASH_CMDS_H__
#define __DATAFLASH_CMDS_H__ #define __DATAFLASH_CMDS_H__
@ -92,3 +98,5 @@
#define DF_CMD_READMANUFACTURERDEVICEINFO 0x9F #define DF_CMD_READMANUFACTURERDEVICEINFO 0x9F
#endif #endif
/** @} */

@ -36,6 +36,12 @@
* dispatch header located in LUFA/Drivers/Board/Dataflash.h. * dispatch header located in LUFA/Drivers/Board/Dataflash.h.
*/ */
/** \ingroup Group_Dataflash
* @defgroup Group_Dataflash_STK526 STK526
*
* @{
*/
#ifndef __DATAFLASH_STK526_H__ #ifndef __DATAFLASH_STK526_H__
#define __DATAFLASH_STK526_H__ #define __DATAFLASH_STK526_H__
@ -106,3 +112,5 @@
} }
#endif #endif
/** @} */

@ -36,6 +36,12 @@
* dispatch header located in LUFA/Drivers/Board/HWB.h. * dispatch header located in LUFA/Drivers/Board/HWB.h.
*/ */
/** \ingroup Group_HWB
* @defgroup Group_HWB_STK526 STK526
*
* @{
*/
#ifndef __HWB_STK526_H__ #ifndef __HWB_STK526_H__
#define __HWB_STK526_H__ #define __HWB_STK526_H__
@ -77,3 +83,5 @@
#endif #endif
#endif #endif
/** @} */

@ -36,6 +36,12 @@
* dispatch header located in LUFA/Drivers/Board/Joystick.h. * dispatch header located in LUFA/Drivers/Board/Joystick.h.
*/ */
/** \ingroup Group_Joystick
* @defgroup Group_Joystick_STK526 STK526
*
* @{
*/
#ifndef __JOYSTICK_STK526_H__ #ifndef __JOYSTICK_STK526_H__
#define __JOYSTICK_STK526_H__ #define __JOYSTICK_STK526_H__
@ -99,3 +105,5 @@
#endif #endif
#endif #endif
/** @} */

@ -36,6 +36,12 @@
* dispatch header located in LUFA/Drivers/Board/LEDs.h. * dispatch header located in LUFA/Drivers/Board/LEDs.h.
*/ */
/** \ingroup Group_LEDs
* @defgroup Group_LEDs_STK526 STK526
*
* @{
*/
#ifndef __LEDS_STK526_H__ #ifndef __LEDS_STK526_H__
#define __LEDS_STK526_H__ #define __LEDS_STK526_H__
@ -115,3 +121,5 @@
#endif #endif
#endif #endif
/** @} */

@ -33,6 +33,14 @@
* Temperature sensor board driver for the USB boards which contain a temperature sensor. * Temperature sensor board driver for the USB boards which contain a temperature sensor.
*/ */
/** \ingroup Group_BoardDrivers
* @defgroup Group_Temperature Temperature Driver - LUFA/Drivers/Board/Temperature.h
*
* Functions, macros, variables, enums and types related to the control of board temperature sensors.
*
* @{
*/
#ifndef __TEMPERATURE_H__ #ifndef __TEMPERATURE_H__
#define __TEMPERATURE_H__ #define __TEMPERATURE_H__
@ -69,13 +77,18 @@
/** Maximum returnable temperature from the Temperature_GetTemperature() function. */ /** Maximum returnable temperature from the Temperature_GetTemperature() function. */
#define TEMP_MAX_TEMP ((TEMP_TABLE_SIZE - 1) + TEMP_TABLE_OFFSET) #define TEMP_MAX_TEMP ((TEMP_TABLE_SIZE - 1) + TEMP_TABLE_OFFSET)
/* Psuedo-Functions: */
#if defined(__DOXYGEN__)
/** Initializes the temperature sensor driver, including setting up the appropriate ADC channel. /** Initializes the temperature sensor driver, including setting up the appropriate ADC channel.
* This must be called before any other temperature sensor routines. * This must be called before any other temperature sensor routines.
* *
* The ADC itself (not the ADC channel) must be configured separately before calling the temperature * The ADC itself (not the ADC channel) must be configured separately before calling the temperature
* sensor functions. * sensor functions.
*/ */
static inline void Temperature_Init(void);
#else
#define Temperature_Init() ADC_SetupChannel(TEMP_ADC_CHANNEL); #define Temperature_Init() ADC_SetupChannel(TEMP_ADC_CHANNEL);
#endif
/* Function Prototypes: */ /* Function Prototypes: */
/** Performs a complete ADC on the temperature sensor channel, and converts the result into a /** Performs a complete ADC on the temperature sensor channel, and converts the result into a
@ -98,3 +111,5 @@
#endif #endif
#endif #endif
/** @} */

@ -36,6 +36,12 @@
* dispatch header located in LUFA/Drivers/Board/Dataflash.h. * dispatch header located in LUFA/Drivers/Board/Dataflash.h.
*/ */
/** \ingroup Group_Dataflash_USBKEY
* @defgroup Group_Dataflash_USBKEY_AT45DB642D AT45DB642D
*
* @{
*/
#ifndef __DATAFLASH_CMDS_H__ #ifndef __DATAFLASH_CMDS_H__
#define __DATAFLASH_CMDS_H__ #define __DATAFLASH_CMDS_H__
@ -92,3 +98,5 @@
#define DF_CMD_READMANUFACTURERDEVICEINFO 0x9F #define DF_CMD_READMANUFACTURERDEVICEINFO 0x9F
#endif #endif
/** @} */

@ -36,6 +36,12 @@
* dispatch header located in LUFA/Drivers/Board/Dataflash.h. * dispatch header located in LUFA/Drivers/Board/Dataflash.h.
*/ */
/** \ingroup Group_Dataflash
* @defgroup Group_Dataflash_USBKEY USBKEY
*
* @{
*/
#ifndef __DATAFLASH_USBKEY_H__ #ifndef __DATAFLASH_USBKEY_H__
#define __DATAFLASH_USBKEY_H__ #define __DATAFLASH_USBKEY_H__
@ -114,3 +120,5 @@
} }
#endif #endif
/** @} */

@ -36,6 +36,12 @@
* dispatch header located in LUFA/Drivers/Board/HWB.h. * dispatch header located in LUFA/Drivers/Board/HWB.h.
*/ */
/** \ingroup Group_HWB
* @defgroup Group_HWB_USBKEY USBKEY
*
* @{
*/
#ifndef __HWB_USBKEY_H__ #ifndef __HWB_USBKEY_H__
#define __HWB_USBKEY_H__ #define __HWB_USBKEY_H__
@ -77,3 +83,5 @@
#endif #endif
#endif #endif
/** @} */

@ -36,6 +36,12 @@
* dispatch header located in LUFA/Drivers/Board/Joystick.h. * dispatch header located in LUFA/Drivers/Board/Joystick.h.
*/ */
/** \ingroup Group_Joystick
* @defgroup Group_Joystick_USBKEY USBKEY
*
* @{
*/
#ifndef __JOYSTICK_USBKEY_H__ #ifndef __JOYSTICK_USBKEY_H__
#define __JOYSTICK_USBKEY_H__ #define __JOYSTICK_USBKEY_H__
@ -102,3 +108,5 @@
#endif #endif
#endif #endif
/** @} */

@ -36,6 +36,12 @@
* dispatch header located in LUFA/Drivers/Board/LEDs.h. * dispatch header located in LUFA/Drivers/Board/LEDs.h.
*/ */
/** \ingroup Group_LEDs
* @defgroup Group_LEDs_USBKEY USBKEY
*
* @{
*/
#ifndef __LEDS_USBKEY_H__ #ifndef __LEDS_USBKEY_H__
#define __LEDS_USBKEY_H__ #define __LEDS_USBKEY_H__
@ -115,3 +121,5 @@
#endif #endif
#endif #endif
/** @} */

@ -43,6 +43,14 @@
* \endcode * \endcode
*/ */
/** \ingroup Group_MiscDrivers
* @defgroup Group_Terminal ANSI Terminal Escape Codes - LUFA/Drivers/Misc/TerminalCodes.h
*
* Escape code macros for ANSI compliant text terminals.
*
* @{
*/
#ifndef __TERMINALCODES_H__ #ifndef __TERMINALCODES_H__
#define __TERMINALCODES_H__ #define __TERMINALCODES_H__
@ -174,3 +182,5 @@
#define ESC_ERASE_LINE ANSI_ESCAPE_SEQUENCE("K") #define ESC_ERASE_LINE ANSI_ESCAPE_SEQUENCE("K")
#endif #endif
/** @} */

@ -35,6 +35,14 @@
* and other descriptor data can be extracted and used as needed. * and other descriptor data can be extracted and used as needed.
*/ */
/** \ingroup Group_Descriptors
* @defgroup Group_ConfigDescriptorParser Configuration Descriptor Parser
*
* Functions, macros, variables, enums and types related to the parsing of Configuration Descriptors.
*
* @{
*/
#ifndef __CONFIGDESCRIPTOR_H__ #ifndef __CONFIGDESCRIPTOR_H__
#define __CONFIGDESCRIPTOR_H__ #define __CONFIGDESCRIPTOR_H__
@ -109,7 +117,7 @@
* for certain descriptors matching unique criteria. * for certain descriptors matching unique criteria.
* *
* Comparator routines are passed in a single pointer named CurrentDescriptor, and should return a value * Comparator routines are passed in a single pointer named CurrentDescriptor, and should return a value
* of a member of the DSEARCH_Return_ErrorCodes_t enum. * of a member of the DSearch_Return_ErrorCodes_t enum.
*/ */
#define DESCRIPTOR_COMPARATOR(name) uint8_t DCOMP_##name (void* const CurrentDescriptor) #define DESCRIPTOR_COMPARATOR(name) uint8_t DCOMP_##name (void* const CurrentDescriptor)
@ -124,7 +132,7 @@
* \param DPos Pointer to the current position in the configuration descriptor * \param DPos Pointer to the current position in the configuration descriptor
* \param DSearch Name of the comparator search function to use on the configuration descriptor * \param DSearch Name of the comparator search function to use on the configuration descriptor
* *
* \return Value of one of the members of the DSEARCH_Comp_Return_ErrorCodes_t enum * \return Value of one of the members of the DSearch_Comp_Return_ErrorCodes_t enum
* *
* Usage Example: * Usage Example:
* \code * \code
@ -151,7 +159,7 @@
USB_Host_GetNextDescriptorComp_P(DSize, DPos, DCOMP_##DSearch) USB_Host_GetNextDescriptorComp_P(DSize, DPos, DCOMP_##DSearch)
/* Enums: */ /* Enums: */
/** Enum for return values of a descriptor comparator made with DESCRIPTOR_COMPARATOR. */ /** Enum for return values of a descriptor comparator made with DESCRIPTOR_COMPARATOR. */
enum DSEARCH_Return_ErrorCodes_t enum DSearch_Return_ErrorCodes_t
{ {
Descriptor_Search_Found = 0, /**< Current descriptor matches comparator criteria. */ Descriptor_Search_Found = 0, /**< Current descriptor matches comparator criteria. */
Descriptor_Search_Fail = 1, /**< No further descriptor could possibly match criteria, fail the search. */ Descriptor_Search_Fail = 1, /**< No further descriptor could possibly match criteria, fail the search. */
@ -159,7 +167,7 @@
}; };
/** Enum for return values of USB_Host_GetNextDescriptorComp() */ /** Enum for return values of USB_Host_GetNextDescriptorComp() */
enum DSEARCH_Comp_Return_ErrorCodes_t enum DSearch_Comp_Return_ErrorCodes_t
{ {
Descriptor_Search_Comp_Found = 0, /**< Configuration descriptor now points to descriptor which matches Descriptor_Search_Comp_Found = 0, /**< Configuration descriptor now points to descriptor which matches
* search criteria of the given comparator function. */ * search criteria of the given comparator function. */
@ -261,3 +269,5 @@
#endif #endif
#endif #endif
/** @} */

@ -45,6 +45,14 @@
* switch. * switch.
*/ */
/** \ingroup Group_USB
* @defgroup Group_HIDParser HID Report Parser
*
* Functions, macros, variables, enums and types related to the parsing of HID class device report descriptors.
*
* @{
*/
#ifndef __HIDPARSER_H__ #ifndef __HIDPARSER_H__
#define __HIDPARSER_H__ #define __HIDPARSER_H__
@ -250,3 +258,5 @@
#endif #endif
#endif #endif
/** @} */

@ -34,6 +34,14 @@
* flag's meaning when applied to an IN, OUT or FEATURE item. * flag's meaning when applied to an IN, OUT or FEATURE item.
*/ */
/** \ingroup Group_HIDParser
* @defgroup Group_HIDIOFConst Input/Output/Feature Masks
*
* Masks indicating the type of Input, Output of Feature HID report item.
*
* @{
*/
#ifndef __HIDREPORTDATA_H__ #ifndef __HIDREPORTDATA_H__
#define __HIDREPORTDATA_H__ #define __HIDREPORTDATA_H__
@ -127,4 +135,6 @@
#define TAG_LOCAL_USAGEMAX 0x20 #define TAG_LOCAL_USAGEMAX 0x20
#endif #endif
/** @} */
#endif #endif

@ -40,6 +40,14 @@
* Each event must only have one associated event handler, but can be raised by multiple sources. * Each event must only have one associated event handler, but can be raised by multiple sources.
*/ */
/** \ingroup Group_USB
* @defgroup Group_Events USB Events
*
* Functions, macros, variables, enums and types related to the management of events from the USB kernel.
*
* @{
*/
#ifndef __USBEVENTS_H__ #ifndef __USBEVENTS_H__
#define __USBEVENTS_H__ #define __USBEVENTS_H__
@ -438,3 +446,5 @@
#endif #endif
#endif #endif
/** @} */

@ -44,6 +44,14 @@
* named counterparts, thus they can be correlated easily with the official USB specification. * named counterparts, thus they can be correlated easily with the official USB specification.
*/ */
/** \ingroup Group_USB
* @defgroup Group_Descriptors USB Descriptors
*
* Functions, macros, variables, enums and types related to standard USB descriptors.
*
* @{
*/
#ifndef __USBDESCRIPTORS_H__ #ifndef __USBDESCRIPTORS_H__
#define __USBDESCRIPTORS_H__ #define __USBDESCRIPTORS_H__
@ -473,12 +481,6 @@
#endif #endif
} USB_Descriptor_String_t; } USB_Descriptor_String_t;
typedef struct
{
uint16_t Size;
void* Address;
} USB_Descriptor_Details_t;
/* Function Prototypes: */ /* Function Prototypes: */
/** Function to retrieve a given descriptor's size and memory location from the given descriptor type value, /** Function to retrieve a given descriptor's size and memory location from the given descriptor type value,
* index and language ID. This function MUST be overridden in the user application (added with full, identical * index and language ID. This function MUST be overridden in the user application (added with full, identical
@ -521,3 +523,5 @@
#endif #endif
#endif #endif
/** @} */

@ -34,6 +34,14 @@
* direction, request recipient, etc.) can be extracted via masking. * direction, request recipient, etc.) can be extracted via masking.
*/ */
/** \ingroup Group_USB
* @defgroup Group_StdRequest Standard USB Requests
*
* Functions, macros, variables, enums and types related to standard USB requests to USB devices.
*
* @{
*/
#ifndef __STDREQTYPE_H__ #ifndef __STDREQTYPE_H__
#define __STDREQTYPE_H__ #define __STDREQTYPE_H__
@ -189,3 +197,5 @@
#endif #endif
#endif #endif
/** @} */

@ -35,6 +35,14 @@
* stream read/write process. * stream read/write process.
*/ */
/** \ingroup Group_USB
* @defgroup Group_StreamCallbacks Endpoint and Pipe Stream Callbacks
*
* Functions, macros, variables, enums and types related to endpoint and pipe stream callback functions.
*
* @{
*/
#ifndef __STREAMCALLBACK_H__ #ifndef __STREAMCALLBACK_H__
#define __STREAMCALLBACK_H__ #define __STREAMCALLBACK_H__
@ -85,3 +93,5 @@
}; };
#endif #endif
/** @} */

@ -34,6 +34,14 @@
* events as VBUS interrupts (on supported USB AVR models), device connections and disconnections, etc. * events as VBUS interrupts (on supported USB AVR models), device connections and disconnections, etc.
*/ */
/** \ingroup Group_USB
* @defgroup Group_USBInterrupt Endpoint and Pipe Interrupts
*
* Functions, macros, variables, enums and types related to endpoint and pipe interrupts.
*
* @{
*/
#ifndef __USBINTERRUPT_H__ #ifndef __USBINTERRUPT_H__
#define __USBINTERRUPT_H__ #define __USBINTERRUPT_H__
@ -222,3 +230,5 @@
#endif #endif
#endif #endif
/** @} */

@ -64,7 +64,7 @@ static void USB_DeviceTask(void)
Endpoint_SelectEndpoint(ENDPOINT_CONTROLEP); Endpoint_SelectEndpoint(ENDPOINT_CONTROLEP);
if (Endpoint_IsSetupReceived()) if (Endpoint_IsSETUPReceived())
{ {
ATOMIC_BLOCK(ATOMIC_RESTORESTATE) ATOMIC_BLOCK(ATOMIC_RESTORESTATE)
{ {

@ -73,6 +73,8 @@
* needs to be determined, VBUS should be routed to an external pin, and the auto-detect behaviour turned off by * needs to be determined, VBUS should be routed to an external pin, and the auto-detect behaviour turned off by
* passing the NO_LIMITED_CONTROLLER_CONNECT token to the compiler via the -D switch at compile time. The connection * passing the NO_LIMITED_CONTROLLER_CONNECT token to the compiler via the -D switch at compile time. The connection
* and disconnection events may be manually fired by RAISE_EVENT(), and the USB_IsConnected global changed manually. * and disconnection events may be manually fired by RAISE_EVENT(), and the USB_IsConnected global changed manually.
*
* \ingroup Group_USBManagement
*/ */
extern volatile bool USB_IsConnected; extern volatile bool USB_IsConnected;
@ -81,6 +83,8 @@
* *
* \note This variable should be treated as read-only in the user application, and never manually * \note This variable should be treated as read-only in the user application, and never manually
* changed in value. * changed in value.
*
* \ingroup Group_USBManagement
*/ */
extern volatile bool USB_IsInitialized; extern volatile bool USB_IsInitialized;
@ -94,6 +98,8 @@
* *
* \note This variable should be treated as read-only in the user application, and never manually * \note This variable should be treated as read-only in the user application, and never manually
* changed in value. * changed in value.
*
* \ingroup Group_Device
*/ */
extern volatile bool USB_IsSuspended; extern volatile bool USB_IsSuspended;
#endif #endif
@ -107,6 +113,8 @@
* by the library. * by the library.
* *
* \note This global is only present if the user application can be a USB host. * \note This global is only present if the user application can be a USB host.
*
* \ingroup Group_Host
*/ */
extern volatile uint8_t USB_HostState; extern volatile uint8_t USB_HostState;
#endif #endif
@ -173,6 +181,8 @@
* event and disabled again on the firing of the USB_DeviceUnattached event. * event and disabled again on the firing of the USB_DeviceUnattached event.
* *
* \see Events.h for more information on the USB events. * \see Events.h for more information on the USB events.
*
* \ingroup Group_USBManagement
*/ */
TASK(USB_USBTask); TASK(USB_USBTask);

@ -105,10 +105,10 @@ void USB_Device_ProcessControlPacket(void)
if (!(RequestHandled)) if (!(RequestHandled))
RAISE_EVENT(USB_UnhandledControlPacket, bRequest, bmRequestType); RAISE_EVENT(USB_UnhandledControlPacket, bRequest, bmRequestType);
if (Endpoint_IsSetupReceived()) if (Endpoint_IsSETUPReceived())
{ {
Endpoint_StallTransaction(); Endpoint_StallTransaction();
Endpoint_ClearSetupReceived(); Endpoint_ClearControlSETUP();
} }
} }
@ -116,13 +116,13 @@ static void USB_Device_SetAddress(void)
{ {
uint8_t wValue_LSB = Endpoint_Read_Byte(); uint8_t wValue_LSB = Endpoint_Read_Byte();
Endpoint_ClearSetupReceived(); Endpoint_ClearControlSETUP();
while (!(Endpoint_IsSetupINReady())); while (!(Endpoint_IsINReady()));
Endpoint_ClearSetupIN(); Endpoint_ClearControlIN();
while (!(Endpoint_IsSetupINReady())); while (!(Endpoint_IsINReady()));
UDADDR = ((1 << ADDEN) | (wValue_LSB & 0x7F)); UDADDR = ((1 << ADDEN) | (wValue_LSB & 0x7F));
@ -152,11 +152,11 @@ static void USB_Device_SetConfiguration(void)
return; return;
} }
Endpoint_ClearSetupReceived(); Endpoint_ClearControlSETUP();
USB_ConfigurationNumber = wValue_LSB; USB_ConfigurationNumber = wValue_LSB;
Endpoint_ClearSetupIN(); Endpoint_ClearControlIN();
if (!(AlreadyConfigured) && USB_ConfigurationNumber) if (!(AlreadyConfigured) && USB_ConfigurationNumber)
RAISE_EVENT(USB_DeviceEnumerationComplete); RAISE_EVENT(USB_DeviceEnumerationComplete);
@ -166,14 +166,14 @@ static void USB_Device_SetConfiguration(void)
void USB_Device_GetConfiguration(void) void USB_Device_GetConfiguration(void)
{ {
Endpoint_ClearSetupReceived(); Endpoint_ClearControlSETUP();
Endpoint_Write_Byte(USB_ConfigurationNumber); Endpoint_Write_Byte(USB_ConfigurationNumber);
Endpoint_ClearSetupIN(); Endpoint_ClearControlIN();
while (!(Endpoint_IsSetupOUTReceived())); while (!(Endpoint_IsOUTReceived()));
Endpoint_ClearSetupOUT(); Endpoint_ClearControlOUT();
} }
static void USB_Device_GetDescriptor(void) static void USB_Device_GetDescriptor(void)
@ -190,18 +190,18 @@ static void USB_Device_GetDescriptor(void)
if ((DescriptorSize = USB_GetDescriptor(wValue, wIndex, &DescriptorPointer)) == NO_DESCRIPTOR) if ((DescriptorSize = USB_GetDescriptor(wValue, wIndex, &DescriptorPointer)) == NO_DESCRIPTOR)
return; return;
Endpoint_ClearSetupReceived(); Endpoint_ClearControlSETUP();
if (wLength > DescriptorSize) if (wLength > DescriptorSize)
wLength = DescriptorSize; wLength = DescriptorSize;
while (wLength) while (wLength)
{ {
while (!(Endpoint_IsSetupINReady())) while (!(Endpoint_IsINReady()))
{ {
if (Endpoint_IsSetupOUTReceived()) if (Endpoint_IsOUTReceived())
{ {
Endpoint_ClearSetupOUT(); Endpoint_ClearControlOUT();
return; return;
} }
} }
@ -220,17 +220,17 @@ static void USB_Device_GetDescriptor(void)
} }
SendZLP = (Endpoint_BytesInEndpoint() == USB_ControlEndpointSize); SendZLP = (Endpoint_BytesInEndpoint() == USB_ControlEndpointSize);
Endpoint_ClearSetupIN(); Endpoint_ClearControlIN();
} }
if (SendZLP) if (SendZLP)
{ {
while (!(Endpoint_IsSetupINReady())); while (!(Endpoint_IsINReady()));
Endpoint_ClearSetupIN(); Endpoint_ClearControlIN();
} }
while (!(Endpoint_IsSetupOUTReceived())); while (!(Endpoint_IsOUTReceived()));
Endpoint_ClearSetupOUT(); Endpoint_ClearControlOUT();
} }
static void USB_Device_GetStatus(const uint8_t bmRequestType) static void USB_Device_GetStatus(const uint8_t bmRequestType)
@ -264,13 +264,14 @@ static void USB_Device_GetStatus(const uint8_t bmRequestType)
} }
Endpoint_SelectEndpoint(ENDPOINT_CONTROLEP); Endpoint_SelectEndpoint(ENDPOINT_CONTROLEP);
Endpoint_ClearSetupReceived(); Endpoint_ClearControlSETUP();
Endpoint_Write_Word_LE(CurrentStatus); Endpoint_Write_Word_LE(CurrentStatus);
Endpoint_ClearSetupIN(); Endpoint_ClearControlIN();
while (!(Endpoint_IsSetupOUTReceived())); while (!(Endpoint_IsOUTReceived()));
Endpoint_ClearSetupOUT(); Endpoint_ClearControlOUT();
} }
#if !defined(FEATURELESS_CONTROL_ONLY_DEVICE) #if !defined(FEATURELESS_CONTROL_ONLY_DEVICE)
@ -305,8 +306,8 @@ static void USB_Device_ClearSetFeature(const uint8_t bRequest, const uint8_t bmR
} }
Endpoint_SelectEndpoint(ENDPOINT_CONTROLEP); Endpoint_SelectEndpoint(ENDPOINT_CONTROLEP);
Endpoint_ClearSetupReceived(); Endpoint_ClearControlSETUP();
Endpoint_ClearSetupIN(); Endpoint_ClearControlIN();
} }
} }

@ -66,6 +66,8 @@
* *
* \note This variable should be treated as read-only in the user application, and never manually * \note This variable should be treated as read-only in the user application, and never manually
* changed in value. * changed in value.
*
* \ingroup Group_Device
*/ */
extern uint8_t USB_ConfigurationNumber; extern uint8_t USB_ConfigurationNumber;
@ -74,12 +76,16 @@
* *
* \note This variable should be treated as read-only in the user application, and never manually * \note This variable should be treated as read-only in the user application, and never manually
* changed in value. * changed in value.
*
* \ingroup Group_Device
*/ */
extern bool USB_RemoteWakeupEnabled; extern bool USB_RemoteWakeupEnabled;
/** Indicates if the device is currently being powered by its own power supply, rather than being /** Indicates if the device is currently being powered by its own power supply, rather than being
* powered by the host's USB supply. This flag should remain cleared if the device does not * powered by the host's USB supply. This flag should remain cleared if the device does not
* support self powered mode, as indicated in the device descriptors. * support self powered mode, as indicated in the device descriptors.
*
* \ingroup Group_Device
*/ */
extern bool USB_CurrentlySelfPowered; extern bool USB_CurrentlySelfPowered;

@ -34,6 +34,14 @@
* the USB controller is initialized in device mode. * the USB controller is initialized in device mode.
*/ */
/** \ingroup Group_USB
* @defgroup Group_Device Device Management
*
* Functions, macros, variables, enums and types related to the management of a USB device when in Device mode.
*
* @{
*/
#ifndef __USBDEVICE_H__ #ifndef __USBDEVICE_H__
#define __USBDEVICE_H__ #define __USBDEVICE_H__
@ -64,6 +72,8 @@
*/ */
#define USB_DEVICE_OPT_FULLSPEED (0 << 0) #define USB_DEVICE_OPT_FULLSPEED (0 << 0)
/* Psuedo-Function Macros: */
#if defined(__DOXYGEN__)
/** Sends a Remote Wakeup request to the host. This signals to the host that the device should /** Sends a Remote Wakeup request to the host. This signals to the host that the device should
* be taken out of suspended mode, and communications should resume. * be taken out of suspended mode, and communications should resume.
* *
@ -77,7 +87,7 @@
* *
* \see StdDescriptors.h for more information on the RMWAKEUP feature and device descriptors. * \see StdDescriptors.h for more information on the RMWAKEUP feature and device descriptors.
*/ */
#define USB_Device_SendRemoteWakeup() MACROS{ UDCON |= (1 << RMWKUP); }MACROE static inline void USB_Device_SendRemoteWakeup(void);
/** Indicates if a Remote Wakeup request is being sent to the host. This returns true if a /** Indicates if a Remote Wakeup request is being sent to the host. This returns true if a
* remote wakeup is currently being sent, false otherwise. * remote wakeup is currently being sent, false otherwise.
@ -89,17 +99,25 @@
* supports the Remote Wakeup feature in the device descriptors. * supports the Remote Wakeup feature in the device descriptors.
* *
* \see StdDescriptors.h for more information on the RMWAKEUP feature and device descriptors. * \see StdDescriptors.h for more information on the RMWAKEUP feature and device descriptors.
*
* \return Boolean true if no Remote Wakeup request is currently being sent, false otherwise
*/ */
#define USB_Device_IsRemoteWakeupSent() ((UDCON & (1 << RMWKUP)) ? false : true) static inline bool USB_Device_IsRemoteWakeupSent(void);
/** Indicates if the device is currently suspended by the host. While suspended, the device is /** Indicates if the device is currently suspended by the host. While suspended, the device is
* to enter a low power state until resumed by the host. While suspended no USB traffic to or * to enter a low power state until resumed by the host. While suspended no USB traffic to or
* from the device can occur (except for Remote Wakeup requests). * from the device can occur (except for Remote Wakeup requests).
* *
* This macro returns true if the USB communications have been suspended by the host, false * \return Boolean true if the USB communications have been suspended by the host, false otherwise.
* otherwise.
*/ */
static inline bool USB_Device_IsUSBSuspended(void);
#else
#define USB_Device_SendRemoteWakeup() MACROS{ UDCON |= (1 << RMWKUP); }MACROE
#define USB_Device_IsRemoteWakeupSent() ((UDCON & (1 << RMWKUP)) ? false : true)
#define USB_Device_IsUSBSuspended() ((UDINT & (1 << SUSPI)) ? true : false) #define USB_Device_IsUSBSuspended() ((UDINT & (1 << SUSPI)) ? true : false)
#endif
/* Enums: */ /* Enums: */
/** Enum for the ErrorCode parameter of the USB_DeviceError event. /** Enum for the ErrorCode parameter of the USB_DeviceError event.
@ -124,3 +142,5 @@
#endif #endif
#endif #endif
/** @} */

@ -88,8 +88,19 @@ uint8_t Endpoint_WaitUntilReady(void)
USB_INT_Clear(USB_INT_SOFI); USB_INT_Clear(USB_INT_SOFI);
while (!(Endpoint_ReadWriteAllowed())) for (;;)
{ {
if (Endpoint_GetEndpointDirection() == ENDPOINT_DIR_IN)
{
if (Endpoint_IsINReady())
return ENDPOINT_READYWAIT_NoError;
}
else
{
if (Endpoint_IsOUTReceived())
return ENDPOINT_READYWAIT_NoError;
}
if (!(USB_IsConnected)) if (!(USB_IsConnected))
return ENDPOINT_READYWAIT_DeviceDisconnected; return ENDPOINT_READYWAIT_DeviceDisconnected;
else if (Endpoint_IsStalled()) else if (Endpoint_IsStalled())
@ -103,8 +114,6 @@ uint8_t Endpoint_WaitUntilReady(void)
return ENDPOINT_READYWAIT_Timeout; return ENDPOINT_READYWAIT_Timeout;
} }
} }
return ENDPOINT_READYWAIT_NoError;
} }
uint8_t Endpoint_Discard_Stream(uint16_t Length uint8_t Endpoint_Discard_Stream(uint16_t Length
@ -120,9 +129,9 @@ uint8_t Endpoint_Discard_Stream(uint16_t Length
while (Length--) while (Length--)
{ {
if (!(Endpoint_ReadWriteAllowed())) if (!(Endpoint_IsReadWriteAllowed()))
{ {
Endpoint_ClearCurrentBank(); Endpoint_ClearOUT();
#if !defined(NO_STREAM_CALLBACKS) #if !defined(NO_STREAM_CALLBACKS)
if ((Callback != NULL) && (Callback() == STREAMCALLBACK_Abort)) if ((Callback != NULL) && (Callback() == STREAMCALLBACK_Abort))
@ -132,9 +141,11 @@ uint8_t Endpoint_Discard_Stream(uint16_t Length
if ((ErrorCode = Endpoint_WaitUntilReady())) if ((ErrorCode = Endpoint_WaitUntilReady()))
return ErrorCode; return ErrorCode;
} }
else
{
Endpoint_Discard_Byte(); Endpoint_Discard_Byte();
} }
}
return ENDPOINT_RWSTREAM_ERROR_NoError; return ENDPOINT_RWSTREAM_ERROR_NoError;
} }
@ -153,9 +164,9 @@ uint8_t Endpoint_Write_Stream_LE(const void* Buffer, uint16_t Length
while (Length--) while (Length--)
{ {
if (!(Endpoint_ReadWriteAllowed())) if (!(Endpoint_IsReadWriteAllowed()))
{ {
Endpoint_ClearCurrentBank(); Endpoint_ClearIN();
#if !defined(NO_STREAM_CALLBACKS) #if !defined(NO_STREAM_CALLBACKS)
if ((Callback != NULL) && (Callback() == STREAMCALLBACK_Abort)) if ((Callback != NULL) && (Callback() == STREAMCALLBACK_Abort))
@ -165,9 +176,11 @@ uint8_t Endpoint_Write_Stream_LE(const void* Buffer, uint16_t Length
if ((ErrorCode = Endpoint_WaitUntilReady())) if ((ErrorCode = Endpoint_WaitUntilReady()))
return ErrorCode; return ErrorCode;
} }
else
{
Endpoint_Write_Byte(*(DataStream++)); Endpoint_Write_Byte(*(DataStream++));
} }
}
return ENDPOINT_RWSTREAM_ERROR_NoError; return ENDPOINT_RWSTREAM_ERROR_NoError;
} }
@ -186,9 +199,9 @@ uint8_t Endpoint_Write_Stream_BE(const void* Buffer, uint16_t Length
while (Length--) while (Length--)
{ {
if (!(Endpoint_ReadWriteAllowed())) if (!(Endpoint_IsReadWriteAllowed()))
{ {
Endpoint_ClearCurrentBank(); Endpoint_ClearIN();
#if !defined(NO_STREAM_CALLBACKS) #if !defined(NO_STREAM_CALLBACKS)
if ((Callback != NULL) && (Callback() == STREAMCALLBACK_Abort)) if ((Callback != NULL) && (Callback() == STREAMCALLBACK_Abort))
@ -198,9 +211,11 @@ uint8_t Endpoint_Write_Stream_BE(const void* Buffer, uint16_t Length
if ((ErrorCode = Endpoint_WaitUntilReady())) if ((ErrorCode = Endpoint_WaitUntilReady()))
return ErrorCode; return ErrorCode;
} }
else
{
Endpoint_Write_Byte(*(DataStream--)); Endpoint_Write_Byte(*(DataStream--));
} }
}
return ENDPOINT_RWSTREAM_ERROR_NoError; return ENDPOINT_RWSTREAM_ERROR_NoError;
} }
@ -219,9 +234,9 @@ uint8_t Endpoint_Read_Stream_LE(void* Buffer, uint16_t Length
while (Length--) while (Length--)
{ {
if (!(Endpoint_ReadWriteAllowed())) if (!(Endpoint_IsReadWriteAllowed()))
{ {
Endpoint_ClearCurrentBank(); Endpoint_ClearOUT();
#if !defined(NO_STREAM_CALLBACKS) #if !defined(NO_STREAM_CALLBACKS)
if ((Callback != NULL) && (Callback() == STREAMCALLBACK_Abort)) if ((Callback != NULL) && (Callback() == STREAMCALLBACK_Abort))
@ -231,9 +246,11 @@ uint8_t Endpoint_Read_Stream_LE(void* Buffer, uint16_t Length
if ((ErrorCode = Endpoint_WaitUntilReady())) if ((ErrorCode = Endpoint_WaitUntilReady()))
return ErrorCode; return ErrorCode;
} }
else
{
*(DataStream++) = Endpoint_Read_Byte(); *(DataStream++) = Endpoint_Read_Byte();
} }
}
return ENDPOINT_RWSTREAM_ERROR_NoError; return ENDPOINT_RWSTREAM_ERROR_NoError;
} }
@ -252,9 +269,9 @@ uint8_t Endpoint_Read_Stream_BE(void* Buffer, uint16_t Length
while (Length--) while (Length--)
{ {
if (!(Endpoint_ReadWriteAllowed())) if (!(Endpoint_IsReadWriteAllowed()))
{ {
Endpoint_ClearCurrentBank(); Endpoint_ClearOUT();
#if !defined(NO_STREAM_CALLBACKS) #if !defined(NO_STREAM_CALLBACKS)
if ((Callback != NULL) && (Callback() == STREAMCALLBACK_Abort)) if ((Callback != NULL) && (Callback() == STREAMCALLBACK_Abort))
@ -264,9 +281,11 @@ uint8_t Endpoint_Read_Stream_BE(void* Buffer, uint16_t Length
if ((ErrorCode = Endpoint_WaitUntilReady())) if ((ErrorCode = Endpoint_WaitUntilReady()))
return ErrorCode; return ErrorCode;
} }
else
{
*(DataStream--) = Endpoint_Read_Byte(); *(DataStream--) = Endpoint_Read_Byte();
} }
}
return ENDPOINT_RWSTREAM_ERROR_NoError; return ENDPOINT_RWSTREAM_ERROR_NoError;
} }
@ -276,9 +295,9 @@ uint8_t Endpoint_Write_Control_Stream_LE(const void* Buffer, uint16_t Length)
uint8_t* DataStream = (uint8_t*)Buffer; uint8_t* DataStream = (uint8_t*)Buffer;
bool SendZLP = true; bool SendZLP = true;
while (Length && !(Endpoint_IsSetupOUTReceived())) while (Length && !(Endpoint_IsOUTReceived()))
{ {
while (!(Endpoint_IsSetupINReady())); while (!(Endpoint_IsINReady()));
while (Length && (Endpoint_BytesInEndpoint() < USB_ControlEndpointSize)) while (Length && (Endpoint_BytesInEndpoint() < USB_ControlEndpointSize))
{ {
@ -288,19 +307,19 @@ uint8_t Endpoint_Write_Control_Stream_LE(const void* Buffer, uint16_t Length)
} }
SendZLP = (Endpoint_BytesInEndpoint() == USB_ControlEndpointSize); SendZLP = (Endpoint_BytesInEndpoint() == USB_ControlEndpointSize);
Endpoint_ClearSetupIN(); Endpoint_ClearControlIN();
} }
if (Endpoint_IsSetupOUTReceived()) if (Endpoint_IsOUTReceived())
return ENDPOINT_RWCSTREAM_ERROR_HostAborted; return ENDPOINT_RWCSTREAM_ERROR_HostAborted;
if (SendZLP) if (SendZLP)
{ {
while (!(Endpoint_IsSetupINReady())); while (!(Endpoint_IsINReady()));
Endpoint_ClearSetupIN(); Endpoint_ClearControlIN();
} }
while (!(Endpoint_IsSetupOUTReceived())); while (!(Endpoint_IsOUTReceived()));
return ENDPOINT_RWCSTREAM_ERROR_NoError; return ENDPOINT_RWCSTREAM_ERROR_NoError;
} }
@ -310,9 +329,9 @@ uint8_t Endpoint_Write_Control_Stream_BE(const void* Buffer, uint16_t Length)
uint8_t* DataStream = (uint8_t*)(Buffer + Length - 1); uint8_t* DataStream = (uint8_t*)(Buffer + Length - 1);
bool SendZLP = true; bool SendZLP = true;
while (Length && !(Endpoint_IsSetupOUTReceived())) while (Length && !(Endpoint_IsOUTReceived()))
{ {
while (!(Endpoint_IsSetupINReady())); while (!(Endpoint_IsINReady()));
while (Length && (Endpoint_BytesInEndpoint() < USB_ControlEndpointSize)) while (Length && (Endpoint_BytesInEndpoint() < USB_ControlEndpointSize))
{ {
@ -322,19 +341,19 @@ uint8_t Endpoint_Write_Control_Stream_BE(const void* Buffer, uint16_t Length)
} }
SendZLP = (Endpoint_BytesInEndpoint() == USB_ControlEndpointSize); SendZLP = (Endpoint_BytesInEndpoint() == USB_ControlEndpointSize);
Endpoint_ClearSetupIN(); Endpoint_ClearControlIN();
} }
if (Endpoint_IsSetupOUTReceived()) if (Endpoint_IsOUTReceived())
return ENDPOINT_RWCSTREAM_ERROR_HostAborted; return ENDPOINT_RWCSTREAM_ERROR_HostAborted;
if (SendZLP) if (SendZLP)
{ {
while (!(Endpoint_IsSetupINReady())); while (!(Endpoint_IsINReady()));
Endpoint_ClearSetupIN(); Endpoint_ClearControlIN();
} }
while (!(Endpoint_IsSetupOUTReceived())); while (!(Endpoint_IsOUTReceived()));
return ENDPOINT_RWCSTREAM_ERROR_NoError; return ENDPOINT_RWCSTREAM_ERROR_NoError;
} }
@ -345,7 +364,7 @@ uint8_t Endpoint_Read_Control_Stream_LE(void* Buffer, uint16_t Length)
while (Length) while (Length)
{ {
while (!(Endpoint_IsSetupOUTReceived())); while (!(Endpoint_IsOUTReceived()));
while (Length && Endpoint_BytesInEndpoint()) while (Length && Endpoint_BytesInEndpoint())
{ {
@ -354,10 +373,10 @@ uint8_t Endpoint_Read_Control_Stream_LE(void* Buffer, uint16_t Length)
Length--; Length--;
} }
Endpoint_ClearSetupOUT(); Endpoint_ClearControlOUT();
} }
while (!(Endpoint_IsSetupINReady())); while (!(Endpoint_IsINReady()));
return ENDPOINT_RWCSTREAM_ERROR_NoError; return ENDPOINT_RWCSTREAM_ERROR_NoError;
} }
@ -368,7 +387,7 @@ uint8_t Endpoint_Read_Control_Stream_BE(void* Buffer, uint16_t Length)
while (Length) while (Length)
{ {
while (!(Endpoint_IsSetupOUTReceived())); while (!(Endpoint_IsOUTReceived()));
while (Length && Endpoint_BytesInEndpoint()) while (Length && Endpoint_BytesInEndpoint())
{ {
@ -377,10 +396,10 @@ uint8_t Endpoint_Read_Control_Stream_BE(void* Buffer, uint16_t Length)
Length--; Length--;
} }
Endpoint_ClearSetupOUT(); Endpoint_ClearControlOUT();
} }
while (!(Endpoint_IsSetupINReady())); while (!(Endpoint_IsINReady()));
return ENDPOINT_RWCSTREAM_ERROR_NoError; return ENDPOINT_RWCSTREAM_ERROR_NoError;
} }

@ -35,6 +35,24 @@
* send/recieve functions for various data types. * send/recieve functions for various data types.
*/ */
/** \ingroup Group_USB
* @defgroup Group_EndpointManagement Endpoint Management
*
* Functions, macros, variables, enums and types related to the setup and management of endpoints while in USB Device mode.
*
* @{
*/
/** @defgroup Group_EndpointRW Endpoint Data Reading and Writing
*
* Functions, macros, variables, enums and types related to data reading and writing from and to endpoints.
*/
/** @defgroup Group_EndpointPacketManagement Endpoint Packet Management
*
* Functions, macros, variables, enums and types related to packet management of endpoints.
*/
#ifndef __ENDPOINT_H__ #ifndef __ENDPOINT_H__
#define __ENDPOINT_H__ #define __ENDPOINT_H__
@ -85,10 +103,10 @@
*/ */
#define ENDPOINT_CONTROLEP 0 #define ENDPOINT_CONTROLEP 0
#if (!defined(FIXED_CONTROL_ENDPOINT_SIZE) || defined(__DOXYGEN__))
/** Default size of the default control endpoint's bank, until altered by the Endpoint0Size value /** Default size of the default control endpoint's bank, until altered by the Endpoint0Size value
* in the device descriptor. Not available if the FIXED_CONTROL_ENDPOINT_SIZE token is defined. * in the device descriptor. Not available if the FIXED_CONTROL_ENDPOINT_SIZE token is defined.
*/ */
#if (!defined(FIXED_CONTROL_ENDPOINT_SIZE) || defined(__DOXYGEN__))
#define ENDPOINT_CONTROLEP_DEFAULT_SIZE 8 #define ENDPOINT_CONTROLEP_DEFAULT_SIZE 8
#endif #endif
@ -165,18 +183,26 @@
*/ */
#define ENDPOINT_INT_OUT UEIENX, (1 << RXOUTE), UEINTX, (1 << RXOUTI) #define ENDPOINT_INT_OUT UEIENX, (1 << RXOUTE), UEINTX, (1 << RXOUTI)
#if defined(USB_FULL_CONTROLLER) || defined(USB_MODIFIED_FULL_CONTROLLER) || defined(__DOXYGEN__) /* Psuedo-Function Macros: */
/** Indicates the number of bytes currently stored in the current endpoint's selected bank. */ #if defined(__DOXYGEN__)
#define Endpoint_BytesInEndpoint() UEBCX /** Indicates the number of bytes currently stored in the current endpoint's selected bank.
#else *
#define Endpoint_BytesInEndpoint() UEBCLX * \note The return width of this function may differ, depending on the maximum endpoint bank size
#endif * of the selected AVR model.
*
* \ingroup Group_EndpointRW
*
* \return Total number of bytes in the currently selected Endpoint's FIFO buffer
*/
static inline uint16_t Endpoint_BytesInEndpoint(void);
/** Returns the endpoint address of the currently selected endpoint. This is typically used to save /** Get the endpoint address of the currently selected endpoint. This is typically used to save
* the currently selected endpoint number so that it can be restored after another endpoint has * the currently selected endpoint number so that it can be restored after another endpoint has
* been manipulated. * been manipulated.
*
* \return Index of the currently selected endpoint
*/ */
#define Endpoint_GetCurrentEndpoint() (UENUM & ENDPOINT_EPNUM_MASK) static inline uint8_t Endpoint_GetCurrentEndpoint(void);
/** Selects the given endpoint number. If the address from the device descriptors is used, the /** Selects the given endpoint number. If the address from the device descriptors is used, the
* value should be masked with the ENDPOINT_EPNUM_MASK constant to extract only the endpoint * value should be masked with the ENDPOINT_EPNUM_MASK constant to extract only the endpoint
@ -184,13 +210,17 @@
* *
* Any endpoint operations which do not require the endpoint number to be indicated will operate on * Any endpoint operations which do not require the endpoint number to be indicated will operate on
* the currently selected endpoint. * the currently selected endpoint.
*
* \param EndpointNumber Endpoint number to select
*/ */
#define Endpoint_SelectEndpoint(epnum) MACROS{ UENUM = epnum; }MACROE static inline void Endpoint_SelectEndpoint(uint8_t EndpointNumber);
/** Resets the endpoint bank FIFO. This clears all the endpoint banks and resets the USB controller's /** Resets the endpoint bank FIFO. This clears all the endpoint banks and resets the USB controller's
* In and Out pointers to the bank's contents. * In and Out pointers to the bank's contents.
*
* \param EndpointNumber Endpoint number whose FIFO buffers are to be reset
*/ */
#define Endpoint_ResetFIFO(epnum) MACROS{ UERST = (1 << epnum); UERST = 0; }MACROE static inline void Endpoint_ResetFIFO(uint8_t EndpointNumber);
/** Enables the currently selected endpoint so that data can be sent and received through it to /** Enables the currently selected endpoint so that data can be sent and received through it to
* and from a host. * and from a host.
@ -198,69 +228,129 @@
* \note Endpoints must first be configured properly rather than just being enabled via the * \note Endpoints must first be configured properly rather than just being enabled via the
* Endpoint_ConfigureEndpoint() macro, which calls Endpoint_EnableEndpoint() automatically. * Endpoint_ConfigureEndpoint() macro, which calls Endpoint_EnableEndpoint() automatically.
*/ */
#define Endpoint_EnableEndpoint() MACROS{ UECONX |= (1 << EPEN); }MACROE static inline void Endpoint_EnableEndpoint(void);
/** Disables the currently selected endpoint so that data cannot be sent and received through it /** Disables the currently selected endpoint so that data cannot be sent and received through it
* to and from a host. * to and from a host.
*/ */
#define Endpoint_DisableEndpoint() MACROS{ UECONX &= ~(1 << EPEN); }MACROE static inline void Endpoint_DisableEndpoint(void);
/** Returns true if the currently selected endpoint is enabled, false otherwise. */ /** Determines if the currently selected endpoint is enabled, but not necessarily configured.
#define Endpoint_IsEnabled() ((UECONX & (1 << EPEN)) ? true : false) *
* \return Boolean True if the currently selected endpoint is enabled, false otherwise
*/
static inline bool Endpoint_IsEnabled(void);
/** Returns true if the currently selected endpoint may be read from (if data is waiting in the endpoint /** Determines if the currently selected endpoint may be read from (if data is waiting in the endpoint
* bank and the endpoint is an OUT direction, or if the bank is not yet full if the endpoint is an * bank and the endpoint is an OUT direction, or if the bank is not yet full if the endpoint is an IN
* IN direction). This function will return false if an error has occurred in the endpoint, or if * direction). This function will return false if an error has occurred in the endpoint, if the endpoint
* the endpoint is an OUT direction and no packet has been received, or if the endpoint is an IN * is an OUT direction and no packet (or an empty packet) has been received, or if the endpoint is an IN
* direction and the endpoint bank is full. * direction and the endpoint bank is full.
*
* \ingroup Group_EndpointPacketManagement
*
* \return Boolean true if the currently selected endpoint may be read from or written to, depending on its direction
*/ */
#define Endpoint_ReadWriteAllowed() ((UEINTX & (1 << RWAL)) ? true : false) static inline bool Endpoint_IsReadWriteAllowed(void);
/** Returns true if the currently selected endpoint is configured, false otherwise. */ /** Determines if the currently selected endpoint is configured.
#define Endpoint_IsConfigured() ((UESTA0X & (1 << CFGOK)) ? true : false) *
* \return Boolean true if the currently selected endpoint has been configured, false otherwise
*/
static inline bool Endpoint_IsConfigured(void);
/** Returns a mask indicating which INTERRUPT type endpoints have interrupted - i.e. their /** Returns a mask indicating which INTERRUPT type endpoints have interrupted - i.e. their
* interrupt duration has elapsed. Which endpoints have interrupted can be determined by * interrupt duration has elapsed. Which endpoints have interrupted can be determined by
* masking the return value against (1 << {Endpoint Number}). * masking the return value against (1 << {Endpoint Number}).
*
* \return Mask whose bits indicate which endpoints have interrupted
*/ */
#define Endpoint_GetEndpointInterrupts() UEINT static inline uint8_t Endpoint_GetEndpointInterrupts(void);
/** Clears the endpoint interrupt flag. This clears the specified endpoint number's interrupt /** Clears the endpoint interrupt flag. This clears the specified endpoint number's interrupt
* mask in the endpoint interrupt flag register. * mask in the endpoint interrupt flag register.
*
* \param EndpointNumber Index of the endpoint whose interrupt flag should be cleared
*/ */
#define Endpoint_ClearEndpointInterrupt(n) MACROS{ UEINT &= ~(1 << n); }MACROE static inline void Endpoint_ClearEndpointInterrupt(uint8_t EndpointNumber);
/** Returns true if the specified endpoint number has interrupted (valid only for INTERRUPT type /** Determines if the specified endpoint number has interrupted (valid only for INTERRUPT type
* endpoints), false otherwise. * endpoints).
*
* \param EndpointNumber Index of the endpoint whose interrupt flag should be tested
*
* \return Boolean true if the specified endpoint has interrupted, false otherwise
*/ */
#define Endpoint_HasEndpointInterrupted(n) ((UEINT & (1 << n)) ? true : false) static inline bool Endpoint_HasEndpointInterrupted(uint8_t EndpointNumber);
/** Clears the currently selected endpoint bank, and switches to the alternate bank if the currently /** Determines if the selected IN endpoint is ready for a new packet.
* selected endpoint is dual-banked. When cleared, this either frees the bank up for the next packet *
* from the host (if the endpoint is of the OUT direction) or sends the packet contents to the host * \ingroup Group_EndpointPacketManagement
* (if the endpoint is of the IN direction). *
* \return Boolean true if the current endpoint is ready for an IN packet, false otherwise.
*/ */
#define Endpoint_ClearCurrentBank() MACROS{ UEINTX &= ~(1 << FIFOCON); }MACROE static inline bool Endpoint_IsINReady(void);
/** Returns true if the current CONTROL type endpoint is ready for an IN packet, false otherwise. */
#define Endpoint_IsSetupINReady() ((UEINTX & (1 << TXINI)) ? true : false)
/** Returns true if the current CONTROL type endpoint is ready for an OUT packet, false otherwise. */ /** Determines if the selected OUT endpoint has received new packet.
#define Endpoint_IsSetupOUTReceived() ((UEINTX & (1 << RXOUTI)) ? true : false) *
* \ingroup Group_EndpointPacketManagement
*
* \return Boolean true if current endpoint is has received an OUT packet, false otherwise.
*/
static inline bool Endpoint_IsOUTReceived(void);
/** Returns true if the current CONTROL type endpoint is ready for a SETUP packet, false otherwise. */ /** Determines if the current CONTROL type endpoint has received a SETUP packet.
#define Endpoint_IsSetupReceived() ((UEINTX & (1 << RXSTPI)) ? true : false) *
* \ingroup Group_EndpointPacketManagement
*
* \return Boolean true if the selected endpoint has received a SETUP packet, false otherwise.
*/
static inline bool Endpoint_IsSETUPReceived(void);
/** Clears a received SETUP packet on the currently selected CONTROL type endpoint. */ /** Clears a received SETUP packet on the currently selected CONTROL type endpoint, freeing up the
#define Endpoint_ClearSetupReceived() MACROS{ UEINTX &= ~(1 << RXSTPI); }MACROE * endpoint for the next packet.
*
* \ingroup Group_EndpointPacketManagement
*
* \note This is not applicable for non CONTROL type endpoints.
*/
static inline void Endpoint_ClearControlSETUP(void);
/** Sends an IN packet to the host on the currently selected CONTROL type endpoint. */ /** Sends an IN packet to the host on the currently selected CONTROL type endpoint, freeing up the
#define Endpoint_ClearSetupIN() MACROS{ UEINTX &= ~(1 << TXINI); }MACROE * endpoint for the next packet.
*
* \ingroup Group_EndpointPacketManagement
*
* \note For non CONTROL type endpoints, use Endpoint_ClearIN() instead.
*/
static inline void Endpoint_ClearControlIN(void);
/** Acknowledges an OUT packet to the host on the currently selected CONTROL type endpoint, freeing /** Acknowledges an OUT packet to the host on the currently selected CONTROL type endpoint, freeing
* up the endpoint for the next packet. * up the endpoint for the next packet.
*
* \ingroup Group_EndpointPacketManagement
*
* \note For non CONTROL type endpoints, use Endpoint_ClearOUT() instead.
*/
static inline void Endpoint_ClearControlOUT(void);
/** Sends an IN packet to the host on the currently selected non CONTROL type endpoint, freeing
* up the endpoint for the next packet and switching to the alternative endpoint bank if double banked.
*
* \ingroup Group_EndpointPacketManagement
*
* \note For CONTROL type endpoints, use Endpoint_ClearControlIN() instead.
*/
static inline void Endpoint_ClearIN(void);
/** Acknowledges an OUT packet to the host on the currently selected non CONTROL type endpoint, freeing
* up the endpoint for the next packet and switching to the alternative endpoint bank if double banked.
*
* \ingroup Group_EndpointPacketManagement
*
* \note For CONTROL type endpoints, use Endpoint_ClearControlOUT() instead.
*/ */
#define Endpoint_ClearSetupOUT() MACROS{ UEINTX &= ~(1 << RXOUTI); }MACROE static inline void Endpoint_ClearOUT(void);
/** Stalls the current endpoint, indicating to the host that a logical problem occurred with the /** Stalls the current endpoint, indicating to the host that a logical problem occurred with the
* indicated endpoint and that the current transfer sequence should be aborted. This provides a * indicated endpoint and that the current transfer sequence should be aborted. This provides a
@ -270,20 +360,94 @@
* The currently selected endpoint remains stalled until either the Endpoint_ClearStall() macro * The currently selected endpoint remains stalled until either the Endpoint_ClearStall() macro
* is called, or the host issues a CLEAR FEATURE request to the device for the currently selected * is called, or the host issues a CLEAR FEATURE request to the device for the currently selected
* endpoint. * endpoint.
*
* \ingroup Group_EndpointPacketManagement
*/
static inline void Endpoint_StallTransaction(void);
/** Clears the STALL condition on the currently selected endpoint.
*
* \ingroup Group_EndpointPacketManagement
*/
static inline void Endpoint_ClearStall(void);
/** Determines if the currently selected endpoint is stalled, false otherwise.
*
* \ingroup Group_EndpointPacketManagement
*
* \return Boolean true if the currently selected endpoint is stalled, false otherwise
*/
static inline bool Endpoint_IsStalled(void);
/** Resets the data toggle of the currently selected endpoint. */
static inline void Endpoint_ResetDataToggle(void);
/** Determines the currently selected endpoint's direction.
*
* \return The currently selected endpoint's direction, as a ENDPOINT_DIR_* mask.
*/ */
static inline uint8_t Endpoint_GetEndpointDirection(void);
#else
#if defined(USB_FULL_CONTROLLER) || defined(USB_MODIFIED_FULL_CONTROLLER) || defined(__DOXYGEN__)
#define Endpoint_BytesInEndpoint() UEBCX
#else
#define Endpoint_BytesInEndpoint() UEBCLX
#endif
#define Endpoint_GetCurrentEndpoint() (UENUM & ENDPOINT_EPNUM_MASK)
#define Endpoint_SelectEndpoint(epnum) MACROS{ UENUM = epnum; }MACROE
#define Endpoint_ResetFIFO(epnum) MACROS{ UERST = (1 << epnum); UERST = 0; }MACROE
#define Endpoint_EnableEndpoint() MACROS{ UECONX |= (1 << EPEN); }MACROE
#define Endpoint_DisableEndpoint() MACROS{ UECONX &= ~(1 << EPEN); }MACROE
#define Endpoint_IsEnabled() ((UECONX & (1 << EPEN)) ? true : false)
#define Endpoint_IsReadWriteAllowed() ((UEINTX & (1 << RWAL)) ? true : false)
#define Endpoint_IsConfigured() ((UESTA0X & (1 << CFGOK)) ? true : false)
#define Endpoint_GetEndpointInterrupts() UEINT
#define Endpoint_ClearEndpointInterrupt(n) MACROS{ UEINT &= ~(1 << n); }MACROE
#define Endpoint_HasEndpointInterrupted(n) ((UEINT & (1 << n)) ? true : false)
#define Endpoint_IsINReady() ((UEINTX & (1 << TXINI)) ? true : false)
#define Endpoint_IsOUTReceived() ((UEINTX & (1 << RXOUTI)) ? true : false)
#define Endpoint_IsSETUPReceived() ((UEINTX & (1 << RXSTPI)) ? true : false)
#define Endpoint_ClearControlSETUP() MACROS{ UEINTX &= ~(1 << RXSTPI); }MACROE
#define Endpoint_ClearControlIN() MACROS{ UEINTX &= ~(1 << TXINI); }MACROE
#define Endpoint_ClearControlOUT() MACROS{ UEINTX &= ~(1 << RXOUTI); }MACROE
#define Endpoint_ClearIN() MACROS{ UEINTX &= ~(1 << TXINI); UEINTX &= ~(1 << FIFOCON); }MACROE
#define Endpoint_ClearOUT() MACROS{ UEINTX &= ~(1 << RXOUTI); UEINTX &= ~(1 << FIFOCON); }MACROE
#define Endpoint_StallTransaction() MACROS{ UECONX |= (1 << STALLRQ); }MACROE #define Endpoint_StallTransaction() MACROS{ UECONX |= (1 << STALLRQ); }MACROE
/** Clears the stall on the currently selected endpoint. */
#define Endpoint_ClearStall() MACROS{ UECONX |= (1 << STALLRQC); }MACROE #define Endpoint_ClearStall() MACROS{ UECONX |= (1 << STALLRQC); }MACROE
/** Returns true if the currently selected endpoint is stalled, false otherwise. */
#define Endpoint_IsStalled() ((UECONX & (1 << STALLRQ)) ? true : false) #define Endpoint_IsStalled() ((UECONX & (1 << STALLRQ)) ? true : false)
/** Resets the data toggle of the currently selected endpoint. */
#define Endpoint_ResetDataToggle() MACROS{ UECONX |= (1 << RSTDT); }MACROE #define Endpoint_ResetDataToggle() MACROS{ UECONX |= (1 << RSTDT); }MACROE
#define Endpoint_GetEndpointDirection() (UECFG0X & ENDPOINT_DIR_IN)
#endif
/* Enums: */ /* Enums: */
/** Enum for the possible error return codes of the Endpoint_WaitUntilReady function */ /** Enum for the possible error return codes of the Endpoint_WaitUntilReady function.
*
* \ingroup Group_EndpointRW
*/
enum Endpoint_WaitUntilReady_ErrorCodes_t enum Endpoint_WaitUntilReady_ErrorCodes_t
{ {
ENDPOINT_READYWAIT_NoError = 0, /**< Endpoint is ready for next packet, no error. */ ENDPOINT_READYWAIT_NoError = 0, /**< Endpoint is ready for next packet, no error. */
@ -299,7 +463,10 @@
*/ */
}; };
/** Enum for the possible error return codes of the Endpoint_*_Stream_* functions. */ /** Enum for the possible error return codes of the Endpoint_*_Stream_* functions.
*
* \ingroup Group_EndpointRW
*/
enum Endpoint_Stream_RW_ErrorCodes_t enum Endpoint_Stream_RW_ErrorCodes_t
{ {
ENDPOINT_RWSTREAM_ERROR_NoError = 0, /**< Command completed successfully, no error. */ ENDPOINT_RWSTREAM_ERROR_NoError = 0, /**< Command completed successfully, no error. */
@ -318,7 +485,10 @@
*/ */
}; };
/** Enum for the possible error return codes of the Endpoint_*_Control_Stream_* functions. */ /** Enum for the possible error return codes of the Endpoint_*_Control_Stream_* functions..
*
* \ingroup Group_EndpointRW
*/
enum Endpoint_ControlStream_RW_ErrorCodes_t enum Endpoint_ControlStream_RW_ErrorCodes_t
{ {
ENDPOINT_RWCSTREAM_ERROR_NoError = 0, /**< Command completed successfully, no error. */ ENDPOINT_RWCSTREAM_ERROR_NoError = 0, /**< Command completed successfully, no error. */
@ -326,21 +496,34 @@
}; };
/* Inline Functions: */ /* Inline Functions: */
/** Reads one byte from the currently selected endpoint's bank, for OUT direction endpoints. */ /** Reads one byte from the currently selected endpoint's bank, for OUT direction endpoints.
*
* \ingroup Group_EndpointRW
*
* \return Next byte in the currently selected endpoint's FIFO buffer
*/
static inline uint8_t Endpoint_Read_Byte(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; static inline uint8_t Endpoint_Read_Byte(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
static inline uint8_t Endpoint_Read_Byte(void) static inline uint8_t Endpoint_Read_Byte(void)
{ {
return UEDATX; return UEDATX;
} }
/** Writes one byte from the currently selected endpoint's bank, for IN direction endpoints. */ /** Writes one byte from the currently selected endpoint's bank, for IN direction endpoints.
*
* \ingroup Group_EndpointRW
*
* \param Byte Next byte to write into the the currently selected endpoint's FIFO buffer
*/
static inline void Endpoint_Write_Byte(const uint8_t Byte) ATTR_ALWAYS_INLINE; static inline void Endpoint_Write_Byte(const uint8_t Byte) ATTR_ALWAYS_INLINE;
static inline void Endpoint_Write_Byte(const uint8_t Byte) static inline void Endpoint_Write_Byte(const uint8_t Byte)
{ {
UEDATX = Byte; UEDATX = Byte;
} }
/** Discards one byte from the currently selected endpoint's bank, for OUT direction endpoints. */ /** Discards one byte from the currently selected endpoint's bank, for OUT direction endpoints.
*
* \ingroup Group_EndpointRW
*/
static inline void Endpoint_Discard_Byte(void) ATTR_ALWAYS_INLINE; static inline void Endpoint_Discard_Byte(void) ATTR_ALWAYS_INLINE;
static inline void Endpoint_Discard_Byte(void) static inline void Endpoint_Discard_Byte(void)
{ {
@ -351,6 +534,10 @@
/** Reads two bytes from the currently selected endpoint's bank in little endian format, for OUT /** Reads two bytes from the currently selected endpoint's bank in little endian format, for OUT
* direction endpoints. * direction endpoints.
*
* \ingroup Group_EndpointRW
*
* \return Next word in the currently selected endpoint's FIFO buffer
*/ */
static inline uint16_t Endpoint_Read_Word_LE(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; static inline uint16_t Endpoint_Read_Word_LE(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
static inline uint16_t Endpoint_Read_Word_LE(void) static inline uint16_t Endpoint_Read_Word_LE(void)
@ -365,6 +552,10 @@
/** Reads two bytes from the currently selected endpoint's bank in big endian format, for OUT /** Reads two bytes from the currently selected endpoint's bank in big endian format, for OUT
* direction endpoints. * direction endpoints.
*
* \ingroup Group_EndpointRW
*
* \return Next word in the currently selected endpoint's FIFO buffer
*/ */
static inline uint16_t Endpoint_Read_Word_BE(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; static inline uint16_t Endpoint_Read_Word_BE(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
static inline uint16_t Endpoint_Read_Word_BE(void) static inline uint16_t Endpoint_Read_Word_BE(void)
@ -379,6 +570,10 @@
/** Writes two bytes to the currently selected endpoint's bank in little endian format, for IN /** Writes two bytes to the currently selected endpoint's bank in little endian format, for IN
* direction endpoints. * direction endpoints.
*
* \ingroup Group_EndpointRW
*
* \param Word Next word to write to the currently selected endpoint's FIFO buffer
*/ */
static inline void Endpoint_Write_Word_LE(const uint16_t Word) ATTR_ALWAYS_INLINE; static inline void Endpoint_Write_Word_LE(const uint16_t Word) ATTR_ALWAYS_INLINE;
static inline void Endpoint_Write_Word_LE(const uint16_t Word) static inline void Endpoint_Write_Word_LE(const uint16_t Word)
@ -389,6 +584,10 @@
/** Writes two bytes to the currently selected endpoint's bank in big endian format, for IN /** Writes two bytes to the currently selected endpoint's bank in big endian format, for IN
* direction endpoints. * direction endpoints.
*
* \ingroup Group_EndpointRW
*
* \param Word Next word to write to the currently selected endpoint's FIFO buffer
*/ */
static inline void Endpoint_Write_Word_BE(const uint16_t Word) ATTR_ALWAYS_INLINE; static inline void Endpoint_Write_Word_BE(const uint16_t Word) ATTR_ALWAYS_INLINE;
static inline void Endpoint_Write_Word_BE(const uint16_t Word) static inline void Endpoint_Write_Word_BE(const uint16_t Word)
@ -397,7 +596,10 @@
UEDATX = (Word & 0xFF); UEDATX = (Word & 0xFF);
} }
/** Discards two bytes from the currently selected endpoint's bank, for OUT direction endpoints. */ /** Discards two bytes from the currently selected endpoint's bank, for OUT direction endpoints.
*
* \ingroup Group_EndpointRW
*/
static inline void Endpoint_Discard_Word(void) ATTR_ALWAYS_INLINE; static inline void Endpoint_Discard_Word(void) ATTR_ALWAYS_INLINE;
static inline void Endpoint_Discard_Word(void) static inline void Endpoint_Discard_Word(void)
{ {
@ -409,6 +611,10 @@
/** Reads four bytes from the currently selected endpoint's bank in little endian format, for OUT /** Reads four bytes from the currently selected endpoint's bank in little endian format, for OUT
* direction endpoints. * direction endpoints.
*
* \ingroup Group_EndpointRW
*
* \return Next double word in the currently selected endpoint's FIFO buffer
*/ */
static inline uint32_t Endpoint_Read_DWord_LE(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; static inline uint32_t Endpoint_Read_DWord_LE(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
static inline uint32_t Endpoint_Read_DWord_LE(void) static inline uint32_t Endpoint_Read_DWord_LE(void)
@ -429,6 +635,10 @@
/** Reads four bytes from the currently selected endpoint's bank in big endian format, for OUT /** Reads four bytes from the currently selected endpoint's bank in big endian format, for OUT
* direction endpoints. * direction endpoints.
*
* \ingroup Group_EndpointRW
*
* \return Next double word in the currently selected endpoint's FIFO buffer
*/ */
static inline uint32_t Endpoint_Read_DWord_BE(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; static inline uint32_t Endpoint_Read_DWord_BE(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
static inline uint32_t Endpoint_Read_DWord_BE(void) static inline uint32_t Endpoint_Read_DWord_BE(void)
@ -449,6 +659,10 @@
/** Writes four bytes to the currently selected endpoint's bank in little endian format, for IN /** Writes four bytes to the currently selected endpoint's bank in little endian format, for IN
* direction endpoints. * direction endpoints.
*
* \ingroup Group_EndpointRW
*
* \param DWord Next double word to write to the currently selected endpoint's FIFO buffer
*/ */
static inline void Endpoint_Write_DWord_LE(const uint32_t DWord) ATTR_ALWAYS_INLINE; static inline void Endpoint_Write_DWord_LE(const uint32_t DWord) ATTR_ALWAYS_INLINE;
static inline void Endpoint_Write_DWord_LE(const uint32_t DWord) static inline void Endpoint_Write_DWord_LE(const uint32_t DWord)
@ -461,6 +675,10 @@
/** Writes four bytes to the currently selected endpoint's bank in big endian format, for IN /** Writes four bytes to the currently selected endpoint's bank in big endian format, for IN
* direction endpoints. * direction endpoints.
*
* \ingroup Group_EndpointRW
*
* \param DWord Next double word to write to the currently selected endpoint's FIFO buffer
*/ */
static inline void Endpoint_Write_DWord_BE(const uint32_t DWord) ATTR_ALWAYS_INLINE; static inline void Endpoint_Write_DWord_BE(const uint32_t DWord) ATTR_ALWAYS_INLINE;
static inline void Endpoint_Write_DWord_BE(const uint32_t DWord) static inline void Endpoint_Write_DWord_BE(const uint32_t DWord)
@ -471,7 +689,10 @@
UEDATX = (DWord & 0xFF); UEDATX = (DWord & 0xFF);
} }
/** Discards four bytes from the currently selected endpoint's bank, for OUT direction endpoints. */ /** Discards four bytes from the currently selected endpoint's bank, for OUT direction endpoints.
*
* \ingroup Group_EndpointRW
*/
static inline void Endpoint_Discard_DWord(void) ATTR_ALWAYS_INLINE; static inline void Endpoint_Discard_DWord(void) ATTR_ALWAYS_INLINE;
static inline void Endpoint_Discard_DWord(void) static inline void Endpoint_Discard_DWord(void)
{ {
@ -539,6 +760,8 @@
* *
* \note This routine should not be called on CONTROL type endpoints. * \note This routine should not be called on CONTROL type endpoints.
* *
* \ingroup Group_EndpointRW
*
* \return A value from the Endpoint_WaitUntilReady_ErrorCodes_t enum. * \return A value from the Endpoint_WaitUntilReady_ErrorCodes_t enum.
*/ */
uint8_t Endpoint_WaitUntilReady(void); uint8_t Endpoint_WaitUntilReady(void);
@ -546,7 +769,7 @@
/** Reads and discards the given number of bytes from the endpoint from the given buffer, /** Reads and discards the given number of bytes from the endpoint from the given buffer,
* discarding fully read packets from the host as needed. The last packet is not automatically * discarding fully read packets from the host as needed. The last packet is not automatically
* discarded once the remaining bytes has been read; the user is responsible for manually * discarded once the remaining bytes has been read; the user is responsible for manually
* discarding the last packet from the host via the Endpoint_ClearCurrentBank() macro. Between * discarding the last packet from the host via the Endpoint_ClearOUT() macro. Between
* each USB packet, the given stream callback function is executed repeatedly until the next * each USB packet, the given stream callback function is executed repeatedly until the next
* packet is ready, allowing for early aborts of stream transfers. * packet is ready, allowing for early aborts of stream transfers.
* *
@ -556,6 +779,8 @@
* *
* \note This routine should not be used on CONTROL type endpoints. * \note This routine should not be used on CONTROL type endpoints.
* *
* \ingroup Group_EndpointRW
*
* \param Length Number of bytes to send via the currently selected endpoint. * \param Length Number of bytes to send via the currently selected endpoint.
* \param Callback Name of a callback routine to call between successive USB packet transfers, NULL if no callback * \param Callback Name of a callback routine to call between successive USB packet transfers, NULL if no callback
* *
@ -570,7 +795,7 @@
/** Writes the given number of bytes to the endpoint from the given buffer in little endian, /** Writes the given number of bytes to the endpoint from the given buffer in little endian,
* sending full packets to the host as needed. The last packet filled is not automatically sent; * sending full packets to the host as needed. The last packet filled is not automatically sent;
* the user is responsible for manually sending the last written packet to the host via the * the user is responsible for manually sending the last written packet to the host via the
* Endpoint_ClearCurrentBank() macro. Between each USB packet, the given stream callback function * Endpoint_ClearIN() macro. Between each USB packet, the given stream callback function
* is executed repeatedly until the endpoint is ready to accept the next packet, allowing for early * is executed repeatedly until the endpoint is ready to accept the next packet, allowing for early
* aborts of stream transfers. * aborts of stream transfers.
* *
@ -580,6 +805,8 @@
* *
* \note This routine should not be used on CONTROL type endpoints. * \note This routine should not be used on CONTROL type endpoints.
* *
* \ingroup Group_EndpointRW
*
* \param Buffer Pointer to the source data buffer to read from. * \param Buffer Pointer to the source data buffer to read from.
* \param Length Number of bytes to read for the currently selected endpoint into the buffer. * \param Length Number of bytes to read for the currently selected endpoint into the buffer.
* \param Callback Name of a callback routine to call between successive USB packet transfers, NULL if no callback * \param Callback Name of a callback routine to call between successive USB packet transfers, NULL if no callback
@ -595,7 +822,7 @@
/** Writes the given number of bytes to the endpoint from the given buffer in big endian, /** Writes the given number of bytes to the endpoint from the given buffer in big endian,
* sending full packets to the host as needed. The last packet filled is not automatically sent; * sending full packets to the host as needed. The last packet filled is not automatically sent;
* the user is responsible for manually sending the last written packet to the host via the * the user is responsible for manually sending the last written packet to the host via the
* Endpoint_ClearCurrentBank() macro. Between each USB packet, the given stream callback function * Endpoint_ClearIN() macro. Between each USB packet, the given stream callback function
* is executed repeatedly until the endpoint is ready to accept the next packet, allowing for early * is executed repeatedly until the endpoint is ready to accept the next packet, allowing for early
* aborts of stream transfers. * aborts of stream transfers.
* *
@ -605,6 +832,8 @@
* *
* \note This routine should not be used on CONTROL type endpoints. * \note This routine should not be used on CONTROL type endpoints.
* *
* \ingroup Group_EndpointRW
*
* \param Buffer Pointer to the source data buffer to read from. * \param Buffer Pointer to the source data buffer to read from.
* \param Length Number of bytes to read for the currently selected endpoint into the buffer. * \param Length Number of bytes to read for the currently selected endpoint into the buffer.
* \param Callback Name of a callback routine to call between successive USB packet transfers, NULL if no callback * \param Callback Name of a callback routine to call between successive USB packet transfers, NULL if no callback
@ -620,7 +849,7 @@
/** Reads the given number of bytes from the endpoint from the given buffer in little endian, /** Reads the given number of bytes from the endpoint from the given buffer in little endian,
* discarding fully read packets from the host as needed. The last packet is not automatically * discarding fully read packets from the host as needed. The last packet is not automatically
* discarded once the remaining bytes has been read; the user is responsible for manually * discarded once the remaining bytes has been read; the user is responsible for manually
* discarding the last packet from the host via the Endpoint_ClearCurrentBank() macro. Between * discarding the last packet from the host via the Endpoint_ClearOUT() macro. Between
* each USB packet, the given stream callback function is executed repeatedly until the endpoint * each USB packet, the given stream callback function is executed repeatedly until the endpoint
* is ready to accept the next packet, allowing for early aborts of stream transfers. * is ready to accept the next packet, allowing for early aborts of stream transfers.
* *
@ -630,6 +859,8 @@
* *
* \note This routine should not be used on CONTROL type endpoints. * \note This routine should not be used on CONTROL type endpoints.
* *
* \ingroup Group_EndpointRW
*
* \param Buffer Pointer to the destination data buffer to write to. * \param Buffer Pointer to the destination data buffer to write to.
* \param Length Number of bytes to send via the currently selected endpoint. * \param Length Number of bytes to send via the currently selected endpoint.
* \param Callback Name of a callback routine to call between successive USB packet transfers, NULL if no callback * \param Callback Name of a callback routine to call between successive USB packet transfers, NULL if no callback
@ -645,7 +876,7 @@
/** Reads the given number of bytes from the endpoint from the given buffer in big endian, /** Reads the given number of bytes from the endpoint from the given buffer in big endian,
* discarding fully read packets from the host as needed. The last packet is not automatically * discarding fully read packets from the host as needed. The last packet is not automatically
* discarded once the remaining bytes has been read; the user is responsible for manually * discarded once the remaining bytes has been read; the user is responsible for manually
* discarding the last packet from the host via the Endpoint_ClearCurrentBank() macro. Between * discarding the last packet from the host via the Endpoint_ClearOUT() macro. Between
* each USB packet, the given stream callback function is executed repeatedly until the endpoint * each USB packet, the given stream callback function is executed repeatedly until the endpoint
* is ready to accept the next packet, allowing for early aborts of stream transfers. * is ready to accept the next packet, allowing for early aborts of stream transfers.
* *
@ -655,6 +886,8 @@
* *
* \note This routine should not be used on CONTROL type endpoints. * \note This routine should not be used on CONTROL type endpoints.
* *
* \ingroup Group_EndpointRW
*
* \param Buffer Pointer to the destination data buffer to write to. * \param Buffer Pointer to the destination data buffer to write to.
* \param Length Number of bytes to send via the currently selected endpoint. * \param Length Number of bytes to send via the currently selected endpoint.
* \param Callback Name of a callback routine to call between successive USB packet transfers, NULL if no callback * \param Callback Name of a callback routine to call between successive USB packet transfers, NULL if no callback
@ -670,13 +903,15 @@
/** Writes the given number of bytes to the CONTROL type endpoint from the given buffer in little endian, /** Writes the given number of bytes to the CONTROL type endpoint from the given buffer in little endian,
* sending full packets to the host as needed. The host OUT acknowledgement is not automatically cleared * sending full packets to the host as needed. The host OUT acknowledgement is not automatically cleared
* in both failure and success states; the user is responsible for manually clearing the setup OUT to * in both failure and success states; the user is responsible for manually clearing the setup OUT to
* finalize the transfer via the Endpoint_ClearSetupOUT() macro. * finalize the transfer via the Endpoint_ClearControlOUT() macro.
* *
* \note This routine should only be used on CONTROL type endpoints. * \note This routine should only be used on CONTROL type endpoints.
* *
* \warning Unlike the standard stream read/write commands, the control stream commands cannot be chained * \warning Unlike the standard stream read/write commands, the control stream commands cannot be chained
* together; i.e. the entire stream data must be read or written at the one time. * together; i.e. the entire stream data must be read or written at the one time.
* *
* \ingroup Group_EndpointRW
*
* \param Buffer Pointer to the source data buffer to read from. * \param Buffer Pointer to the source data buffer to read from.
* \param Length Number of bytes to read for the currently selected endpoint into the buffer. * \param Length Number of bytes to read for the currently selected endpoint into the buffer.
* *
@ -687,13 +922,15 @@
/** Writes the given number of bytes to the CONTROL type endpoint from the given buffer in big endian, /** Writes the given number of bytes to the CONTROL type endpoint from the given buffer in big endian,
* sending full packets to the host as needed. The host OUT acknowledgement is not automatically cleared * sending full packets to the host as needed. The host OUT acknowledgement is not automatically cleared
* in both failure and success states; the user is responsible for manually clearing the setup OUT to * in both failure and success states; the user is responsible for manually clearing the setup OUT to
* finalize the transfer via the Endpoint_ClearSetupOUT() macro. * finalize the transfer via the Endpoint_ClearControlOUT() macro.
* *
* \note This routine should only be used on CONTROL type endpoints. * \note This routine should only be used on CONTROL type endpoints.
* *
* \warning Unlike the standard stream read/write commands, the control stream commands cannot be chained * \warning Unlike the standard stream read/write commands, the control stream commands cannot be chained
* together; i.e. the entire stream data must be read or written at the one time. * together; i.e. the entire stream data must be read or written at the one time.
* *
* \ingroup Group_EndpointRW
*
* \param Buffer Pointer to the source data buffer to read from. * \param Buffer Pointer to the source data buffer to read from.
* \param Length Number of bytes to read for the currently selected endpoint into the buffer. * \param Length Number of bytes to read for the currently selected endpoint into the buffer.
* *
@ -704,13 +941,15 @@
/** Reads the given number of bytes from the CONTROL endpoint from the given buffer in little endian, /** Reads the given number of bytes from the CONTROL endpoint from the given buffer in little endian,
* discarding fully read packets from the host as needed. The device IN acknowledgement is not * discarding fully read packets from the host as needed. The device IN acknowledgement is not
* automatically sent after success or failure states; the user is responsible for manually sending the * automatically sent after success or failure states; the user is responsible for manually sending the
* setup IN to finalize the transfer via the Endpoint_ClearSetupIN() macro. * setup IN to finalize the transfer via the Endpoint_ClearControlIN() macro.
* *
* \note This routine should only be used on CONTROL type endpoints. * \note This routine should only be used on CONTROL type endpoints.
* *
* \warning Unlike the standard stream read/write commands, the control stream commands cannot be chained * \warning Unlike the standard stream read/write commands, the control stream commands cannot be chained
* together; i.e. the entire stream data must be read or written at the one time. * together; i.e. the entire stream data must be read or written at the one time.
* *
* \ingroup Group_EndpointRW
*
* \param Buffer Pointer to the destination data buffer to write to. * \param Buffer Pointer to the destination data buffer to write to.
* \param Length Number of bytes to send via the currently selected endpoint. * \param Length Number of bytes to send via the currently selected endpoint.
* *
@ -721,13 +960,15 @@
/** Reads the given number of bytes from the CONTROL endpoint from the given buffer in big endian, /** Reads the given number of bytes from the CONTROL endpoint from the given buffer in big endian,
* discarding fully read packets from the host as needed. The device IN acknowledgement is not * discarding fully read packets from the host as needed. The device IN acknowledgement is not
* automatically sent after success or failure states; the user is responsible for manually sending the * automatically sent after success or failure states; the user is responsible for manually sending the
* setup IN to finalize the transfer via the Endpoint_ClearSetupIN() macro. * setup IN to finalize the transfer via the Endpoint_ClearControlIN() macro.
* *
* \note This routine should only be used on CONTROL type endpoints. * \note This routine should only be used on CONTROL type endpoints.
* *
* \warning Unlike the standard stream read/write commands, the control stream commands cannot be chained * \warning Unlike the standard stream read/write commands, the control stream commands cannot be chained
* together; i.e. the entire stream data must be read or written at the one time. * together; i.e. the entire stream data must be read or written at the one time.
* *
* \ingroup Group_EndpointRW
*
* \param Buffer Pointer to the destination data buffer to write to. * \param Buffer Pointer to the destination data buffer to write to.
* \param Length Number of bytes to send via the currently selected endpoint. * \param Length Number of bytes to send via the currently selected endpoint.
* *
@ -735,67 +976,6 @@
*/ */
uint8_t Endpoint_Read_Control_Stream_BE(void* Buffer, uint16_t Length) ATTR_NON_NULL_PTR_ARG(1); uint8_t Endpoint_Read_Control_Stream_BE(void* Buffer, uint16_t Length) ATTR_NON_NULL_PTR_ARG(1);
/* Function Aliases: */
/** Alias for Endpoint_Discard_Byte().
*/
#define Endpoint_Ignore_Byte() Endpoint_Discard_Byte()
/** Alias for Endpoint_Discard_Word().
*/
#define Endpoint_Ignore_Word() Endpoint_Discard_Word()
/** Alias for Endpoint_Discard_DWord().
*/
#define Endpoint_Ignore_DWord() Endpoint_Discard_DWord()
/** Alias for Endpoint_Read_Word_LE(). By default USB transfers use little endian format, thus
* the command with no endianness specified indicates little endian mode.
*/
#define Endpoint_Read_Word() Endpoint_Read_Word_LE()
/** Alias for Endpoint_Write_Word_LE(). By default USB transfers use little endian format, thus
* the command with no endianness specified indicates little endian mode.
*/
#define Endpoint_Write_Word(Word) Endpoint_Write_Word_LE(Word)
/** Alias for Endpoint_Read_DWord_LE(). By default USB transfers use little endian format, thus
* the command with no endianness specified indicates little endian mode.
*/
#define Endpoint_Read_DWord() Endpoint_Read_DWord_LE()
/** Alias for Endpoint_Write_DWord_LE(). By default USB transfers use little endian format, thus
* the command with no endianness specified indicates little endian mode.
*/
#define Endpoint_Write_DWord(DWord) Endpoint_Write_DWord_LE(DWord)
/** Alias for Endpoint_Read_Stream_LE(). By default USB transfers use little endian format, thus
* the command with no endianness specified indicates little endian mode.
*/
#if !defined(NO_STREAM_CALLBACKS)
#define Endpoint_Read_Stream(Buffer, Length, Callback) Endpoint_Read_Stream_LE(Buffer, Length, Callback)
#else
#define Endpoint_Read_Stream(Buffer, Length) Endpoint_Read_Stream_LE(Buffer, Length)
#endif
/** Alias for Endpoint_Write_Stream_LE(). By default USB transfers use little endian format, thus
* the command with no endianness specified indicates little endian mode.
*/
#if !defined(NO_STREAM_CALLBACKS)
#define Endpoint_Write_Stream(Buffer, Length, Callback) Endpoint_Write_Stream_LE(Buffer, Length, Callback)
#else
#define Endpoint_Write_Stream(Buffer, Length) Endpoint_Write_Stream_LE(Buffer, Length)
#endif
/** Alias for Endpoint_Read_Control_Stream_LE(). By default USB transfers use little endian format, thus
* the command with no endianness specified indicates little endian mode.
*/
#define Endpoint_Read_Control_Stream(Data, Length) Endpoint_Read_Control_Stream_LE(Data, Length)
/** Alias for Endpoint_Write_Control_Stream_LE(). By default USB transfers use little endian format, thus
* the command with no endianness specified indicates little endian mode.
*/
#define Endpoint_Write_Control_Stream(Data, Length) Endpoint_Write_Control_Stream_LE(Data, Length)
/* Private Interface - For use in library only: */ /* Private Interface - For use in library only: */
#if !defined(__DOXYGEN__) #if !defined(__DOXYGEN__)
/* Macros: */ /* Macros: */
@ -868,3 +1048,5 @@
#endif #endif
#endif #endif
/** @} */

@ -87,7 +87,7 @@ void USB_Host_ResetDevice(void)
USB_INT_Disable(USB_INT_DDISCI); USB_INT_Disable(USB_INT_DDISCI);
USB_Host_ResetBus(); USB_Host_ResetBus();
while (!(USB_Host_IsResetBusDone())); while (!(USB_Host_IsBusResetComplete()));
USB_INT_Clear(USB_INT_HSOFI); USB_INT_Clear(USB_INT_HSOFI);
USB_Host_ResumeBus(); USB_Host_ResumeBus();

@ -34,6 +34,14 @@
* the USB controller is initialized in host mode. * the USB controller is initialized in host mode.
*/ */
/** \ingroup Group_USB
* @defgroup Group_Host Host Management
*
* Functions, macros, variables, enums and types related to the management of a USB host when in Host mode.
*
* @{
*/
#ifndef __USBHOST_H__ #ifndef __USBHOST_H__
#define __USBHOST_H__ #define __USBHOST_H__
@ -82,63 +90,93 @@
#define HOST_DEVICE_SETTLE_DELAY_MS 1500 #define HOST_DEVICE_SETTLE_DELAY_MS 1500
#endif #endif
/* Psuedo-Function Macros: */
#if defined(__DOXYGEN__)
/** Resets the USB bus, including the endpoints in any attached device and pipes on the AVR host. /** Resets the USB bus, including the endpoints in any attached device and pipes on the AVR host.
* USB bus resets leave the default control pipe configured (if already configured). * USB bus resets leave the default control pipe configured (if already configured).
* *
* If the USB bus has been suspended prior to issuing a bus reset, the attached device will be * If the USB bus has been suspended prior to issuing a bus reset, the attached device will be
* woken up automatically and the bus resumed after the reset has been correctly issued. * woken up automatically and the bus resumed after the reset has been correctly issued.
*/ */
#define USB_Host_ResetBus() MACROS{ UHCON |= (1 << RESET); }MACROE static inline void USB_Host_ResetBus(void);
/** Determines if a previously issued bus reset (via the USB_Host_ResetBus() macro) has /** Determines if a previously issued bus reset (via the USB_Host_ResetBus() macro) has
* completed. This macro returns true if no bus reset is currently being sent, false * completed.
* otherwise. *
* \return Boolean true if no bus reset is currently being sent, false otherwise.
*/ */
#define USB_Host_IsResetBusDone() ((UHCON & (1 << RESET)) ? false : true) static inline void USB_Host_IsBusResetComplete(void);
/** Resumes USB communications with an attached and enumerated device, by resuming the transmission /** Resumes USB communications with an attached and enumerated device, by resuming the transmission
* of the 1MS Start Of Frame messages to the device. When resumed, USB communications between the * of the 1MS Start Of Frame messages to the device. When resumed, USB communications between the
* host and attached device may occur. * host and attached device may occur.
*/ */
#define USB_Host_ResumeBus() MACROS{ UHCON |= (1 << SOFEN); }MACROE static inline void USB_Host_ResumeBus(void);
/** Suspends the USB bus, preventing any communications from occurring between the host and attached /** Suspends the USB bus, preventing any communications from occurring between the host and attached
* device until the bus has been resumed. This stops the transmission of the 1MS Start Of Frame * device until the bus has been resumed. This stops the transmission of the 1MS Start Of Frame
* messages to the device. * messages to the device.
*/ */
#define USB_Host_SuspendBus() MACROS{ UHCON &= ~(1 << SOFEN); }MACROE static inline void USB_Host_SuspendBus(void);
/** Returns true if the USB bus has been suspended via the use of the USB_Host_SuspendBus() macro, /** Determines if the USB bus has been suspended via the use of the USB_Host_SuspendBus() macro,
* false otherwise. While suspended, no USB communications can occur until the bus is resumed, * false otherwise. While suspended, no USB communications can occur until the bus is resumed,
* except for the Remote Wakeup event from the device if supported. * except for the Remote Wakeup event from the device if supported.
*
* \return Boolean true if the bus is currently suspended, false otherwise
*/ */
#define USB_Host_IsBusSuspended() ((UHCON & (1 << SOFEN)) ? false : true) static inline bool USB_Host_IsBusSuspended(void);
/** Returns true if the attached device is currently enumerated in Full Speed mode (12Mb/s), or /** Determines if the attached device is currently enumerated in Full Speed mode (12Mb/s), or
* false if the attached device is enumerated in Low Speed mode (1.5Mb/s). * false if the attached device is enumerated in Low Speed mode (1.5Mb/s).
*
* \return Boolean true if the attached device is enumerated in Full Speed mode, false otherwise
*/ */
#define USB_Host_IsDeviceFullSpeed() ((USBSTA & (1 << SPEED)) ? true : false) static inline bool USB_Host_IsDeviceFullSpeed(void);
/** Returns true if the attached device is currently issuing a Remote Wakeup request, requesting /** Determines if the attached device is currently issuing a Remote Wakeup request, requesting
* that the host resume the USB bus and wake up the device, false otherwise. * that the host resume the USB bus and wake up the device, false otherwise.
*
* \return Boolean true if the attached device has sent a Remote Wakeup request, false otherwise
*/ */
#define USB_Host_IsRemoteWakeupSent() ((UHINT & (1 << RXRSMI)) ? true : false) static inline bool USB_Host_IsRemoteWakeupSent(void);
/** Clears the flag indicating that a Remote Wakeup request has been issued by an attached /** Clears the flag indicating that a Remote Wakeup request has been issued by an attached device. */
* device. static inline void USB_Host_ClearRemoteWakeupSent(void);
*/
#define USB_Host_ClearRemoteWakeupSent() MACROS{ UHINT &= ~(1 << RXRSMI); }MACROE
/** Accepts a Remote Wakeup request from an attached device. This must be issued in response to /** Accepts a Remote Wakeup request from an attached device. This must be issued in response to
* a device's Remote Wakeup request within 2ms for the request to be accepted and the bus to * a device's Remote Wakeup request within 2ms for the request to be accepted and the bus to
* be resumed. * be resumed.
*/ */
#define USB_Host_ResumeFromWakeupRequest() MACROS{ UHCON |= (1 << RESUME); }MACROE static inline void USB_Host_ResumeFromWakeupRequest(void);
/** Returns true if no resume from Remote Wakeup request is currently being sent to an attached /** Determines if a resume from Remote Wakeup request is currently being sent to an attached
* device, false otherwise. * device.
*
* \return Boolean true if no resume request is currently being sent, false otherwise
*/ */
static inline bool USB_Host_IsResumeFromWakeupRequestSent(void);
#else
#define USB_Host_ResetBus() MACROS{ UHCON |= (1 << RESET); }MACROE
#define USB_Host_IsBusResetComplete() ((UHCON & (1 << RESET)) ? false : true)
#define USB_Host_ResumeBus() MACROS{ UHCON |= (1 << SOFEN); }MACROE
#define USB_Host_SuspendBus() MACROS{ UHCON &= ~(1 << SOFEN); }MACROE
#define USB_Host_IsBusSuspended() ((UHCON & (1 << SOFEN)) ? false : true)
#define USB_Host_IsDeviceFullSpeed() ((USBSTA & (1 << SPEED)) ? true : false)
#define USB_Host_IsRemoteWakeupSent() ((UHINT & (1 << RXRSMI)) ? true : false)
#define USB_Host_ClearRemoteWakeupSent() MACROS{ UHINT &= ~(1 << RXRSMI); }MACROE
#define USB_Host_ResumeFromWakeupRequest() MACROS{ UHCON |= (1 << RESUME); }MACROE
#define USB_Host_IsResumeFromWakeupRequestSent() ((UHCON & (1 << RESUME)) ? false : true) #define USB_Host_IsResumeFromWakeupRequestSent() ((UHCON & (1 << RESUME)) ? false : true)
#endif
/* Enums: */ /* Enums: */
/** Enum for the various states of the USB Host state machine. Only some states are /** Enum for the various states of the USB Host state machine. Only some states are
@ -243,3 +281,5 @@
#endif #endif
#endif #endif
/** @} */

@ -52,19 +52,17 @@ uint8_t USB_Host_SendControlRequest(void* BufferPtr)
Pipe_SetToken(PIPE_TOKEN_SETUP); Pipe_SetToken(PIPE_TOKEN_SETUP);
Pipe_ClearErrorFlags(); Pipe_ClearErrorFlags();
Pipe_ClearSetupSent();
Pipe_Unfreeze(); Pipe_Unfreeze();
for (uint8_t HeaderByte = 0; HeaderByte < sizeof(USB_Host_Request_Header_t); HeaderByte++) for (uint8_t HeaderByte = 0; HeaderByte < sizeof(USB_Host_Request_Header_t); HeaderByte++)
Pipe_Write_Byte(*(HeaderStream++)); Pipe_Write_Byte(*(HeaderStream++));
Pipe_ClearSetupOUT(); Pipe_ClearControlSETUP();
if ((ReturnStatus = USB_Host_Wait_For_Setup_IOS(USB_HOST_WAITFOR_SetupSent))) if ((ReturnStatus = USB_Host_Wait_For_Setup_IOS(USB_HOST_WAITFOR_SetupSent)))
goto End_Of_Control_Send; goto End_Of_Control_Send;
Pipe_ClearSetupSent();
Pipe_Freeze(); Pipe_Freeze();
if ((ReturnStatus = USB_Host_WaitMS(1)) != HOST_WAITERROR_Successful) if ((ReturnStatus = USB_Host_WaitMS(1)) != HOST_WAITERROR_Successful)
@ -93,7 +91,7 @@ uint8_t USB_Host_SendControlRequest(void* BufferPtr)
} }
Pipe_Freeze(); Pipe_Freeze();
Pipe_ClearSetupIN(); Pipe_ClearControlIN();
} }
} }
@ -103,7 +101,7 @@ uint8_t USB_Host_SendControlRequest(void* BufferPtr)
if ((ReturnStatus = USB_Host_Wait_For_Setup_IOS(USB_HOST_WAITFOR_OutReady))) if ((ReturnStatus = USB_Host_Wait_For_Setup_IOS(USB_HOST_WAITFOR_OutReady)))
goto End_Of_Control_Send; goto End_Of_Control_Send;
Pipe_ClearSetupOUT(); Pipe_ClearControlOUT();
if ((ReturnStatus = USB_Host_Wait_For_Setup_IOS(USB_HOST_WAITFOR_OutReady))) if ((ReturnStatus = USB_Host_Wait_For_Setup_IOS(USB_HOST_WAITFOR_OutReady)))
goto End_Of_Control_Send; goto End_Of_Control_Send;
@ -126,7 +124,7 @@ uint8_t USB_Host_SendControlRequest(void* BufferPtr)
DataLen--; DataLen--;
} }
Pipe_ClearSetupOUT(); Pipe_ClearControlOUT();
} }
if ((ReturnStatus = USB_Host_Wait_For_Setup_IOS(USB_HOST_WAITFOR_OutReady))) if ((ReturnStatus = USB_Host_Wait_For_Setup_IOS(USB_HOST_WAITFOR_OutReady)))
@ -141,7 +139,7 @@ uint8_t USB_Host_SendControlRequest(void* BufferPtr)
if ((ReturnStatus = USB_Host_Wait_For_Setup_IOS(USB_HOST_WAITFOR_InReceived))) if ((ReturnStatus = USB_Host_Wait_For_Setup_IOS(USB_HOST_WAITFOR_InReceived)))
goto End_Of_Control_Send; goto End_Of_Control_Send;
Pipe_ClearSetupIN(); Pipe_ClearControlIN();
} }
End_Of_Control_Send: End_Of_Control_Send:
@ -159,9 +157,9 @@ static uint8_t USB_Host_Wait_For_Setup_IOS(const uint8_t WaitType)
{ {
uint16_t TimeoutCounter = USB_HOST_TIMEOUT_MS; uint16_t TimeoutCounter = USB_HOST_TIMEOUT_MS;
while (!(((WaitType == USB_HOST_WAITFOR_SetupSent) && Pipe_IsSetupSent()) || while (!(((WaitType == USB_HOST_WAITFOR_SetupSent) && Pipe_IsSETUPSent()) ||
((WaitType == USB_HOST_WAITFOR_InReceived) && Pipe_IsSetupINReceived()) || ((WaitType == USB_HOST_WAITFOR_InReceived) && Pipe_IsINReceived()) ||
((WaitType == USB_HOST_WAITFOR_OutReady) && Pipe_IsSetupOUTReady()))) ((WaitType == USB_HOST_WAITFOR_OutReady) && Pipe_IsOUTReady())))
{ {
uint8_t ErrorCode; uint8_t ErrorCode;

@ -58,6 +58,8 @@
* *
* \see StdRequestType.h for information on the request type and data. * \see StdRequestType.h for information on the request type and data.
* \see The USB 2.0 specification for more information on standard control requests. * \see The USB 2.0 specification for more information on standard control requests.
*
* \ingroup Group_PipeControlReq
*/ */
typedef struct typedef struct
{ {
@ -71,6 +73,8 @@
/* Enums: */ /* Enums: */
/** Enum for the USB_Host_SendControlRequest() return code, indicating the reason for the error /** Enum for the USB_Host_SendControlRequest() return code, indicating the reason for the error
* if the transfer of the request is unsuccessful. * if the transfer of the request is unsuccessful.
*
* \ingroup Group_PipeControlReq
*/ */
enum USB_Host_SendControlErrorCodes_t enum USB_Host_SendControlErrorCodes_t
{ {
@ -89,6 +93,8 @@
/** Global for the request to send via the USB_Host_SendControlRequest() function. This /** Global for the request to send via the USB_Host_SendControlRequest() function. This
* global should be filled with the correct control request data before sending the request to * global should be filled with the correct control request data before sending the request to
* the attached device while in host mode. * the attached device while in host mode.
*
* \ingroup Group_PipeControlReq
*/ */
extern USB_Host_Request_Header_t USB_HostRequest; extern USB_Host_Request_Header_t USB_HostRequest;
@ -97,6 +103,8 @@
* and transfers the data stored in the buffer to the device, or from the device to the buffer * and transfers the data stored in the buffer to the device, or from the device to the buffer
* as requested. The transfer is made on the currently selected pipe. * as requested. The transfer is made on the currently selected pipe.
* *
* \ingroup Group_PipeControlReq
*
* \param BufferPtr Pointer to the start of the data buffer if the request has a data stage, or * \param BufferPtr Pointer to the start of the data buffer if the request has a data stage, or
* NULL if the request transfers no data to or from the device. * NULL if the request transfers no data to or from the device.
* *

@ -34,6 +34,14 @@
* USB interface in either device or (if supported) host mode. * USB interface in either device or (if supported) host mode.
*/ */
/** \ingroup Group_USB
* @defgroup Group_USBManagement USB Interface Management
*
* Functions, macros, variables, enums and types related to the setup and management of the USB interface.
*
* @{
*/
#ifndef __USBLOWLEVEL_H__ #ifndef __USBLOWLEVEL_H__
#define __USBLOWLEVEL_H__ #define __USBLOWLEVEL_H__
@ -70,7 +78,6 @@
/* Preprocessor Checks and Defines: */ /* Preprocessor Checks and Defines: */
#if !defined(F_CLOCK) #if !defined(F_CLOCK)
#error F_CLOCK is not defined. You must device F_CLOCK to the frequency of the unprescaled input clock in your project makefile. #error F_CLOCK is not defined. You must device F_CLOCK to the frequency of the unprescaled input clock in your project makefile.
#define F_CLOCK 0
#endif #endif
#if (F_CLOCK == 8000000) #if (F_CLOCK == 8000000)
@ -376,3 +383,5 @@
#endif #endif
#endif #endif
/** @} */

@ -36,6 +36,14 @@
* \note These macros are only for AVRs which support the OTG protocol, and do not exist for device-only AVRs. * \note These macros are only for AVRs which support the OTG protocol, and do not exist for device-only AVRs.
*/ */
/** \ingroup Group_USB
* @defgroup Group_OTGManagement USB On The Go (OTG) Management
*
* Functions, macros, variables, enums and types related to the setup and management of dual role devices.
*
* @{
*/
#ifndef __USBOTG_H__ #ifndef __USBOTG_H__
#define __USBOTG_H__ #define __USBOTG_H__
@ -47,56 +55,79 @@
/* Public Interface - May be used in end-application: */ /* Public Interface - May be used in end-application: */
/* Macros: */ /* Macros: */
/** Mask for the VBUS pulsing method of SRP, supported by some OTG devices.
*
* \see USB_OTG_DEV_Initiate_SRP()
*/
#define USB_OTG_SRP_VBUS (1 << SRPSEL)
/** Mask for the Data + pulsing method of SRP, supported by some OTG devices.
*
* \see USB_OTG_DEV_Initiate_SRP()
*/
#define USB_OTG_STP_DATA 0
/* Psuedo-Function Macros: */
#if defined(__DOXYGEN__)
/** Initiate a Host Negotiation Protocol request. This indicates to the other connected device /** Initiate a Host Negotiation Protocol request. This indicates to the other connected device
* that the device wishes to change device/host roles. * that the device wishes to change device/host roles.
*/ */
#define USB_OTG_DEV_Request_HNP() MACROS{ OTGCON |= (1 << HNPREQ); }MACROE static inline void USB_OTG_DEV_Request_HNP(void);
/** Cancel a Host Negotiation Protocol request. This stops a pending HNP request to the other /** Cancel a Host Negotiation Protocol request. This stops a pending HNP request to the other
* connected device. * connected device.
*/ */
#define USB_OTG_DEV_Cancel_HNP_Request() MACROS{ OTGCON &= ~(1 << HNPREQ); }MACROE static inline void USB_OTG_DEV_Cancel_HNP_Request(void);
/** Returns boolean false if not currently sending a HNP to the other connected device, or true /** Determines if the device is currently sending a HNP to an attached host.
* if a HNP is currently being issued. *
* \return Boolean true if currently sending a HNP to the other connected device, false otherwise
*/ */
#define USB_OTG_DEV_IsSendingHNP() ((OTGCON & (1 << HNPREQ)) ? true : false) static inline bool USB_OTG_DEV_IsSendingHNP(void);
/** Accepts a HNP from a connected device, indicating that both devices should exchange /** Accepts a HNP from a connected device, indicating that both devices should exchange
* device/host roles. * device/host roles.
*/ */
#define USB_OTG_HOST_Accept_HNP() USB_OTG_DEV_Request_HNP() static inline void USB_OTG_HOST_Accept_HNP(void);
/** Rejects a HNP from a connected device, indicating that both devices should remain in their /** Rejects a HNP from a connected device, indicating that both devices should remain in their
* current device/host roles. * current device/host roles.
*/ */
#define USB_OTG_HOST_Reject_HNP() USB_OTG_DEV_Cancel_HNP_Request() static inline void USB_OTG_HOST_Reject_HNP(void);
/** Returns boolean false if the connected device is not currently sending a HNP request, or true /** Indicates if the connected device is not currently sending a HNP request.
* if a HNP is currently being issued by the connected device. *
* \return Boolean true if a HNP is currently being issued by the connected device, false otherwise.
*/ */
#define USB_OTG_HOST_IsHNPReceived() ((OTGCON & (1 << HNPREQ)) ? true : false) static inline bool USB_OTG_HOST_IsHNPReceived(void);
/** Initiates a Session Request Protocol request. Most OTG devices turn off VBUS when the USB /** Initiates a Session Request Protocol request. Most OTG devices turn off VBUS when the USB
* interface is not in use, to conserve power. Sending a SRP to a USB OTG device running in * interface is not in use, to conserve power. Sending a SRP to a USB OTG device running in
* host mode indicates that VBUS should be applied and a session started. * host mode indicates that VBUS should be applied and a session started.
* *
* There are two different methods of sending a SRP - either pulses on the VBUS line, or by * There are two different methods of sending a SRP - either pulses on the VBUS line, or by
* pulsing the Data + line via the internal pull-up resistor. The SRP mode is given as the * pulsing the Data + line via the internal pull-up resistor.
* "type" parameter, and can be either USB_OTG_SRP_VBUS or USB_OTG_STP_DATA.
*/
#define USB_OTG_DEV_Initiate_SRP(type) MACROS{ OTGCON = ((OTGCON & ~(1 << SRPSEL)) | (type | (1 << SRPREQ))); }MACROE
/** Mask for the VBUS pulsing method of SRP, supported by some OTG devices.
* *
* \see USB_OTG_DEV_Initiate_SRP() * \param SRPTypeMask Mask indicating the type of SRP to use, either USB_OTG_SRP_VBUS or USB_OTG_STP_DATA.
*/ */
#define USB_OTG_SRP_VBUS (1 << SRPSEL) static inline void USB_OTG_DEV_Initiate_SRP(uint8_t SRPTypeMask);
#else
/** Mask for the Data + pulsing method of SRP, supported by some OTG devices. #define USB_OTG_DEV_Request_HNP() MACROS{ OTGCON |= (1 << HNPREQ); }MACROE
*
* \see USB_OTG_DEV_Initiate_SRP()
*/
#define USB_OTG_STP_DATA 0
#define USB_OTG_DEV_Cancel_HNP_Request() MACROS{ OTGCON &= ~(1 << HNPREQ); }MACROE
#define USB_OTG_DEV_IsSendingHNP() ((OTGCON & (1 << HNPREQ)) ? true : false)
#define USB_OTG_HOST_Accept_HNP() MACROS{ OTGCON |= (1 << HNPREQ); }MACROE
#define USB_OTG_HOST_Reject_HNP() MACROS{ OTGCON &= ~(1 << HNPREQ); }MACROE
#define USB_OTG_HOST_IsHNPReceived() ((OTGCON & (1 << HNPREQ)) ? true : false)
#define USB_OTG_DEV_Initiate_SRP(type) MACROS{ OTGCON = ((OTGCON & ~(1 << SRPSEL)) | (type | (1 << SRPREQ))); }MACROE
#endif #endif
#endif
/** @} */

@ -74,8 +74,19 @@ uint8_t Pipe_WaitUntilReady(void)
USB_INT_Clear(USB_INT_HSOFI); USB_INT_Clear(USB_INT_HSOFI);
while (!(Pipe_ReadWriteAllowed())) for (;;)
{ {
if (Pipe_GetPipeToken() == PIPE_TOKEN_IN)
{
if (Pipe_IsINReceived())
return PIPE_READYWAIT_NoError;
}
else
{
if (Pipe_IsOUTReady())
return PIPE_READYWAIT_NoError;
}
if (Pipe_IsStalled()) if (Pipe_IsStalled())
return PIPE_READYWAIT_PipeStalled; return PIPE_READYWAIT_PipeStalled;
else if (!(USB_IsConnected)) else if (!(USB_IsConnected))
@ -89,8 +100,6 @@ uint8_t Pipe_WaitUntilReady(void)
return PIPE_READYWAIT_Timeout; return PIPE_READYWAIT_Timeout;
} }
} }
return PIPE_READYWAIT_NoError;
} }
uint8_t Pipe_Write_Stream_LE(const void* Data, uint16_t Length uint8_t Pipe_Write_Stream_LE(const void* Data, uint16_t Length
@ -107,9 +116,9 @@ uint8_t Pipe_Write_Stream_LE(const void* Data, uint16_t Length
while (Length--) while (Length--)
{ {
if (!(Pipe_ReadWriteAllowed())) if (!(Pipe_IsReadWriteAllowed()))
{ {
Pipe_ClearCurrentBank(); Pipe_ClearOUT();
#if !defined(NO_STREAM_CALLBACKS) #if !defined(NO_STREAM_CALLBACKS)
if ((Callback != NULL) && (Callback() == STREAMCALLBACK_Abort)) if ((Callback != NULL) && (Callback() == STREAMCALLBACK_Abort))
@ -119,9 +128,11 @@ uint8_t Pipe_Write_Stream_LE(const void* Data, uint16_t Length
if ((ErrorCode = Pipe_WaitUntilReady())) if ((ErrorCode = Pipe_WaitUntilReady()))
return ErrorCode; return ErrorCode;
} }
else
{
Pipe_Write_Byte(*(DataStream++)); Pipe_Write_Byte(*(DataStream++));
} }
}
return PIPE_RWSTREAM_ERROR_NoError; return PIPE_RWSTREAM_ERROR_NoError;
} }
@ -140,9 +151,9 @@ uint8_t Pipe_Write_Stream_BE(const void* Data, uint16_t Length
while (Length--) while (Length--)
{ {
if (!(Pipe_ReadWriteAllowed())) if (!(Pipe_IsReadWriteAllowed()))
{ {
Pipe_ClearCurrentBank(); Pipe_ClearOUT();
#if !defined(NO_STREAM_CALLBACKS) #if !defined(NO_STREAM_CALLBACKS)
if ((Callback != NULL) && (Callback() == STREAMCALLBACK_Abort)) if ((Callback != NULL) && (Callback() == STREAMCALLBACK_Abort))
@ -152,9 +163,11 @@ uint8_t Pipe_Write_Stream_BE(const void* Data, uint16_t Length
if ((ErrorCode = Pipe_WaitUntilReady())) if ((ErrorCode = Pipe_WaitUntilReady()))
return ErrorCode; return ErrorCode;
} }
else
{
Pipe_Write_Byte(*(DataStream--)); Pipe_Write_Byte(*(DataStream--));
} }
}
return PIPE_RWSTREAM_ERROR_NoError; return PIPE_RWSTREAM_ERROR_NoError;
} }
@ -172,9 +185,9 @@ uint8_t Pipe_Discard_Stream(uint16_t Length
while (Length--) while (Length--)
{ {
if (!(Pipe_ReadWriteAllowed())) if (!(Pipe_IsReadWriteAllowed()))
{ {
Pipe_ClearCurrentBank(); Pipe_ClearIN();
#if !defined(NO_STREAM_CALLBACKS) #if !defined(NO_STREAM_CALLBACKS)
if ((Callback != NULL) && (Callback() == STREAMCALLBACK_Abort)) if ((Callback != NULL) && (Callback() == STREAMCALLBACK_Abort))
@ -184,9 +197,11 @@ uint8_t Pipe_Discard_Stream(uint16_t Length
if ((ErrorCode = Pipe_WaitUntilReady())) if ((ErrorCode = Pipe_WaitUntilReady()))
return ErrorCode; return ErrorCode;
} }
else
{
Pipe_Discard_Byte(); Pipe_Discard_Byte();
} }
}
return PIPE_RWSTREAM_ERROR_NoError; return PIPE_RWSTREAM_ERROR_NoError;
} }
@ -205,9 +220,9 @@ uint8_t Pipe_Read_Stream_LE(void* Buffer, uint16_t Length
while (Length--) while (Length--)
{ {
if (!(Pipe_ReadWriteAllowed())) if (!(Pipe_IsReadWriteAllowed()))
{ {
Pipe_ClearCurrentBank(); Pipe_ClearIN();
#if !defined(NO_STREAM_CALLBACKS) #if !defined(NO_STREAM_CALLBACKS)
if ((Callback != NULL) && (Callback() == STREAMCALLBACK_Abort)) if ((Callback != NULL) && (Callback() == STREAMCALLBACK_Abort))
@ -217,9 +232,11 @@ uint8_t Pipe_Read_Stream_LE(void* Buffer, uint16_t Length
if ((ErrorCode = Pipe_WaitUntilReady())) if ((ErrorCode = Pipe_WaitUntilReady()))
return ErrorCode; return ErrorCode;
} }
else
{
*(DataStream++) = Pipe_Read_Byte(); *(DataStream++) = Pipe_Read_Byte();
} }
}
return PIPE_RWSTREAM_ERROR_NoError; return PIPE_RWSTREAM_ERROR_NoError;
} }
@ -238,9 +255,9 @@ uint8_t Pipe_Read_Stream_BE(void* Buffer, uint16_t Length
while (Length--) while (Length--)
{ {
if (!(Pipe_ReadWriteAllowed())) if (!(Pipe_IsReadWriteAllowed()))
{ {
Pipe_ClearCurrentBank(); Pipe_ClearIN();
#if !defined(NO_STREAM_CALLBACKS) #if !defined(NO_STREAM_CALLBACKS)
if ((Callback != NULL) && (Callback() == STREAMCALLBACK_Abort)) if ((Callback != NULL) && (Callback() == STREAMCALLBACK_Abort))
@ -250,9 +267,11 @@ uint8_t Pipe_Read_Stream_BE(void* Buffer, uint16_t Length
if ((ErrorCode = Pipe_WaitUntilReady())) if ((ErrorCode = Pipe_WaitUntilReady()))
return ErrorCode; return ErrorCode;
} }
else
{
*(DataStream--) = Pipe_Read_Byte(); *(DataStream--) = Pipe_Read_Byte();
} }
}
return PIPE_RWSTREAM_ERROR_NoError; return PIPE_RWSTREAM_ERROR_NoError;
} }

@ -35,6 +35,29 @@
* send/recieve functions for various data types. * send/recieve functions for various data types.
*/ */
/** \ingroup Group_USB
* @defgroup Group_PipeManagement Pipe Management
*
* Functions, macros, variables, enums and types related to the setup and management of pipes while in USB Device mode.
*
* @{
*/
/** @defgroup Group_PipeRW Pipe Data Reading and Writing
*
* Functions, macros, variables, enums and types related to data reading and writing from and to pipes.
*/
/** @defgroup Group_PipePacketManagement Pipe Packet Management
*
* Functions, macros, variables, enums and types related to packet management of pipes.
*/
/** @defgroup Group_PipeControlReq Pipe Control Request Management
*
* Functions, macros, variables, enums and types related to control request management of pipes.
*/
#ifndef __PIPE_H__ #ifndef __PIPE_H__
#define __PIPE_H__ #define __PIPE_H__
@ -221,21 +244,38 @@
*/ */
#define PIPE_INT_STALL UPIENX, (1 << RXSTALLE), UPINTX, (1 << RXSTALLI) #define PIPE_INT_STALL UPIENX, (1 << RXSTALLE), UPINTX, (1 << RXSTALLI)
/** Indicates the number of bytes currently stored in the current pipe's selected bank. */ /* Psuedo-Function Macros: */
#define Pipe_BytesInPipe() UPBCX #if defined(__DOXYGEN__)
/** Indicates the number of bytes currently stored in the current pipes's selected bank.
*
* \note The return width of this function may differ, depending on the maximum pipe bank size
* of the selected AVR model.
*
* \ingroup Group_PipeRW
*
* \return Total number of bytes in the currently selected Pipe's FIFO buffer
*/
static inline uint16_t Pipe_BytesInPipe(void);
/** Resets the desired pipe, including the pipe banks and flags. */ /** Returns the pipe address of the currently selected pipe. This is typically used to save the
#define Pipe_ResetPipe(pipenum) MACROS{ UPRST = (1 << pipenum); UPRST = 0; }MACROE * currently selected pipe number so that it can be restored after another pipe has been manipulated.
*
* \return Index of the currently selected pipe
*/
static inline uint8_t Pipe_GetCurrentPipe(void);
/** Selects the given pipe number. Any pipe operations which do not require the pipe number to be /** Selects the given pipe number. Any pipe operations which do not require the pipe number to be
* indicated will operate on the currently selected pipe. * indicated will operate on the currently selected pipe.
*
* \param PipeNumber Index of the pipe to select
*/ */
#define Pipe_SelectPipe(pipenum) MACROS{ UPNUM = pipenum; }MACROE static inline void Pipe_SelectPipe(uint8_t PipeNumber);
/** Returns the pipe address of the currently selected pipe. This is typically used to save the /** Resets the desired pipe, including the pipe banks and flags.
* currently selected pipe number so that it can be restored after another pipe has been manipulated. *
* \param PipeNumber Index of the pipe to reset
*/ */
#define Pipe_GetCurrentPipe() (UPNUM & PIPE_PIPENUM_MASK) static inline void Pipe_ResetPipe(uint8_t PipeNumber);
/** Enables the currently selected pipe so that data can be sent and received through it to and from /** Enables the currently selected pipe so that data can be sent and received through it to and from
* an attached device. * an attached device.
@ -243,136 +283,300 @@
* \note Pipes must first be configured properly rather than just being enabled via the * \note Pipes must first be configured properly rather than just being enabled via the
* Pipe_ConfigurePipe() macro, which calls Pipe_EnablePipe() automatically. * Pipe_ConfigurePipe() macro, which calls Pipe_EnablePipe() automatically.
*/ */
#define Pipe_EnablePipe() MACROS{ UPCONX |= (1 << PEN); }MACROE static inline void Pipe_EnablePipe(void);
/** Disables the currently selected pipe so that data cannot be sent and received through it to and /** Disables the currently selected pipe so that data cannot be sent and received through it to and
* from an attached device. * from an attached device.
*/ */
#define Pipe_DisablePipe() MACROS{ UPCONX &= ~(1 << PEN); }MACROE static inline void Pipe_DisablePipe(void);
/** Returns true if the currently selected pipe is enabled, false otherwise. */ /** Determines if the currently selected pipe is enabled, but not necessarily configured.
#define Pipe_IsEnabled() ((UPCONX & (1 << PEN)) ? true : false) *
* \return Boolean True if the currently selected pipe is enabled, false otherwise
*/
static inline bool Pipe_IsEnabled(void);
/** Gets the current pipe token, indicating the pipe's data direction and type.
*
* \return The current pipe token, as a PIPE_TOKEN_* mask
*/
static inline uint8_t Pipe_GetCurrentToken(void);
/** Sets the token for the currently selected endpoint to one of the tokens specified by the PIPE_TOKEN_* /** Sets the token for the currently selected pipe to one of the tokens specified by the PIPE_TOKEN_*
* masks. This should only be used on CONTROL type endpoints, to allow for bidirectional transfer of * masks. This can be used on CONTROL type pipes, to allow for bidirectional transfer of data during
* data during control requests. * control requests, or on regular pipes to allow for half-duplex bidirectional data transfer to devices
* which have two endpoints of opposite direction sharing the same endpoint address within the device.
*
* \param Token New pipe token to set the selected pipe to, as a PIPE_TOKEN_* mask
*/ */
#define Pipe_SetToken(token) MACROS{ UPCFG0X = ((UPCFG0X & ~PIPE_TOKEN_MASK) | token); }MACROE static inline void Pipe_SetPipeToken(uint8_t Token);
/** Configures the currently selected pipe to allow for an unlimited number of IN requests. */ /** Configures the currently selected pipe to allow for an unlimited number of IN requests. */
#define Pipe_SetInfiniteINRequests() MACROS{ UPCONX |= (1 << INMODE); }MACROE static inline void Pipe_SetInfiniteINRequests(void);
/** Configures the currently selected pipe to only allow the specified number of IN requests to be /** Configures the currently selected pipe to only allow the specified number of IN requests to be
* accepted by the pipe before it is automatically frozen. * accepted by the pipe before it is automatically frozen.
*
* \param TotalINRequests Total number of IN requests that the pipe may receive before freezing
*/ */
#define Pipe_SetFiniteINRequests(n) MACROS{ UPCONX &= ~(1 << INMODE); UPINRQX = n; }MACROE static inline void Pipe_SetFiniteINRequests(uint8_t TotalINRequests);
/** Returns true if the currently selected pipe is configured, false otherwise. */ /** Determines if the currently selected pipe is configured.
#define Pipe_IsConfigured() ((UPSTAX & (1 << CFGOK)) ? true : false) *
* \return Boolean true if the selected pipe is configured, false otherwise
*/
static inline bool Pipe_IsConfigured(void);
/** Sets the period between interrupts for an INTERRUPT type pipe to a specified number of milliseconds. */ /** Sets the period between interrupts for an INTERRUPT type pipe to a specified number of milliseconds.
#define Pipe_SetInterruptPeriod(ms) MACROS{ UPCFG2X = ms; }MACROE *
* \param Milliseconds Number of milliseconds between each pipe poll
*/
static inline void Pipe_SetInterruptPeriod(uint8_t Milliseconds);
/** Returns a mask indicating which pipe's interrupt periods have elapsed, indicating that the pipe should /** Returns a mask indicating which pipe's interrupt periods have elapsed, indicating that the pipe should
* be serviced. * be serviced.
*
* \return Mask whose bits indicate which pipes have interrupted
*/ */
#define Pipe_GetPipeInterrupts() UPINT static inline uint8_t Pipe_GetPipeInterrupts(void);
/** Clears the interrupt flag for the specified pipe number. */
#define Pipe_ClearPipeInterrupt(n) MACROS{ UPINT &= ~(1 << n); }MACROE
/** Returns true if the specified pipe's interrupt period has elapsed, false otherwise. */ /** Clears the interrupt flag for the specified pipe number.
#define Pipe_HasPipeInterrupted(n) ((UPINT & (1 << n)) ? true : false) *
* \param PipeNumber Index of the pipe whose interrupt flag is to be cleared
*/
static inline void Pipe_ClearPipeInterrupt(uint8_t PipeNumber);
/** Clears the pipe bank, and switches to the alternate bank if the currently selected pipe is /** Determines if the specified pipe number has interrupted (valid only for INTERRUPT type
* dual-banked. When cleared, this either frees the bank up for the next packet from the host * pipes).
* (if the endpoint is of the OUT direction) or sends the packet contents to the host (if the *
* pipe is of the IN direction). * \param PipeNumber Index of the pipe whose interrupt flag should be tested
*
* \return Boolean true if the specified pipe has interrupted, false otherwise
*/ */
#define Pipe_ClearCurrentBank() MACROS{ UPINTX &= ~(1 << FIFOCON); }MACROE static inline bool Pipe_HasPipeInterrupted(uint8_t PipeNumber);
/** Unfreezes the pipe, allowing it to communicate with an attached device. */ /** Unfreezes the selected pipe, allowing it to communicate with an attached device. */
#define Pipe_Unfreeze() MACROS{ UPCONX &= ~(1 << PFREEZE); }MACROE static inline void Pipe_Unfreeze(void);
/** Freezes the pipe, preventing it from communicating with an attached device. */ /** Freezes the selected pipe, preventing it from communicating with an attached device. */
#define Pipe_Freeze() MACROS{ UPCONX |= (1 << PFREEZE); }MACROE static inline void Pipe_Freeze(void);
/** Clears the master pipe error flag. */ /** Clears the master pipe error flag. */
#define Pipe_ClearError() MACROS{ UPINTX &= ~(1 << PERRI); }MACROE static inline void Pipe_ClearError(void);
/** Returns true if the master pipe error flag is set for the currently selected pipe, indicating that /** Determines if the master pipe error flag is set for the currently selected pipe, indicating that
* some sort of hardware error has occurred on the pipe. * some sort of hardware error has occurred on the pipe.
* *
* \see Pipe_GetErrorFlags() macro for information on retrieving the exact error flag. * \see Pipe_GetErrorFlags() macro for information on retrieving the exact error flag.
*
* \return Boolean true if an error has ocurred on the selected pipe, false otherwise
*/ */
#define Pipe_IsError() ((UPINTX & (1 << PERRI)) ? true : false) static inline bool Pipe_IsError(void);
/** Clears all the currently selected pipe's hardware error flags, but does not clear the master error /** Clears all the currently selected pipe's hardware error flags, but does not clear the master error
* flag for the pipe. */ * flag for the pipe.
#define Pipe_ClearErrorFlags() MACROS{ UPERRX = 0; }MACROE */
static inline void Pipe_ClearErrorFlags(void);
/** Returns a mask of the hardware error flags which have occurred on the currently selected pipe. This /** Gets a mask of the hardware error flags which have occurred on the currently selected pipe. This
* value can then be masked against the PIPE_ERRORFLAG_* masks to determine what error has occurred. * value can then be masked against the PIPE_ERRORFLAG_* masks to determine what error has occurred.
*
* \return Mask comprising of PIPE_ERRORFLAG_* bits indicating what error has ocurred on the selected pipe
*/ */
#define Pipe_GetErrorFlags() UPERRX static inline uint8_t Pipe_GetErrorFlags(void);
/** Returns true if the currently selected pipe may be read from (if data is waiting in the pipe /** Determines if the currently selected pipe may be read from (if data is waiting in the pipe
* bank and the pipe is an IN direction, or if the bank is not yet full if the pipe is an OUT * bank and the pipe is an IN direction, or if the bank is not yet full if the pipe is an OUT
* direction). This function will return false if an error has occurred in the pipe, or if the pipe * direction). This function will return false if an error has occurred in the pipe, or if the pipe
* is an IN direction and no packet has been received, or if the pipe is an OUT direction and the * is an IN direction and no packet (or an empty packet) has been received, or if the pipe is an OUT
* pipe bank is full. * direction and the pipe bank is full.
*
* \ingroup Group_PipePacketManagement
*
* \return Boolean true if the currently selected pipe may be read from or written to, depending on its direction
*/ */
#define Pipe_ReadWriteAllowed() ((UPINTX & (1 << RWAL)) ? true : false) static inline bool Pipe_IsReadWriteAllowed(void);
/** Clears the flag indicating that a SETUP request has been sent to the attached device from the /** Determines if an IN request has been received on the currently selected pipe.
* currently selected CONTROL type pipe. *
* \ingroup Group_PipePacketManagement
*
* \return Boolean true if the current pipe has received an IN packet, false otherwise.
*/ */
#define Pipe_ClearSetupSent() MACROS{ UPINTX &= ~(1 << TXSTPI); }MACROE static inline bool Pipe_IsINReceived(void);
/** Returns true if no SETUP request is currently being sent to the attached device, false otherwise. */ /** Determines if the currently selected pipe is ready to send an OUT request.
#define Pipe_IsSetupSent() ((UPINTX & (1 << TXSTPI)) ? true : false) *
* \ingroup Group_PipePacketManagement
*
* \return Boolean true if the current pipe is ready for an OUT packet, false otherwise.
*/
static inline bool Pipe_IsOUTReady(void);
/** Returns true if the currently selected pipe has been stalled by the attached device, false otherwise. */ /** Determines if no SETUP request is currently being sent to the attached device on the selected
#define Pipe_IsStalled() ((UPINTX & (1 << RXSTALLI)) ? true : false) * CONTROL type pipe.
*
* \ingroup Group_PipePacketManagement
*
* \return Boolean true if the current pipe is ready for a SETUP packet, false otherwise.
*/
static inline bool Pipe_IsSETUPSent(void);
/** Clears the stall condition on the currently selected pipe. */ /** Acknowledges the reception of a setup IN request from the attached device on the currently selected
#define Pipe_ClearStall() MACROS{ UPINTX &= ~(1 << RXSTALLI); }MACROE * CONTROL type pipe, freeing the bank ready for the next packet.
*
* \ingroup Group_PipePacketManagement
*
* \note For non CONTROL type pipes, use Pipe_ClearIN() instead.
*/
static inline void Pipe_ClearControlIN(void);
/** Returns true if an IN request has been received on the currently selected CONTROL type pipe, false /** Sends the currently selected pipe's contents to the device as an OUT packet on the selected pipe, freeing
* otherwise. * the bank ready for the next packet.
*
* \ingroup Group_PipePacketManagement
*
* \note For non CONTROL type pipes, use Pipe_ClearOUT() instead.
*/ */
#define Pipe_IsSetupINReceived() ((UPINTX & (1 << RXINI)) ? true : false) static inline void Pipe_ClearControlOUT(void);
/** Returns true if the currently selected CONTROL type pipe is ready to send an OUT request, false /** Sends the currently selected CONTROL type pipe's contents to the device as a SETUP packet.
* otherwise. *
* \ingroup Group_PipePacketManagement
*
* \note This is not applicable for non CONTROL type pipes.
*/ */
#define Pipe_IsSetupOUTReady() ((UPINTX & (1 << TXOUTI)) ? true : false) static inline void Pipe_ClearControlSETUP(void);
/** Acknowledges the reception of a setup IN request from the attached device on the currently selected /** Acknowledges the reception of a setup IN request from the attached device on the currently selected
* CONTROL type endpoint, allowing for the transmission of a setup OUT packet, or the reception of * pipe, freeing the bank ready for the next packet.
* another setup IN packet. *
* \ingroup Group_PipePacketManagement
*
* \note For CONTROL type pipes, use Pipe_ClearControlIN() instead.
*/ */
#define Pipe_ClearSetupIN() MACROS{ UPINTX &= ~(1 << RXINI); UPINTX &= ~(1 << FIFOCON); }MACROE static inline void Pipe_ClearIN(void);
/** Sends the currently selected CONTROL type pipe's contents to the device as a setup OUT packet. */ /** Sends the currently selected pipe's contents to the device as an OUT packet on the selected pipe, freeing
#define Pipe_ClearSetupOUT() MACROS{ UPINTX &= ~(1 << TXOUTI); UPINTX &= ~(1 << FIFOCON); }MACROE * the bank ready for the next packet.
*
* \ingroup Group_PipePacketManagement
*
* \note For CONTROL type pipes, use Pipe_ClearControlOUT() instead.
*/
static inline void Pipe_ClearOUT(void);
/** Returns true if the device sent a NAK (Negative Acknowledge) in response to the last sent packet on /** Determines if the device sent a NAK (Negative Acknowledge) in response to the last sent packet on
* the currently selected pipe. This occurs when the host sends a packet to the device, but the device * the currently selected pipe. This occurs when the host sends a packet to the device, but the device
* is not currently ready to handle the packet (i.e. its endpoint banks are full). Once a NAK has been * is not currently ready to handle the packet (i.e. its endpoint banks are full). Once a NAK has been
* received, it must be cleared using Pipe_ClearNAKReceived() before the previous (or any other) packet * received, it must be cleared using Pipe_ClearNAKReceived() before the previous (or any other) packet
* can be re-sent. * can be re-sent.
*
* \ingroup Group_PipePacketManagement
*
* \return Boolean true if an NAK has been received on the current pipe, false otherwise
*/ */
#define Pipe_IsNAKReceived() ((UPINTX & (1 << NAKEDI)) ? true : false) static inline bool Pipe_IsNAKReceived(void);
/** Clears the NAK condition on the currently selected pipe. /** Clears the NAK condition on the currently selected pipe.
*
* \ingroup Group_PipePacketManagement
* *
* \see Pipe_IsNAKReceived() for more details. * \see Pipe_IsNAKReceived() for more details.
*/ */
static inline void Pipe_ClearNAKReceived(void);
/** Determines if the currently selected pipe has had the STALL condition set by the attached device.
*
* \ingroup Group_PipePacketManagement
*
* \return Boolean true if the current pipe has been stalled by the attached device, false otherwise
*/
static inline bool Pipe_IsStalled(void);
/** Clears the STALL condition detection flag on the currently selected pipe, but does not clear the
* STALL condition itself (this must be done via a ClearFeature control request to the device).
*
* \ingroup Group_PipePacketManagement
*/
static inline void Pipe_ClearStall(void);
#else
#define Pipe_BytesInPipe() UPBCX
#define Pipe_GetCurrentPipe() (UPNUM & PIPE_PIPENUM_MASK)
#define Pipe_SelectPipe(pipenum) MACROS{ UPNUM = pipenum; }MACROE
#define Pipe_ResetPipe(pipenum) MACROS{ UPRST = (1 << pipenum); UPRST = 0; }MACROE
#define Pipe_EnablePipe() MACROS{ UPCONX |= (1 << PEN); }MACROE
#define Pipe_DisablePipe() MACROS{ UPCONX &= ~(1 << PEN); }MACROE
#define Pipe_IsEnabled() ((UPCONX & (1 << PEN)) ? true : false)
#define Pipe_GetPipeToken() (UPCFG0X & PIPE_TOKEN_MASK)
#define Pipe_SetToken(token) MACROS{ UPCFG0X = ((UPCFG0X & ~PIPE_TOKEN_MASK) | token); }MACROE
#define Pipe_SetInfiniteINRequests() MACROS{ UPCONX |= (1 << INMODE); }MACROE
#define Pipe_SetFiniteINRequests(n) MACROS{ UPCONX &= ~(1 << INMODE); UPINRQX = n; }MACROE
#define Pipe_IsConfigured() ((UPSTAX & (1 << CFGOK)) ? true : false)
#define Pipe_SetInterruptPeriod(ms) MACROS{ UPCFG2X = ms; }MACROE
#define Pipe_GetPipeInterrupts() UPINT
#define Pipe_ClearPipeInterrupt(n) MACROS{ UPINT &= ~(1 << n); }MACROE
#define Pipe_HasPipeInterrupted(n) ((UPINT & (1 << n)) ? true : false)
#define Pipe_Unfreeze() MACROS{ UPCONX &= ~(1 << PFREEZE); }MACROE
#define Pipe_Freeze() MACROS{ UPCONX |= (1 << PFREEZE); }MACROE
#define Pipe_ClearError() MACROS{ UPINTX &= ~(1 << PERRI); }MACROE
#define Pipe_IsError() ((UPINTX & (1 << PERRI)) ? true : false)
#define Pipe_ClearErrorFlags() MACROS{ UPERRX = 0; }MACROE
#define Pipe_GetErrorFlags() UPERRX
#define Pipe_IsReadWriteAllowed() ((UPINTX & (1 << RWAL)) ? true : false)
#define Pipe_IsINReceived() ((UPINTX & (1 << RXINI)) ? true : false)
#define Pipe_IsOUTReady() ((UPINTX & (1 << TXOUTI)) ? true : false)
#define Pipe_IsSETUPSent() ((UPINTX & (1 << TXSTPI)) ? true : false)
#define Pipe_ClearIN() MACROS{ UPINTX &= ~(1 << RXINI); UPINTX &= ~(1 << FIFOCON); }MACROE
#define Pipe_ClearControlIN() MACROS{ UPINTX &= ~(1 << RXINI); UPINTX &= ~(1 << FIFOCON); }MACROE
#define Pipe_ClearOUT() MACROS{ UPINTX &= ~(1 << TXOUTI); UPINTX &= ~(1 << FIFOCON); }MACROE
#define Pipe_ClearControlOUT() MACROS{ UPINTX &= ~(1 << TXOUTI); UPINTX &= ~(1 << FIFOCON); }MACROE
#define Pipe_ClearControlSETUP() MACROS{ UPINTX &= ~(1 << TXSTPI); UPINTX &= ~(1 << FIFOCON); }MACROE
#define Pipe_IsNAKReceived() ((UPINTX & (1 << NAKEDI)) ? true : false)
#define Pipe_ClearNAKReceived() MACROS{ UPINTX &= ~(1 << NAKEDI); }MACROE #define Pipe_ClearNAKReceived() MACROS{ UPINTX &= ~(1 << NAKEDI); }MACROE
#define Pipe_IsStalled() ((UPINTX & (1 << RXSTALLI)) ? true : false)
#define Pipe_ClearStall() MACROS{ UPINTX &= ~(1 << RXSTALLI); }MACROE
#endif
/* Enums: */ /* Enums: */
/** Enum for the possible error return codes of the Pipe_WaitUntilReady function */ /** Enum for the possible error return codes of the Pipe_WaitUntilReady function
*
* \ingroup Group_PipeRW
*/
enum Pipe_WaitUntilReady_ErrorCodes_t enum Pipe_WaitUntilReady_ErrorCodes_t
{ {
PIPE_READYWAIT_NoError = 0, /**< Pipe ready for next packet, no error */ PIPE_READYWAIT_NoError = 0, /**< Pipe ready for next packet, no error */
@ -384,7 +588,10 @@
*/ */
}; };
/** Enum for the possible error return codes of the Pipe_*_Stream_* functions. */ /** Enum for the possible error return codes of the Pipe_*_Stream_* functions.
*
* \ingroup Group_PipeRW
*/
enum Pipe_Stream_RW_ErrorCodes_t enum Pipe_Stream_RW_ErrorCodes_t
{ {
PIPE_RWSTREAM_ERROR_NoError = 0, /**< Command completed successfully, no error. */ PIPE_RWSTREAM_ERROR_NoError = 0, /**< Command completed successfully, no error. */
@ -402,21 +609,34 @@
}; };
/* Inline Functions: */ /* Inline Functions: */
/** Reads one byte from the currently selected pipe's bank, for OUT direction pipes. */ /** Reads one byte from the currently selected pipe's bank, for OUT direction pipes.
*
* \ingroup Group_PipeRW
*
* \return Next byte in the currently selected pipe's FIFO buffer
*/
static inline uint8_t Pipe_Read_Byte(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; static inline uint8_t Pipe_Read_Byte(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
static inline uint8_t Pipe_Read_Byte(void) static inline uint8_t Pipe_Read_Byte(void)
{ {
return UPDATX; return UPDATX;
} }
/** Writes one byte from the currently selected pipe's bank, for IN direction pipes. */ /** Writes one byte from the currently selected pipe's bank, for IN direction pipes.
*
* \ingroup Group_PipeRW
*
* \param Byte Next byte to write into the the currently selected pipe's FIFO buffer
*/
static inline void Pipe_Write_Byte(const uint8_t Byte) ATTR_ALWAYS_INLINE; static inline void Pipe_Write_Byte(const uint8_t Byte) ATTR_ALWAYS_INLINE;
static inline void Pipe_Write_Byte(const uint8_t Byte) static inline void Pipe_Write_Byte(const uint8_t Byte)
{ {
UPDATX = Byte; UPDATX = Byte;
} }
/** Discards one byte from the currently selected pipe's bank, for OUT direction pipes. */ /** Discards one byte from the currently selected pipe's bank, for OUT direction pipes.
*
* \ingroup Group_PipeRW
*/
static inline void Pipe_Discard_Byte(void) ATTR_ALWAYS_INLINE; static inline void Pipe_Discard_Byte(void) ATTR_ALWAYS_INLINE;
static inline void Pipe_Discard_Byte(void) static inline void Pipe_Discard_Byte(void)
{ {
@ -427,6 +647,10 @@
/** Reads two bytes from the currently selected pipe's bank in little endian format, for OUT /** Reads two bytes from the currently selected pipe's bank in little endian format, for OUT
* direction pipes. * direction pipes.
*
* \ingroup Group_PipeRW
*
* \return Next word in the currently selected pipe's FIFO buffer
*/ */
static inline uint16_t Pipe_Read_Word_LE(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; static inline uint16_t Pipe_Read_Word_LE(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
static inline uint16_t Pipe_Read_Word_LE(void) static inline uint16_t Pipe_Read_Word_LE(void)
@ -441,6 +665,10 @@
/** Reads two bytes from the currently selected pipe's bank in big endian format, for OUT /** Reads two bytes from the currently selected pipe's bank in big endian format, for OUT
* direction pipes. * direction pipes.
*
* \ingroup Group_PipeRW
*
* \return Next word in the currently selected pipe's FIFO buffer
*/ */
static inline uint16_t Pipe_Read_Word_BE(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; static inline uint16_t Pipe_Read_Word_BE(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
static inline uint16_t Pipe_Read_Word_BE(void) static inline uint16_t Pipe_Read_Word_BE(void)
@ -455,6 +683,10 @@
/** Writes two bytes to the currently selected pipe's bank in little endian format, for IN /** Writes two bytes to the currently selected pipe's bank in little endian format, for IN
* direction pipes. * direction pipes.
*
* \ingroup Group_PipeRW
*
* \param Word Next word to write to the currently selected pipe's FIFO buffer
*/ */
static inline void Pipe_Write_Word_LE(const uint16_t Word) ATTR_ALWAYS_INLINE; static inline void Pipe_Write_Word_LE(const uint16_t Word) ATTR_ALWAYS_INLINE;
static inline void Pipe_Write_Word_LE(const uint16_t Word) static inline void Pipe_Write_Word_LE(const uint16_t Word)
@ -465,6 +697,10 @@
/** Writes two bytes to the currently selected pipe's bank in big endian format, for IN /** Writes two bytes to the currently selected pipe's bank in big endian format, for IN
* direction pipes. * direction pipes.
*
* \ingroup Group_PipeRW
*
* \param Word Next word to write to the currently selected pipe's FIFO buffer
*/ */
static inline void Pipe_Write_Word_BE(const uint16_t Word) ATTR_ALWAYS_INLINE; static inline void Pipe_Write_Word_BE(const uint16_t Word) ATTR_ALWAYS_INLINE;
static inline void Pipe_Write_Word_BE(const uint16_t Word) static inline void Pipe_Write_Word_BE(const uint16_t Word)
@ -473,9 +709,12 @@
UPDATX = (Word & 0xFF); UPDATX = (Word & 0xFF);
} }
/** Discards two bytes from the currently selected pipe's bank, for OUT direction pipes. */ /** Discards two bytes from the currently selected pipe's bank, for OUT direction pipes.
static inline void Pipe_Ignore_Word(void) ATTR_ALWAYS_INLINE; *
static inline void Pipe_Ignore_Word(void) * \ingroup Group_PipeRW
*/
static inline void Pipe_Discard_Word(void) ATTR_ALWAYS_INLINE;
static inline void Pipe_Discard_Word(void)
{ {
uint8_t Dummy; uint8_t Dummy;
@ -485,6 +724,10 @@
/** Reads four bytes from the currently selected pipe's bank in little endian format, for OUT /** Reads four bytes from the currently selected pipe's bank in little endian format, for OUT
* direction pipes. * direction pipes.
*
* \ingroup Group_PipeRW
*
* \return Next double word in the currently selected pipe's FIFO buffer
*/ */
static inline uint32_t Pipe_Read_DWord_LE(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; static inline uint32_t Pipe_Read_DWord_LE(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
static inline uint32_t Pipe_Read_DWord_LE(void) static inline uint32_t Pipe_Read_DWord_LE(void)
@ -505,6 +748,10 @@
/** Reads four bytes from the currently selected pipe's bank in big endian format, for OUT /** Reads four bytes from the currently selected pipe's bank in big endian format, for OUT
* direction pipes. * direction pipes.
*
* \ingroup Group_PipeRW
*
* \return Next double word in the currently selected pipe's FIFO buffer
*/ */
static inline uint32_t Pipe_Read_DWord_BE(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; static inline uint32_t Pipe_Read_DWord_BE(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
static inline uint32_t Pipe_Read_DWord_BE(void) static inline uint32_t Pipe_Read_DWord_BE(void)
@ -525,6 +772,10 @@
/** Writes four bytes to the currently selected pipe's bank in little endian format, for IN /** Writes four bytes to the currently selected pipe's bank in little endian format, for IN
* direction pipes. * direction pipes.
*
* \ingroup Group_PipeRW
*
* \param DWord Next double word to write to the currently selected pipe's FIFO buffer
*/ */
static inline void Pipe_Write_DWord_LE(const uint32_t DWord) ATTR_ALWAYS_INLINE; static inline void Pipe_Write_DWord_LE(const uint32_t DWord) ATTR_ALWAYS_INLINE;
static inline void Pipe_Write_DWord_LE(const uint32_t DWord) static inline void Pipe_Write_DWord_LE(const uint32_t DWord)
@ -535,6 +786,10 @@
/** Writes four bytes to the currently selected pipe's bank in big endian format, for IN /** Writes four bytes to the currently selected pipe's bank in big endian format, for IN
* direction pipes. * direction pipes.
*
* \ingroup Group_PipeRW
*
* \param DWord Next double word to write to the currently selected pipe's FIFO buffer
*/ */
static inline void Pipe_Write_DWord_BE(const uint32_t DWord) ATTR_ALWAYS_INLINE; static inline void Pipe_Write_DWord_BE(const uint32_t DWord) ATTR_ALWAYS_INLINE;
static inline void Pipe_Write_DWord_BE(const uint32_t DWord) static inline void Pipe_Write_DWord_BE(const uint32_t DWord)
@ -543,7 +798,10 @@
Pipe_Write_Word_BE(DWord); Pipe_Write_Word_BE(DWord);
} }
/** Discards four bytes from the currently selected pipe's bank, for OUT direction pipes. */ /** Discards four bytes from the currently selected pipe's bank, for OUT direction pipes.
*
* \ingroup Group_PipeRW
*/
static inline void Pipe_Ignore_DWord(void) ATTR_ALWAYS_INLINE; static inline void Pipe_Ignore_DWord(void) ATTR_ALWAYS_INLINE;
static inline void Pipe_Ignore_DWord(void) static inline void Pipe_Ignore_DWord(void)
{ {
@ -595,6 +853,8 @@
* *
* \note This routine should not be called on CONTROL type pipes. * \note This routine should not be called on CONTROL type pipes.
* *
* \ingroup Group_PipeRW
*
* \return A value from the Pipe_WaitUntilReady_ErrorCodes_t enum. * \return A value from the Pipe_WaitUntilReady_ErrorCodes_t enum.
*/ */
uint8_t Pipe_WaitUntilReady(void); uint8_t Pipe_WaitUntilReady(void);
@ -602,13 +862,15 @@
/** Writes the given number of bytes to the pipe from the given buffer in little endian, /** Writes the given number of bytes to the pipe from the given buffer in little endian,
* sending full packets to the device as needed. The last packet filled is not automatically sent; * sending full packets to the device as needed. The last packet filled is not automatically sent;
* the user is responsible for manually sending the last written packet to the host via the * the user is responsible for manually sending the last written packet to the host via the
* Pipe_ClearCurrentBank() macro. Between each USB packet, the given stream callback function is * Pipe_ClearOUT() macro. Between each USB packet, the given stream callback function is
* executed repeatedly until the next packet is ready, allowing for early aborts of stream transfers. * executed repeatedly until the next packet is ready, allowing for early aborts of stream transfers.
* *
* The callback routine should be created using the STREAM_CALLBACK() macro. If the token * The callback routine should be created using the STREAM_CALLBACK() macro. If the token
* NO_STREAM_CALLBACKS is passed via the -D option to the compiler, stream callbacks are disabled * NO_STREAM_CALLBACKS is passed via the -D option to the compiler, stream callbacks are disabled
* and this function has the Callback parameter omitted. * and this function has the Callback parameter omitted.
* *
* \ingroup Group_PipeRW
*
* \param Buffer Pointer to the source data buffer to read from. * \param Buffer Pointer to the source data buffer to read from.
* \param Length Number of bytes to read for the currently selected pipe into the buffer. * \param Length Number of bytes to read for the currently selected pipe into the buffer.
* \param Callback Name of a callback routine to call between successive USB packet transfers, NULL if no callback * \param Callback Name of a callback routine to call between successive USB packet transfers, NULL if no callback
@ -624,13 +886,15 @@
/** Writes the given number of bytes to the pipe from the given buffer in big endian, /** Writes the given number of bytes to the pipe from the given buffer in big endian,
* sending full packets to the device as needed. The last packet filled is not automatically sent; * sending full packets to the device as needed. The last packet filled is not automatically sent;
* the user is responsible for manually sending the last written packet to the host via the * the user is responsible for manually sending the last written packet to the host via the
* Pipe_ClearCurrentBank() macro. Between each USB packet, the given stream callback function is * Pipe_ClearOUT() macro. Between each USB packet, the given stream callback function is
* executed repeatedly until the next packet is ready, allowing for early aborts of stream transfers. * executed repeatedly until the next packet is ready, allowing for early aborts of stream transfers.
* *
* The callback routine should be created using the STREAM_CALLBACK() macro. If the token * The callback routine should be created using the STREAM_CALLBACK() macro. If the token
* NO_STREAM_CALLBACKS is passed via the -D option to the compiler, stream callbacks are disabled * NO_STREAM_CALLBACKS is passed via the -D option to the compiler, stream callbacks are disabled
* and this function has the Callback parameter omitted. * and this function has the Callback parameter omitted.
* *
* \ingroup Group_PipeRW
*
* \param Buffer Pointer to the source data buffer to read from. * \param Buffer Pointer to the source data buffer to read from.
* \param Length Number of bytes to read for the currently selected pipe into the buffer. * \param Length Number of bytes to read for the currently selected pipe into the buffer.
* \param Callback Name of a callback routine to call between successive USB packet transfers, NULL if no callback * \param Callback Name of a callback routine to call between successive USB packet transfers, NULL if no callback
@ -645,7 +909,7 @@
/** Reads and discards the given number of bytes from the pipe, discarding fully read packets from the host /** Reads and discards the given number of bytes from the pipe, discarding fully read packets from the host
* as needed. The last packet is not automatically discarded once the remaining bytes has been read; the * as needed. The last packet is not automatically discarded once the remaining bytes has been read; the
* user is responsible for manually discarding the last packet from the host via the Pipe_ClearCurrentBank() macro. * user is responsible for manually discarding the last packet from the device via the Pipe_ClearIN() macro.
* Between each USB packet, the given stream callback function is executed repeatedly until the next packet is ready, * Between each USB packet, the given stream callback function is executed repeatedly until the next packet is ready,
* allowing for early aborts of stream transfers. * allowing for early aborts of stream transfers.
* *
@ -653,6 +917,8 @@
* NO_STREAM_CALLBACKS is passed via the -D option to the compiler, stream callbacks are disabled * NO_STREAM_CALLBACKS is passed via the -D option to the compiler, stream callbacks are disabled
* and this function has the Callback parameter omitted. * and this function has the Callback parameter omitted.
* *
* \ingroup Group_PipeRW
*
* \param Length Number of bytes to send via the currently selected pipe. * \param Length Number of bytes to send via the currently selected pipe.
* \param Callback Name of a callback routine to call between successive USB packet transfers, NULL if no callback * \param Callback Name of a callback routine to call between successive USB packet transfers, NULL if no callback
* *
@ -667,13 +933,15 @@
/** Reads the given number of bytes from the pipe into the given buffer in little endian, /** Reads the given number of bytes from the pipe into the given buffer in little endian,
* sending full packets to the device as needed. The last packet filled is not automatically sent; * sending full packets to the device as needed. The last packet filled is not automatically sent;
* the user is responsible for manually sending the last written packet to the host via the * the user is responsible for manually sending the last written packet to the host via the
* Pipe_ClearCurrentBank() macro. Between each USB packet, the given stream callback function is * Pipe_ClearIN() macro. Between each USB packet, the given stream callback function is
* executed repeatedly until the next packet is ready, allowing for early aborts of stream transfers. * executed repeatedly until the next packet is ready, allowing for early aborts of stream transfers.
* *
* The callback routine should be created using the STREAM_CALLBACK() macro. If the token * The callback routine should be created using the STREAM_CALLBACK() macro. If the token
* NO_STREAM_CALLBACKS is passed via the -D option to the compiler, stream callbacks are disabled * NO_STREAM_CALLBACKS is passed via the -D option to the compiler, stream callbacks are disabled
* and this function has the Callback parameter omitted. * and this function has the Callback parameter omitted.
* *
* \ingroup Group_PipeRW
*
* \param Buffer Pointer to the source data buffer to write to. * \param Buffer Pointer to the source data buffer to write to.
* \param Length Number of bytes to read for the currently selected pipe to read from. * \param Length Number of bytes to read for the currently selected pipe to read from.
* \param Callback Name of a callback routine to call between successive USB packet transfers, NULL if no callback * \param Callback Name of a callback routine to call between successive USB packet transfers, NULL if no callback
@ -689,13 +957,15 @@
/** Reads the given number of bytes from the pipe into the given buffer in big endian, /** Reads the given number of bytes from the pipe into the given buffer in big endian,
* sending full packets to the device as needed. The last packet filled is not automatically sent; * sending full packets to the device as needed. The last packet filled is not automatically sent;
* the user is responsible for manually sending the last written packet to the host via the * the user is responsible for manually sending the last written packet to the host via the
* Pipe_ClearCurrentBank() macro. Between each USB packet, the given stream callback function is * Pipe_ClearIN() macro. Between each USB packet, the given stream callback function is
* executed repeatedly until the next packet is ready, allowing for early aborts of stream transfers. * executed repeatedly until the next packet is ready, allowing for early aborts of stream transfers.
* *
* The callback routine should be created using the STREAM_CALLBACK() macro. If the token * The callback routine should be created using the STREAM_CALLBACK() macro. If the token
* NO_STREAM_CALLBACKS is passed via the -D option to the compiler, stream callbacks are disabled * NO_STREAM_CALLBACKS is passed via the -D option to the compiler, stream callbacks are disabled
* and this function has the Callback parameter omitted. * and this function has the Callback parameter omitted.
* *
* \ingroup Group_PipeRW
*
* \param Buffer Pointer to the source data buffer to write to. * \param Buffer Pointer to the source data buffer to write to.
* \param Length Number of bytes to read for the currently selected pipe to read from. * \param Length Number of bytes to read for the currently selected pipe to read from.
* \param Callback Name of a callback routine to call between successive USB packet transfers, NULL if no callback * \param Callback Name of a callback routine to call between successive USB packet transfers, NULL if no callback
@ -708,57 +978,6 @@
#endif #endif
) ATTR_NON_NULL_PTR_ARG(1); ) ATTR_NON_NULL_PTR_ARG(1);
/* Function Aliases: */
/** Alias for Pipe_Discard_Byte().
*/
#define Pipe_Ignore_Byte() Pipe_Discard_Byte()
/** Alias for Pipe_Discard_Word().
*/
#define Pipe_Ignore_Word() Pipe_Discard_Word()
/** Alias for Pipe_Discard_DWord().
*/
#define Pipe_Ignore_DWord() Pipe_Discard_DWord()
/** Alias for Pipe_Read_Word_LE(). By default USB transfers use little endian format, thus
* the command with no endianness specified indicates little endian mode.
*/
#define Pipe_Read_Word() Pipe_Read_Word_LE()
/** Alias for Pipe_Write_Word_LE(). By default USB transfers use little endian format, thus
* the command with no endianness specified indicates little endian mode.
*/
#define Pipe_Write_Word(Word) Pipe_Write_Word_LE(Word)
/** Alias for Pipe_Read_DWord_LE(). By default USB transfers use little endian format, thus
* the command with no endianness specified indicates little endian mode.
*/
#define Pipe_Read_DWord() Pipe_Read_DWord_LE()
/** Alias for Pipe_Write_DWord_LE(). By default USB transfers use little endian format, thus
* the command with no endianness specified indicates little endian mode.
*/
#define Pipe_Write_DWord(DWord) Pipe_Write_DWord_LE(DWord)
/** Alias for Pipe_Read_Stream_LE(). By default USB transfers use little endian format, thus
* the command with no endianness specified indicates little endian mode.
*/
#if !defined(NO_STREAM_CALLBACKS)
#define Pipe_Read_Stream(Buffer, Length, Callback) Pipe_Read_Stream_LE(Buffer, Length, Callback)
#else
#define Pipe_Read_Stream(Buffer, Length) Pipe_Read_Stream_LE(Buffer, Length)
#endif
/** Alias for Pipe_Write_Stream_LE(). By default USB transfers use little endian format, thus
* the command with no endianness specified indicates little endian mode.
*/
#if !defined(NO_STREAM_CALLBACKS)
#define Pipe_Write_Stream(Buffer, Length, Callback) Pipe_Read_Stream_LE(Buffer, Length, Callback)
#else
#define Pipe_Write_Stream(Buffer, Length) Pipe_Read_Stream_LE(Buffer, Length)
#endif
/* Private Interface - For use in library only: */ /* Private Interface - For use in library only: */
#if !defined(__DOXYGEN__) #if !defined(__DOXYGEN__)
/* Macros: */ /* Macros: */
@ -796,3 +1015,5 @@
#endif #endif
#endif #endif
/** @} */

@ -38,6 +38,11 @@
* the USB library unless desired by the library user. * the USB library unless desired by the library user.
*/ */
/** @defgroup Group_USB USB - LUFA/Drivers/USB/USB.h
*
* Functions, macros, variables, enums and types related to the management of USB communications.
*/
#ifndef __USB_H__ #ifndef __USB_H__
#define __USB_H__ #define __USB_H__
@ -79,5 +84,8 @@
#include "LowLevel/OTG.h" #include "LowLevel/OTG.h"
#endif #endif
#include "Class/ConfigDescriptor.h"
#include "Class/HIDParser.h"
#endif #endif

@ -0,0 +1,20 @@
/** \file
*
* This file contains special DoxyGen information for the generation of the main page and other special
* documentation pages. It is not a project source file.
*/
/** @defgroup Group_BoardDrivers Board Drivers
*
* Functions, macros, variables, enums and types related to the control of physical board hardware.
*/
/** @defgroup Group_SubsystemDrivers Subsystem Drivers
*
* Functions, macros, variables, enums and types related to the control of AVR subsystems.
*/
/** @defgroup Group_MiscDrivers Miscellaneous Drivers
*
* Miscellaneous driver Functions, macros, variables, enums and types.
*/

@ -51,6 +51,13 @@
* memory) to be freed. BLOCK_SIZE gives the number of bytes in each memory block. * memory) to be freed. BLOCK_SIZE gives the number of bytes in each memory block.
*/ */
/** @defgroup Group_MemoryAllocator Dynamic Block Memory Allocator - LUFA/MemoryAllocator/DynAlloc.h
*
* Dynamic auto-degragmenting memory block allocator functions. See DynAlloc.h description for more details.
*
* @{
*/
#ifndef __DYN_ALLOC__ #ifndef __DYN_ALLOC__
#define __DYN_ALLOC__ #define __DYN_ALLOC__
@ -180,3 +187,5 @@
#endif #endif
#endif #endif
/** @} */

@ -12,12 +12,48 @@
* *
* \section Sec_MigrationXXXXXX Migrating from 090401 to XXXXXX * \section Sec_MigrationXXXXXX Migrating from 090401 to XXXXXX
* *
* <b>All</b>
* - The ButtLoadTag.h header has been removed, as it was never used for its intended purpose. Projects should either remove all
* BUTTLOADTAG elements, or download and extract ButtLoadTag.h header from the ButtLoad project.
*
* <b>Library Demos</b>
* - Most demos, bootloaders and applications have had significant changes from previous versions. Applications built off of any
* library demos should update to the latest versions.
*
* <b>Device Mode</b>
* - The Endpoint_ClearCurrentBank() macro has been removed, and is now replaced with the Endpoint_ClearIN(), Endpoint_ClearOUT(),
* Endpoint_ClearControlIN(), Endpoint_ClearControlOUT() and other related macros. See Endpoint.h documentation for more details
* on the new endpoint management macros.
* - The Endpoint_ReadWriteAllowed() macro has been renamed to Endpoint_IsReadWriteAllowed() to be more consistent with the rest of
* the API naming scheme.
* - The Endpoint_IsSetupINReady() and Endpoint_IsOutReceived() macros have been renamed to Endpoint_IsINReady() and
* Endpoint_IsOUTReceived() respectively.
* - The Endpoint_IsSetupReceived() macro has been renamed to Endpoint_IsSETUPReceived().
* - The Endpoint_ClearSetupReceived() macro has been renamed to Endpoint_ClearControlSETUP().
* - All endpoint read/write/discard aliases which did not have an explicity endianness specifier (such as Endpoint_Read_Word()) have
* been removed for clarity. Existing projects should use the "_LE" suffix on such calls to use the explicit Little Endian versions.
*
* <b>Host Mode</b> * <b>Host Mode</b>
* - The USB_Host_SendControlRequest() function no longer automatically selects the Control pipe (pipe 0) to allow it to be used on * - The USB_Host_SendControlRequest() function no longer automatically selects the Control pipe (pipe 0) to allow it to be used on
* other control type pipes. Care should be taken to ensure that the Control pipe is always selected before the function is called * other control type pipes. Care should be taken to ensure that the Control pipe is always selected before the function is called
* in existing projects where the Control pipe is to be operated on. * in existing projects where the Control pipe is to be operated on.
* - The USB Host management task now saves and restores the currently selected pipe before and after the task runs. Projects no longer * - The USB Host management task now saves and restores the currently selected pipe before and after the task runs. Projects no longer
* need to manage this manually when calling the USB management task. * need to manage this manually when calling the USB management task.
* - The Pipe_ClearCurrentBank() macro has been removed, and is now replaced with the Pipe_ClearIN(), Pipe_ClearOUT(),
* Pipe_ClearControlIN(), Pipe_ClearControlOUT() and other related macros. See Pipe.h documentation for more details on the new pipe
* management macros.
* - The Pipe_ReadWriteAllowed() macro has been renamed to Pipe_IsReadWriteAllowed() to be more consistent with the rest of the API
* naming scheme.
* - The Pipe_IsSetupINReceived() and Pipe_IsOutReady() macros have been renamed to Pipe_IsINReceived() and Pipe_IsOUTReady()
* respectively.
* - The new Pipe_ClearControlSETUP() macro should be used to send CONTROL transactions, rather than the previous Pipe_ClearSetupOUT() macro.
* - The Pipe_IsSetupSent() macro has been renamed to Pipe_IsSETUPSent().
* - The Pipe_ClearSetupSent() macro is no longer applicable and should be removed.
* - All pipe read/write/discard aliases which did not have an explicity endianness specifier (such as Pipe_Read_Word()) have
* been removed for clarity. Existing projects should use the "_LE" suffix on such calls to use the explicit Little Endian versions.
* - The Host_IsResetBusDone() macro has been renamed to Host_IsBusResetComplete().
* - The Pipe_Ignore_Word() function has been renamed to Pipe_Discard_Word() to remain consistent with the rest of the pipe API.
*
* *
* \section Sec_Migration090401 Migrating from 090209 to 090401 * \section Sec_Migration090401 Migrating from 090209 to 090401
* *

@ -65,6 +65,13 @@
* \endcode * \endcode
*/ */
/** @defgroup Group_Scheduler Simple Task Scheduler - LUFA/Scheduler/Scheduler.h
*
* Simple round-robbin task scheduler. See Scheduler.h description for more details.
*
* @{
*/
#ifndef __SCHEDULER_H__ #ifndef __SCHEDULER_H__
#define __SCHEDULER_H__ #define __SCHEDULER_H__
@ -261,3 +268,5 @@
#endif #endif
#endif #endif
/** @} */

@ -37,12 +37,6 @@
#include "Magstripe.h" #include "Magstripe.h"
/* Project Tags, for reading out using the ButtLoad project */
BUTTLOADTAG(ProjName, "Magstripe Reader");
BUTTLOADTAG(BuildTime, __TIME__);
BUTTLOADTAG(BuildDate, __DATE__);
BUTTLOADTAG(LUFAVersion, "LUFA V" LUFA_VERSION_STRING);
/* Scheduler Task List */ /* Scheduler Task List */
TASK_LIST TASK_LIST
{ {
@ -184,30 +178,30 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
if (wLength > sizeof(KeyboardReportData)) if (wLength > sizeof(KeyboardReportData))
wLength = sizeof(KeyboardReportData); wLength = sizeof(KeyboardReportData);
Endpoint_ClearSetupReceived(); Endpoint_ClearControlSETUP();
/* Write the report data to the control endpoint */ /* Write the report data to the control endpoint */
Endpoint_Write_Control_Stream_LE(&KeyboardReportData, wLength); Endpoint_Write_Control_Stream_LE(&KeyboardReportData, wLength);
/* Finalize the stream transfer to send the last packet or clear the host abort */ /* Finalize the stream transfer to send the last packet or clear the host abort */
Endpoint_ClearSetupOUT(); Endpoint_ClearControlOUT();
} }
break; break;
case REQ_GetProtocol: case REQ_GetProtocol:
if (bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE)) if (bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE))
{ {
Endpoint_ClearSetupReceived(); Endpoint_ClearControlSETUP();
/* Write the current protocol flag to the host */ /* Write the current protocol flag to the host */
Endpoint_Write_Byte(UsingReportProtocol); Endpoint_Write_Byte(UsingReportProtocol);
/* Send the flag to the host */ /* Send the flag to the host */
Endpoint_ClearSetupIN(); Endpoint_ClearControlIN();
/* Acknowledge status stage */ /* Acknowledge status stage */
while (!(Endpoint_IsSetupOUTReceived())); while (!(Endpoint_IsOUTReceived()));
Endpoint_ClearSetupOUT(); Endpoint_ClearControlOUT();
} }
break; break;
@ -217,14 +211,14 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
/* Read in the wValue parameter containing the new protocol mode */ /* Read in the wValue parameter containing the new protocol mode */
uint16_t wValue = Endpoint_Read_Word_LE(); uint16_t wValue = Endpoint_Read_Word_LE();
Endpoint_ClearSetupReceived(); Endpoint_ClearControlSETUP();
/* Set or clear the flag depending on what the host indicates that the current Protocol should be */ /* Set or clear the flag depending on what the host indicates that the current Protocol should be */
UsingReportProtocol = (wValue != 0x0000); UsingReportProtocol = (wValue != 0x0000);
/* Acknowledge status stage */ /* Acknowledge status stage */
while (!(Endpoint_IsSetupINReady())); while (!(Endpoint_IsINReady()));
Endpoint_ClearSetupIN(); Endpoint_ClearControlIN();
} }
break; break;
@ -234,31 +228,31 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
/* Read in the wValue parameter containing the idle period */ /* Read in the wValue parameter containing the idle period */
uint16_t wValue = Endpoint_Read_Word_LE(); uint16_t wValue = Endpoint_Read_Word_LE();
Endpoint_ClearSetupReceived(); Endpoint_ClearControlSETUP();
/* Get idle period in MSB */ /* Get idle period in MSB */
IdleCount = (wValue >> 8); IdleCount = (wValue >> 8);
/* Acknowledge status stage */ /* Acknowledge status stage */
while (!(Endpoint_IsSetupINReady())); while (!(Endpoint_IsINReady()));
Endpoint_ClearSetupIN(); Endpoint_ClearControlIN();
} }
break; break;
case REQ_GetIdle: case REQ_GetIdle:
if (bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE)) if (bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE))
{ {
Endpoint_ClearSetupReceived(); Endpoint_ClearControlSETUP();
/* Write the current idle duration to the host */ /* Write the current idle duration to the host */
Endpoint_Write_Byte(IdleCount); Endpoint_Write_Byte(IdleCount);
/* Send the flag to the host */ /* Send the flag to the host */
Endpoint_ClearSetupIN(); Endpoint_ClearControlIN();
/* Acknowledge status stage */ /* Acknowledge status stage */
while (!(Endpoint_IsSetupOUTReceived())); while (!(Endpoint_IsOUTReceived()));
Endpoint_ClearSetupOUT(); Endpoint_ClearControlOUT();
} }
break; break;
@ -410,7 +404,7 @@ TASK(USB_Keyboard_Report)
Endpoint_SelectEndpoint(KEYBOARD_EPNUM); Endpoint_SelectEndpoint(KEYBOARD_EPNUM);
/* Check if Keyboard Endpoint Ready for Read/Write */ /* Check if Keyboard Endpoint Ready for Read/Write */
if (Endpoint_ReadWriteAllowed()) if (Endpoint_IsReadWriteAllowed())
{ {
/* Only fetch the next key to send once the period between key presses has elapsed */ /* Only fetch the next key to send once the period between key presses has elapsed */
if (!(KeyDelayRemaining)) if (!(KeyDelayRemaining))
@ -436,7 +430,7 @@ TASK(USB_Keyboard_Report)
Endpoint_Write_Stream_LE(&KeyboardReportData, sizeof(USB_KeyboardReport_Data_t)); Endpoint_Write_Stream_LE(&KeyboardReportData, sizeof(USB_KeyboardReport_Data_t));
/* Finalize the stream transfer to send the last packet */ /* Finalize the stream transfer to send the last packet */
Endpoint_ClearCurrentBank(); Endpoint_ClearIN();
/* Reset the key delay period counter */ /* Reset the key delay period counter */
KeyDelayRemaining = 2; KeyDelayRemaining = 2;

@ -50,7 +50,6 @@
#include "CircularBitBuffer.h" #include "CircularBitBuffer.h"
#include <LUFA/Version.h> // Library Version Information #include <LUFA/Version.h> // Library Version Information
#include <LUFA/Common/ButtLoadTag.h> // PROGMEM tags readable by the ButtLoad project
#include <LUFA/Drivers/USB/USB.h> // USB Functionality #include <LUFA/Drivers/USB/USB.h> // USB Functionality
#include <LUFA/Scheduler/Scheduler.h> // Simple scheduler for task management #include <LUFA/Scheduler/Scheduler.h> // Simple scheduler for task management

Loading…
Cancel
Save