From 78242ebba180b37d5c428d47982df8a612882e2d Mon Sep 17 00:00:00 2001 From: Kai Ryu Date: Sun, 3 Aug 2014 12:00:18 +0900 Subject: [PATCH] Add init callback function to softpwm_led --- common/keyboard.c | 10 +++++----- common/ledmap.c | 4 ++++ common/softpwm_led.c | 3 ++- common/softpwm_led.h | 2 ++ keyboard/gh60/backlight.c | 9 +++++++++ 5 files changed, 22 insertions(+), 6 deletions(-) diff --git a/common/keyboard.c b/common/keyboard.c index 1fedc8c8..ef2efb6f 100644 --- a/common/keyboard.c +++ b/common/keyboard.c @@ -91,18 +91,18 @@ void keyboard_init(void) ledmap_init(); #endif -#ifdef BACKLIGHT_ENABLE - backlight_init(); -#endif - #ifdef SOFTPWM_LED_ENABLE - softpwm_led_init(); + softpwm_init(); #endif #ifdef BREATHING_LED_ENABLE breathing_led_init(); #endif +#ifdef BACKLIGHT_ENABLE + backlight_init(); +#endif + #ifdef KEYMAP_IN_EEPROM_ENABLE keymap_in_eeprom_init(); #endif diff --git a/common/ledmap.c b/common/ledmap.c index 113db621..beb0a72c 100644 --- a/common/ledmap.c +++ b/common/ledmap.c @@ -83,6 +83,10 @@ void layer_state_change(uint32_t state) #endif #ifdef SOFTPWM_LED_ENABLE +void softpwm_led_init(void) +{ +} + void softpwm_led_on(uint8_t index) { if (backlight_binding & LED_BIT(index)) { diff --git a/common/softpwm_led.c b/common/softpwm_led.c index 5fd0e80f..d21c0357 100644 --- a/common/softpwm_led.c +++ b/common/softpwm_led.c @@ -11,7 +11,7 @@ static uint8_t softpwm_led_state = 0; static uint8_t softpwm_led_ocr[LED_COUNT] = {0}; static uint8_t softpwm_led_ocr_buff[LED_COUNT] = {0}; -void softpwm_led_init(void) +void softpwm_init(void) { #ifdef SOFTPWM_LED_TIMER3 /* Timer3 setup */ @@ -38,6 +38,7 @@ void softpwm_led_init(void) OCR1AL = SOFTPWM_LED_TIMER_TOP & 0xff; SREG = sreg; #endif + softpwm_led_init(); } void softpwm_led_enable(void) diff --git a/common/softpwm_led.h b/common/softpwm_led.h index 63e5a133..ad95b577 100644 --- a/common/softpwm_led.h +++ b/common/softpwm_led.h @@ -8,6 +8,7 @@ typedef led_pack_t led_state_t; #ifdef SOFTPWM_LED_ENABLE +void softpwm_init(void); void softpwm_led_init(void); void softpwm_led_enable(void); void softpwm_led_disable(void); @@ -43,6 +44,7 @@ void breathing_led_set_duration_all(uint8_t dur); #else +#define softpwm_init() #define softpwm_led_init() #define softpwm_led_enable() #define softpwm_led_disable() diff --git a/keyboard/gh60/backlight.c b/keyboard/gh60/backlight.c index b07c5314..009d6afa 100644 --- a/keyboard/gh60/backlight.c +++ b/keyboard/gh60/backlight.c @@ -174,6 +174,15 @@ inline void backlight_set_raw(uint8_t raw) #ifdef SOFTPWM_LED_ENABLE #ifndef LEDMAP_ENABLE +void softpwm_led_init(void) +{ +#if defined(GH60_REV_CHN) + DDRB |= (1<