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

master
Joel Challis 2021-10-24 20:39:41 +01:00 committed by GitHub
parent c3c562cbb6
commit 2ec268bd21
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 27 additions and 35 deletions

View File

@ -335,6 +335,12 @@ void keyboard_init(void) {
#ifdef DIP_SWITCH_ENABLE #ifdef DIP_SWITCH_ENABLE
dip_switch_init(); dip_switch_init();
#endif #endif
#ifdef SLEEP_LED_ENABLE
sleep_led_init();
#endif
#ifdef VIRTSER_ENABLE
virtser_init();
#endif
#if defined(DEBUG_MATRIX_SCAN_RATE) && defined(CONSOLE_ENABLE) #if defined(DEBUG_MATRIX_SCAN_RATE) && defined(CONSOLE_ENABLE)
debug_enable = true; debug_enable = true;

View File

@ -20,7 +20,18 @@ void platform_setup(void);
void protocol_setup(void); void protocol_setup(void);
void protocol_init(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 /** \brief Main
* *
@ -30,8 +41,10 @@ int main(void) __attribute__((weak));
int main(void) { int main(void) {
platform_setup(); platform_setup();
protocol_setup(); protocol_setup();
keyboard_setup();
protocol_init(); protocol_init();
keyboard_init();
/* Main loop */ /* Main loop */
while (true) { while (true) {

View File

@ -138,8 +138,6 @@ void protocol_setup(void) {
// TESTING // TESTING
// chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL); // chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL);
keyboard_setup();
} }
void protocol_init(void) { void protocol_init(void) {
@ -176,18 +174,10 @@ void protocol_init(void) {
print("USB configured.\n"); print("USB configured.\n");
/* init TMK modules */
keyboard_init();
host_set_driver(driver); 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(); usb_event_queue_task();
#if !defined(NO_USB_STARTUP_CHECK) #if !defined(NO_USB_STARTUP_CHECK)
@ -210,8 +200,9 @@ void protocol_task(void) {
# endif /* MOUSEKEY_ENABLE */ # endif /* MOUSEKEY_ENABLE */
} }
#endif #endif
}
keyboard_task(); void protocol_post_task(void) {
#ifdef CONSOLE_ENABLE #ifdef CONSOLE_ENABLE
console_task(); console_task();
#endif #endif

View File

@ -1070,7 +1070,6 @@ void protocol_setup(void) {
setup_mcu(); setup_mcu();
usb_device_state_init(); usb_device_state_init();
keyboard_setup();
} }
void protocol_init(void) { void protocol_init(void) {
@ -1095,21 +1094,11 @@ void protocol_init(void) {
#else #else
USB_USBTask(); USB_USBTask();
#endif #endif
/* init modules */
keyboard_init();
host_set_driver(&lufa_driver); host_set_driver(&lufa_driver);
#ifdef SLEEP_LED_ENABLE
sleep_led_init();
#endif
#ifdef VIRTSER_ENABLE
virtser_init();
#endif
print("Keyboard start.\n");
} }
void protocol_task(void) { void protocol_pre_task(void) {
#if !defined(NO_USB_STARTUP_CHECK) #if !defined(NO_USB_STARTUP_CHECK)
if (USB_DeviceState == DEVICE_STATE_Suspended) { if (USB_DeviceState == DEVICE_STATE_Suspended) {
print("[s]"); print("[s]");
@ -1133,9 +1122,9 @@ void protocol_task(void) {
suspend_wakeup_init(); suspend_wakeup_init();
} }
#endif #endif
}
keyboard_task(); void protocol_post_task(void) {
#ifdef MIDI_ENABLE #ifdef MIDI_ENABLE
MIDI_Device_USBTask(&USB_MIDI_Interface); MIDI_Device_USBTask(&USB_MIDI_Interface);
#endif #endif

View File

@ -111,22 +111,15 @@ void protocol_setup(void) {
// clock prescaler // clock prescaler
clock_prescale_set(clock_div_1); clock_prescale_set(clock_div_1);
#endif #endif
keyboard_setup();
} }
void protocol_init(void) { void protocol_init(void) {
setup_usb(); setup_usb();
sei(); sei();
keyboard_init();
host_set_driver(vusb_driver()); host_set_driver(vusb_driver());
wait_ms(50); wait_ms(50);
#ifdef SLEEP_LED_ENABLE
sleep_led_init();
#endif
} }
void protocol_task(void) { void protocol_task(void) {