diff options
author | tmk <hasu@tmk-kbd.com> | 2015-05-17 19:34:34 +0900 |
---|---|---|
committer | tmk <hasu@tmk-kbd.com> | 2015-05-19 00:39:43 +0900 |
commit | 6b588eb7f7893500e18686e673dbf12b511dc975 (patch) | |
tree | 62d7a75008d3407f318ae650c7a45643944eee31 | |
parent | 9a2282157fbdf57ef0a50d4fea7da72505906588 (diff) | |
download | qmk_firmware-6b588eb7f7893500e18686e673dbf12b511dc975.tar.gz qmk_firmware-6b588eb7f7893500e18686e673dbf12b511dc975.zip |
Add keyboard_setup() and matrix_setup()
-rw-r--r-- | tmk_core/common/avr/suspend.c | 2 | ||||
-rw-r--r-- | tmk_core/common/keyboard.c | 6 | ||||
-rw-r--r-- | tmk_core/common/keyboard.h | 8 | ||||
-rw-r--r-- | tmk_core/common/matrix.h | 4 | ||||
-rw-r--r-- | tmk_core/protocol/lufa/lufa.c | 9 | ||||
-rw-r--r-- | tmk_core/protocol/pjrc/main.c | 2 |
6 files changed, 25 insertions, 6 deletions
diff --git a/tmk_core/common/avr/suspend.c b/tmk_core/common/avr/suspend.c index 80243f02b..af99f52b5 100644 --- a/tmk_core/common/avr/suspend.c +++ b/tmk_core/common/avr/suspend.c | |||
@@ -85,6 +85,8 @@ void suspend_power_down(void) | |||
85 | power_down(WDTO_15MS); | 85 | power_down(WDTO_15MS); |
86 | } | 86 | } |
87 | 87 | ||
88 | __attribute__ ((weak)) void matrix_power_up(void) {} | ||
89 | __attribute__ ((weak)) void matrix_power_down(void) {} | ||
88 | bool suspend_wakeup_condition(void) | 90 | bool suspend_wakeup_condition(void) |
89 | { | 91 | { |
90 | matrix_power_up(); | 92 | matrix_power_up(); |
diff --git a/tmk_core/common/keyboard.c b/tmk_core/common/keyboard.c index b03b124d7..eb7b096be 100644 --- a/tmk_core/common/keyboard.c +++ b/tmk_core/common/keyboard.c | |||
@@ -62,6 +62,12 @@ static bool has_ghost_in_row(uint8_t row) | |||
62 | #endif | 62 | #endif |
63 | 63 | ||
64 | 64 | ||
65 | __attribute__ ((weak)) void matrix_setup(void) {} | ||
66 | void keyboard_setup(void) | ||
67 | { | ||
68 | matrix_setup(); | ||
69 | } | ||
70 | |||
65 | void keyboard_init(void) | 71 | void keyboard_init(void) |
66 | { | 72 | { |
67 | timer_init(); | 73 | timer_init(); |
diff --git a/tmk_core/common/keyboard.h b/tmk_core/common/keyboard.h index 6442716fc..7738251b6 100644 --- a/tmk_core/common/keyboard.h +++ b/tmk_core/common/keyboard.h | |||
@@ -58,13 +58,15 @@ static inline bool IS_RELEASED(keyevent_t event) { return (!IS_NOEVENT(event) && | |||
58 | } | 58 | } |
59 | 59 | ||
60 | 60 | ||
61 | /* it runs once at early stage of startup before keyboard_init. */ | ||
62 | void keyboard_setup(void); | ||
63 | /* it runs once after initializing host side protocol, debug and MCU peripherals. */ | ||
61 | void keyboard_init(void); | 64 | void keyboard_init(void); |
65 | /* it runs repeatedly in main loop */ | ||
62 | void keyboard_task(void); | 66 | void keyboard_task(void); |
67 | /* it runs when host LED status is updated */ | ||
63 | void keyboard_set_leds(uint8_t leds); | 68 | void keyboard_set_leds(uint8_t leds); |
64 | 69 | ||
65 | __attribute__ ((weak)) void matrix_power_up(void) {} | ||
66 | __attribute__ ((weak)) void matrix_power_down(void) {} | ||
67 | |||
68 | #ifdef __cplusplus | 70 | #ifdef __cplusplus |
69 | } | 71 | } |
70 | #endif | 72 | #endif |
diff --git a/tmk_core/common/matrix.h b/tmk_core/common/matrix.h index 107ee7265..ec6f8cd43 100644 --- a/tmk_core/common/matrix.h +++ b/tmk_core/common/matrix.h | |||
@@ -43,7 +43,9 @@ extern "C" { | |||
43 | uint8_t matrix_rows(void); | 43 | uint8_t matrix_rows(void); |
44 | /* number of matrix columns */ | 44 | /* number of matrix columns */ |
45 | uint8_t matrix_cols(void); | 45 | uint8_t matrix_cols(void); |
46 | /* intialize matrix for scaning. should be called once. */ | 46 | /* should be called at early stage of startup before matrix_init.(optional) */ |
47 | void matrix_setup(void); | ||
48 | /* intialize matrix for scaning. */ | ||
47 | void matrix_init(void); | 49 | void matrix_init(void); |
48 | /* scan all key states on matrix */ | 50 | /* scan all key states on matrix */ |
49 | uint8_t matrix_scan(void); | 51 | uint8_t matrix_scan(void); |
diff --git a/tmk_core/protocol/lufa/lufa.c b/tmk_core/protocol/lufa/lufa.c index cdfc7bc6a..391064c9b 100644 --- a/tmk_core/protocol/lufa/lufa.c +++ b/tmk_core/protocol/lufa/lufa.c | |||
@@ -544,7 +544,7 @@ int8_t sendchar(uint8_t c) | |||
544 | /******************************************************************************* | 544 | /******************************************************************************* |
545 | * main | 545 | * main |
546 | ******************************************************************************/ | 546 | ******************************************************************************/ |
547 | static void SetupHardware(void) | 547 | static void setup_mcu(void) |
548 | { | 548 | { |
549 | /* Disable watchdog if enabled by bootloader/fuses */ | 549 | /* Disable watchdog if enabled by bootloader/fuses */ |
550 | MCUSR &= ~(1 << WDRF); | 550 | MCUSR &= ~(1 << WDRF); |
@@ -552,7 +552,10 @@ static void SetupHardware(void) | |||
552 | 552 | ||
553 | /* Disable clock division */ | 553 | /* Disable clock division */ |
554 | clock_prescale_set(clock_div_1); | 554 | clock_prescale_set(clock_div_1); |
555 | } | ||
555 | 556 | ||
557 | static void setup_usb(void) | ||
558 | { | ||
556 | // Leonardo needs. Without this USB device is not recognized. | 559 | // Leonardo needs. Without this USB device is not recognized. |
557 | USB_Disable(); | 560 | USB_Disable(); |
558 | 561 | ||
@@ -566,7 +569,9 @@ static void SetupHardware(void) | |||
566 | int main(void) __attribute__ ((weak)); | 569 | int main(void) __attribute__ ((weak)); |
567 | int main(void) | 570 | int main(void) |
568 | { | 571 | { |
569 | SetupHardware(); | 572 | setup_mcu(); |
573 | keyboard_setup(); | ||
574 | setup_usb(); | ||
570 | sei(); | 575 | sei(); |
571 | 576 | ||
572 | /* wait for USB startup & debug output */ | 577 | /* wait for USB startup & debug output */ |
diff --git a/tmk_core/protocol/pjrc/main.c b/tmk_core/protocol/pjrc/main.c index e7bdcc059..45eb17d4c 100644 --- a/tmk_core/protocol/pjrc/main.c +++ b/tmk_core/protocol/pjrc/main.c | |||
@@ -46,6 +46,8 @@ int main(void) | |||
46 | // set for 16 MHz clock | 46 | // set for 16 MHz clock |
47 | CPU_PRESCALE(0); | 47 | CPU_PRESCALE(0); |
48 | 48 | ||
49 | keyboard_setup(); | ||
50 | |||
49 | // Initialize the USB, and then wait for the host to set configuration. | 51 | // Initialize the USB, and then wait for the host to set configuration. |
50 | // If the Teensy is powered without a PC connected to the USB port, | 52 | // If the Teensy is powered without a PC connected to the USB port, |
51 | // this will wait forever. | 53 | // this will wait forever. |