1
0
Fork 0

Refactor vusb to protocol use pre/post task (#14944)

This commit is contained in:
Joel Challis 2024-03-14 10:45:12 +00:00 committed by GitHub
parent 4bbfecae90
commit 63dd131d81
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 35 additions and 61 deletions

View file

@ -31,14 +31,6 @@
# include "sleep_led.h"
#endif
#ifdef CONSOLE_ENABLE
void console_task(void);
#endif
#ifdef RAW_ENABLE
void raw_hid_task(void);
#endif
/* This is from main.c of USBaspLoader */
static void initForUsbConnectivity(void) {
uint8_t i = 0;
@ -136,7 +128,7 @@ static inline bool should_do_suspend(void) {
return vusb_suspended;
}
void protocol_task(void) {
void protocol_pre_task(void) {
#if !defined(NO_USB_STARTUP_CHECK)
if (should_do_suspend()) {
dprintln("suspending keyboard");
@ -159,7 +151,9 @@ void protocol_task(void) {
vusb_wakeup();
}
#endif
}
void protocol_keyboard_task(void) {
usbPoll();
// TODO: configuration process is inconsistent. it sometime fails.
@ -167,20 +161,8 @@ void protocol_task(void) {
if (usbConfiguration && usbInterruptIsReady()) {
keyboard_task();
}
#ifdef RAW_ENABLE
usbPoll();
if (usbConfiguration && usbInterruptIsReady4()) {
raw_hid_task();
}
#endif
#ifdef CONSOLE_ENABLE
usbPoll();
if (usbConfiguration && usbInterruptIsReady3()) {
console_task();
}
#endif
}
void protocol_post_task(void) {
// do nothing
}

View file

@ -162,6 +162,12 @@ __attribute__((weak)) void raw_hid_receive(uint8_t *data, uint8_t length) {
}
void raw_hid_task(void) {
usbPoll();
if (!usbConfiguration || !usbInterruptIsReady4()) {
return;
}
if (raw_output_received_bytes == RAW_BUFFER_SIZE) {
raw_hid_receive(raw_output_buffer, RAW_BUFFER_SIZE);
raw_output_received_bytes = 0;
@ -182,7 +188,9 @@ int8_t sendchar(uint8_t c) {
}
void console_task(void) {
if (!usbConfiguration) {
usbPoll();
if (!usbConfiguration || !usbInterruptIsReady3()) {
return;
}