Add basic sleep_led for chibios.
This commit is contained in:
parent
7d4f3dd5a1
commit
dc9fc9a7a4
@ -55,16 +55,16 @@ many embedded systems.
|
|||||||
To use the printf you need to supply your own character output function,
|
To use the printf you need to supply your own character output function,
|
||||||
something like :
|
something like :
|
||||||
|
|
||||||
void putc ( void* p, char c)
|
void putc ( void* p, char c)
|
||||||
{
|
{
|
||||||
while (!SERIAL_PORT_EMPTY) ;
|
while (!SERIAL_PORT_EMPTY) ;
|
||||||
SERIAL_PORT_TX_REGISTER = c;
|
SERIAL_PORT_TX_REGISTER = c;
|
||||||
}
|
}
|
||||||
|
|
||||||
Before you can call printf you need to initialize it to use your
|
Before you can call printf you need to initialize it to use your
|
||||||
character output function with something like:
|
character output function with something like:
|
||||||
|
|
||||||
init_printf(NULL,putc);
|
init_printf(NULL,putc);
|
||||||
|
|
||||||
Notice the 'NULL' in 'init_printf' and the parameter 'void* p' in 'putc',
|
Notice the 'NULL' in 'init_printf' and the parameter 'void* p' in 'putc',
|
||||||
the NULL (or any pointer) you pass into the 'init_printf' will eventually be
|
the NULL (or any pointer) you pass into the 'init_printf' will eventually be
|
||||||
|
19
tmk_core/common/chibios/sleep_led.c
Normal file
19
tmk_core/common/chibios/sleep_led.c
Normal 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
|
||||||
|
}
|
@ -23,5 +23,5 @@ uint16_t timer_elapsed(uint16_t last)
|
|||||||
|
|
||||||
uint32_t timer_elapsed32(uint32_t last)
|
uint32_t timer_elapsed32(uint32_t last)
|
||||||
{
|
{
|
||||||
return ST2MS(chVTTimeElapsedSinceX(MS2ST(last)));
|
return ST2MS(chVTTimeElapsedSinceX(MS2ST(last)));
|
||||||
}
|
}
|
||||||
|
@ -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.
|
- 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.
|
- 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:
|
- The USB stack works pretty completely; however there are bits of other TMK stuff that are not done yet:
|
||||||
|
|
||||||
### Immediate todo
|
### Immediate todo
|
||||||
|
|
||||||
- suspend
|
- power saving for suspend?
|
||||||
- sleep led
|
- PWM for sleep led
|
||||||
|
|
||||||
|
### Not tested, but possibly working
|
||||||
|
|
||||||
|
- backlight
|
||||||
|
|
||||||
### 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; eeprom needs to be emulated in flash, which means less writes; wear-levelling?)
|
||||||
|
|
||||||
### Tried with
|
### Tried with
|
||||||
|
|
||||||
|
@ -48,6 +48,28 @@ host_driver_t chibios_driver = {
|
|||||||
send_consumer
|
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
|
/* Main thread
|
||||||
*/
|
*/
|
||||||
int main(void) {
|
int main(void) {
|
||||||
@ -59,6 +81,9 @@ int main(void) {
|
|||||||
chThdSleepMilliseconds(400);
|
chThdSleepMilliseconds(400);
|
||||||
palClearPad(GPIOC, GPIOC_LED_BLUE);
|
palClearPad(GPIOC, GPIOC_LED_BLUE);
|
||||||
|
|
||||||
|
// TESTING
|
||||||
|
// chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL);
|
||||||
|
|
||||||
/* Init USB */
|
/* Init USB */
|
||||||
init_usb_driver(&USB_DRIVER);
|
init_usb_driver(&USB_DRIVER);
|
||||||
|
|
||||||
|
@ -23,6 +23,8 @@
|
|||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
#ifdef SLEEP_LED_ENABLE
|
#ifdef SLEEP_LED_ENABLE
|
||||||
#include "sleep_led.h"
|
#include "sleep_led.h"
|
||||||
|
#include "led.h"
|
||||||
|
#include "host.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* ---------------------------------------------------------
|
/* ---------------------------------------------------------
|
||||||
|
@ -19,6 +19,9 @@
|
|||||||
#ifndef _USB_MAIN_H_
|
#ifndef _USB_MAIN_H_
|
||||||
#define _USB_MAIN_H_
|
#define _USB_MAIN_H_
|
||||||
|
|
||||||
|
// TESTING
|
||||||
|
// extern uint8_t blinkLedState;
|
||||||
|
|
||||||
#include "ch.h"
|
#include "ch.h"
|
||||||
#include "hal.h"
|
#include "hal.h"
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user