1
0
Fork 0

Revert to old init order for host driver (#15029)

* Partially revert 14888
This commit is contained in:
Joel Challis 2021-11-02 18:53:46 +00:00 committed by GitHub
parent 0ecd4926b2
commit 634e42b2b4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 21 additions and 11 deletions

View file

@ -19,11 +19,21 @@
void platform_setup(void); void platform_setup(void);
void protocol_setup(void); void protocol_setup(void);
void protocol_init(void); void protocol_pre_init(void);
void protocol_post_init(void);
void protocol_pre_task(void); void protocol_pre_task(void);
void protocol_post_task(void); void protocol_post_task(void);
// Bodge as refactoring vusb sucks.... // Bodge as refactoring this area sucks....
void protocol_init(void) __attribute__((weak));
void protocol_init(void) {
protocol_pre_init();
keyboard_init();
protocol_post_init();
}
void protocol_task(void) __attribute__((weak)); void protocol_task(void) __attribute__((weak));
void protocol_task(void) { void protocol_task(void) {
protocol_pre_task(); protocol_pre_task();
@ -44,7 +54,6 @@ int main(void) {
keyboard_setup(); keyboard_setup();
protocol_init(); protocol_init();
keyboard_init();
/* Main loop */ /* Main loop */
while (true) { while (true) {

View file

@ -140,7 +140,7 @@ void protocol_setup(void) {
// chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL); // chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL);
} }
void protocol_init(void) { void protocol_pre_init(void) {
/* Init USB */ /* Init USB */
usb_event_queue_init(); usb_event_queue_init();
init_usb_driver(&USB_DRIVER); init_usb_driver(&USB_DRIVER);
@ -173,10 +173,10 @@ void protocol_init(void) {
wait_ms(50); wait_ms(50);
print("USB configured.\n"); print("USB configured.\n");
host_set_driver(driver);
} }
void protocol_post_init(void) { host_set_driver(driver); }
void protocol_pre_task(void) { void protocol_pre_task(void) {
usb_event_queue_task(); usb_event_queue_task();

View file

@ -1072,7 +1072,7 @@ void protocol_setup(void) {
usb_device_state_init(); usb_device_state_init();
} }
void protocol_init(void) { void protocol_pre_init(void) {
setup_usb(); setup_usb();
sei(); sei();
@ -1094,10 +1094,10 @@ void protocol_init(void) {
#else #else
USB_USBTask(); USB_USBTask();
#endif #endif
host_set_driver(&lufa_driver);
} }
void protocol_post_init(void) { host_set_driver(&lufa_driver); }
void protocol_pre_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) {

View file

@ -113,12 +113,13 @@ void protocol_setup(void) {
#endif #endif
} }
void protocol_init(void) { void protocol_pre_init(void) {
setup_usb(); setup_usb();
sei(); sei();
}
void protocol_post_init(void) {
host_set_driver(vusb_driver()); host_set_driver(vusb_driver());
wait_ms(50); wait_ms(50);
} }