slow-acting

pjrc_hid
Jack Humbert 7 years ago
parent 7c57104b51
commit 13ff230615

@ -65,7 +65,7 @@ CONSOLE_ENABLE = yes # Console for debug(+400)
COMMAND_ENABLE = no # Commands for debug and configuration
NKRO_ENABLE = yes # Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work
BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality
MIDI_ENABLE = yes # MIDI controls
MIDI_ENABLE = no # MIDI controls
AUDIO_ENABLE = yes # Audio output on port C6
UNICODE_ENABLE = no # Unicode
BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID

@ -1296,3 +1296,35 @@ __attribute__ ((weak))
void shutdown_user() {}
//------------------------------------------------------------------------------
#ifdef CONSOLE_ENABLE
__attribute__ ((weak))
void process_console_data_user(uint8_t * data, uint8_t length) {
}
__attribute__ ((weak))
void process_console_data_kb(uint8_t * data, uint8_t length) {
process_console_data_user(data, length);
}
void process_console_data_quantum(uint8_t * data, uint8_t length) {
// print("Received message:\n ");
// while (*data) {
// sendchar(*data);
// data++;
// }
switch (data[0]) {
case 0xFE:
print("Entering bootloader\n");
reset_keyboard();
break;
case 0x01:
print("Saying hello\n");
audio_on();
break;
}
process_console_data_kb(data, length);
}
#endif

@ -193,4 +193,10 @@ void led_set_kb(uint8_t usb_led);
void api_send_unicode(uint32_t unicode);
#ifdef CONSOLE_ENABLE
void process_console_data_user(uint8_t * data, uint8_t length);
void process_console_data_kb(uint8_t * data, uint8_t length);
void process_console_data_quantum(uint8_t * data, uint8_t length);
#endif
#endif

@ -264,15 +264,27 @@ static void raw_hid_task(void)
* Console
******************************************************************************/
#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)
{
/* Device must be connected and configured for the task to run */
if (USB_DeviceState != DEVICE_STATE_Configured)
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();
#if 0
// TODO: impl receivechar()/recvchar()
Endpoint_SelectEndpoint(CONSOLE_OUT_EPNUM);
@ -282,39 +294,45 @@ static void Console_Task(void)
/* 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 ConsoleData[CONSOLE_EPSIZE];
/* Read Console Report Data */
Endpoint_Read_Stream_LE(&ConsoleData, sizeof(ConsoleData), NULL);
/* Process Console Report Data */
//ProcessConsoleHIDReport(ConsoleData);
data_read = true;
}
/* Finalize the stream transfer to send the last packet */
Endpoint_ClearOUT();
}
#endif
/* IN packet */
Endpoint_SelectEndpoint(CONSOLE_IN_EPNUM);
if (!Endpoint_IsEnabled() || !Endpoint_IsConfigured()) {
Endpoint_SelectEndpoint(ep);
return;
if (data_read) {
/* Process Console Report Data */
process_console_data_quantum(ConsoleData, sizeof(ConsoleData));
}
}
// fill empty bank
while (Endpoint_IsReadWriteAllowed())
Endpoint_Write_8(0);
if (console_flush) {
/* IN packet */
Endpoint_SelectEndpoint(CONSOLE_IN_EPNUM);
if (!Endpoint_IsEnabled() || !Endpoint_IsConfigured()) {
Endpoint_SelectEndpoint(ep);
return;
}
// flash senchar packet
if (Endpoint_IsINReady()) {
Endpoint_ClearIN();
// fill empty bank
while (Endpoint_IsReadWriteAllowed())
Endpoint_Write_8(0);
// flash senchar packet
if (Endpoint_IsINReady()) {
Endpoint_ClearIN();
}
// CONSOLE_FLUSH_SET(false);
}
Endpoint_SelectEndpoint(ep);
}
#endif
@ -381,12 +399,6 @@ void EVENT_USB_Device_WakeUp()
#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
void EVENT_USB_Device_StartOfFrame(void)
@ -395,9 +407,9 @@ void EVENT_USB_Device_StartOfFrame(void)
if (++count % 50) return;
count = 0;
if (!console_flush) return;
//if (!console_flush) return;
Console_Task();
console_flush = false;
//console_flush = false;
}
#endif
@ -440,10 +452,10 @@ void EVENT_USB_Device_ConfigurationChanged(void)
/* Setup Console HID Report Endpoints */
ConfigSuccess &= ENDPOINT_CONFIG(CONSOLE_IN_EPNUM, EP_TYPE_INTERRUPT, ENDPOINT_DIR_IN,
CONSOLE_EPSIZE, ENDPOINT_BANK_SINGLE);
#if 0
// #if 0
ConfigSuccess &= ENDPOINT_CONFIG(CONSOLE_OUT_EPNUM, EP_TYPE_INTERRUPT, ENDPOINT_DIR_OUT,
CONSOLE_EPSIZE, ENDPOINT_BANK_SINGLE);
#endif
// #endif
#endif
#ifdef NKRO_ENABLE

Loading…
Cancel
Save