|
|
@ -264,15 +264,27 @@ static void raw_hid_task(void)
|
|
|
|
* Console
|
|
|
|
* Console
|
|
|
|
******************************************************************************/
|
|
|
|
******************************************************************************/
|
|
|
|
#ifdef CONSOLE_ENABLE
|
|
|
|
#ifdef CONSOLE_ENABLE
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static bool console_flush = false;
|
|
|
|
|
|
|
|
#define CONSOLE_FLUSH_SET(b) do { \
|
|
|
|
|
|
|
|
ATOMIC_BLOCK(ATOMIC_RESTORESTATE) {\
|
|
|
|
|
|
|
|
console_flush = b; \
|
|
|
|
|
|
|
|
} \
|
|
|
|
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
|
|
|
|
static void Console_Task(void)
|
|
|
|
static void Console_Task(void)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
/* Device must be connected and configured for the task to run */
|
|
|
|
/* Device must be connected and configured for the task to run */
|
|
|
|
if (USB_DeviceState != DEVICE_STATE_Configured)
|
|
|
|
if (USB_DeviceState != DEVICE_STATE_Configured)
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Create a temporary buffer to hold the read in report from the host */
|
|
|
|
|
|
|
|
uint8_t ConsoleData[CONSOLE_EPSIZE];
|
|
|
|
|
|
|
|
bool data_read = false;
|
|
|
|
uint8_t ep = Endpoint_GetCurrentEndpoint();
|
|
|
|
uint8_t ep = Endpoint_GetCurrentEndpoint();
|
|
|
|
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
|
|
|
|
// TODO: impl receivechar()/recvchar()
|
|
|
|
// TODO: impl receivechar()/recvchar()
|
|
|
|
Endpoint_SelectEndpoint(CONSOLE_OUT_EPNUM);
|
|
|
|
Endpoint_SelectEndpoint(CONSOLE_OUT_EPNUM);
|
|
|
|
|
|
|
|
|
|
|
@ -282,39 +294,45 @@ static void Console_Task(void)
|
|
|
|
/* Check to see if the packet contains data */
|
|
|
|
/* Check to see if the packet contains data */
|
|
|
|
if (Endpoint_IsReadWriteAllowed())
|
|
|
|
if (Endpoint_IsReadWriteAllowed())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
/* Create a temporary buffer to hold the read in report from the host */
|
|
|
|
|
|
|
|
uint8_t ConsoleData[CONSOLE_EPSIZE];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Read Console Report Data */
|
|
|
|
/* Read Console Report Data */
|
|
|
|
Endpoint_Read_Stream_LE(&ConsoleData, sizeof(ConsoleData), NULL);
|
|
|
|
Endpoint_Read_Stream_LE(&ConsoleData, sizeof(ConsoleData), NULL);
|
|
|
|
|
|
|
|
data_read = true;
|
|
|
|
/* Process Console Report Data */
|
|
|
|
|
|
|
|
//ProcessConsoleHIDReport(ConsoleData);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Finalize the stream transfer to send the last packet */
|
|
|
|
/* Finalize the stream transfer to send the last packet */
|
|
|
|
Endpoint_ClearOUT();
|
|
|
|
Endpoint_ClearOUT();
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* IN packet */
|
|
|
|
if (data_read) {
|
|
|
|
Endpoint_SelectEndpoint(CONSOLE_IN_EPNUM);
|
|
|
|
/* Process Console Report Data */
|
|
|
|
if (!Endpoint_IsEnabled() || !Endpoint_IsConfigured()) {
|
|
|
|
process_console_data_quantum(ConsoleData, sizeof(ConsoleData));
|
|
|
|
Endpoint_SelectEndpoint(ep);
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// fill empty bank
|
|
|
|
if (console_flush) {
|
|
|
|
while (Endpoint_IsReadWriteAllowed())
|
|
|
|
/* IN packet */
|
|
|
|
Endpoint_Write_8(0);
|
|
|
|
Endpoint_SelectEndpoint(CONSOLE_IN_EPNUM);
|
|
|
|
|
|
|
|
if (!Endpoint_IsEnabled() || !Endpoint_IsConfigured()) {
|
|
|
|
|
|
|
|
Endpoint_SelectEndpoint(ep);
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// flash senchar packet
|
|
|
|
// fill empty bank
|
|
|
|
if (Endpoint_IsINReady()) {
|
|
|
|
while (Endpoint_IsReadWriteAllowed())
|
|
|
|
Endpoint_ClearIN();
|
|
|
|
Endpoint_Write_8(0);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// flash senchar packet
|
|
|
|
|
|
|
|
if (Endpoint_IsINReady()) {
|
|
|
|
|
|
|
|
Endpoint_ClearIN();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// CONSOLE_FLUSH_SET(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Endpoint_SelectEndpoint(ep);
|
|
|
|
Endpoint_SelectEndpoint(ep);
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -381,12 +399,6 @@ void EVENT_USB_Device_WakeUp()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef CONSOLE_ENABLE
|
|
|
|
#ifdef CONSOLE_ENABLE
|
|
|
|
static bool console_flush = false;
|
|
|
|
|
|
|
|
#define CONSOLE_FLUSH_SET(b) do { \
|
|
|
|
|
|
|
|
ATOMIC_BLOCK(ATOMIC_RESTORESTATE) {\
|
|
|
|
|
|
|
|
console_flush = b; \
|
|
|
|
|
|
|
|
} \
|
|
|
|
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// called every 1ms
|
|
|
|
// called every 1ms
|
|
|
|
void EVENT_USB_Device_StartOfFrame(void)
|
|
|
|
void EVENT_USB_Device_StartOfFrame(void)
|
|
|
@ -395,9 +407,9 @@ void EVENT_USB_Device_StartOfFrame(void)
|
|
|
|
if (++count % 50) return;
|
|
|
|
if (++count % 50) return;
|
|
|
|
count = 0;
|
|
|
|
count = 0;
|
|
|
|
|
|
|
|
|
|
|
|
if (!console_flush) return;
|
|
|
|
//if (!console_flush) return;
|
|
|
|
Console_Task();
|
|
|
|
Console_Task();
|
|
|
|
console_flush = false;
|
|
|
|
//console_flush = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
@ -440,10 +452,10 @@ void EVENT_USB_Device_ConfigurationChanged(void)
|
|
|
|
/* Setup Console HID Report Endpoints */
|
|
|
|
/* Setup Console HID Report Endpoints */
|
|
|
|
ConfigSuccess &= ENDPOINT_CONFIG(CONSOLE_IN_EPNUM, EP_TYPE_INTERRUPT, ENDPOINT_DIR_IN,
|
|
|
|
ConfigSuccess &= ENDPOINT_CONFIG(CONSOLE_IN_EPNUM, EP_TYPE_INTERRUPT, ENDPOINT_DIR_IN,
|
|
|
|
CONSOLE_EPSIZE, ENDPOINT_BANK_SINGLE);
|
|
|
|
CONSOLE_EPSIZE, ENDPOINT_BANK_SINGLE);
|
|
|
|
#if 0
|
|
|
|
// #if 0
|
|
|
|
ConfigSuccess &= ENDPOINT_CONFIG(CONSOLE_OUT_EPNUM, EP_TYPE_INTERRUPT, ENDPOINT_DIR_OUT,
|
|
|
|
ConfigSuccess &= ENDPOINT_CONFIG(CONSOLE_OUT_EPNUM, EP_TYPE_INTERRUPT, ENDPOINT_DIR_OUT,
|
|
|
|
CONSOLE_EPSIZE, ENDPOINT_BANK_SINGLE);
|
|
|
|
CONSOLE_EPSIZE, ENDPOINT_BANK_SINGLE);
|
|
|
|
#endif
|
|
|
|
// #endif
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef NKRO_ENABLE
|
|
|
|
#ifdef NKRO_ENABLE
|
|
|
|