Browse Source

Small updates.

master
flabbergast 8 years ago
parent
commit
9cc281b4ef

+ 3
- 2
tmk_core/protocol/chibios/README.md View File

- USB string descriptors are a mess. I did not find a way to cleanly generate the right structures from actual strings, so the definitions in individual keyboards' `config.h` are ugly as heck. - USB string descriptors are a mess. I did not find a way to cleanly generate the right structures from actual strings, so the definitions in individual keyboards' `config.h` are ugly as heck.
- There are some random constants left so far, e.g. 5ms sleep between calling `keyboard_task` in `main.c`. There should be no such in `usb_main.c`. Everything is based on timers/interrupts/kernel scheduling (well except `keyboard_task`), so no periodically called things (again, except `keyboard_task`, which is just how TMK is designed). - There are some random constants left so far, e.g. 5ms sleep between calling `keyboard_task` in `main.c`. There should be no such in `usb_main.c`. Everything is based on timers/interrupts/kernel scheduling (well except `keyboard_task`), so no periodically called things (again, except `keyboard_task`, which is just how TMK is designed).
- It is easy to add some code for testing (e.g. blink LED, do stuff on button press, etc...) - just create another thread in `main.c`, it will run independently of the keyboard business. - It is easy to add some code for testing (e.g. blink LED, do stuff on button press, etc...) - just create another thread in `main.c`, it will run independently of the keyboard business.
- Jumping to bootloader works, but it is not entirely pleasant, since it is very much MCU dependent. So, one needs to dig out the right address to jump to, and pass it to the compiler in the `Makefile`. Also, a patch to upstream ChibiOS is needed (supplied), because it `ResetHandler` needs adjusting.
- The USB stack works pretty completely; however there are bits of other TMK stuff that are not done yet: - The USB stack works pretty completely; however there are bits of other TMK stuff that are not done yet:


### Immediate todo ### Immediate todo


- suspend / sleep led
- suspend
- sleep led


### Missing / not working (TMK vs ChibiOS bits) ### Missing / not working (TMK vs ChibiOS bits)


- eeprom / bootmagic (will be chip dependent) - eeprom / bootmagic (will be chip dependent)
- bootloader jump (chip dependent)


### Tried with ### Tried with



+ 1
- 1
tmk_core/protocol/chibios/main.c View File

host_set_driver(&chibios_driver); host_set_driver(&chibios_driver);


#ifdef SLEEP_LED_ENABLE #ifdef SLEEP_LED_ENABLE
sleep_led_init();
sleep_led_init();
#endif #endif


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

+ 18
- 0
tmk_core/protocol/chibios/usb_main.c View File



#include "usb_main.h" #include "usb_main.h"


#include "debug.h"
#ifdef SLEEP_LED_ENABLE
#include "sleep_led.h"
#endif

/* --------------------------------------------------------- /* ---------------------------------------------------------
* Global interface variables and declarations * Global interface variables and declarations
* --------------------------------------------------------- * ---------------------------------------------------------
static void usb_event_cb(USBDriver *usbp, usbevent_t event) { static void usb_event_cb(USBDriver *usbp, usbevent_t event) {
switch(event) { switch(event) {
case USB_EVENT_RESET: case USB_EVENT_RESET:
//TODO: from ISR! print("[R]");
return; return;


case USB_EVENT_ADDRESS: case USB_EVENT_ADDRESS:
return; return;


case USB_EVENT_SUSPEND: case USB_EVENT_SUSPEND:
//TODO: from ISR! print("[S]");
//TODO: signal suspend?
#ifdef SLEEP_LED_ENABLE
sleep_led_enable();
#endif /* SLEEP_LED_ENABLE */
return; return;


case USB_EVENT_WAKEUP: case USB_EVENT_WAKEUP:
//TODO: from ISR! print("[W]");
//TODO: suspend_wakeup_init();
#ifdef SLEEP_LED_ENABLE
sleep_led_disable();
// NOTE: converters may not accept this
led_set(host_keyboard_leds());
#endif /* SLEEP_LED_ENABLE */
return; return;


case USB_EVENT_STALLED: case USB_EVENT_STALLED: