1
0

Add basic sleep_led for chibios.

This commit is contained in:
flabbergast 2015-09-10 10:31:19 +01:00
parent 7d4f3dd5a1
commit dc9fc9a7a4
7 changed files with 65 additions and 11 deletions

View File

@ -0,0 +1,19 @@
#include "ch.h"
#include "led.h"
#include "sleep_led.h"
void sleep_led_init(void) {
}
void sleep_led_enable(void) {
led_set(1<<USB_LED_CAPS_LOCK);
}
void sleep_led_disable(void) {
led_set(0);
}
void sleep_led_toggle(void) {
// not working yet, state not saved anywhere currently
}

View File

@ -8,17 +8,22 @@ Also pay attention to `-O0` (enabled for debugging); for deployment use `-O2`.
- 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).
- 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.
- Jumping to bootloader works, but it is not entirely pleasant, since it is very much MCU dependent. The code is now geared towards STM32 chips and their built-in bootloaders. 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.
- Sleep LED works, but at the moment only on/off, i.e. no breathing.
- The USB stack works pretty completely; however there are bits of other TMK stuff that are not done yet:
### Immediate todo
- suspend
- sleep led
- power saving for suspend?
- PWM for sleep led
### Not tested, but possibly working
- backlight
### Missing / not working (TMK vs ChibiOS bits)
- eeprom / bootmagic (will be chip dependent)
- eeprom / bootmagic (will be chip dependent; eeprom needs to be emulated in flash, which means less writes; wear-levelling?)
### Tried with

View File

@ -48,6 +48,28 @@ host_driver_t chibios_driver = {
send_consumer
};
/* TESTING
* Amber LED blinker thread, times are in milliseconds.
*/
// uint8_t blinkLedState = 0;
// static THD_WORKING_AREA(waThread1, 128);
// static THD_FUNCTION(Thread1, arg) {
// (void)arg;
// chRegSetThreadName("blinker1");
// while(true) {
// if(blinkLedState) {
// blinkLedState = 0;
// palSetPad(GPIOC, GPIOC_LED_ORANGE);
// chThdSleepMilliseconds(100);
// palClearPad(GPIOC, GPIOC_LED_ORANGE);
// }
// chThdSleepMilliseconds(100);
// }
// }
/* Main thread
*/
int main(void) {
@ -59,6 +81,9 @@ int main(void) {
chThdSleepMilliseconds(400);
palClearPad(GPIOC, GPIOC_LED_BLUE);
// TESTING
// chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL);
/* Init USB */
init_usb_driver(&USB_DRIVER);

View File

@ -23,6 +23,8 @@
#include "debug.h"
#ifdef SLEEP_LED_ENABLE
#include "sleep_led.h"
#include "led.h"
#include "host.h"
#endif
/* ---------------------------------------------------------

View File

@ -19,6 +19,9 @@
#ifndef _USB_MAIN_H_
#define _USB_MAIN_H_
// TESTING
// extern uint8_t blinkLedState;
#include "ch.h"
#include "hal.h"