forked from mfulz_github/qmk_firmware
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.
This commit is contained in:
parent
ef06bfd1c0
commit
8f6b4ddf76
|
@ -90,7 +90,7 @@ int main(void)
|
|||
Endpoint_SelectEndpoint(CDC_TX_EPNUM);
|
||||
|
||||
/* Wait until any pending transmissions have completed before shutting down */
|
||||
while (!(Endpoint_ReadWriteAllowed()));
|
||||
while (!(Endpoint_IsINReady()));
|
||||
|
||||
/* Shut down the USB subsystem */
|
||||
USB_ShutDown();
|
||||
|
@ -160,45 +160,45 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
|
|||
case REQ_GetLineEncoding:
|
||||
if (bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE))
|
||||
{
|
||||
Endpoint_ClearSetupReceived();
|
||||
Endpoint_ClearControlSETUP();
|
||||
|
||||
for (uint8_t i = 0; i < sizeof(LineCoding); i++)
|
||||
Endpoint_Write_Byte(*(LineCodingData++));
|
||||
|
||||
Endpoint_ClearSetupIN();
|
||||
Endpoint_ClearControlIN();
|
||||
|
||||
/* Acknowledge status stage */
|
||||
while (!(Endpoint_IsSetupOUTReceived()));
|
||||
Endpoint_ClearSetupOUT();
|
||||
while (!(Endpoint_IsOUTReceived()));
|
||||
Endpoint_ClearControlOUT();
|
||||
}
|
||||
|
||||
break;
|
||||
case REQ_SetLineEncoding:
|
||||
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++)
|
||||
*(LineCodingData++) = Endpoint_Read_Byte();
|
||||
|
||||
Endpoint_ClearSetupOUT();
|
||||
Endpoint_ClearControlOUT();
|
||||
|
||||
/* Acknowledge status stage */
|
||||
while (!(Endpoint_IsSetupINReady()));
|
||||
Endpoint_ClearSetupIN();
|
||||
while (!(Endpoint_IsINReady()));
|
||||
Endpoint_ClearControlIN();
|
||||
}
|
||||
|
||||
break;
|
||||
case REQ_SetControlLineState:
|
||||
if (bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE))
|
||||
{
|
||||
Endpoint_ClearSetupReceived();
|
||||
Endpoint_ClearControlSETUP();
|
||||
|
||||
/* Acknowledge status stage */
|
||||
while (!(Endpoint_IsSetupINReady()));
|
||||
Endpoint_ClearSetupIN();
|
||||
while (!(Endpoint_IsINReady()));
|
||||
Endpoint_ClearControlIN();
|
||||
}
|
||||
|
||||
break;
|
||||
|
@ -332,10 +332,10 @@ static uint8_t FetchNextCommandByte(void)
|
|||
Endpoint_SelectEndpoint(CDC_RX_EPNUM);
|
||||
|
||||
/* If OUT endpoint empty, clear it and wait for the next packet from the host */
|
||||
if (!(Endpoint_ReadWriteAllowed()))
|
||||
while (!(Endpoint_IsReadWriteAllowed()))
|
||||
{
|
||||
Endpoint_ClearCurrentBank();
|
||||
while (!(Endpoint_ReadWriteAllowed()));
|
||||
Endpoint_ClearOUT();
|
||||
while (!(Endpoint_IsOUTReceived()));
|
||||
}
|
||||
|
||||
/* Fetch the next byte from the OUT endpoint */
|
||||
|
@ -353,10 +353,10 @@ static void WriteNextResponseByte(const uint8_t Response)
|
|||
Endpoint_SelectEndpoint(CDC_TX_EPNUM);
|
||||
|
||||
/* If OUT endpoint empty, clear it and wait for the next packet from the host */
|
||||
if (!(Endpoint_ReadWriteAllowed()))
|
||||
if (!(Endpoint_IsReadWriteAllowed()))
|
||||
{
|
||||
Endpoint_ClearCurrentBank();
|
||||
while (!(Endpoint_ReadWriteAllowed()));
|
||||
Endpoint_ClearIN();
|
||||
while (!(Endpoint_IsINReady()));
|
||||
}
|
||||
|
||||
/* Write the next byte to the OUT endpoint */
|
||||
|
@ -372,7 +372,7 @@ TASK(CDC_Task)
|
|||
Endpoint_SelectEndpoint(CDC_RX_EPNUM);
|
||||
|
||||
/* 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) */
|
||||
uint8_t Command = FetchNextCommandByte();
|
||||
|
@ -557,22 +557,22 @@ TASK(CDC_Task)
|
|||
Endpoint_SelectEndpoint(CDC_TX_EPNUM);
|
||||
|
||||
/* 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 */
|
||||
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 (IsEndpointFull)
|
||||
{
|
||||
while (!(Endpoint_ReadWriteAllowed()));
|
||||
Endpoint_ClearCurrentBank();
|
||||
while (!(Endpoint_IsINReady()));
|
||||
Endpoint_ClearIN();
|
||||
}
|
||||
|
||||
/* Select the OUT endpoint */
|
||||
Endpoint_SelectEndpoint(CDC_RX_EPNUM);
|
||||
|
||||
/* Acknowledge the command from the host */
|
||||
Endpoint_ClearCurrentBank();
|
||||
Endpoint_ClearOUT();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -163,7 +163,7 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
|
|||
switch (bRequest)
|
||||
{
|
||||
case DFU_DNLOAD:
|
||||
Endpoint_ClearSetupReceived();
|
||||
Endpoint_ClearControlSETUP();
|
||||
|
||||
/* Check if bootloader is waiting to terminate */
|
||||
if (WaitForExit)
|
||||
|
@ -178,7 +178,7 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
|
|||
/* If the request has a data stage, load it into the command struct */
|
||||
if (SentCommand.DataSize)
|
||||
{
|
||||
while (!(Endpoint_IsSetupOUTReceived()));
|
||||
while (!(Endpoint_IsOUTReceived()));
|
||||
|
||||
/* First byte of the data stage is the DNLOAD request's command */
|
||||
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 */
|
||||
if (!(Endpoint_BytesInEndpoint()))
|
||||
{
|
||||
Endpoint_ClearSetupOUT();
|
||||
while (!(Endpoint_IsSetupOUTReceived()));
|
||||
Endpoint_ClearControlOUT();
|
||||
while (!(Endpoint_IsOUTReceived()));
|
||||
}
|
||||
|
||||
/* 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 */
|
||||
if (!(Endpoint_BytesInEndpoint()))
|
||||
{
|
||||
Endpoint_ClearSetupOUT();
|
||||
while (!(Endpoint_IsSetupOUTReceived()));
|
||||
Endpoint_ClearControlOUT();
|
||||
while (!(Endpoint_IsOUTReceived()));
|
||||
}
|
||||
|
||||
/* 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 */
|
||||
while (!(Endpoint_IsSetupINReady()));
|
||||
Endpoint_ClearSetupIN();
|
||||
while (!(Endpoint_IsINReady()));
|
||||
Endpoint_ClearControlIN();
|
||||
|
||||
break;
|
||||
case DFU_UPLOAD:
|
||||
Endpoint_ClearSetupReceived();
|
||||
Endpoint_ClearControlSETUP();
|
||||
|
||||
while (!(Endpoint_IsSetupINReady()));
|
||||
while (!(Endpoint_IsINReady()));
|
||||
|
||||
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 */
|
||||
if (Endpoint_BytesInEndpoint() == FIXED_CONTROL_ENDPOINT_SIZE)
|
||||
{
|
||||
Endpoint_ClearSetupIN();
|
||||
while (!(Endpoint_IsSetupINReady()));
|
||||
Endpoint_ClearControlIN();
|
||||
while (!(Endpoint_IsINReady()));
|
||||
}
|
||||
|
||||
/* 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 */
|
||||
if (Endpoint_BytesInEndpoint() == FIXED_CONTROL_ENDPOINT_SIZE)
|
||||
{
|
||||
Endpoint_ClearSetupIN();
|
||||
while (!(Endpoint_IsSetupINReady()));
|
||||
Endpoint_ClearControlIN();
|
||||
while (!(Endpoint_IsINReady()));
|
||||
}
|
||||
|
||||
/* Read the EEPROM byte and send it via USB to the host */
|
||||
|
@ -384,15 +384,15 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
|
|||
DFU_State = dfuIDLE;
|
||||
}
|
||||
|
||||
Endpoint_ClearSetupIN();
|
||||
Endpoint_ClearControlIN();
|
||||
|
||||
/* Acknowledge status stage */
|
||||
while (!(Endpoint_IsSetupOUTReceived()));
|
||||
Endpoint_ClearSetupOUT();
|
||||
while (!(Endpoint_IsOUTReceived()));
|
||||
Endpoint_ClearControlOUT();
|
||||
|
||||
break;
|
||||
case DFU_GETSTATUS:
|
||||
Endpoint_ClearSetupReceived();
|
||||
Endpoint_ClearControlSETUP();
|
||||
|
||||
/* Write 8-bit status value */
|
||||
Endpoint_Write_Byte(DFU_Status);
|
||||
|
@ -407,46 +407,46 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
|
|||
/* Write 8-bit state string ID number */
|
||||
Endpoint_Write_Byte(0);
|
||||
|
||||
Endpoint_ClearSetupIN();
|
||||
Endpoint_ClearControlIN();
|
||||
|
||||
/* Acknowledge status stage */
|
||||
while (!(Endpoint_IsSetupOUTReceived()));
|
||||
Endpoint_ClearSetupOUT();
|
||||
while (!(Endpoint_IsOUTReceived()));
|
||||
Endpoint_ClearControlOUT();
|
||||
|
||||
break;
|
||||
case DFU_CLRSTATUS:
|
||||
Endpoint_ClearSetupReceived();
|
||||
Endpoint_ClearControlSETUP();
|
||||
|
||||
/* Reset the status value variable to the default OK status */
|
||||
DFU_Status = OK;
|
||||
|
||||
/* Acknowledge status stage */
|
||||
while (!(Endpoint_IsSetupINReady()));
|
||||
Endpoint_ClearSetupIN();
|
||||
while (!(Endpoint_IsINReady()));
|
||||
Endpoint_ClearControlIN();
|
||||
|
||||
break;
|
||||
case DFU_GETSTATE:
|
||||
Endpoint_ClearSetupReceived();
|
||||
Endpoint_ClearControlSETUP();
|
||||
|
||||
/* Write the current device state to the endpoint */
|
||||
Endpoint_Write_Byte(DFU_State);
|
||||
|
||||
Endpoint_ClearSetupIN();
|
||||
Endpoint_ClearControlIN();
|
||||
|
||||
/* Acknowledge status stage */
|
||||
while (!(Endpoint_IsSetupOUTReceived()));
|
||||
Endpoint_ClearSetupOUT();
|
||||
while (!(Endpoint_IsOUTReceived()));
|
||||
Endpoint_ClearControlOUT();
|
||||
|
||||
break;
|
||||
case DFU_ABORT:
|
||||
Endpoint_ClearSetupReceived();
|
||||
Endpoint_ClearControlSETUP();
|
||||
|
||||
/* Reset the current state variable to the default idle state */
|
||||
DFU_State = dfuIDLE;
|
||||
|
||||
/* Acknowledge status stage */
|
||||
while (!(Endpoint_IsSetupINReady()));
|
||||
Endpoint_ClearSetupIN();
|
||||
while (!(Endpoint_IsINReady()));
|
||||
Endpoint_ClearControlIN();
|
||||
|
||||
break;
|
||||
}
|
||||
|
@ -463,10 +463,10 @@ static void DiscardFillerBytes(uint8_t NumberOfBytes)
|
|||
{
|
||||
if (!(Endpoint_BytesInEndpoint()))
|
||||
{
|
||||
Endpoint_ClearSetupOUT();
|
||||
Endpoint_ClearControlOUT();
|
||||
|
||||
/* Wait until next data packet received */
|
||||
while (!(Endpoint_IsSetupOUTReceived()));
|
||||
while (!(Endpoint_IsOUTReceived()));
|
||||
}
|
||||
|
||||
Endpoint_Discard_Byte();
|
||||
|
|
|
@ -101,10 +101,10 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
|
|||
case REQ_SetReport:
|
||||
if (bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE))
|
||||
{
|
||||
Endpoint_ClearSetupReceived();
|
||||
Endpoint_ClearControlSETUP();
|
||||
|
||||
/* Wait until the command (report) has been sent by the host */
|
||||
while (!(Endpoint_IsSetupOUTReceived()));
|
||||
while (!(Endpoint_IsOUTReceived()));
|
||||
|
||||
/* Read in the write destination address */
|
||||
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 */
|
||||
if (!(Endpoint_BytesInEndpoint()))
|
||||
{
|
||||
Endpoint_ClearSetupOUT();
|
||||
while (!(Endpoint_IsSetupOUTReceived()));
|
||||
Endpoint_ClearControlOUT();
|
||||
while (!(Endpoint_IsOUTReceived()));
|
||||
}
|
||||
|
||||
/* Write the next data word to the FLASH page */
|
||||
|
@ -142,11 +142,11 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
|
|||
boot_rww_enable();
|
||||
}
|
||||
|
||||
Endpoint_ClearSetupOUT();
|
||||
Endpoint_ClearControlOUT();
|
||||
|
||||
/* Acknowledge status stage */
|
||||
while (!(Endpoint_IsSetupINReady()));
|
||||
Endpoint_ClearSetupIN();
|
||||
while (!(Endpoint_IsINReady()));
|
||||
Endpoint_ClearControlIN();
|
||||
}
|
||||
|
||||
break;
|
||||
|
|
|
@ -36,12 +36,6 @@
|
|||
|
||||
#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 */
|
||||
TASK_LIST
|
||||
{
|
||||
|
@ -145,7 +139,7 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
|
|||
{
|
||||
uint16_t wValue = Endpoint_Read_Word_LE();
|
||||
|
||||
Endpoint_ClearSetupReceived();
|
||||
Endpoint_ClearControlSETUP();
|
||||
|
||||
/* Check if the host is enabling the audio interface (setting AlternateSetting to 1) */
|
||||
if (wValue)
|
||||
|
@ -160,8 +154,8 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
|
|||
}
|
||||
|
||||
/* Acknowledge status stage */
|
||||
while (!(Endpoint_IsSetupINReady()));
|
||||
Endpoint_ClearSetupIN();
|
||||
while (!(Endpoint_IsINReady()));
|
||||
Endpoint_ClearControlIN();
|
||||
}
|
||||
|
||||
break;
|
||||
|
@ -201,8 +195,8 @@ TASK(USB_Audio_Task)
|
|||
/* Select the audio stream endpoint */
|
||||
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 */
|
||||
if (Endpoint_ReadWriteAllowed() && (TIFR0 & (1 << OCF0A)))
|
||||
/* Check if the current endpoint can be written to and that the next sample should be stored */
|
||||
if (Endpoint_IsINReady() && (TIFR0 & (1 << OCF0A)))
|
||||
{
|
||||
/* Clear the sample reload timer */
|
||||
TIFR0 |= (1 << OCF0A);
|
||||
|
@ -219,10 +213,10 @@ TASK(USB_Audio_Task)
|
|||
Endpoint_Write_Word_LE(AudioSample);
|
||||
|
||||
/* Check to see if the bank is now full */
|
||||
if (!(Endpoint_ReadWriteAllowed()))
|
||||
if (!(Endpoint_IsReadWriteAllowed()))
|
||||
{
|
||||
/* Send the full packet to the host */
|
||||
Endpoint_ClearCurrentBank();
|
||||
Endpoint_ClearIN();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,7 +44,6 @@
|
|||
#include "Descriptors.h"
|
||||
|
||||
#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/Board/LEDs.h> // LEDs driver
|
||||
#include <LUFA/Drivers/AT90USBXXX/ADC.h> // ADC driver
|
||||
|
|
|
@ -36,12 +36,6 @@
|
|||
|
||||
#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 */
|
||||
TASK_LIST
|
||||
{
|
||||
|
@ -172,7 +166,7 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
|
|||
{
|
||||
uint16_t wValue = Endpoint_Read_Word_LE();
|
||||
|
||||
Endpoint_ClearSetupReceived();
|
||||
Endpoint_ClearControlSETUP();
|
||||
|
||||
/* Check if the host is enabling the audio interface (setting AlternateSetting to 1) */
|
||||
if (wValue)
|
||||
|
@ -187,8 +181,8 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
|
|||
}
|
||||
|
||||
/* Acknowledge status stage */
|
||||
while (!(Endpoint_IsSetupINReady()));
|
||||
Endpoint_ClearSetupIN();
|
||||
while (!(Endpoint_IsINReady()));
|
||||
Endpoint_ClearControlIN();
|
||||
}
|
||||
|
||||
break;
|
||||
|
@ -231,7 +225,7 @@ TASK(USB_Audio_Task)
|
|||
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 */
|
||||
if (Endpoint_ReadWriteAllowed() && (TIFR0 & (1 << OCF0A)))
|
||||
if (Endpoint_IsOUTReceived() && (TIFR0 & (1 << OCF0A)))
|
||||
{
|
||||
/* Clear the sample reload timer */
|
||||
TIFR0 |= (1 << OCF0A);
|
||||
|
@ -241,10 +235,10 @@ TASK(USB_Audio_Task)
|
|||
int16_t RightSample_16Bit = (int16_t)Endpoint_Read_Word_LE();
|
||||
|
||||
/* 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 */
|
||||
Endpoint_ClearCurrentBank();
|
||||
Endpoint_ClearOUT();
|
||||
}
|
||||
|
||||
/* Massage signed 16-bit left and right audio samples into signed 8-bit */
|
||||
|
|
|
@ -44,7 +44,6 @@
|
|||
#include "Descriptors.h"
|
||||
|
||||
#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/Board/LEDs.h> // LEDs driver
|
||||
#include <LUFA/Scheduler/Scheduler.h> // Simple scheduler for task management
|
||||
|
|
|
@ -36,12 +36,6 @@
|
|||
|
||||
#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 */
|
||||
TASK_LIST
|
||||
{
|
||||
|
@ -172,13 +166,13 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
|
|||
if (bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE))
|
||||
{
|
||||
/* Acknowledge the SETUP packet, ready for data transfer */
|
||||
Endpoint_ClearSetupReceived();
|
||||
Endpoint_ClearControlSETUP();
|
||||
|
||||
/* Write the line coding data to the control endpoint */
|
||||
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 */
|
||||
Endpoint_ClearSetupOUT();
|
||||
Endpoint_ClearControlOUT();
|
||||
}
|
||||
|
||||
break;
|
||||
|
@ -186,13 +180,13 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
|
|||
if (bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE))
|
||||
{
|
||||
/* 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 */
|
||||
Endpoint_Read_Control_Stream_LE(LineCodingData, sizeof(CDC_Line_Coding_t));
|
||||
|
||||
/* Finalize the stream transfer to clear the last packet from the host */
|
||||
Endpoint_ClearSetupIN();
|
||||
Endpoint_ClearControlIN();
|
||||
}
|
||||
|
||||
break;
|
||||
|
@ -211,11 +205,11 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
|
|||
#endif
|
||||
|
||||
/* Acknowledge the SETUP packet, ready for data transfer */
|
||||
Endpoint_ClearSetupReceived();
|
||||
Endpoint_ClearControlSETUP();
|
||||
|
||||
/* Acknowledge status stage */
|
||||
while (!(Endpoint_IsSetupINReady()));
|
||||
Endpoint_ClearSetupIN();
|
||||
while (!(Endpoint_IsINReady()));
|
||||
Endpoint_ClearControlIN();
|
||||
}
|
||||
|
||||
break;
|
||||
|
@ -276,7 +270,7 @@ TASK(CDC_Task)
|
|||
Endpoint_SelectEndpoint(CDC_NOTIFICATION_EPNUM);
|
||||
Endpoint_Write_Stream_LE(&Notification, sizeof(Notification));
|
||||
Endpoint_Write_Stream_LE(&LineStateMask, sizeof(LineStateMask));
|
||||
Endpoint_ClearCurrentBank();
|
||||
Endpoint_ClearIN();
|
||||
#endif
|
||||
|
||||
/* Determine if a joystick action has occurred */
|
||||
|
@ -307,19 +301,19 @@ TASK(CDC_Task)
|
|||
Endpoint_Write_Stream_LE(ReportString, strlen(ReportString));
|
||||
|
||||
/* Finalize the stream transfer to send the last packet */
|
||||
Endpoint_ClearCurrentBank();
|
||||
Endpoint_ClearIN();
|
||||
|
||||
/* 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 */
|
||||
Endpoint_ClearCurrentBank();
|
||||
Endpoint_ClearIN();
|
||||
}
|
||||
|
||||
/* Select the Serial Rx Endpoint */
|
||||
Endpoint_SelectEndpoint(CDC_RX_EPNUM);
|
||||
|
||||
/* Throw away any received data from the host */
|
||||
if (Endpoint_ReadWriteAllowed())
|
||||
Endpoint_ClearCurrentBank();
|
||||
if (Endpoint_IsOUTReceived())
|
||||
Endpoint_ClearOUT();
|
||||
}
|
||||
|
|
|
@ -45,7 +45,6 @@
|
|||
#include "Descriptors.h"
|
||||
|
||||
#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/Board/Joystick.h> // Joystick driver
|
||||
#include <LUFA/Drivers/Board/LEDs.h> // LEDs driver
|
||||
|
|
|
@ -36,12 +36,6 @@
|
|||
|
||||
#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 */
|
||||
TASK_LIST
|
||||
{
|
||||
|
@ -195,7 +189,7 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
|
|||
uint8_t* LineCodingData;
|
||||
|
||||
/* Discard the unused wValue parameter */
|
||||
Endpoint_Ignore_Word();
|
||||
Endpoint_Discard_Word();
|
||||
|
||||
/* wIndex indicates the interface being controlled */
|
||||
uint16_t wIndex = Endpoint_Read_Word_LE();
|
||||
|
@ -210,13 +204,13 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
|
|||
if (bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE))
|
||||
{
|
||||
/* Acknowledge the SETUP packet, ready for data transfer */
|
||||
Endpoint_ClearSetupReceived();
|
||||
Endpoint_ClearControlSETUP();
|
||||
|
||||
/* Write the line coding data to the control endpoint */
|
||||
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 */
|
||||
Endpoint_ClearSetupOUT();
|
||||
Endpoint_ClearControlOUT();
|
||||
}
|
||||
|
||||
break;
|
||||
|
@ -224,13 +218,13 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
|
|||
if (bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE))
|
||||
{
|
||||
/* 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 */
|
||||
Endpoint_Read_Control_Stream_LE(LineCodingData, sizeof(CDC_Line_Coding_t));
|
||||
|
||||
/* Finalize the stream transfer to clear the last packet from the host */
|
||||
Endpoint_ClearSetupIN();
|
||||
Endpoint_ClearControlIN();
|
||||
}
|
||||
|
||||
break;
|
||||
|
@ -238,11 +232,11 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
|
|||
if (bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE))
|
||||
{
|
||||
/* Acknowledge the SETUP packet, ready for data transfer */
|
||||
Endpoint_ClearSetupReceived();
|
||||
Endpoint_ClearControlSETUP();
|
||||
|
||||
/* Acknowledge status stage */
|
||||
while (!(Endpoint_IsSetupINReady()));
|
||||
Endpoint_ClearSetupIN();
|
||||
while (!(Endpoint_IsINReady()));
|
||||
Endpoint_ClearControlIN();
|
||||
}
|
||||
|
||||
break;
|
||||
|
@ -313,15 +307,21 @@ TASK(CDC1_Task)
|
|||
Endpoint_Write_Stream_LE(ReportString, strlen(ReportString));
|
||||
|
||||
/* 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 */
|
||||
Endpoint_SelectEndpoint(CDC1_RX_EPNUM);
|
||||
|
||||
/* Throw away any received data from the host */
|
||||
if (Endpoint_ReadWriteAllowed())
|
||||
Endpoint_ClearCurrentBank();
|
||||
if (Endpoint_IsOUTReceived())
|
||||
Endpoint_ClearOUT();
|
||||
}
|
||||
|
||||
/** 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);
|
||||
|
||||
/* 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 */
|
||||
uint8_t Buffer[Endpoint_BytesInEndpoint()];
|
||||
|
@ -345,7 +345,7 @@ TASK(CDC2_Task)
|
|||
Endpoint_Read_Stream_LE(&Buffer, DataLength);
|
||||
|
||||
/* Finalize the stream transfer to send the last packet */
|
||||
Endpoint_ClearCurrentBank();
|
||||
Endpoint_ClearOUT();
|
||||
|
||||
/* Select the Serial Tx Endpoint */
|
||||
Endpoint_SelectEndpoint(CDC2_TX_EPNUM);
|
||||
|
@ -354,6 +354,12 @@ TASK(CDC2_Task)
|
|||
Endpoint_Write_Stream_LE(&Buffer, DataLength);
|
||||
|
||||
/* 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 <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/Board/Joystick.h> // Joystick driver
|
||||
#include <LUFA/Drivers/Board/LEDs.h> // LEDs driver
|
||||
|
|
|
@ -36,12 +36,6 @@
|
|||
|
||||
#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 */
|
||||
TASK_LIST
|
||||
{
|
||||
|
@ -171,7 +165,7 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
|
|||
case REQ_GetReport:
|
||||
if (bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE))
|
||||
{
|
||||
Endpoint_ClearSetupReceived();
|
||||
Endpoint_ClearControlSETUP();
|
||||
|
||||
uint8_t GenericData[GENERIC_REPORT_SIZE];
|
||||
|
||||
|
@ -181,32 +175,32 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
|
|||
Endpoint_Write_Control_Stream_LE(&GenericData, sizeof(GenericData));
|
||||
|
||||
/* Finalize the stream transfer to send the last packet or clear the host abort */
|
||||
Endpoint_ClearSetupOUT();
|
||||
Endpoint_ClearControlOUT();
|
||||
}
|
||||
|
||||
break;
|
||||
case REQ_SetReport:
|
||||
if (bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE))
|
||||
{
|
||||
Endpoint_ClearSetupReceived();
|
||||
Endpoint_ClearControlSETUP();
|
||||
|
||||
/* Wait until the generic report has been sent by the host */
|
||||
while (!(Endpoint_IsSetupOUTReceived()));
|
||||
while (!(Endpoint_IsOUTReceived()));
|
||||
|
||||
uint8_t GenericData[GENERIC_REPORT_SIZE];
|
||||
|
||||
Endpoint_Read_Control_Stream(&GenericData, sizeof(GenericData));
|
||||
Endpoint_Read_Control_Stream_LE(&GenericData, sizeof(GenericData));
|
||||
|
||||
ProcessGenericHIDReport(GenericData);
|
||||
|
||||
/* Clear the endpoint data */
|
||||
Endpoint_ClearSetupOUT();
|
||||
Endpoint_ClearControlOUT();
|
||||
|
||||
/* 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 */
|
||||
Endpoint_ClearSetupIN();
|
||||
Endpoint_ClearControlIN();
|
||||
}
|
||||
|
||||
break;
|
||||
|
@ -280,24 +274,30 @@ TASK(USB_HID_Report)
|
|||
{
|
||||
Endpoint_SelectEndpoint(GENERIC_OUT_EPNUM);
|
||||
|
||||
if (Endpoint_ReadWriteAllowed())
|
||||
/* Check to see if a packet has been sent from the host */
|
||||
if (Endpoint_IsOUTReceived())
|
||||
{
|
||||
/* Create a temporary buffer to hold the read in report from the host */
|
||||
uint8_t GenericData[GENERIC_REPORT_SIZE];
|
||||
|
||||
/* Read Generic Report Data */
|
||||
Endpoint_Read_Stream_LE(&GenericData, sizeof(GenericData));
|
||||
|
||||
/* Process Generic Report Data */
|
||||
ProcessGenericHIDReport(GenericData);
|
||||
/* Check to see if the packet contains data */
|
||||
if (Endpoint_IsReadWriteAllowed())
|
||||
{
|
||||
/* Create a temporary buffer to hold the read in report from the host */
|
||||
uint8_t GenericData[GENERIC_REPORT_SIZE];
|
||||
|
||||
/* Read Generic Report Data */
|
||||
Endpoint_Read_Stream_LE(&GenericData, sizeof(GenericData));
|
||||
|
||||
/* Process Generic Report Data */
|
||||
ProcessGenericHIDReport(GenericData);
|
||||
}
|
||||
|
||||
/* Finalize the stream transfer to send the last packet */
|
||||
Endpoint_ClearCurrentBank();
|
||||
Endpoint_ClearOUT();
|
||||
}
|
||||
|
||||
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 */
|
||||
uint8_t GenericData[GENERIC_REPORT_SIZE];
|
||||
|
@ -309,7 +309,7 @@ TASK(USB_HID_Report)
|
|||
Endpoint_Write_Stream_LE(&GenericData, sizeof(GenericData));
|
||||
|
||||
/* 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));
|
||||
|
||||
/* Finalize the stream transfer to send the last packet */
|
||||
Endpoint_ClearCurrentBank();
|
||||
Endpoint_ClearIN();
|
||||
}
|
||||
|
||||
/* Check if Generic OUT endpoint has interrupted */
|
||||
|
@ -388,7 +388,7 @@ ISR(ENDPOINT_PIPE_vect, ISR_BLOCK)
|
|||
ProcessGenericHIDReport(GenericData);
|
||||
|
||||
/* Finalize the stream transfer to send the last packet */
|
||||
Endpoint_ClearCurrentBank();
|
||||
Endpoint_ClearOUT();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -48,7 +48,6 @@
|
|||
|
||||
#include <LUFA/Version.h> // Library Version Information
|
||||
#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/Board/LEDs.h> // LEDs driver
|
||||
|
||||
|
|
|
@ -36,12 +36,6 @@
|
|||
|
||||
#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 */
|
||||
TASK_LIST
|
||||
{
|
||||
|
@ -151,13 +145,13 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
|
|||
if (wLength > sizeof(JoystickReportData))
|
||||
wLength = sizeof(JoystickReportData);
|
||||
|
||||
Endpoint_ClearSetupReceived();
|
||||
Endpoint_ClearControlSETUP();
|
||||
|
||||
/* Write the report data to the control endpoint */
|
||||
Endpoint_Write_Control_Stream_LE(&JoystickReportData, wLength);
|
||||
|
||||
/* Finalize the stream transfer to send the last packet or clear the host abort */
|
||||
Endpoint_ClearSetupOUT();
|
||||
Endpoint_ClearControlOUT();
|
||||
}
|
||||
|
||||
break;
|
||||
|
@ -241,8 +235,8 @@ TASK(USB_Joystick_Report)
|
|||
/* Select the Joystick Report Endpoint */
|
||||
Endpoint_SelectEndpoint(JOYSTICK_EPNUM);
|
||||
|
||||
/* Check if Joystick Endpoint Ready for Read/Write */
|
||||
if (Endpoint_ReadWriteAllowed())
|
||||
/* Check to see if the host is ready for another packet */
|
||||
if (Endpoint_IsINReady())
|
||||
{
|
||||
USB_JoystickReport_Data_t JoystickReportData;
|
||||
|
||||
|
@ -253,12 +247,10 @@ TASK(USB_Joystick_Report)
|
|||
Endpoint_Write_Stream_LE(&JoystickReportData, sizeof(JoystickReportData));
|
||||
|
||||
/* Finalize the stream transfer to send the last packet */
|
||||
Endpoint_ClearCurrentBank();
|
||||
Endpoint_ClearIN();
|
||||
|
||||
/* Clear the report data afterwards */
|
||||
JoystickReportData.X = 0;
|
||||
JoystickReportData.Y = 0;
|
||||
JoystickReportData.Button = 0;
|
||||
memset(&JoystickReportData, 0, sizeof(JoystickReportData));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,7 +45,6 @@
|
|||
#include "Descriptors.h"
|
||||
|
||||
#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/Board/Joystick.h> // Joystick driver
|
||||
#include <LUFA/Drivers/Board/LEDs.h> // LEDs driver
|
||||
|
|
|
@ -37,12 +37,6 @@
|
|||
|
||||
#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 */
|
||||
TASK_LIST
|
||||
{
|
||||
|
@ -222,23 +216,23 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
|
|||
if (wLength > sizeof(KeyboardReportData))
|
||||
wLength = sizeof(KeyboardReportData);
|
||||
|
||||
Endpoint_ClearSetupReceived();
|
||||
Endpoint_ClearControlSETUP();
|
||||
|
||||
/* Write the report data to the control endpoint */
|
||||
Endpoint_Write_Control_Stream_LE(&KeyboardReportData, wLength);
|
||||
|
||||
/* Finalize the stream transfer to send the last packet or clear the host abort */
|
||||
Endpoint_ClearSetupOUT();
|
||||
Endpoint_ClearControlOUT();
|
||||
}
|
||||
|
||||
break;
|
||||
case REQ_SetReport:
|
||||
if (bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE))
|
||||
{
|
||||
Endpoint_ClearSetupReceived();
|
||||
Endpoint_ClearControlSETUP();
|
||||
|
||||
/* 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 */
|
||||
uint8_t LEDStatus = Endpoint_Read_Byte();
|
||||
|
@ -247,28 +241,28 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
|
|||
ProcessLEDReport(LEDStatus);
|
||||
|
||||
/* Clear the endpoint data */
|
||||
Endpoint_ClearSetupOUT();
|
||||
Endpoint_ClearControlOUT();
|
||||
|
||||
/* Acknowledge status stage */
|
||||
while (!(Endpoint_IsSetupINReady()));
|
||||
Endpoint_ClearSetupIN();
|
||||
while (!(Endpoint_IsINReady()));
|
||||
Endpoint_ClearControlIN();
|
||||
}
|
||||
|
||||
break;
|
||||
case REQ_GetProtocol:
|
||||
if (bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE))
|
||||
{
|
||||
Endpoint_ClearSetupReceived();
|
||||
Endpoint_ClearControlSETUP();
|
||||
|
||||
/* Write the current protocol flag to the host */
|
||||
Endpoint_Write_Byte(UsingReportProtocol);
|
||||
|
||||
/* Send the flag to the host */
|
||||
Endpoint_ClearSetupIN();
|
||||
Endpoint_ClearControlIN();
|
||||
|
||||
/* Acknowledge status stage */
|
||||
while (!(Endpoint_IsSetupOUTReceived()));
|
||||
Endpoint_ClearSetupOUT();
|
||||
while (!(Endpoint_IsOUTReceived()));
|
||||
Endpoint_ClearControlOUT();
|
||||
}
|
||||
|
||||
break;
|
||||
|
@ -278,14 +272,14 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
|
|||
/* Read in the wValue parameter containing the new protocol mode */
|
||||
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 */
|
||||
UsingReportProtocol = (wValue != 0x0000);
|
||||
|
||||
/* Acknowledge status stage */
|
||||
while (!(Endpoint_IsSetupINReady()));
|
||||
Endpoint_ClearSetupIN();
|
||||
while (!(Endpoint_IsINReady()));
|
||||
Endpoint_ClearControlIN();
|
||||
}
|
||||
|
||||
break;
|
||||
|
@ -295,31 +289,31 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
|
|||
/* Read in the wValue parameter containing the idle period */
|
||||
uint16_t wValue = Endpoint_Read_Word_LE();
|
||||
|
||||
Endpoint_ClearSetupReceived();
|
||||
Endpoint_ClearControlSETUP();
|
||||
|
||||
/* Get idle period in MSB */
|
||||
IdleCount = (wValue >> 8);
|
||||
|
||||
/* Acknowledge status stage */
|
||||
while (!(Endpoint_IsSetupINReady()));
|
||||
Endpoint_ClearSetupIN();
|
||||
while (!(Endpoint_IsINReady()));
|
||||
Endpoint_ClearControlIN();
|
||||
}
|
||||
|
||||
break;
|
||||
case REQ_GetIdle:
|
||||
if (bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE))
|
||||
{
|
||||
Endpoint_ClearSetupReceived();
|
||||
Endpoint_ClearControlSETUP();
|
||||
|
||||
/* Write the current idle duration to the host */
|
||||
Endpoint_Write_Byte(IdleCount);
|
||||
|
||||
/* Send the flag to the host */
|
||||
Endpoint_ClearSetupIN();
|
||||
Endpoint_ClearControlIN();
|
||||
|
||||
/* Acknowledge status stage */
|
||||
while (!(Endpoint_IsSetupOUTReceived()));
|
||||
Endpoint_ClearSetupOUT();
|
||||
while (!(Endpoint_IsOUTReceived()));
|
||||
Endpoint_ClearControlOUT();
|
||||
}
|
||||
|
||||
break;
|
||||
|
@ -415,13 +409,13 @@ static inline void SendNextReport(void)
|
|||
Endpoint_SelectEndpoint(KEYBOARD_EPNUM);
|
||||
|
||||
/* 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 */
|
||||
Endpoint_Write_Stream_LE(&KeyboardReportData, sizeof(KeyboardReportData));
|
||||
|
||||
/* Finalize the stream transfer to send the last packet */
|
||||
Endpoint_ClearCurrentBank();
|
||||
Endpoint_ClearIN();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -431,18 +425,22 @@ static inline void ReceiveNextReport(void)
|
|||
/* Select the Keyboard LED Report Endpoint */
|
||||
Endpoint_SelectEndpoint(KEYBOARD_LEDS_EPNUM);
|
||||
|
||||
/* Check if Keyboard LED Endpoint Ready for Read/Write */
|
||||
if (!(Endpoint_ReadWriteAllowed()))
|
||||
return;
|
||||
/* Check if Keyboard LED Endpoint contains a packet */
|
||||
if (Endpoint_IsOUTReceived())
|
||||
{
|
||||
/* Check to see if the packet contains data */
|
||||
if (Endpoint_IsReadWriteAllowed())
|
||||
{
|
||||
/* Read in the LED report from the host */
|
||||
uint8_t LEDReport = Endpoint_Read_Byte();
|
||||
|
||||
/* Read in the LED report from the host */
|
||||
uint8_t LEDReport = Endpoint_Read_Byte();
|
||||
/* Process the read LED report from the host */
|
||||
ProcessLEDReport(LEDReport);
|
||||
}
|
||||
|
||||
/* Handshake the OUT Endpoint - clear endpoint and ready for next report */
|
||||
Endpoint_ClearCurrentBank();
|
||||
|
||||
/* Process the read LED report from the host */
|
||||
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
|
||||
|
|
|
@ -49,7 +49,6 @@
|
|||
|
||||
#include <LUFA/Version.h> // Library Version Information
|
||||
#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/Board/Joystick.h> // Joystick driver
|
||||
#include <LUFA/Drivers/Board/LEDs.h> // LEDs driver
|
||||
|
|
|
@ -37,12 +37,6 @@
|
|||
|
||||
#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 */
|
||||
TASK_LIST
|
||||
{
|
||||
|
@ -150,7 +144,7 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
|
|||
case REQ_GetReport:
|
||||
if (bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE))
|
||||
{
|
||||
Endpoint_Ignore_Word();
|
||||
Endpoint_Discard_Word();
|
||||
|
||||
uint16_t wIndex = Endpoint_Read_Word_LE();
|
||||
|
||||
|
@ -173,7 +167,7 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
|
|||
if (wLength > ReportSize)
|
||||
wLength = ReportSize;
|
||||
|
||||
Endpoint_ClearSetupReceived();
|
||||
Endpoint_ClearControlSETUP();
|
||||
|
||||
/* Write the report data to the control endpoint */
|
||||
Endpoint_Write_Control_Stream_LE(ReportData, wLength);
|
||||
|
@ -182,17 +176,17 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
|
|||
memset(ReportData, 0, ReportSize);
|
||||
|
||||
/* Finalize the stream transfer to send the last packet or clear the host abort */
|
||||
Endpoint_ClearSetupOUT();
|
||||
Endpoint_ClearControlOUT();
|
||||
}
|
||||
|
||||
break;
|
||||
case REQ_SetReport:
|
||||
if (bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE))
|
||||
{
|
||||
Endpoint_ClearSetupReceived();
|
||||
Endpoint_ClearControlSETUP();
|
||||
|
||||
/* 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 */
|
||||
uint8_t LEDStatus = Endpoint_Read_Byte();
|
||||
|
@ -211,11 +205,11 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
|
|||
LEDs_SetAllLEDs(LEDMask);
|
||||
|
||||
/* Clear the endpoint data */
|
||||
Endpoint_ClearSetupOUT();
|
||||
Endpoint_ClearControlOUT();
|
||||
|
||||
/* Acknowledge status stage */
|
||||
while (!(Endpoint_IsSetupINReady()));
|
||||
Endpoint_ClearSetupIN();
|
||||
while (!(Endpoint_IsINReady()));
|
||||
Endpoint_ClearControlIN();
|
||||
}
|
||||
|
||||
break;
|
||||
|
@ -281,13 +275,13 @@ TASK(USB_Keyboard)
|
|||
Endpoint_SelectEndpoint(KEYBOARD_IN_EPNUM);
|
||||
|
||||
/* Check if Keyboard Endpoint Ready for Read/Write */
|
||||
if (Endpoint_ReadWriteAllowed())
|
||||
if (Endpoint_IsReadWriteAllowed())
|
||||
{
|
||||
/* Write Keyboard Report Data */
|
||||
Endpoint_Write_Stream_LE(&KeyboardReportData, sizeof(KeyboardReportData));
|
||||
|
||||
/* Finalize the stream transfer to send the last packet */
|
||||
Endpoint_ClearCurrentBank();
|
||||
Endpoint_ClearIN();
|
||||
|
||||
/* Clear the report data afterwards */
|
||||
memset(&KeyboardReportData, 0, sizeof(KeyboardReportData));
|
||||
|
@ -297,7 +291,7 @@ TASK(USB_Keyboard)
|
|||
Endpoint_SelectEndpoint(KEYBOARD_OUT_EPNUM);
|
||||
|
||||
/* Check if Keyboard LED Endpoint Ready for Read/Write */
|
||||
if (Endpoint_ReadWriteAllowed())
|
||||
if (Endpoint_IsReadWriteAllowed())
|
||||
{
|
||||
/* Read in the LED report from the host */
|
||||
uint8_t LEDStatus = Endpoint_Read_Byte();
|
||||
|
@ -316,7 +310,7 @@ TASK(USB_Keyboard)
|
|||
LEDs_SetAllLEDs(LEDMask);
|
||||
|
||||
/* 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);
|
||||
|
||||
/* Check if Mouse Endpoint Ready for Read/Write */
|
||||
if (Endpoint_ReadWriteAllowed())
|
||||
if (Endpoint_IsReadWriteAllowed())
|
||||
{
|
||||
/* Write Mouse Report Data */
|
||||
Endpoint_Write_Stream_LE(&MouseReportData, sizeof(MouseReportData));
|
||||
|
||||
/* Finalize the stream transfer to send the last packet */
|
||||
Endpoint_ClearCurrentBank();
|
||||
Endpoint_ClearIN();
|
||||
|
||||
/* Clear the report data afterwards */
|
||||
memset(&MouseReportData, 0, sizeof(MouseReportData));
|
||||
|
|
|
@ -42,7 +42,6 @@
|
|||
#include "Descriptors.h"
|
||||
|
||||
#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/Board/Joystick.h> // Joystick driver
|
||||
#include <LUFA/Drivers/Board/LEDs.h> // LEDs driver
|
||||
|
|
|
@ -36,12 +36,6 @@
|
|||
|
||||
#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 */
|
||||
TASK_LIST
|
||||
{
|
||||
|
@ -134,7 +128,7 @@ TASK(USB_MIDI_Task)
|
|||
Endpoint_SelectEndpoint(MIDI_STREAM_IN_EPNUM);
|
||||
|
||||
/* 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 */
|
||||
uint8_t JoystickStatus = Joystick_GetStatus();
|
||||
|
@ -166,8 +160,8 @@ TASK(USB_MIDI_Task)
|
|||
Endpoint_SelectEndpoint(MIDI_STREAM_OUT_EPNUM);
|
||||
|
||||
/* Check if endpoint is ready to be read from, if so discard its (unused) data */
|
||||
if (Endpoint_ReadWriteAllowed())
|
||||
Endpoint_ClearCurrentBank();
|
||||
if (Endpoint_IsOUTReceived())
|
||||
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
|
||||
|
@ -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)
|
||||
{
|
||||
/* 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 */
|
||||
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);
|
||||
|
||||
/* Send the data in the endpoint to the host */
|
||||
Endpoint_ClearCurrentBank();
|
||||
Endpoint_ClearIN();
|
||||
}
|
||||
|
|
|
@ -45,7 +45,6 @@
|
|||
#include "Descriptors.h"
|
||||
|
||||
#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/Board/Joystick.h> // Joystick 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);
|
||||
|
||||
/* Wait until endpoint is ready before continuing */
|
||||
while (!(Endpoint_ReadWriteAllowed()));
|
||||
while (!(Endpoint_IsReadWriteAllowed()));
|
||||
|
||||
while (TotalBlocks)
|
||||
{
|
||||
|
@ -74,13 +74,13 @@ void DataflashManager_WriteBlocks(const uint32_t BlockAddress, uint16_t TotalBlo
|
|||
while (BytesInBlockDiv16 < (VIRTUAL_MEMORY_BLOCK_SIZE >> 4))
|
||||
{
|
||||
/* Check if the endpoint is currently empty */
|
||||
if (!(Endpoint_ReadWriteAllowed()))
|
||||
if (!(Endpoint_IsReadWriteAllowed()))
|
||||
{
|
||||
/* Clear the current endpoint bank */
|
||||
Endpoint_ClearCurrentBank();
|
||||
Endpoint_ClearOUT();
|
||||
|
||||
/* Wait until the host has sent another packet */
|
||||
while (!(Endpoint_ReadWriteAllowed()));
|
||||
while (!(Endpoint_IsReadWriteAllowed()));
|
||||
}
|
||||
|
||||
/* Check if end of dataflash page reached */
|
||||
|
@ -157,8 +157,8 @@ void DataflashManager_WriteBlocks(const uint32_t BlockAddress, uint16_t TotalBlo
|
|||
Dataflash_WaitWhileBusy();
|
||||
|
||||
/* If the endpoint is empty, clear it ready for the next packet from the host */
|
||||
if (!(Endpoint_ReadWriteAllowed()))
|
||||
Endpoint_ClearCurrentBank();
|
||||
if (!(Endpoint_IsReadWriteAllowed()))
|
||||
Endpoint_ClearOUT();
|
||||
|
||||
/* Deselect all dataflash chips */
|
||||
Dataflash_DeselectChip();
|
||||
|
@ -187,7 +187,7 @@ void DataflashManager_ReadBlocks(const uint32_t BlockAddress, uint16_t TotalBloc
|
|||
Dataflash_SendByte(0x00);
|
||||
|
||||
/* Wait until endpoint is ready before continuing */
|
||||
while (!(Endpoint_ReadWriteAllowed()));
|
||||
while (!(Endpoint_IsReadWriteAllowed()));
|
||||
|
||||
while (TotalBlocks)
|
||||
{
|
||||
|
@ -197,13 +197,13 @@ void DataflashManager_ReadBlocks(const uint32_t BlockAddress, uint16_t TotalBloc
|
|||
while (BytesInBlockDiv16 < (VIRTUAL_MEMORY_BLOCK_SIZE >> 4))
|
||||
{
|
||||
/* Check if the endpoint is currently full */
|
||||
if (!(Endpoint_ReadWriteAllowed()))
|
||||
if (!(Endpoint_IsReadWriteAllowed()))
|
||||
{
|
||||
/* Clear the endpoint bank to send its contents to the host */
|
||||
Endpoint_ClearCurrentBank();
|
||||
Endpoint_ClearIN();
|
||||
|
||||
/* Wait until the endpoint is ready for more data */
|
||||
while (!(Endpoint_ReadWriteAllowed()));
|
||||
while (!(Endpoint_IsReadWriteAllowed()));
|
||||
}
|
||||
|
||||
/* 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 (!(Endpoint_ReadWriteAllowed()))
|
||||
Endpoint_ClearCurrentBank();
|
||||
if (!(Endpoint_IsReadWriteAllowed()))
|
||||
Endpoint_ClearIN();
|
||||
|
||||
/* Deselect all dataflash chips */
|
||||
Dataflash_DeselectChip();
|
||||
|
|
|
@ -37,12 +37,6 @@
|
|||
#define INCLUDE_FROM_MASSSTORAGE_C
|
||||
#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 */
|
||||
TASK_LIST
|
||||
{
|
||||
|
@ -159,30 +153,30 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
|
|||
case REQ_MassStorageReset:
|
||||
if (bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE))
|
||||
{
|
||||
Endpoint_ClearSetupReceived();
|
||||
Endpoint_ClearControlSETUP();
|
||||
|
||||
/* Indicate that the current transfer should be aborted */
|
||||
IsMassStoreReset = true;
|
||||
|
||||
/* Acknowledge status stage */
|
||||
while (!(Endpoint_IsSetupINReady()));
|
||||
Endpoint_ClearSetupIN();
|
||||
while (!(Endpoint_IsINReady()));
|
||||
Endpoint_ClearControlIN();
|
||||
}
|
||||
|
||||
break;
|
||||
case REQ_GetMaxLUN:
|
||||
if (bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE))
|
||||
{
|
||||
/* Indicate to the host the number of supported LUNs (virtual disks) on the device */
|
||||
Endpoint_ClearSetupReceived();
|
||||
Endpoint_ClearControlSETUP();
|
||||
|
||||
/* Indicate to the host the number of supported LUNs (virtual disks) on the device */
|
||||
Endpoint_Write_Byte(TOTAL_LUNS - 1);
|
||||
|
||||
Endpoint_ClearSetupIN();
|
||||
Endpoint_ClearControlIN();
|
||||
|
||||
/* Acknowledge status stage */
|
||||
while (!(Endpoint_IsSetupOUTReceived()));
|
||||
Endpoint_ClearSetupOUT();
|
||||
while (!(Endpoint_IsOUTReceived()));
|
||||
Endpoint_ClearControlOUT();
|
||||
}
|
||||
|
||||
break;
|
||||
|
@ -234,7 +228,7 @@ TASK(USB_MassStorage)
|
|||
Endpoint_SelectEndpoint(MASS_STORAGE_OUT_EPNUM);
|
||||
|
||||
/* Check to see if a command from the host has been issued */
|
||||
if (Endpoint_ReadWriteAllowed())
|
||||
if (Endpoint_IsReadWriteAllowed())
|
||||
{
|
||||
/* Indicate busy */
|
||||
UpdateStatus(Status_ProcessingCommandBlock);
|
||||
|
@ -326,7 +320,7 @@ static bool ReadInCommandBlock(void)
|
|||
return false;
|
||||
|
||||
/* Finalize the stream transfer to send the last packet */
|
||||
Endpoint_ClearCurrentBank();
|
||||
Endpoint_ClearOUT();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -367,7 +361,7 @@ static void ReturnCommandStatus(void)
|
|||
return;
|
||||
|
||||
/* 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
|
||||
|
|
|
@ -46,7 +46,6 @@
|
|||
#include "DataflashManager.h"
|
||||
|
||||
#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/Board/LEDs.h> // LEDs 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);
|
||||
|
||||
/* Finalize the stream transfer to send the last packet */
|
||||
Endpoint_ClearCurrentBank();
|
||||
Endpoint_ClearIN();
|
||||
|
||||
/* Succeed the command and update the bytes transferred counter */
|
||||
CommandBlock.DataTransferLength -= BytesTransferred;
|
||||
|
@ -201,7 +201,7 @@ static bool SCSI_Command_Request_Sense(void)
|
|||
Endpoint_Write_Stream_LE(&PadBytes, (AllocationLength - BytesTransferred), AbortOnMassStoreReset);
|
||||
|
||||
/* Finalize the stream transfer to send the last packet */
|
||||
Endpoint_ClearCurrentBank();
|
||||
Endpoint_ClearIN();
|
||||
|
||||
/* Succeed the command and update the bytes transferred counter */
|
||||
CommandBlock.DataTransferLength -= BytesTransferred;
|
||||
|
@ -227,7 +227,7 @@ static bool SCSI_Command_Read_Capacity_10(void)
|
|||
return false;
|
||||
|
||||
/* Send the endpoint data packet to the host */
|
||||
Endpoint_ClearCurrentBank();
|
||||
Endpoint_ClearIN();
|
||||
|
||||
/* Succeed the command and update the bytes transferred counter */
|
||||
CommandBlock.DataTransferLength -= 8;
|
||||
|
|
|
@ -36,12 +36,6 @@
|
|||
|
||||
#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 */
|
||||
TASK_LIST
|
||||
{
|
||||
|
@ -212,7 +206,7 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
|
|||
if (wLength > sizeof(MouseReportData))
|
||||
wLength = sizeof(MouseReportData);
|
||||
|
||||
Endpoint_ClearSetupReceived();
|
||||
Endpoint_ClearControlSETUP();
|
||||
|
||||
/* Write the report data to the control endpoint */
|
||||
Endpoint_Write_Control_Stream_LE(&MouseReportData, wLength);
|
||||
|
@ -221,24 +215,24 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
|
|||
memset(&MouseReportData, 0, sizeof(MouseReportData));
|
||||
|
||||
/* Finalize the stream transfer to send the last packet or clear the host abort */
|
||||
Endpoint_ClearSetupOUT();
|
||||
Endpoint_ClearControlOUT();
|
||||
}
|
||||
|
||||
break;
|
||||
case REQ_GetProtocol:
|
||||
if (bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE))
|
||||
{
|
||||
Endpoint_ClearSetupReceived();
|
||||
Endpoint_ClearControlSETUP();
|
||||
|
||||
/* Write the current protocol flag to the host */
|
||||
Endpoint_Write_Byte(UsingReportProtocol);
|
||||
|
||||
/* Send the flag to the host */
|
||||
Endpoint_ClearSetupIN();
|
||||
Endpoint_ClearControlIN();
|
||||
|
||||
/* Acknowledge status stage */
|
||||
while (!(Endpoint_IsSetupOUTReceived()));
|
||||
Endpoint_ClearSetupOUT();
|
||||
while (!(Endpoint_IsOUTReceived()));
|
||||
Endpoint_ClearControlOUT();
|
||||
}
|
||||
|
||||
break;
|
||||
|
@ -248,14 +242,14 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
|
|||
/* Read in the wValue parameter containing the new protocol mode */
|
||||
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 */
|
||||
UsingReportProtocol = (wValue != 0x0000);
|
||||
|
||||
/* Acknowledge status stage */
|
||||
while (!(Endpoint_IsSetupINReady()));
|
||||
Endpoint_ClearSetupIN();
|
||||
while (!(Endpoint_IsINReady()));
|
||||
Endpoint_ClearControlIN();
|
||||
}
|
||||
|
||||
break;
|
||||
|
@ -265,31 +259,31 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
|
|||
/* Read in the wValue parameter containing the idle period */
|
||||
uint16_t wValue = Endpoint_Read_Word_LE();
|
||||
|
||||
Endpoint_ClearSetupReceived();
|
||||
Endpoint_ClearControlSETUP();
|
||||
|
||||
/* Get idle period in MSB */
|
||||
IdleCount = (wValue >> 8);
|
||||
|
||||
/* Acknowledge status stage */
|
||||
while (!(Endpoint_IsSetupINReady()));
|
||||
Endpoint_ClearSetupIN();
|
||||
while (!(Endpoint_IsINReady()));
|
||||
Endpoint_ClearControlIN();
|
||||
}
|
||||
|
||||
break;
|
||||
case REQ_GetIdle:
|
||||
if (bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE))
|
||||
{
|
||||
Endpoint_ClearSetupReceived();
|
||||
Endpoint_ClearControlSETUP();
|
||||
|
||||
/* Write the current idle duration to the host */
|
||||
Endpoint_Write_Byte(IdleCount);
|
||||
|
||||
/* Send the flag to the host */
|
||||
Endpoint_ClearSetupIN();
|
||||
Endpoint_ClearControlIN();
|
||||
|
||||
/* Acknowledge status stage */
|
||||
while (!(Endpoint_IsSetupOUTReceived()));
|
||||
Endpoint_ClearSetupOUT();
|
||||
while (!(Endpoint_IsOUTReceived()));
|
||||
Endpoint_ClearControlOUT();
|
||||
}
|
||||
|
||||
break;
|
||||
|
@ -367,13 +361,13 @@ static inline void SendNextReport(void)
|
|||
Endpoint_SelectEndpoint(MOUSE_EPNUM);
|
||||
|
||||
/* 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 */
|
||||
Endpoint_Write_Stream_LE(&MouseReportData, sizeof(MouseReportData));
|
||||
|
||||
/* Finalize the stream transfer to send the last packet */
|
||||
Endpoint_ClearCurrentBank();
|
||||
Endpoint_ClearIN();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -47,7 +47,6 @@
|
|||
#include "Descriptors.h"
|
||||
|
||||
#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/Board/Joystick.h> // Joystick driver
|
||||
#include <LUFA/Drivers/Board/LEDs.h> // LEDs driver
|
||||
|
|
|
@ -36,12 +36,6 @@
|
|||
|
||||
#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 */
|
||||
TASK_LIST
|
||||
{
|
||||
|
@ -162,13 +156,13 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
|
|||
if (bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE))
|
||||
{
|
||||
/* Clear the SETUP packet, ready for data transfer */
|
||||
Endpoint_ClearSetupReceived();
|
||||
Endpoint_ClearControlSETUP();
|
||||
|
||||
/* Read in the RNDIS message into the message buffer */
|
||||
Endpoint_Read_Control_Stream_LE(RNDISMessageBuffer, wLength);
|
||||
|
||||
/* Finalize the stream transfer to clear the last packet from the host */
|
||||
Endpoint_ClearSetupIN();
|
||||
Endpoint_ClearControlIN();
|
||||
|
||||
/* Process the RNDIS message */
|
||||
ProcessRNDISControlMessage();
|
||||
|
@ -191,13 +185,13 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
|
|||
wLength = MessageHeader->MessageLength;
|
||||
|
||||
/* Clear the SETUP packet, ready for data transfer */
|
||||
Endpoint_ClearSetupReceived();
|
||||
Endpoint_ClearControlSETUP();
|
||||
|
||||
/* Write the message response data to the endpoint */
|
||||
Endpoint_Write_Control_Stream_LE(RNDISMessageBuffer, wLength);
|
||||
|
||||
/* 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 */
|
||||
MessageHeader->MessageLength = 0;
|
||||
|
@ -247,7 +241,7 @@ TASK(RNDIS_Task)
|
|||
Endpoint_SelectEndpoint(CDC_NOTIFICATION_EPNUM);
|
||||
|
||||
/* 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)
|
||||
{
|
||||
|
@ -262,7 +256,7 @@ TASK(RNDIS_Task)
|
|||
Endpoint_Write_Stream_LE(&Notification, sizeof(Notification));
|
||||
|
||||
/* Finalize the stream transfer to send the last packet */
|
||||
Endpoint_ClearCurrentBank();
|
||||
Endpoint_ClearIN();
|
||||
|
||||
/* Indicate a response is no longer ready */
|
||||
ResponseReady = false;
|
||||
|
@ -278,7 +272,7 @@ TASK(RNDIS_Task)
|
|||
Endpoint_SelectEndpoint(CDC_RX_EPNUM);
|
||||
|
||||
/* 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 */
|
||||
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);
|
||||
|
||||
/* Finalize the stream transfer to send the last packet */
|
||||
Endpoint_ClearCurrentBank();
|
||||
Endpoint_ClearOUT();
|
||||
|
||||
/* Store the size of the Ethernet frame */
|
||||
FrameIN.FrameLength = RNDISPacketHeader.DataLength;
|
||||
|
@ -307,7 +301,7 @@ TASK(RNDIS_Task)
|
|||
Endpoint_SelectEndpoint(CDC_TX_EPNUM);
|
||||
|
||||
/* Check if the data IN endpoint is ready for more data, and that the IN buffer is full */
|
||||
if (Endpoint_ReadWriteAllowed() && FrameOUT.FrameInBuffer)
|
||||
if (Endpoint_IsINReady() && FrameOUT.FrameInBuffer)
|
||||
{
|
||||
/* Clear the packet header with all 0s so that the relevant fields can be filled */
|
||||
memset(&RNDISPacketHeader, 0, sizeof(RNDIS_PACKET_MSG_t));
|
||||
|
@ -325,7 +319,7 @@ TASK(RNDIS_Task)
|
|||
Endpoint_Write_Stream_LE(FrameOUT.FrameData, RNDISPacketHeader.DataLength);
|
||||
|
||||
/* Finalize the stream transfer to send the last packet */
|
||||
Endpoint_ClearCurrentBank();
|
||||
Endpoint_ClearIN();
|
||||
|
||||
/* Indicate Ethernet OUT buffer no longer full */
|
||||
FrameOUT.FrameInBuffer = false;
|
||||
|
|
|
@ -52,7 +52,6 @@
|
|||
#include "Webserver.h"
|
||||
|
||||
#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/Board/LEDs.h> // LEDs driver
|
||||
#include <LUFA/Scheduler/Scheduler.h> // Simple scheduler for task management
|
||||
|
|
|
@ -30,12 +30,6 @@
|
|||
|
||||
#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 */
|
||||
TASK_LIST
|
||||
{
|
||||
|
@ -165,13 +159,13 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
|
|||
if (bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE))
|
||||
{
|
||||
/* Acknowledge the SETUP packet, ready for data transfer */
|
||||
Endpoint_ClearSetupReceived();
|
||||
Endpoint_ClearControlSETUP();
|
||||
|
||||
/* Write the line coding data to the control endpoint */
|
||||
Endpoint_Write_Control_Stream_LE(LineCodingData, sizeof(LineCoding));
|
||||
|
||||
/* Finalize the stream transfer to send the last packet or clear the host abort */
|
||||
Endpoint_ClearSetupOUT();
|
||||
Endpoint_ClearControlOUT();
|
||||
}
|
||||
|
||||
break;
|
||||
|
@ -179,13 +173,13 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
|
|||
if (bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE))
|
||||
{
|
||||
/* 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 */
|
||||
Endpoint_Read_Control_Stream_LE(LineCodingData, sizeof(LineCoding));
|
||||
|
||||
/* Finalize the stream transfer to clear the last packet from the host */
|
||||
Endpoint_ClearSetupIN();
|
||||
Endpoint_ClearControlIN();
|
||||
|
||||
/* Reconfigure the USART with the new settings */
|
||||
ReconfigureUSART();
|
||||
|
@ -207,11 +201,11 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
|
|||
#endif
|
||||
|
||||
/* Acknowledge the SETUP packet, ready for data transfer */
|
||||
Endpoint_ClearSetupReceived();
|
||||
Endpoint_ClearControlSETUP();
|
||||
|
||||
/* Acknowledge status stage */
|
||||
while (!(Endpoint_IsSetupINReady()));
|
||||
Endpoint_ClearSetupIN();
|
||||
while (!(Endpoint_IsINReady()));
|
||||
Endpoint_ClearControlIN();
|
||||
}
|
||||
|
||||
break;
|
||||
|
@ -244,13 +238,13 @@ TASK(CDC_Task)
|
|||
Endpoint_SelectEndpoint(CDC_NOTIFICATION_EPNUM);
|
||||
Endpoint_Write_Stream_LE(&Notification, sizeof(Notification));
|
||||
Endpoint_Write_Stream_LE(&LineStateMask, sizeof(LineStateMask));
|
||||
Endpoint_ClearCurrentBank();
|
||||
Endpoint_ClearIN();
|
||||
#endif
|
||||
|
||||
/* Select the Serial Rx Endpoint */
|
||||
Endpoint_SelectEndpoint(CDC_RX_EPNUM);
|
||||
|
||||
if (Endpoint_ReadWriteAllowed())
|
||||
if (Endpoint_IsOUTReceived())
|
||||
{
|
||||
/* Read the received data endpoint into the transmission buffer */
|
||||
while (Endpoint_BytesInEndpoint())
|
||||
|
@ -263,7 +257,7 @@ TASK(CDC_Task)
|
|||
}
|
||||
|
||||
/* Clear the endpoint buffer */
|
||||
Endpoint_ClearCurrentBank();
|
||||
Endpoint_ClearOUT();
|
||||
}
|
||||
|
||||
/* Check if Rx buffer contains data */
|
||||
|
@ -284,27 +278,20 @@ TASK(CDC_Task)
|
|||
if (Tx_Buffer.Elements)
|
||||
{
|
||||
/* Wait until Serial Tx Endpoint Ready for Read/Write */
|
||||
while (!(Endpoint_ReadWriteAllowed()));
|
||||
|
||||
/* Check before sending the data if the endpoint is completely full */
|
||||
bool IsFull = (Endpoint_BytesInEndpoint() == CDC_TXRX_EPSIZE);
|
||||
while (!(Endpoint_IsReadWriteAllowed()));
|
||||
|
||||
/* Write the transmission buffer contents to the received data endpoint */
|
||||
while (Tx_Buffer.Elements && (Endpoint_BytesInEndpoint() < CDC_TXRX_EPSIZE))
|
||||
Endpoint_Write_Byte(Buffer_GetElement(&Tx_Buffer));
|
||||
|
||||
/* 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 */
|
||||
while (!(Endpoint_ReadWriteAllowed()));
|
||||
/* Wait until Serial Tx Endpoint Ready for Read/Write */
|
||||
while (!(Endpoint_IsReadWriteAllowed()));
|
||||
|
||||
/* Send an empty packet to terminate the transfer */
|
||||
Endpoint_ClearCurrentBank();
|
||||
}
|
||||
/* Send an empty packet to terminate the transfer */
|
||||
Endpoint_ClearIN();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,7 +46,6 @@
|
|||
#include "RingBuff.h"
|
||||
|
||||
#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/AT90USBXXX/Serial.h> // USART driver
|
||||
#include <LUFA/Drivers/Board/LEDs.h> // LEDs driver
|
||||
|
|
|
@ -36,12 +36,6 @@
|
|||
|
||||
#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 */
|
||||
TASK_LIST
|
||||
{
|
||||
|
@ -244,33 +238,37 @@ TASK(USB_CDC_Host)
|
|||
/* Select and the data IN pipe */
|
||||
Pipe_SelectPipe(CDC_DATAPIPE_IN);
|
||||
|
||||
/* Check if data is in the pipe */
|
||||
if (Pipe_ReadWriteAllowed())
|
||||
/* Check to see if a packet has been received */
|
||||
if (Pipe_IsINReceived())
|
||||
{
|
||||
/* Get the length of the pipe data, and create a new buffer to hold it */
|
||||
uint16_t BufferLength = Pipe_BytesInPipe();
|
||||
uint8_t Buffer[BufferLength];
|
||||
|
||||
/* Read in the pipe data to the temporary buffer */
|
||||
Pipe_Read_Stream_LE(Buffer, BufferLength);
|
||||
|
||||
/* Check if data is in the pipe */
|
||||
if (Pipe_IsReadWriteAllowed())
|
||||
{
|
||||
/* Get the length of the pipe data, and create a new buffer to hold it */
|
||||
uint16_t BufferLength = Pipe_BytesInPipe();
|
||||
uint8_t Buffer[BufferLength];
|
||||
|
||||
/* Read in the pipe data to the temporary buffer */
|
||||
Pipe_Read_Stream_LE(Buffer, BufferLength);
|
||||
|
||||
/* Print out the buffer contents to the USART */
|
||||
for (uint16_t BufferByte = 0; BufferByte < BufferLength; BufferByte++)
|
||||
putchar(Buffer[BufferByte]);
|
||||
}
|
||||
|
||||
/* Clear the pipe after it is read, ready for the next packet */
|
||||
Pipe_ClearCurrentBank();
|
||||
|
||||
/* Print out the buffer contents to the USART */
|
||||
for (uint16_t BufferByte = 0; BufferByte < BufferLength; BufferByte++)
|
||||
putchar(Buffer[BufferByte]);
|
||||
Pipe_ClearIN();
|
||||
}
|
||||
|
||||
/* Select and unfreeze the notification pipe */
|
||||
Pipe_SelectPipe(CDC_NOTIFICATIONPIPE);
|
||||
Pipe_Unfreeze();
|
||||
|
||||
/* Check if data is in the pipe */
|
||||
if (Pipe_ReadWriteAllowed())
|
||||
/* Check if a packet has been received */
|
||||
if (Pipe_IsINReceived())
|
||||
{
|
||||
/* Discard the event notification */
|
||||
Pipe_ClearCurrentBank();
|
||||
Pipe_ClearIN();
|
||||
}
|
||||
|
||||
/* Freeze notification IN pipe after use */
|
||||
|
|
|
@ -44,7 +44,6 @@
|
|||
#include <stdio.h>
|
||||
|
||||
#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/USB/USB.h> // USB Functionality
|
||||
#include <LUFA/Drivers/AT90USBXXX/Serial_Stream.h> // Serial stream driver
|
||||
|
|
|
@ -38,7 +38,6 @@
|
|||
|
||||
/* Includes: */
|
||||
#include <LUFA/Drivers/USB/USB.h> // USB Functionality
|
||||
#include <LUFA/Drivers/USB/Class/ConfigDescriptor.h> // Configuration Descriptor Parser
|
||||
|
||||
#include "CDCHost.h"
|
||||
|
||||
|
|
|
@ -38,7 +38,6 @@
|
|||
|
||||
/* Includes: */
|
||||
#include <LUFA/Drivers/USB/USB.h> // USB Functionality
|
||||
#include <LUFA/Drivers/USB/Class/ConfigDescriptor.h> // Configuration Descriptor Parser
|
||||
|
||||
#include "GenericHIDHost.h"
|
||||
|
||||
|
|
|
@ -36,12 +36,6 @@
|
|||
|
||||
#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 */
|
||||
TASK_LIST
|
||||
{
|
||||
|
@ -185,30 +179,34 @@ void ReadNextReport(void)
|
|||
Pipe_SelectPipe(HID_DATA_IN_PIPE);
|
||||
Pipe_Unfreeze();
|
||||
|
||||
/* Ensure pipe contains data and is ready to be read before continuing */
|
||||
if (!(Pipe_ReadWriteAllowed()))
|
||||
/* Check to see if a packet has been received */
|
||||
if (!(Pipe_IsINReceived()))
|
||||
{
|
||||
#if !defined(INTERRUPT_DATA_PIPE)
|
||||
/* Refreeze HID data IN pipe */
|
||||
Pipe_Freeze();
|
||||
#endif
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
uint8_t ReportINData[Pipe_BytesInPipe()];
|
||||
/* Ensure pipe contains data before trying to read from it */
|
||||
if (Pipe_IsReadWriteAllowed())
|
||||
{
|
||||
uint8_t ReportINData[Pipe_BytesInPipe()];
|
||||
|
||||
/* Read in HID report data */
|
||||
Pipe_Read_Stream_LE(&ReportINData, sizeof(ReportINData));
|
||||
/* Read in HID report data */
|
||||
Pipe_Read_Stream_LE(&ReportINData, sizeof(ReportINData));
|
||||
|
||||
/* Print report data through the serial port */
|
||||
for (uint16_t CurrByte = 0; CurrByte < sizeof(ReportINData); CurrByte++)
|
||||
printf_P(PSTR("0x%02X "), ReportINData[CurrByte]);
|
||||
|
||||
puts_P(PSTR("\r\n"));
|
||||
}
|
||||
|
||||
/* Clear the IN endpoint, ready for next data packet */
|
||||
Pipe_ClearCurrentBank();
|
||||
|
||||
/* Print report data through the serial port */
|
||||
for (uint16_t CurrByte = 0; CurrByte < sizeof(ReportINData); CurrByte++)
|
||||
printf_P(PSTR("0x%02X "), ReportINData[CurrByte]);
|
||||
|
||||
puts_P(PSTR("\r\n"));
|
||||
Pipe_ClearIN();
|
||||
|
||||
#if !defined(INTERRUPT_DATA_PIPE)
|
||||
/* Refreeze HID data IN pipe */
|
||||
|
@ -235,7 +233,7 @@ void WriteNextReport(uint8_t* ReportOUTData, uint8_t ReportIndex, uint8_t Report
|
|||
Pipe_Unfreeze();
|
||||
|
||||
/* Ensure pipe is ready to be written to before continuing */
|
||||
if (!(Pipe_ReadWriteAllowed()))
|
||||
if (!(Pipe_IsOUTReady()))
|
||||
{
|
||||
/* Refreeze the data OUT pipe */
|
||||
Pipe_Freeze();
|
||||
|
@ -251,7 +249,7 @@ void WriteNextReport(uint8_t* ReportOUTData, uint8_t ReportIndex, uint8_t Report
|
|||
Pipe_Write_Stream_LE(ReportOUTData, ReportLength);
|
||||
|
||||
/* Clear the OUT endpoint, send last data packet */
|
||||
Pipe_ClearCurrentBank();
|
||||
Pipe_ClearOUT();
|
||||
|
||||
/* Refreeze the data OUT pipe */
|
||||
Pipe_Freeze();
|
||||
|
|
|
@ -45,7 +45,6 @@
|
|||
#include <stdio.h>
|
||||
|
||||
#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/USB/USB.h> // USB Functionality
|
||||
#include <LUFA/Drivers/AT90USBXXX/Serial_Stream.h> // Serial stream driver
|
||||
|
@ -94,6 +93,6 @@
|
|||
/* Function Prototypes: */
|
||||
void UpdateStatus(uint8_t CurrentStatus);
|
||||
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
|
||||
|
|
|
@ -38,7 +38,6 @@
|
|||
|
||||
/* Includes: */
|
||||
#include <LUFA/Drivers/USB/USB.h> // USB Functionality
|
||||
#include <LUFA/Drivers/USB/Class/ConfigDescriptor.h> // Configuration Descriptor Parser
|
||||
|
||||
#include "KeyboardHost.h"
|
||||
|
||||
|
|
|
@ -36,12 +36,6 @@
|
|||
|
||||
#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 */
|
||||
TASK_LIST
|
||||
{
|
||||
|
@ -191,52 +185,57 @@ void ReadNextReport(void)
|
|||
Pipe_Unfreeze();
|
||||
#endif
|
||||
|
||||
/* Ensure pipe contains data and is ready to be read before continuing */
|
||||
if (!(Pipe_ReadWriteAllowed()))
|
||||
/* Check to see if a packet has been received */
|
||||
if (!(Pipe_IsINReceived()))
|
||||
{
|
||||
#if !defined(INTERRUPT_DATA_PIPE)
|
||||
/* Refreeze keyboard data pipe */
|
||||
/* Refreeze HID data IN pipe */
|
||||
Pipe_Freeze();
|
||||
#endif
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/* Read in keyboard report data */
|
||||
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) */
|
||||
LEDs_ChangeLEDs(LEDS_LED1, (KeyboardReport.Modifier) ? LEDS_LED1 : 0);
|
||||
|
||||
/* Check if a key has been pressed */
|
||||
if (KeyboardReport.KeyCode)
|
||||
/* Ensure pipe contains data before trying to read from it */
|
||||
if (Pipe_IsReadWriteAllowed())
|
||||
{
|
||||
/* Toggle status LED to indicate keypress */
|
||||
if (LEDs_GetLEDs() & LEDS_LED2)
|
||||
LEDs_TurnOffLEDs(LEDS_LED2);
|
||||
else
|
||||
LEDs_TurnOnLEDs(LEDS_LED2);
|
||||
|
||||
char PressedKey = 0;
|
||||
/* Read in keyboard report data */
|
||||
Pipe_Read_Stream_LE(&KeyboardReport, sizeof(KeyboardReport));
|
||||
|
||||
/* Retrieve pressed key character if alphanumeric */
|
||||
if ((KeyboardReport.KeyCode >= 0x04) && (KeyboardReport.KeyCode <= 0x1D))
|
||||
PressedKey = (KeyboardReport.KeyCode - 0x04) + 'A';
|
||||
else if ((KeyboardReport.KeyCode >= 0x1E) && (KeyboardReport.KeyCode <= 0x27))
|
||||
PressedKey = (KeyboardReport.KeyCode - 0x1E) + '0';
|
||||
else if (KeyboardReport.KeyCode == 0x2C)
|
||||
PressedKey = ' ';
|
||||
else if (KeyboardReport.KeyCode == 0x28)
|
||||
PressedKey = '\n';
|
||||
|
||||
/* Print the pressed key character out through the serial port if valid */
|
||||
if (PressedKey)
|
||||
putchar(PressedKey);
|
||||
/* 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);
|
||||
|
||||
/* Check if a key has been pressed */
|
||||
if (KeyboardReport.KeyCode)
|
||||
{
|
||||
/* Toggle status LED to indicate keypress */
|
||||
if (LEDs_GetLEDs() & LEDS_LED2)
|
||||
LEDs_TurnOffLEDs(LEDS_LED2);
|
||||
else
|
||||
LEDs_TurnOnLEDs(LEDS_LED2);
|
||||
|
||||
char PressedKey = 0;
|
||||
|
||||
/* Retrieve pressed key character if alphanumeric */
|
||||
if ((KeyboardReport.KeyCode >= 0x04) && (KeyboardReport.KeyCode <= 0x1D))
|
||||
PressedKey = (KeyboardReport.KeyCode - 0x04) + 'A';
|
||||
else if ((KeyboardReport.KeyCode >= 0x1E) && (KeyboardReport.KeyCode <= 0x27))
|
||||
PressedKey = (KeyboardReport.KeyCode - 0x1E) + '0';
|
||||
else if (KeyboardReport.KeyCode == 0x2C)
|
||||
PressedKey = ' ';
|
||||
else if (KeyboardReport.KeyCode == 0x28)
|
||||
PressedKey = '\n';
|
||||
|
||||
/* Print the pressed key character out through the serial port if valid */
|
||||
if (PressedKey)
|
||||
putchar(PressedKey);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Clear the IN endpoint, ready for next data packet */
|
||||
Pipe_ClearIN();
|
||||
|
||||
#if !defined(INTERRUPT_DATA_PIPE)
|
||||
/* Refreeze keyboard data pipe */
|
||||
Pipe_Freeze();
|
||||
|
|
|
@ -45,7 +45,6 @@
|
|||
#include <stdio.h>
|
||||
|
||||
#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/USB/USB.h> // USB Functionality
|
||||
#include <LUFA/Drivers/AT90USBXXX/Serial_Stream.h> // Serial stream driver
|
||||
|
|
|
@ -38,7 +38,6 @@
|
|||
|
||||
/* Includes: */
|
||||
#include <LUFA/Drivers/USB/USB.h> // USB Functionality
|
||||
#include <LUFA/Drivers/USB/Class/ConfigDescriptor.h> // Configuration Descriptor Parser
|
||||
|
||||
#include "HIDReport.h"
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
#define _HID_REPORT_H_
|
||||
|
||||
/* Includes: */
|
||||
#include <LUFA/Drivers/USB/Class/HIDParser.h> // HID Class Report Parser
|
||||
#include <LUFA/Drivers/USB/USB.h> // USB Functionality
|
||||
|
||||
#include "KeyboardHostWithParser.h"
|
||||
|
||||
|
|
|
@ -36,12 +36,6 @@
|
|||
|
||||
#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 */
|
||||
TASK_LIST
|
||||
{
|
||||
|
@ -270,70 +264,24 @@ TASK(USB_Keyboard_Host)
|
|||
Pipe_SelectPipe(KEYBOARD_DATAPIPE);
|
||||
Pipe_Unfreeze();
|
||||
|
||||
/* Check if data has been received from the attached keyboard */
|
||||
if (Pipe_ReadWriteAllowed())
|
||||
/* Check to see if a packet has been received */
|
||||
if (Pipe_IsINReceived())
|
||||
{
|
||||
/* Create buffer big enough for the report */
|
||||
uint8_t KeyboardReport[Pipe_BytesInPipe()];
|
||||
/* Check if data has been received from the attached keyboard */
|
||||
if (Pipe_IsReadWriteAllowed())
|
||||
{
|
||||
/* Create buffer big enough for the report */
|
||||
uint8_t KeyboardReport[Pipe_BytesInPipe()];
|
||||
|
||||
/* Load in the keyboard report */
|
||||
Pipe_Read_Stream_LE(KeyboardReport, Pipe_BytesInPipe());
|
||||
/* Load in the keyboard report */
|
||||
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 */
|
||||
Pipe_ClearCurrentBank();
|
||||
|
||||
/* Check each HID report item in turn, looking for keyboard scan code reports */
|
||||
for (uint8_t ReportNumber = 0; ReportNumber < HIDReportInfo.TotalReportItems; ReportNumber++)
|
||||
{
|
||||
/* Create a temporary item pointer to the next report item */
|
||||
HID_ReportItem_t* ReportItem = &HIDReportInfo.ReportItems[ReportNumber];
|
||||
|
||||
/* Check if the current report item is a keyboard scancode */
|
||||
if ((ReportItem->Attributes.Usage.Page == USAGE_PAGE_KEYBOARD) &&
|
||||
(ReportItem->Attributes.BitSize == 8) &&
|
||||
(ReportItem->Attributes.Logical.Maximum > 1) &&
|
||||
(ReportItem->ItemType == REPORT_ITEM_TYPE_In))
|
||||
{
|
||||
/* Retrieve the keyboard scancode from the report data retrieved from the device */
|
||||
bool FoundData = GetReportItemInfo(KeyboardReport, ReportItem);
|
||||
|
||||
/* For multi-report devices - if the requested data was not in the issued report, continue */
|
||||
if (!(FoundData))
|
||||
continue;
|
||||
|
||||
/* Key code is an unsigned char in length, cast to the appropriate type */
|
||||
uint8_t KeyCode = (uint8_t)ReportItem->Value;
|
||||
|
||||
/* If scancode is non-zero, a key is being pressed */
|
||||
if (KeyCode)
|
||||
{
|
||||
/* Toggle status LED to indicate keypress */
|
||||
if (LEDs_GetLEDs() & LEDS_LED2)
|
||||
LEDs_TurnOffLEDs(LEDS_LED2);
|
||||
else
|
||||
LEDs_TurnOnLEDs(LEDS_LED2);
|
||||
|
||||
char PressedKey = 0;
|
||||
|
||||
/* Convert scancode to printable character if alphanumeric */
|
||||
if ((KeyCode >= 0x04) && (KeyCode <= 0x1D))
|
||||
PressedKey = (KeyCode - 0x04) + 'A';
|
||||
else if ((KeyCode >= 0x1E) && (KeyCode <= 0x27))
|
||||
PressedKey = (KeyCode - 0x1E) + '0';
|
||||
else if (KeyCode == 0x2C)
|
||||
PressedKey = ' ';
|
||||
else if (KeyCode == 0x28)
|
||||
PressedKey = '\n';
|
||||
|
||||
/* Print the pressed key character out through the serial port if valid */
|
||||
if (PressedKey)
|
||||
putchar(PressedKey);
|
||||
}
|
||||
|
||||
/* Once a scancode is found, stop scanning through the report items */
|
||||
break;
|
||||
}
|
||||
}
|
||||
Pipe_ClearIN();
|
||||
}
|
||||
|
||||
/* Freeze keyboard data pipe */
|
||||
|
@ -341,3 +289,64 @@ TASK(USB_Keyboard_Host)
|
|||
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 */
|
||||
for (uint8_t ReportNumber = 0; ReportNumber < HIDReportInfo.TotalReportItems; ReportNumber++)
|
||||
{
|
||||
/* Create a temporary item pointer to the next report item */
|
||||
HID_ReportItem_t* ReportItem = &HIDReportInfo.ReportItems[ReportNumber];
|
||||
|
||||
/* Check if the current report item is a keyboard scancode */
|
||||
if ((ReportItem->Attributes.Usage.Page == USAGE_PAGE_KEYBOARD) &&
|
||||
(ReportItem->Attributes.BitSize == 8) &&
|
||||
(ReportItem->Attributes.Logical.Maximum > 1) &&
|
||||
(ReportItem->ItemType == REPORT_ITEM_TYPE_In))
|
||||
{
|
||||
/* Retrieve the keyboard scancode from the report data retrieved from the device */
|
||||
bool FoundData = GetReportItemInfo(KeyboardReport, ReportItem);
|
||||
|
||||
/* For multi-report devices - if the requested data was not in the issued report, continue */
|
||||
if (!(FoundData))
|
||||
continue;
|
||||
|
||||
/* Key code is an unsigned char in length, cast to the appropriate type */
|
||||
uint8_t KeyCode = (uint8_t)ReportItem->Value;
|
||||
|
||||
/* If scancode is non-zero, a key is being pressed */
|
||||
if (KeyCode)
|
||||
{
|
||||
/* Toggle status LED to indicate keypress */
|
||||
if (LEDs_GetLEDs() & LEDS_LED2)
|
||||
LEDs_TurnOffLEDs(LEDS_LED2);
|
||||
else
|
||||
LEDs_TurnOnLEDs(LEDS_LED2);
|
||||
|
||||
char PressedKey = 0;
|
||||
|
||||
/* Convert scancode to printable character if alphanumeric */
|
||||
if ((KeyCode >= 0x04) && (KeyCode <= 0x1D))
|
||||
PressedKey = (KeyCode - 0x04) + 'A';
|
||||
else if ((KeyCode >= 0x1E) && (KeyCode <= 0x27))
|
||||
PressedKey = (KeyCode - 0x1E) + '0';
|
||||
else if (KeyCode == 0x2C)
|
||||
PressedKey = ' ';
|
||||
else if (KeyCode == 0x28)
|
||||
PressedKey = '\n';
|
||||
|
||||
/* Print the pressed key character out through the serial port if valid */
|
||||
if (PressedKey)
|
||||
putchar(PressedKey);
|
||||
}
|
||||
|
||||
/* Once a scancode is found, stop scanning through the report items */
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,7 +39,6 @@
|
|||
#include <stdio.h>
|
||||
|
||||
#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/USB/USB.h> // USB Functionality
|
||||
#include <LUFA/Drivers/AT90USBXXX/Serial_Stream.h> // Serial stream driver
|
||||
|
@ -77,5 +76,6 @@
|
|||
|
||||
/* Function Prototypes: */
|
||||
void UpdateStatus(uint8_t CurrentStatus);
|
||||
void ProcessKeyboardReport(uint8_t* KeyboardReport);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -38,7 +38,6 @@
|
|||
|
||||
/* Includes: */
|
||||
#include <LUFA/Drivers/USB/USB.h> // USB Functionality
|
||||
#include <LUFA/Drivers/USB/Class/ConfigDescriptor.h> // Configuration Descriptor Parser
|
||||
|
||||
#include "MassStorageHost.h"
|
||||
|
||||
|
|
|
@ -36,12 +36,6 @@
|
|||
|
||||
#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 */
|
||||
TASK_LIST
|
||||
{
|
||||
|
|
|
@ -48,7 +48,6 @@
|
|||
#include "MassStoreCommands.h"
|
||||
|
||||
#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/USB/USB.h> // USB Functionality
|
||||
#include <LUFA/Drivers/AT90USBXXX/Serial_Stream.h> // Serial stream driver
|
||||
|
|
|
@ -88,7 +88,7 @@ static uint8_t MassStore_SendCommand(void)
|
|||
return ErrorCode;
|
||||
|
||||
/* 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 */
|
||||
USB_Host_WaitMS(1);
|
||||
|
@ -117,7 +117,7 @@ static uint8_t MassStore_WaitForDataReceived(void)
|
|||
Pipe_Unfreeze();
|
||||
|
||||
/* 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) */
|
||||
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 */
|
||||
if ((ErrorCode = Pipe_Read_Stream_LE(BufferPtr, BytesRem)) != PIPE_RWSTREAM_ERROR_NoError)
|
||||
return ErrorCode;
|
||||
|
||||
/* Acknowledge the packet */
|
||||
Pipe_ClearIN();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -193,10 +196,10 @@ static uint8_t MassStore_SendReceiveData(void* BufferPtr)
|
|||
/* Write the block data to the pipe */
|
||||
if ((ErrorCode = Pipe_Write_Stream_LE(BufferPtr, BytesRem)) != PIPE_RWSTREAM_ERROR_NoError)
|
||||
return ErrorCode;
|
||||
|
||||
/* Acknowledge the packet */
|
||||
Pipe_ClearOUT();
|
||||
}
|
||||
|
||||
/* Acknowledge the packet */
|
||||
Pipe_ClearCurrentBank();
|
||||
|
||||
/* Some buggy devices require a delay here before the pipe freezing or they will lock up */
|
||||
USB_Host_WaitMS(1);
|
||||
|
@ -216,8 +219,8 @@ static uint8_t MassStore_GetReturnedStatus(void)
|
|||
uint8_t ErrorCode = PIPE_RWSTREAM_ERROR_NoError;
|
||||
|
||||
/* If an error in the command ocurred, abort */
|
||||
if (MassStore_WaitForDataReceived() != NoError)
|
||||
return;
|
||||
if ((ErrorCode == MassStore_WaitForDataReceived()) != PIPE_RWSTREAM_ERROR_NoError)
|
||||
return ErrorCode;
|
||||
|
||||
/* Select the IN data pipe for data reception */
|
||||
Pipe_SelectPipe(MASS_STORE_DATA_IN_PIPE);
|
||||
|
@ -228,7 +231,7 @@ static uint8_t MassStore_GetReturnedStatus(void)
|
|||
return ErrorCode;
|
||||
|
||||
/* 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 */
|
||||
USB_Host_WaitMS(1);
|
||||
|
|
|
@ -38,7 +38,6 @@
|
|||
|
||||
/* Includes: */
|
||||
#include <LUFA/Drivers/USB/USB.h> // USB Functionality
|
||||
#include <LUFA/Drivers/USB/Class/ConfigDescriptor.h> // Configuration Descriptor Parser
|
||||
|
||||
#include "MouseHost.h"
|
||||
|
||||
|
|
|
@ -36,12 +36,6 @@
|
|||
|
||||
#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 */
|
||||
TASK_LIST
|
||||
{
|
||||
|
@ -188,49 +182,53 @@ void ReadNextReport(void)
|
|||
Pipe_SelectPipe(MOUSE_DATAPIPE);
|
||||
|
||||
#if !defined(INTERRUPT_DATA_PIPE)
|
||||
/* Unfreeze mouse data pipe */
|
||||
/* Unfreeze keyboard data pipe */
|
||||
Pipe_Unfreeze();
|
||||
#endif
|
||||
|
||||
/* Ensure pipe contains data and is ready to be read before continuing */
|
||||
if (!(Pipe_ReadWriteAllowed()))
|
||||
/* Check to see if a packet has been received */
|
||||
if (!(Pipe_IsINReceived()))
|
||||
{
|
||||
#if !defined(INTERRUPT_DATA_PIPE)
|
||||
/* Refreeze mouse data pipe */
|
||||
/* Refreeze HID data IN pipe */
|
||||
Pipe_Freeze();
|
||||
#endif
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/* Read in mouse report data */
|
||||
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 */
|
||||
if (MouseReport.X > 0)
|
||||
LEDMask |= LEDS_LED1;
|
||||
else if (MouseReport.X < 0)
|
||||
LEDMask |= LEDS_LED2;
|
||||
|
||||
/* Alter status LEDs according to mouse Y movement */
|
||||
if (MouseReport.Y > 0)
|
||||
LEDMask |= LEDS_LED3;
|
||||
else if (MouseReport.Y < 0)
|
||||
LEDMask |= LEDS_LED4;
|
||||
/* Ensure pipe contains data before trying to read from it */
|
||||
if (Pipe_IsReadWriteAllowed())
|
||||
{
|
||||
/* Read in mouse report data */
|
||||
Pipe_Read_Stream_LE(&MouseReport, sizeof(MouseReport));
|
||||
|
||||
/* Alter status LEDs according to mouse button position */
|
||||
if (MouseReport.Button)
|
||||
LEDMask = LEDS_ALL_LEDS;
|
||||
|
||||
LEDs_SetAllLEDs(LEDMask);
|
||||
|
||||
/* Print mouse report data through the serial port */
|
||||
printf_P(PSTR("dX:%2d dY:%2d Button:%d\r\n"), MouseReport.X,
|
||||
MouseReport.Y,
|
||||
MouseReport.Button);
|
||||
/* Alter status LEDs according to mouse X movement */
|
||||
if (MouseReport.X > 0)
|
||||
LEDMask |= LEDS_LED1;
|
||||
else if (MouseReport.X < 0)
|
||||
LEDMask |= LEDS_LED2;
|
||||
|
||||
/* Alter status LEDs according to mouse Y movement */
|
||||
if (MouseReport.Y > 0)
|
||||
LEDMask |= LEDS_LED3;
|
||||
else if (MouseReport.Y < 0)
|
||||
LEDMask |= LEDS_LED4;
|
||||
|
||||
/* Alter status LEDs according to mouse button position */
|
||||
if (MouseReport.Button)
|
||||
LEDMask = LEDS_ALL_LEDS;
|
||||
|
||||
LEDs_SetAllLEDs(LEDMask);
|
||||
|
||||
/* Print mouse report data through the serial port */
|
||||
printf_P(PSTR("dX:%2d dY:%2d Button:%d\r\n"), MouseReport.X,
|
||||
MouseReport.Y,
|
||||
MouseReport.Button);
|
||||
}
|
||||
|
||||
/* Clear the IN endpoint, ready for next data packet */
|
||||
Pipe_ClearIN();
|
||||
|
||||
#if !defined(INTERRUPT_DATA_PIPE)
|
||||
/* Refreeze mouse data pipe */
|
||||
|
|
|
@ -45,7 +45,6 @@
|
|||
#include <stdio.h>
|
||||
|
||||
#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/USB/USB.h> // USB Functionality
|
||||
#include <LUFA/Drivers/AT90USBXXX/Serial_Stream.h> // Serial stream driver
|
||||
|
|
|
@ -38,7 +38,6 @@
|
|||
|
||||
/* Includes: */
|
||||
#include <LUFA/Drivers/USB/USB.h> // USB Functionality
|
||||
#include <LUFA/Drivers/USB/Class/ConfigDescriptor.h> // Configuration Descriptor Parser
|
||||
|
||||
#include "HIDReport.h"
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
#define _HID_REPORT_H_
|
||||
|
||||
/* 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"
|
||||
|
||||
|
|
|
@ -36,12 +36,6 @@
|
|||
|
||||
#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 */
|
||||
TASK_LIST
|
||||
{
|
||||
|
@ -271,79 +265,24 @@ TASK(USB_Mouse_Host)
|
|||
Pipe_SelectPipe(MOUSE_DATAPIPE);
|
||||
Pipe_Unfreeze();
|
||||
|
||||
/* Check if data has been received from the attached mouse */
|
||||
if (Pipe_ReadWriteAllowed())
|
||||
/* Check to see if a packet has been received */
|
||||
if (Pipe_IsINReceived())
|
||||
{
|
||||
uint8_t LEDMask = LEDS_NO_LEDS;
|
||||
|
||||
/* Create buffer big enough for the report */
|
||||
uint8_t MouseReport[Pipe_BytesInPipe()];
|
||||
|
||||
/* Load in the mouse report */
|
||||
Pipe_Read_Stream_LE(MouseReport, Pipe_BytesInPipe());
|
||||
|
||||
/* Clear the IN endpoint, ready for next data packet */
|
||||
Pipe_ClearCurrentBank();
|
||||
|
||||
/* Check each HID report item in turn, looking for mouse X/Y/button reports */
|
||||
for (uint8_t ReportNumber = 0; ReportNumber < HIDReportInfo.TotalReportItems; ReportNumber++)
|
||||
/* Check if data has been received from the attached mouse */
|
||||
if (Pipe_IsReadWriteAllowed())
|
||||
{
|
||||
/* Create a temporary item pointer to the next report item */
|
||||
HID_ReportItem_t* ReportItem = &HIDReportInfo.ReportItems[ReportNumber];
|
||||
|
||||
bool FoundData;
|
||||
/* Create buffer big enough for the report */
|
||||
uint8_t MouseReport[Pipe_BytesInPipe()];
|
||||
|
||||
if ((ReportItem->Attributes.Usage.Page == USAGE_PAGE_BUTTON) &&
|
||||
(ReportItem->ItemType == REPORT_ITEM_TYPE_In))
|
||||
{
|
||||
/* Get the mouse button value */
|
||||
FoundData = GetReportItemInfo(MouseReport, ReportItem);
|
||||
|
||||
/* For multi-report devices - if the requested data was not in the issued report, continue */
|
||||
if (!(FoundData))
|
||||
continue;
|
||||
|
||||
/* If button is pressed, all LEDs are turned on */
|
||||
if (ReportItem->Value)
|
||||
LEDMask = LEDS_ALL_LEDS;
|
||||
}
|
||||
else if ((ReportItem->Attributes.Usage.Page == USAGE_PAGE_GENERIC_DCTRL) &&
|
||||
((ReportItem->Attributes.Usage.Usage == USAGE_X) ||
|
||||
(ReportItem->Attributes.Usage.Usage == USAGE_Y)) &&
|
||||
(ReportItem->ItemType == REPORT_ITEM_TYPE_In))
|
||||
{
|
||||
/* Get the mouse relative position value */
|
||||
FoundData = GetReportItemInfo(MouseReport, ReportItem);
|
||||
|
||||
/* For multi-report devices - if the requested data was not in the issued report, continue */
|
||||
if (!(FoundData))
|
||||
continue;
|
||||
|
||||
int16_t DeltaMovement;
|
||||
|
||||
if (ReportItem->Attributes.BitSize > 8)
|
||||
DeltaMovement = (int16_t)ReportItem->Value;
|
||||
else
|
||||
DeltaMovement = (int8_t)ReportItem->Value;
|
||||
|
||||
/* Determine if the report is for the X or Y delta movement */
|
||||
if (ReportItem->Attributes.Usage.Usage == USAGE_X)
|
||||
{
|
||||
/* Turn on the appropriate LED according to direction if the delta is non-zero */
|
||||
if (DeltaMovement)
|
||||
LEDMask |= ((DeltaMovement > 0) ? LEDS_LED1 : LEDS_LED2);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Turn on the appropriate LED according to direction if the delta is non-zero */
|
||||
if (DeltaMovement)
|
||||
LEDMask |= ((DeltaMovement > 0) ? LEDS_LED3 : LEDS_LED4);
|
||||
}
|
||||
}
|
||||
/* Load in the mouse report */
|
||||
Pipe_Read_Stream_LE(MouseReport, Pipe_BytesInPipe());
|
||||
|
||||
/* Process the read in mouse report from the device */
|
||||
ProcessMouseReport(MouseReport);
|
||||
}
|
||||
|
||||
/* Display the button information on the board LEDs */
|
||||
LEDs_SetAllLEDs(LEDMask);
|
||||
/* Clear the IN endpoint, ready for next data packet */
|
||||
Pipe_ClearIN();
|
||||
}
|
||||
|
||||
/* Freeze mouse data pipe */
|
||||
|
@ -352,3 +291,72 @@ TASK(USB_Mouse_Host)
|
|||
}
|
||||
}
|
||||
|
||||
/** 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 */
|
||||
for (uint8_t ReportNumber = 0; ReportNumber < HIDReportInfo.TotalReportItems; ReportNumber++)
|
||||
{
|
||||
/* Create a temporary item pointer to the next report item */
|
||||
HID_ReportItem_t* ReportItem = &HIDReportInfo.ReportItems[ReportNumber];
|
||||
|
||||
bool FoundData;
|
||||
|
||||
if ((ReportItem->Attributes.Usage.Page == USAGE_PAGE_BUTTON) &&
|
||||
(ReportItem->ItemType == REPORT_ITEM_TYPE_In))
|
||||
{
|
||||
/* Get the mouse button value */
|
||||
FoundData = GetReportItemInfo(MouseReport, ReportItem);
|
||||
|
||||
/* For multi-report devices - if the requested data was not in the issued report, continue */
|
||||
if (!(FoundData))
|
||||
continue;
|
||||
|
||||
/* If button is pressed, all LEDs are turned on */
|
||||
if (ReportItem->Value)
|
||||
LEDMask = LEDS_ALL_LEDS;
|
||||
}
|
||||
else if ((ReportItem->Attributes.Usage.Page == USAGE_PAGE_GENERIC_DCTRL) &&
|
||||
((ReportItem->Attributes.Usage.Usage == USAGE_X) ||
|
||||
(ReportItem->Attributes.Usage.Usage == USAGE_Y)) &&
|
||||
(ReportItem->ItemType == REPORT_ITEM_TYPE_In))
|
||||
{
|
||||
/* Get the mouse relative position value */
|
||||
FoundData = GetReportItemInfo(MouseReport, ReportItem);
|
||||
|
||||
/* For multi-report devices - if the requested data was not in the issued report, continue */
|
||||
if (!(FoundData))
|
||||
continue;
|
||||
|
||||
int16_t DeltaMovement;
|
||||
|
||||
if (ReportItem->Attributes.BitSize > 8)
|
||||
DeltaMovement = (int16_t)ReportItem->Value;
|
||||
else
|
||||
DeltaMovement = (int8_t)ReportItem->Value;
|
||||
|
||||
/* Determine if the report is for the X or Y delta movement */
|
||||
if (ReportItem->Attributes.Usage.Usage == USAGE_X)
|
||||
{
|
||||
/* Turn on the appropriate LED according to direction if the delta is non-zero */
|
||||
if (DeltaMovement)
|
||||
LEDMask |= ((DeltaMovement > 0) ? LEDS_LED1 : LEDS_LED2);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Turn on the appropriate LED according to direction if the delta is non-zero */
|
||||
if (DeltaMovement)
|
||||
LEDMask |= ((DeltaMovement > 0) ? LEDS_LED3 : LEDS_LED4);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Display the button information on the board LEDs */
|
||||
LEDs_SetAllLEDs(LEDMask);
|
||||
}
|
|
@ -39,7 +39,6 @@
|
|||
#include <stdio.h>
|
||||
|
||||
#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/USB/USB.h> // USB Functionality
|
||||
#include <LUFA/Drivers/AT90USBXXX/Serial_Stream.h> // Serial stream driver
|
||||
|
@ -77,5 +76,6 @@
|
|||
|
||||
/* Function Prototypes: */
|
||||
void UpdateStatus(uint8_t CurrentStatus);
|
||||
|
||||
void ProcessMouseReport(uint8_t* MouseReport);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -38,7 +38,6 @@
|
|||
|
||||
/* Includes: */
|
||||
#include <LUFA/Drivers/USB/USB.h> // USB Functionality
|
||||
#include <LUFA/Drivers/USB/Class/ConfigDescriptor.h> // Configuration Descriptor Parser
|
||||
|
||||
#include "StillImageHost.h"
|
||||
|
||||
|
|
|
@ -72,7 +72,7 @@ void SImage_SendBlockHeader(void)
|
|||
}
|
||||
|
||||
/* Send the PIMA command block to the attached device */
|
||||
Pipe_ClearCurrentBank();
|
||||
Pipe_ClearOUT();
|
||||
}
|
||||
|
||||
/* Freeze pipe after use */
|
||||
|
@ -90,7 +90,7 @@ void SImage_RecieveEventHeader(void)
|
|||
Pipe_Read_Stream_LE(&PIMA_EventBlock, sizeof(PIMA_EventBlock));
|
||||
|
||||
/* Clear the pipe after read complete to prepare for next event */
|
||||
Pipe_ClearCurrentBank();
|
||||
Pipe_ClearIN();
|
||||
|
||||
/* Freeze the event pipe again after use */
|
||||
Pipe_Freeze();
|
||||
|
@ -106,7 +106,7 @@ uint8_t SImage_RecieveBlockHeader(void)
|
|||
Pipe_Unfreeze();
|
||||
|
||||
/* 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) */
|
||||
if (USB_INT_HasOccurred(USB_INT_HSOFI))
|
||||
|
@ -179,7 +179,7 @@ uint8_t SImage_RecieveBlockHeader(void)
|
|||
}
|
||||
|
||||
/* Clear pipe bank after use */
|
||||
Pipe_ClearCurrentBank();
|
||||
Pipe_ClearIN();
|
||||
}
|
||||
|
||||
/* Freeze the IN pipe after use */
|
||||
|
@ -203,7 +203,7 @@ void SImage_SendData(void* Buffer, uint16_t Bytes)
|
|||
Pipe_Write_Stream_LE(Buffer, Bytes);
|
||||
|
||||
/* Send the last packet to the attached device */
|
||||
Pipe_ClearCurrentBank();
|
||||
Pipe_ClearOUT();
|
||||
|
||||
/* Freeze the pipe again after use */
|
||||
Pipe_Freeze();
|
||||
|
|
|
@ -36,11 +36,6 @@
|
|||
|
||||
#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 */
|
||||
TASK_LIST
|
||||
{
|
||||
|
@ -243,7 +238,7 @@ TASK(USB_SImage_Host)
|
|||
SImage_ReadData(DeviceInfo, DeviceInfoSize);
|
||||
|
||||
/* 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 */
|
||||
uint8_t* DeviceInfoPos = DeviceInfo;
|
||||
|
|
|
@ -46,7 +46,6 @@
|
|||
#include "PIMACodes.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/USB/USB.h> // USB Functionality
|
||||
#include <LUFA/Drivers/AT90USBXXX/Serial_Stream.h> // Serial stream driver
|
||||
|
|
|
@ -36,12 +36,6 @@
|
|||
|
||||
#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 */
|
||||
TASK_LIST
|
||||
{
|
||||
|
|
|
@ -46,7 +46,6 @@
|
|||
#include <LUFA/Drivers/USB/USB.h> // USB Functionality
|
||||
#include <LUFA/Scheduler/Scheduler.h> // Simple scheduler for task management
|
||||
#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/AT90USBXXX/ADC.h> // ADC 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
|
||||
* 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
|
||||
* - 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
|
||||
*
|
||||
|
|
|
@ -36,6 +36,15 @@
|
|||
* \note Do not include this file directly, rather include the Common.h header file instead to gain this file's
|
||||
* 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__
|
||||
#define __BOARDTYPES_H__
|
||||
|
@ -70,3 +79,5 @@
|
|||
#define BOARD_USER 5
|
||||
|
||||
#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
|
|
@ -33,6 +33,24 @@
|
|||
* This file contains macros which are common to all library elements, and which may be useful in user code. It
|
||||
* 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__
|
||||
#define __COMMON_H__
|
||||
|
@ -66,14 +84,22 @@
|
|||
/** 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
|
||||
* removes/reorders code to the point where break points cannot reliably be set.
|
||||
*
|
||||
* \ingroup Group_Debugging
|
||||
*/
|
||||
#define JTAG_DEBUG_POINT() asm volatile ("NOP" ::)
|
||||
|
||||
/** 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" ::)
|
||||
|
||||
/** 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
|
||||
|
||||
/** 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
|
||||
* {x} failed."
|
||||
*
|
||||
* \ingroup Group_Debugging
|
||||
*/
|
||||
#define SERIAL_STREAM_ASSERT(x) MACROS{ if (!(x)) { printf_P(PSTR("%s: Function \"%s\", Line %d: " \
|
||||
"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,
|
||||
* etc.
|
||||
*
|
||||
* \ingroup Group_BitManip
|
||||
*
|
||||
* \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;
|
||||
|
@ -104,6 +134,8 @@
|
|||
}
|
||||
|
||||
/** 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
|
||||
*/
|
||||
|
@ -114,6 +146,8 @@
|
|||
}
|
||||
|
||||
/** 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
|
||||
*/
|
||||
|
@ -127,6 +161,8 @@
|
|||
}
|
||||
|
||||
/** 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 Bytes Length of the data in bytes
|
||||
|
@ -148,3 +184,5 @@
|
|||
}
|
||||
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
|
|
|
@ -37,6 +37,14 @@
|
|||
* \note Do not include this file directly, rather include the Common.h header file instead to gain this file's
|
||||
* 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__
|
||||
#define __FUNCATTR_H__
|
||||
|
@ -108,3 +116,5 @@
|
|||
#define ATTR_ALIAS(x) __attribute__ ((alias( #x )))
|
||||
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
|
|
|
@ -408,7 +408,7 @@ SORT_BRIEF_DOCS = NO
|
|||
# hierarchy of group names into alphabetical order. If set to NO (the default)
|
||||
# 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
|
||||
# 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
|
||||
# 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
|
||||
# (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
|
||||
# is shown.
|
||||
|
||||
TREEVIEW_WIDTH = 250
|
||||
TREEVIEW_WIDTH = 300
|
||||
|
||||
# Use this tag to change the font size of Latex formulas included
|
||||
# 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.
|
||||
# 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
|
||||
# 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
|
||||
# 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
|
||||
# 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
|
||||
# other documented files.
|
||||
|
||||
INCLUDE_GRAPH = NO
|
||||
INCLUDE_GRAPH = YES
|
||||
|
||||
# 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
|
||||
# documented header file showing the documented files that directly or
|
||||
# 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
|
||||
# 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
|
||||
# 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
|
||||
# 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
|
||||
# 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
|
||||
# generated by dot. Possible values are png, jpg, or gif
|
||||
|
|
|
@ -35,6 +35,10 @@
|
|||
* User code should include this file, which will in turn include the correct ADC driver header file for the
|
||||
* currently selected AVR model.
|
||||
*/
|
||||
|
||||
/** \ingroup Group_SubsystemDrivers
|
||||
* @defgroup Group_ADC ADC Driver - LUFA/Drivers/AT90USBXXX/ADC.h
|
||||
*/
|
||||
|
||||
#ifndef __ADC_H__
|
||||
#define __ADC_H__
|
||||
|
@ -55,4 +59,29 @@
|
|||
#error "ADC is not available for the currently selected AVR model."
|
||||
#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
|
||||
|
|
|
@ -36,15 +36,21 @@
|
|||
* dispatch header located in LUFA/Drivers/AT90USBXXX/ADC.h.
|
||||
*/
|
||||
|
||||
/** \ingroup Group_ADC
|
||||
* @defgroup Group_ADC_AT90USBXXX67 AT90USBXXX6 and AT90USBXXX7 Models
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifndef __ADC_AT90USBXXX67_H__
|
||||
#define __ADC_AT90USBXXX67_H__
|
||||
|
||||
/* Includes: */
|
||||
#include "../../../Common/Common.h"
|
||||
|
||||
#include <avr/io.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "../../../Common/Common.h"
|
||||
|
||||
/* Enable C linkage for C++ Compilers: */
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
|
@ -175,3 +181,5 @@
|
|||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
|
|
|
@ -33,6 +33,14 @@
|
|||
* 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__
|
||||
#define __SPI_H__
|
||||
|
||||
|
@ -137,3 +145,5 @@
|
|||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
|
|
|
@ -33,6 +33,14 @@
|
|||
* 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__
|
||||
#define __SERIAL_H__
|
||||
|
||||
|
@ -113,3 +121,5 @@
|
|||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
|
|
|
@ -35,6 +35,15 @@
|
|||
* 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__
|
||||
#define __SERIAL_STREAM_H__
|
||||
|
||||
|
@ -80,3 +89,5 @@
|
|||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
|
|
|
@ -35,6 +35,12 @@
|
|||
* \note This file should not be included directly. It is automatically included as needed by the HWB driver
|
||||
* dispatch header located in LUFA/Drivers/Board/HWB.h.
|
||||
*/
|
||||
|
||||
/** \ingroup Group_HWB
|
||||
* @defgroup Group_HWB_ATAVRUSBRF01 ATAVRUSBRF01
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifndef __HWB_ATAVRUSBRF01_H__
|
||||
#define __HWB_ATAVRUSBRF01_H__
|
||||
|
@ -77,3 +83,5 @@
|
|||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
|
|
|
@ -36,6 +36,12 @@
|
|||
* dispatch header located in LUFA/Drivers/Board/LEDs.h.
|
||||
*/
|
||||
|
||||
/** \ingroup Group_LEDs
|
||||
* @defgroup Group_LEDs_ATAVRUSBRF01 ATAVRUSBRF01
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifndef __LEDS_ATAVRUSBRF01_H__
|
||||
#define __LEDS_ATAVRUSBRF01_H__
|
||||
|
||||
|
@ -118,3 +124,5 @@
|
|||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
|
|
|
@ -40,6 +40,14 @@
|
|||
* 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__
|
||||
#define __DATAFLASH_H__
|
||||
|
||||
|
@ -59,21 +67,33 @@
|
|||
#endif
|
||||
|
||||
/* Public Interface - May be used in end-application: */
|
||||
/* Macros: */
|
||||
/** Returns the mask of the currently selected Dataflash chip, either DATAFLASH_NO_CHIP or a
|
||||
* DATAFLASH_CHIPn mask (where n is the chip number).
|
||||
*/
|
||||
#define Dataflash_GetSelectedChip() (DATAFLASH_CHIPCS_PORT & DATAFLASH_CHIPCS_MASK)
|
||||
/* Psuedo-Function Macros: */
|
||||
#if defined(__DOXYGEN__)
|
||||
/** 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).
|
||||
*/
|
||||
static inline uint8_t Dataflash_GetSelectedChip(void);
|
||||
|
||||
/** Selects the dataflash chip given as a chip mask, in the form of DATAFLASH_CHIPn (where n
|
||||
* is the chip number).
|
||||
*/
|
||||
#define Dataflash_SelectChip(mask) MACROS{ DATAFLASH_CHIPCS_PORT = ((DATAFLASH_CHIPCS_PORT \
|
||||
& ~DATAFLASH_CHIPCS_MASK) | mask); }MACROE
|
||||
/** Selects the given dataflash chip.
|
||||
*
|
||||
* \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 \
|
||||
& ~DATAFLASH_CHIPCS_MASK) | mask); }MACROE
|
||||
|
||||
#define Dataflash_DeselectChip() Dataflash_SelectChip(DATAFLASH_NO_CHIP)
|
||||
#endif
|
||||
|
||||
/** Deselects the current dataflash chip, so that no dataflash is selected. */
|
||||
#define Dataflash_DeselectChip() Dataflash_SelectChip(DATAFLASH_NO_CHIP)
|
||||
|
||||
/* Inline Functions: */
|
||||
/** Sends a byte to the currently selected dataflash IC, and returns a byte from the dataflash.
|
||||
*
|
||||
|
@ -182,3 +202,5 @@
|
|||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
|
|
|
@ -39,7 +39,15 @@
|
|||
* If the BOARD value is set to BOARD_USER, this will include the /Board/HWB.h file in the user project
|
||||
* 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__
|
||||
#define __HWB_H__
|
||||
|
||||
|
@ -85,3 +93,5 @@
|
|||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
|
|
|
@ -40,6 +40,14 @@
|
|||
* 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__
|
||||
#define __JOYSTICK_H__
|
||||
|
||||
|
@ -83,3 +91,5 @@
|
|||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
|
|
|
@ -39,7 +39,15 @@
|
|||
* If the BOARD value is set to BOARD_USER, this will include the /Board/LEDs.h file in the user project
|
||||
* 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__
|
||||
#define __LEDS_H__
|
||||
|
||||
|
@ -111,3 +119,5 @@
|
|||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
|
|
|
@ -35,6 +35,12 @@
|
|||
* \note This file should not be included directly. It is automatically included as needed by the LEDs driver
|
||||
* dispatch header located in LUFA/Drivers/Board/LEDs.h.
|
||||
*/
|
||||
|
||||
/** \ingroup Group_LEDs
|
||||
* @defgroup Group_LEDs_RZUSBSTICK RZUSBSTICK
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifndef __LEDS_RZUSBSTICK_H__
|
||||
#define __LEDS_RZUSBSTICK_H__
|
||||
|
@ -139,3 +145,5 @@
|
|||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
|
|
|
@ -36,6 +36,12 @@
|
|||
* dispatch header located in LUFA/Drivers/Board/Dataflash.h.
|
||||
*/
|
||||
|
||||
/** \ingroup Group_Dataflash_STK525
|
||||
* @defgroup Group_Dataflash_STK525_AT45DB321C AT45DB321C
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifndef __DATAFLASH_CMDS_H__
|
||||
#define __DATAFLASH_CMDS_H__
|
||||
|
||||
|
@ -82,3 +88,5 @@
|
|||
#define DF_CMD_READMANUFACTURERDEVICEINFO 0x9F
|
||||
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
|
|
|
@ -36,6 +36,12 @@
|
|||
* dispatch header located in LUFA/Drivers/Board/Dataflash.h.
|
||||
*/
|
||||
|
||||
/** \ingroup Group_Dataflash
|
||||
* @defgroup Group_Dataflash_STK525 STK525
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifndef __DATAFLASH_STK525_H__
|
||||
#define __DATAFLASH_STK525_H__
|
||||
|
||||
|
@ -106,3 +112,5 @@
|
|||
}
|
||||
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
|
|
|
@ -35,7 +35,13 @@
|
|||
* \note This file should not be included directly. It is automatically included as needed by the HWB driver
|
||||
* dispatch header located in LUFA/Drivers/Board/HWB.h.
|
||||
*/
|
||||
|
||||
|
||||
/** \ingroup Group_HWB
|
||||
* @defgroup Group_HWB_STK525 STK525
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifndef __HWB_STK525_H__
|
||||
#define __HWB_STK525_H__
|
||||
|
||||
|
@ -77,3 +83,5 @@
|
|||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
|
|
|
@ -36,6 +36,12 @@
|
|||
* dispatch header located in LUFA/Drivers/Board/Joystick.h.
|
||||
*/
|
||||
|
||||
/** \ingroup Group_Joystick
|
||||
* @defgroup Group_Joystick_STK525 STK525
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifndef __JOYSTICK_STK525_H__
|
||||
#define __JOYSTICK_STK525_H__
|
||||
|
||||
|
@ -102,3 +108,5 @@
|
|||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
|
|
|
@ -35,6 +35,12 @@
|
|||
* \note This file should not be included directly. It is automatically included as needed by the LEDs driver
|
||||
* dispatch header located in LUFA/Drivers/Board/LEDs.h.
|
||||
*/
|
||||
|
||||
/** \ingroup Group_LEDs
|
||||
* @defgroup Group_LEDs_STK525 STK525
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifndef __LEDS_STK525_H__
|
||||
#define __LEDS_STK525_H__
|
||||
|
@ -115,3 +121,5 @@
|
|||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
|
|
|
@ -36,6 +36,12 @@
|
|||
* dispatch header located in LUFA/Drivers/Board/Dataflash.h.
|
||||
*/
|
||||
|
||||
/** \ingroup Group_Dataflash_STK526
|
||||
* @defgroup Group_Dataflash_STK526_AT45DB642D AT45DB642D
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifndef __DATAFLASH_CMDS_H__
|
||||
#define __DATAFLASH_CMDS_H__
|
||||
|
||||
|
@ -92,3 +98,5 @@
|
|||
#define DF_CMD_READMANUFACTURERDEVICEINFO 0x9F
|
||||
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
|
|
|
@ -36,6 +36,12 @@
|
|||
* dispatch header located in LUFA/Drivers/Board/Dataflash.h.
|
||||
*/
|
||||
|
||||
/** \ingroup Group_Dataflash
|
||||
* @defgroup Group_Dataflash_STK526 STK526
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifndef __DATAFLASH_STK526_H__
|
||||
#define __DATAFLASH_STK526_H__
|
||||
|
||||
|
@ -106,3 +112,5 @@
|
|||
}
|
||||
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
|
|
|
@ -35,7 +35,13 @@
|
|||
* \note This file should not be included directly. It is automatically included as needed by the HWB driver
|
||||
* dispatch header located in LUFA/Drivers/Board/HWB.h.
|
||||
*/
|
||||
|
||||
|
||||
/** \ingroup Group_HWB
|
||||
* @defgroup Group_HWB_STK526 STK526
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifndef __HWB_STK526_H__
|
||||
#define __HWB_STK526_H__
|
||||
|
||||
|
@ -77,3 +83,5 @@
|
|||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
|
|
|
@ -35,6 +35,12 @@
|
|||
* \note This file should not be included directly. It is automatically included as needed by the joystick driver
|
||||
* dispatch header located in LUFA/Drivers/Board/Joystick.h.
|
||||
*/
|
||||
|
||||
/** \ingroup Group_Joystick
|
||||
* @defgroup Group_Joystick_STK526 STK526
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifndef __JOYSTICK_STK526_H__
|
||||
#define __JOYSTICK_STK526_H__
|
||||
|
@ -99,3 +105,5 @@
|
|||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
|
|
|
@ -35,6 +35,12 @@
|
|||
* \note This file should not be included directly. It is automatically included as needed by the LEDs driver
|
||||
* dispatch header located in LUFA/Drivers/Board/LEDs.h.
|
||||
*/
|
||||
|
||||
/** \ingroup Group_LEDs
|
||||
* @defgroup Group_LEDs_STK526 STK526
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifndef __LEDS_STK526_H__
|
||||
#define __LEDS_STK526_H__
|
||||
|
@ -115,3 +121,5 @@
|
|||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
|
|
|
@ -33,6 +33,14 @@
|
|||
* 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__
|
||||
#define __TEMPERATURE_H__
|
||||
|
||||
|
@ -68,14 +76,19 @@
|
|||
|
||||
/** Maximum returnable temperature from the Temperature_GetTemperature() function. */
|
||||
#define TEMP_MAX_TEMP ((TEMP_TABLE_SIZE - 1) + TEMP_TABLE_OFFSET)
|
||||
|
||||
/** Initializes the temperature sensor driver, including setting up the appropriate ADC channel.
|
||||
* 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
|
||||
* sensor functions.
|
||||
*/
|
||||
#define Temperature_Init() ADC_SetupChannel(TEMP_ADC_CHANNEL);
|
||||
|
||||
/* Psuedo-Functions: */
|
||||
#if defined(__DOXYGEN__)
|
||||
/** Initializes the temperature sensor driver, including setting up the appropriate ADC channel.
|
||||
* 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
|
||||
* sensor functions.
|
||||
*/
|
||||
static inline void Temperature_Init(void);
|
||||
#else
|
||||
#define Temperature_Init() ADC_SetupChannel(TEMP_ADC_CHANNEL);
|
||||
#endif
|
||||
|
||||
/* Function Prototypes: */
|
||||
/** Performs a complete ADC on the temperature sensor channel, and converts the result into a
|
||||
|
@ -98,3 +111,5 @@
|
|||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
|
|
|
@ -36,6 +36,12 @@
|
|||
* dispatch header located in LUFA/Drivers/Board/Dataflash.h.
|
||||
*/
|
||||
|
||||
/** \ingroup Group_Dataflash_USBKEY
|
||||
* @defgroup Group_Dataflash_USBKEY_AT45DB642D AT45DB642D
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifndef __DATAFLASH_CMDS_H__
|
||||
#define __DATAFLASH_CMDS_H__
|
||||
|
||||
|
@ -92,3 +98,5 @@
|
|||
#define DF_CMD_READMANUFACTURERDEVICEINFO 0x9F
|
||||
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
|
|
|
@ -36,6 +36,12 @@
|
|||
* dispatch header located in LUFA/Drivers/Board/Dataflash.h.
|
||||
*/
|
||||
|
||||
/** \ingroup Group_Dataflash
|
||||
* @defgroup Group_Dataflash_USBKEY USBKEY
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifndef __DATAFLASH_USBKEY_H__
|
||||
#define __DATAFLASH_USBKEY_H__
|
||||
|
||||
|
@ -114,3 +120,5 @@
|
|||
}
|
||||
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
|
|
|
@ -35,7 +35,13 @@
|
|||
* \note This file should not be included directly. It is automatically included as needed by the HWB driver
|
||||
* dispatch header located in LUFA/Drivers/Board/HWB.h.
|
||||
*/
|
||||
|
||||
|
||||
/** \ingroup Group_HWB
|
||||
* @defgroup Group_HWB_USBKEY USBKEY
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifndef __HWB_USBKEY_H__
|
||||
#define __HWB_USBKEY_H__
|
||||
|
||||
|
@ -77,3 +83,5 @@
|
|||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
|
|
|
@ -35,7 +35,13 @@
|
|||
* \note This file should not be included directly. It is automatically included as needed by the joystick driver
|
||||
* dispatch header located in LUFA/Drivers/Board/Joystick.h.
|
||||
*/
|
||||
|
||||
|
||||
/** \ingroup Group_Joystick
|
||||
* @defgroup Group_Joystick_USBKEY USBKEY
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifndef __JOYSTICK_USBKEY_H__
|
||||
#define __JOYSTICK_USBKEY_H__
|
||||
|
||||
|
@ -102,3 +108,5 @@
|
|||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
|
|
|
@ -36,6 +36,12 @@
|
|||
* dispatch header located in LUFA/Drivers/Board/LEDs.h.
|
||||
*/
|
||||
|
||||
/** \ingroup Group_LEDs
|
||||
* @defgroup Group_LEDs_USBKEY USBKEY
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifndef __LEDS_USBKEY_H__
|
||||
#define __LEDS_USBKEY_H__
|
||||
|
||||
|
@ -115,3 +121,5 @@
|
|||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
|
|
|
@ -43,6 +43,14 @@
|
|||
* \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__
|
||||
#define __TERMINALCODES_H__
|
||||
|
||||
|
@ -174,3 +182,5 @@
|
|||
#define ESC_ERASE_LINE ANSI_ESCAPE_SEQUENCE("K")
|
||||
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
|
|
|
@ -35,6 +35,14 @@
|
|||
* 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__
|
||||
#define __CONFIGDESCRIPTOR_H__
|
||||
|
||||
|
@ -109,7 +117,7 @@
|
|||
* for certain descriptors matching unique criteria.
|
||||
*
|
||||
* 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)
|
||||
|
||||
|
@ -124,7 +132,7 @@
|
|||
* \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
|
||||
*
|
||||
* \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:
|
||||
* \code
|
||||
|
@ -151,7 +159,7 @@
|
|||
USB_Host_GetNextDescriptorComp_P(DSize, DPos, DCOMP_##DSearch)
|
||||
/* Enums: */
|
||||
/** 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_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 DSEARCH_Comp_Return_ErrorCodes_t
|
||||
enum DSearch_Comp_Return_ErrorCodes_t
|
||||
{
|
||||
Descriptor_Search_Comp_Found = 0, /**< Configuration descriptor now points to descriptor which matches
|
||||
* search criteria of the given comparator function. */
|
||||
|
@ -259,5 +267,7 @@
|
|||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
|
|
|
@ -44,6 +44,14 @@
|
|||
* HID_INCLUDE_CONSTANT_DATA_ITEMS tokens in the user project makefile, passing them to the compiler via the -D
|
||||
* 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__
|
||||
#define __HIDPARSER_H__
|
||||
|
@ -250,3 +258,5 @@
|
|||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
|
|
|
@ -34,6 +34,14 @@
|
|||
* 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__
|
||||
#define __HIDREPORTDATA_H__
|
||||
|
||||
|
@ -126,5 +134,7 @@
|
|||
#define TAG_LOCAL_USAGEMIN 0x10
|
||||
#define TAG_LOCAL_USAGEMAX 0x20
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
|
||||
#endif
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue