Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Begin to carve out platform/protocol API - Migrate keyboard_* calls #14888

Merged
merged 4 commits into from
Oct 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions quantum/keyboard.c
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,12 @@ void keyboard_init(void) {
#ifdef DIP_SWITCH_ENABLE
dip_switch_init();
#endif
#ifdef SLEEP_LED_ENABLE
sleep_led_init();
#endif
#ifdef VIRTSER_ENABLE
virtser_init();
#endif

#if defined(DEBUG_MATRIX_SCAN_RATE) && defined(CONSOLE_ENABLE)
debug_enable = true;
Expand Down
15 changes: 14 additions & 1 deletion quantum/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,18 @@ void platform_setup(void);

void protocol_setup(void);
void protocol_init(void);
void protocol_task(void);
void protocol_pre_task(void);
void protocol_post_task(void);

// Bodge as refactoring vusb sucks....
void protocol_task(void) __attribute__((weak));
void protocol_task(void) {
protocol_pre_task();

keyboard_task();

protocol_post_task();
}

/** \brief Main
*
Expand All @@ -30,8 +41,10 @@ int main(void) __attribute__((weak));
int main(void) {
platform_setup();
protocol_setup();
keyboard_setup();

protocol_init();
keyboard_init();

/* Main loop */
while (true) {
Expand Down
15 changes: 3 additions & 12 deletions tmk_core/protocol/chibios/chibios.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,6 @@ void protocol_setup(void) {

// TESTING
// chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL);

keyboard_setup();
}

void protocol_init(void) {
Expand Down Expand Up @@ -176,18 +174,10 @@ void protocol_init(void) {

print("USB configured.\n");

/* init TMK modules */
keyboard_init();
host_set_driver(driver);

#ifdef SLEEP_LED_ENABLE
sleep_led_init();
#endif

print("Keyboard start.\n");
}

void protocol_task(void) {
void protocol_pre_task(void) {
usb_event_queue_task();

#if !defined(NO_USB_STARTUP_CHECK)
Expand All @@ -210,8 +200,9 @@ void protocol_task(void) {
# endif /* MOUSEKEY_ENABLE */
}
#endif
}

keyboard_task();
void protocol_post_task(void) {
#ifdef CONSOLE_ENABLE
console_task();
#endif
Expand Down
19 changes: 4 additions & 15 deletions tmk_core/protocol/lufa/lufa.c
Original file line number Diff line number Diff line change
Expand Up @@ -1070,7 +1070,6 @@ void protocol_setup(void) {

setup_mcu();
usb_device_state_init();
keyboard_setup();
}

void protocol_init(void) {
Expand All @@ -1095,21 +1094,11 @@ void protocol_init(void) {
#else
USB_USBTask();
#endif
/* init modules */
keyboard_init();
host_set_driver(&lufa_driver);
#ifdef SLEEP_LED_ENABLE
sleep_led_init();
#endif

#ifdef VIRTSER_ENABLE
virtser_init();
#endif

print("Keyboard start.\n");
host_set_driver(&lufa_driver);
}

void protocol_task(void) {
void protocol_pre_task(void) {
#if !defined(NO_USB_STARTUP_CHECK)
if (USB_DeviceState == DEVICE_STATE_Suspended) {
print("[s]");
Expand All @@ -1133,9 +1122,9 @@ void protocol_task(void) {
suspend_wakeup_init();
}
#endif
}

keyboard_task();

void protocol_post_task(void) {
#ifdef MIDI_ENABLE
MIDI_Device_USBTask(&USB_MIDI_Interface);
#endif
Expand Down
7 changes: 0 additions & 7 deletions tmk_core/protocol/vusb/protocol.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,22 +111,15 @@ void protocol_setup(void) {
// clock prescaler
clock_prescale_set(clock_div_1);
#endif
keyboard_setup();
}

void protocol_init(void) {
setup_usb();
sei();

keyboard_init();

host_set_driver(vusb_driver());

wait_ms(50);

#ifdef SLEEP_LED_ENABLE
sleep_led_init();
#endif
}

void protocol_task(void) {
Expand Down