lotus: Jump to bootloader via raw HID

Signed-off-by: Daniel Schaefer <dhs@frame.work>
This commit is contained in:
Daniel Schaefer 2022-12-29 21:05:35 +08:00
parent 3cdcca467a
commit 6dcfb422aa

View File

@ -2,6 +2,7 @@
// SPDX-License-Identifier: GPL-2.0-or-later
#include "lotus.h"
#include "raw_hid.h"
#define BOOT_DONE_GPIO GP5
@ -41,4 +42,41 @@ bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
default:
return true; // Process all other keycodes normally
}
}
}
void handle_hid(uint8_t *data, uint8_t length) {
uint8_t command_id = data[0];
uint8_t *command_data = &(data[1]);
uprintf("raw_hid_receive(command: %u, length: %d)\n", command_id, length);
switch (command_id) {
case 0x01:
print("protocol_ver\n");
command_data[0] = 0x0B >> 8;
command_data[1] = 0x0B & 0xFF;
#ifndef VIA_ENABLE
raw_hid_send(data, length);
#endif
break;
case 0x0B:
print("bootloader_jump\n");
bootloader_jump();
break;
default:
print("Unrecognized command ID\n");
break;
}
}
// Add hooks to handle raw HID commands.
// Need add both functions to make it work when
// either RAW_ENABLE or VIA_ENABLE are enabled.
void via_command_kb(uint8_t *data, uint8_t length) {
handle_hid(data, length);
}
#ifndef VIA_ENABLE
void raw_hid_receive(uint8_t *data, uint8_t length) {
handle_hid(data, length);
}
#endif