aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortmk <hasu@tmk-kbd.com>2015-05-17 19:34:34 +0900
committertmk <hasu@tmk-kbd.com>2015-05-19 00:39:43 +0900
commit6b588eb7f7893500e18686e673dbf12b511dc975 (patch)
tree62d7a75008d3407f318ae650c7a45643944eee31
parent9a2282157fbdf57ef0a50d4fea7da72505906588 (diff)
downloadqmk_firmware-6b588eb7f7893500e18686e673dbf12b511dc975.tar.gz
qmk_firmware-6b588eb7f7893500e18686e673dbf12b511dc975.zip
Add keyboard_setup() and matrix_setup()
-rw-r--r--tmk_core/common/avr/suspend.c2
-rw-r--r--tmk_core/common/keyboard.c6
-rw-r--r--tmk_core/common/keyboard.h8
-rw-r--r--tmk_core/common/matrix.h4
-rw-r--r--tmk_core/protocol/lufa/lufa.c9
-rw-r--r--tmk_core/protocol/pjrc/main.c2
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) {}
88bool suspend_wakeup_condition(void) 90bool 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) {}
66void keyboard_setup(void)
67{
68 matrix_setup();
69}
70
65void keyboard_init(void) 71void 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. */
62void keyboard_setup(void);
63/* it runs once after initializing host side protocol, debug and MCU peripherals. */
61void keyboard_init(void); 64void keyboard_init(void);
65/* it runs repeatedly in main loop */
62void keyboard_task(void); 66void keyboard_task(void);
67/* it runs when host LED status is updated */
63void keyboard_set_leds(uint8_t leds); 68void 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" {
43uint8_t matrix_rows(void); 43uint8_t matrix_rows(void);
44/* number of matrix columns */ 44/* number of matrix columns */
45uint8_t matrix_cols(void); 45uint8_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) */
47void matrix_setup(void);
48/* intialize matrix for scaning. */
47void matrix_init(void); 49void matrix_init(void);
48/* scan all key states on matrix */ 50/* scan all key states on matrix */
49uint8_t matrix_scan(void); 51uint8_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 ******************************************************************************/
547static void SetupHardware(void) 547static 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
557static 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)
566int main(void) __attribute__ ((weak)); 569int main(void) __attribute__ ((weak));
567int main(void) 570int 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.