projects
/
pub
/
lufa.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Spell checked non-source documentation pages.
[pub/lufa.git]
/
Demos
/
Device
/
Keyboard
/
Keyboard.c
diff --git
a/Demos/Device/Keyboard/Keyboard.c
b/Demos/Device/Keyboard/Keyboard.c
index
d6b254f
..
8c4157a
100644
(file)
--- a/
Demos/Device/Keyboard/Keyboard.c
+++ b/
Demos/Device/Keyboard/Keyboard.c
@@
-31,18
+31,12
@@
\r
/** \file
\r
*
\r
\r
/** \file
\r
*
\r
- * Main source file for the Keyboard
FullInt
demo. This file contains the main tasks of the demo and
\r
+ * Main source file for the Keyboard demo. This file contains the main tasks of the demo and
\r
* is responsible for the initial application hardware configuration.
\r
*/
\r
\r
#include "Keyboard.h"
\r
\r
* is responsible for the initial application hardware configuration.
\r
*/
\r
\r
#include "Keyboard.h"
\r
\r
-/* Project Tags, for reading out using the ButtLoad project */
\r
-BUTTLOADTAG(ProjName, "LUFA Keyboard App");
\r
-BUTTLOADTAG(BuildTime, __TIME__);
\r
-BUTTLOADTAG(BuildDate, __DATE__);
\r
-BUTTLOADTAG(LUFAVersion, "LUFA V" LUFA_VERSION_STRING);
\r
-
\r
/* Scheduler Task List */
\r
TASK_LIST
\r
{
\r
/* Scheduler Task List */
\r
TASK_LIST
\r
{
\r
@@
-67,7
+61,7
@@
bool UsingReportProtocol = true;
uint8_t IdleCount = 0;
\r
\r
/** Current Idle period remaining. When the IdleCount value is set, this tracks the remaining number of idle
\r
uint8_t IdleCount = 0;
\r
\r
/** Current Idle period remaining. When the IdleCount value is set, this tracks the remaining number of idle
\r
- * milliseconds. This is sep
e
rate to the IdleCount timer and is incremented and compared as the host may request
\r
+ * milliseconds. This is sep
a
rate to the IdleCount timer and is incremented and compared as the host may request
\r
* the current idle period via a Get Idle HID class request, thus its value must be preserved.
\r
*/
\r
uint16_t IdleMSRemaining = 0;
\r
* the current idle period via a Get Idle HID class request, thus its value must be preserved.
\r
*/
\r
uint16_t IdleMSRemaining = 0;
\r
@@
-222,53
+216,53
@@
EVENT_HANDLER(USB_UnhandledControlPacket)
if (wLength > sizeof(KeyboardReportData))
\r
wLength = sizeof(KeyboardReportData);
\r
\r
if (wLength > sizeof(KeyboardReportData))
\r
wLength = sizeof(KeyboardReportData);
\r
\r
- Endpoint_Clear
SetupReceived
();
\r
+ Endpoint_Clear
ControlSETUP
();
\r
\r
/* Write the report data to the control endpoint */
\r
Endpoint_Write_Control_Stream_LE(&KeyboardReportData, wLength);
\r
\r
/* Finalize the stream transfer to send the last packet or clear the host abort */
\r
\r
/* Write the report data to the control endpoint */
\r
Endpoint_Write_Control_Stream_LE(&KeyboardReportData, wLength);
\r
\r
/* Finalize the stream transfer to send the last packet or clear the host abort */
\r
- Endpoint_Clear
Setup
OUT();
\r
+ Endpoint_Clear
Control
OUT();
\r
}
\r
\r
break;
\r
case REQ_SetReport:
\r
if (bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE))
\r
{
\r
}
\r
\r
break;
\r
case REQ_SetReport:
\r
if (bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE))
\r
{
\r
- Endpoint_Clear
SetupReceived
();
\r
+ Endpoint_Clear
ControlSETUP
();
\r
\r
/* Wait until the LED report has been sent by the host */
\r
\r
/* Wait until the LED report has been sent by the host */
\r
- while (!(Endpoint_Is
Setup
OUTReceived()));
\r
+ while (!(Endpoint_IsOUTReceived()));
\r
\r
/* Read in the LED report from the host */
\r
uint8_t LEDStatus = Endpoint_Read_Byte();
\r
\r
\r
/* Read in the LED report from the host */
\r
uint8_t LEDStatus = Endpoint_Read_Byte();
\r
\r
- /* Process the incom
m
ing LED report */
\r
+ /* Process the incoming LED report */
\r
ProcessLEDReport(LEDStatus);
\r
\r
/* Clear the endpoint data */
\r
ProcessLEDReport(LEDStatus);
\r
\r
/* Clear the endpoint data */
\r
- Endpoint_Clear
Setup
OUT();
\r
+ Endpoint_Clear
Control
OUT();
\r
\r
/* Acknowledge status stage */
\r
\r
/* Acknowledge status stage */
\r
- while (!(Endpoint_Is
Setup
INReady()));
\r
- Endpoint_Clear
Setup
IN();
\r
+ while (!(Endpoint_IsINReady()));
\r
+ Endpoint_Clear
Control
IN();
\r
}
\r
\r
break;
\r
case REQ_GetProtocol:
\r
if (bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE))
\r
{
\r
}
\r
\r
break;
\r
case REQ_GetProtocol:
\r
if (bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE))
\r
{
\r
- Endpoint_Clear
SetupReceived
();
\r
+ Endpoint_Clear
ControlSETUP
();
\r
\r
/* Write the current protocol flag to the host */
\r
Endpoint_Write_Byte(UsingReportProtocol);
\r
\r
/* Send the flag to the host */
\r
\r
/* Write the current protocol flag to the host */
\r
Endpoint_Write_Byte(UsingReportProtocol);
\r
\r
/* Send the flag to the host */
\r
- Endpoint_Clear
Setup
IN();
\r
+ Endpoint_Clear
Control
IN();
\r
\r
/* Acknowledge status stage */
\r
\r
/* Acknowledge status stage */
\r
- while (!(Endpoint_Is
Setup
OUTReceived()));
\r
- Endpoint_Clear
Setup
OUT();
\r
+ while (!(Endpoint_IsOUTReceived()));
\r
+ Endpoint_Clear
Control
OUT();
\r
}
\r
\r
break;
\r
}
\r
\r
break;
\r
@@
-278,14
+272,14
@@
EVENT_HANDLER(USB_UnhandledControlPacket)
/* Read in the wValue parameter containing the new protocol mode */
\r
uint16_t wValue = Endpoint_Read_Word_LE();
\r
\r
/* Read in the wValue parameter containing the new protocol mode */
\r
uint16_t wValue = Endpoint_Read_Word_LE();
\r
\r
- Endpoint_Clear
SetupReceived
();
\r
+ Endpoint_Clear
ControlSETUP
();
\r
\r
/* Set or clear the flag depending on what the host indicates that the current Protocol should be */
\r
UsingReportProtocol = (wValue != 0x0000);
\r
\r
/* Acknowledge status stage */
\r
\r
/* Set or clear the flag depending on what the host indicates that the current Protocol should be */
\r
UsingReportProtocol = (wValue != 0x0000);
\r
\r
/* Acknowledge status stage */
\r
- while (!(Endpoint_Is
Setup
INReady()));
\r
- Endpoint_Clear
Setup
IN();
\r
+ while (!(Endpoint_IsINReady()));
\r
+ Endpoint_Clear
Control
IN();
\r
}
\r
\r
break;
\r
}
\r
\r
break;
\r
@@
-295,31
+289,31
@@
EVENT_HANDLER(USB_UnhandledControlPacket)
/* Read in the wValue parameter containing the idle period */
\r
uint16_t wValue = Endpoint_Read_Word_LE();
\r
\r
/* Read in the wValue parameter containing the idle period */
\r
uint16_t wValue = Endpoint_Read_Word_LE();
\r
\r
- Endpoint_Clear
SetupReceived
();
\r
+ Endpoint_Clear
ControlSETUP
();
\r
\r
/* Get idle period in MSB */
\r
IdleCount = (wValue >> 8);
\r
\r
/* Acknowledge status stage */
\r
\r
/* Get idle period in MSB */
\r
IdleCount = (wValue >> 8);
\r
\r
/* Acknowledge status stage */
\r
- while (!(Endpoint_Is
Setup
INReady()));
\r
- Endpoint_Clear
Setup
IN();
\r
+ while (!(Endpoint_IsINReady()));
\r
+ Endpoint_Clear
Control
IN();
\r
}
\r
\r
break;
\r
case REQ_GetIdle:
\r
if (bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE))
\r
{
\r
}
\r
\r
break;
\r
case REQ_GetIdle:
\r
if (bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE))
\r
{
\r
- Endpoint_Clear
SetupReceived
();
\r
+ Endpoint_Clear
ControlSETUP
();
\r
\r
/* Write the current idle duration to the host */
\r
Endpoint_Write_Byte(IdleCount);
\r
\r
/* Send the flag to the host */
\r
\r
/* Write the current idle duration to the host */
\r
Endpoint_Write_Byte(IdleCount);
\r
\r
/* Send the flag to the host */
\r
- Endpoint_Clear
Setup
IN();
\r
+ Endpoint_Clear
Control
IN();
\r
\r
/* Acknowledge status stage */
\r
\r
/* Acknowledge status stage */
\r
- while (!(Endpoint_Is
Setup
OUTReceived()));
\r
- Endpoint_Clear
Setup
OUT();
\r
+ while (!(Endpoint_IsOUTReceived()));
\r
+ Endpoint_Clear
Control
OUT();
\r
}
\r
\r
break;
\r
}
\r
\r
break;
\r
@@
-415,13
+409,13
@@
static inline void SendNextReport(void)
Endpoint_SelectEndpoint(KEYBOARD_EPNUM);
\r
\r
/* Check if Keyboard Endpoint Ready for Read/Write, and if we should send a report */
\r
Endpoint_SelectEndpoint(KEYBOARD_EPNUM);
\r
\r
/* Check if Keyboard Endpoint Ready for Read/Write, and if we should send a report */
\r
- if (Endpoint_ReadWriteAllowed() && SendReport)
\r
+ if (Endpoint_
Is
ReadWriteAllowed() && SendReport)
\r
{
\r
/* Write Keyboard Report Data */
\r
Endpoint_Write_Stream_LE(&KeyboardReportData, sizeof(KeyboardReportData));
\r
\r
/* Finalize the stream transfer to send the last packet */
\r
{
\r
/* Write Keyboard Report Data */
\r
Endpoint_Write_Stream_LE(&KeyboardReportData, sizeof(KeyboardReportData));
\r
\r
/* Finalize the stream transfer to send the last packet */
\r
- Endpoint_Clear
CurrentBank
();
\r
+ Endpoint_Clear
IN
();
\r
}
\r
}
\r
\r
}
\r
}
\r
\r
@@
-431,24
+425,28
@@
static inline void ReceiveNextReport(void)
/* Select the Keyboard LED Report Endpoint */
\r
Endpoint_SelectEndpoint(KEYBOARD_LEDS_EPNUM);
\r
\r
/* Select the Keyboard LED Report Endpoint */
\r
Endpoint_SelectEndpoint(KEYBOARD_LEDS_EPNUM);
\r
\r
- /* Check if Keyboard LED Endpoint Ready for Read/Write */
\r
- if (!(Endpoint_ReadWriteAllowed()))
\r
- return;
\r
-
\r
- /* Read in the LED report from the host */
\r
- uint8_t LEDReport = Endpoint_Read_Byte();
\r
+ /* Check if Keyboard LED Endpoint contains a packet */
\r
+ if (Endpoint_IsOUTReceived())
\r
+ {
\r
+ /* Check to see if the packet contains data */
\r
+ if (Endpoint_IsReadWriteAllowed())
\r
+ {
\r
+ /* Read in the LED report from the host */
\r
+ uint8_t LEDReport = Endpoint_Read_Byte();
\r
\r
\r
- /* Handshake the OUT Endpoint - clear endpoint and ready for next report */
\r
- Endpoint_ClearCurrentBank();
\r
+ /* Process the read LED report from the host */
\r
+ ProcessLEDReport(LEDReport);
\r
+ }
\r
\r
\r
- /* Process the read LED report from the host */
\r
- ProcessLEDReport(LEDReport);
\r
+ /* Handshake the OUT Endpoint - clear endpoint and ready for next report */
\r
+ Endpoint_ClearOUT();
\r
+ }
\r
}
\r
\r
/** Function to manage status updates to the user. This is done via LEDs on the given board, if available, but may be changed to
\r
* log to a serial port, or anything else that is suitable for status updates.
\r
*
\r
}
\r
\r
/** Function to manage status updates to the user. This is done via LEDs on the given board, if available, but may be changed to
\r
* log to a serial port, or anything else that is suitable for status updates.
\r
*
\r
- * \param CurrentStatus Current status of the system, from the Keyboard
FullInt
_StatusCodes_t enum
\r
+ * \param CurrentStatus Current status of the system, from the Keyboard_StatusCodes_t enum
\r
*/
\r
void UpdateStatus(uint8_t CurrentStatus)
\r
{
\r
*/
\r
void UpdateStatus(uint8_t CurrentStatus)
\r
{
\r
@@
-545,4
+543,3
@@
ISR(ENDPOINT_PIPE_vect, ISR_BLOCK)
}
\r
#endif
\r
}
\r
}
\r
#endif
\r
}
\r
-
\r