summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--common_features.mk15
-rw-r--r--quantum/backlight/backlight.c49
-rw-r--r--quantum/backlight/backlight.h8
-rw-r--r--quantum/backlight/backlight_arm.c4
-rw-r--r--quantum/backlight/backlight_avr.c5
-rw-r--r--quantum/backlight/backlight_driver_common.c49
-rw-r--r--quantum/backlight/backlight_driver_common.h7
-rw-r--r--quantum/backlight/backlight_software.c (renamed from quantum/backlight/backlight_soft.c)5
8 files changed, 73 insertions, 69 deletions
diff --git a/common_features.mk b/common_features.mk
index 36cae78657..fe65974e7a 100644
--- a/common_features.mk
+++ b/common_features.mk
@@ -297,24 +297,27 @@ VALID_BACKLIGHT_TYPES := pwm software custom
BACKLIGHT_ENABLE ?= no
BACKLIGHT_DRIVER ?= pwm
ifeq ($(strip $(BACKLIGHT_ENABLE)), yes)
- SRC += $(QUANTUM_DIR)/process_keycode/process_backlight.c
ifeq ($(filter $(BACKLIGHT_DRIVER),$(VALID_BACKLIGHT_TYPES)),)
$(error BACKLIGHT_DRIVER="$(BACKLIGHT_DRIVER)" is not a valid backlight type)
endif
COMMON_VPATH += $(QUANTUM_DIR)/backlight
SRC += $(QUANTUM_DIR)/backlight/backlight.c
+ SRC += $(QUANTUM_DIR)/process_keycode/process_backlight.c
OPT_DEFS += -DBACKLIGHT_ENABLE
ifeq ($(strip $(BACKLIGHT_DRIVER)), custom)
OPT_DEFS += -DBACKLIGHT_CUSTOM_DRIVER
- else ifeq ($(strip $(BACKLIGHT_DRIVER)), software)
- SRC += $(QUANTUM_DIR)/backlight/backlight_soft.c
else
- ifeq ($(PLATFORM),AVR)
- SRC += $(QUANTUM_DIR)/backlight/backlight_avr.c
+ SRC += $(QUANTUM_DIR)/backlight/backlight_driver_common.c
+ ifeq ($(strip $(BACKLIGHT_DRIVER)), pwm)
+ ifeq ($(PLATFORM),AVR)
+ SRC += $(QUANTUM_DIR)/backlight/backlight_avr.c
+ else
+ SRC += $(QUANTUM_DIR)/backlight/backlight_arm.c
+ endif
else
- SRC += $(QUANTUM_DIR)/backlight/backlight_arm.c
+ SRC += $(QUANTUM_DIR)/backlight/backlight_$(strip $(BACKLIGHT_DRIVER)).c
endif
endif
endif
diff --git a/quantum/backlight/backlight.c b/quantum/backlight/backlight.c
index 4a0eac64c6..34dd8cbdb5 100644
--- a/quantum/backlight/backlight.c
+++ b/quantum/backlight/backlight.c
@@ -20,6 +20,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "eeconfig.h"
#include "debug.h"
+#if defined(STM32F0XX) || defined(STM32F0xx)
+# pragma message("Backlight support for STMF072 has had limited testing, YMMV. If unsure, set 'BACKLIGHT_ENABLE = no' in your rules.mk")
+#endif
+
backlight_config_t backlight_config;
#ifdef BACKLIGHT_BREATHING
@@ -27,51 +31,6 @@ backlight_config_t backlight_config;
static uint8_t breathing_period = BREATHING_PERIOD;
#endif
-#ifndef BACKLIGHT_CUSTOM_DRIVER
-# if defined(BACKLIGHT_PINS)
-static const pin_t backlight_pins[] = BACKLIGHT_PINS;
-# ifndef BACKLIGHT_LED_COUNT
-# define BACKLIGHT_LED_COUNT (sizeof(backlight_pins) / sizeof(pin_t))
-# endif
-
-# define FOR_EACH_LED(x) \
- for (uint8_t i = 0; i < BACKLIGHT_LED_COUNT; i++) { \
- pin_t backlight_pin = backlight_pins[i]; \
- { x } \
- }
-# else
-// we support only one backlight pin
-static const pin_t backlight_pin = BACKLIGHT_PIN;
-# define FOR_EACH_LED(x) x
-# endif
-
-static inline void backlight_on(pin_t backlight_pin) {
-# if BACKLIGHT_ON_STATE == 0
- writePinLow(backlight_pin);
-# else
- writePinHigh(backlight_pin);
-# endif
-}
-
-static inline void backlight_off(pin_t backlight_pin) {
-# if BACKLIGHT_ON_STATE == 0
- writePinHigh(backlight_pin);
-# else
- writePinLow(backlight_pin);
-# endif
-}
-
-void backlight_pins_init(void) {
- // Setup backlight pin as output and output to off state.
- FOR_EACH_LED(setPinOutput(backlight_pin); backlight_off(backlight_pin);)
-}
-
-void backlight_pins_on(void) { FOR_EACH_LED(backlight_on(backlight_pin);) }
-
-void backlight_pins_off(void) { FOR_EACH_LED(backlight_off(backlight_pin);) }
-
-#endif
-
/** \brief Backlight initialization
*
* FIXME: needs doc
diff --git a/quantum/backlight/backlight.h b/quantum/backlight/backlight.h
index 07a4880e9f..3e506737d4 100644
--- a/quantum/backlight/backlight.h
+++ b/quantum/backlight/backlight.h
@@ -44,10 +44,6 @@ typedef union {
};
} backlight_config_t;
-void backlight_pins_init(void);
-void backlight_pins_on(void);
-void backlight_pins_off(void);
-
void backlight_init(void);
void backlight_toggle(void);
void backlight_enable(void);
@@ -79,11 +75,11 @@ void breathing_period_default(void);
void breathing_period_inc(void);
void breathing_period_dec(void);
+void breathing_toggle(void);
+
// implementation specific
void breathing_enable(void);
void breathing_disable(void);
-void breathing_toggle(void);
bool is_breathing(void);
void breathing_pulse(void);
-void breathing_task(void);
#endif
diff --git a/quantum/backlight/backlight_arm.c b/quantum/backlight/backlight_arm.c
index a6d38a1a02..723544adb9 100644
--- a/quantum/backlight/backlight_arm.c
+++ b/quantum/backlight/backlight_arm.c
@@ -6,10 +6,6 @@
// TODO: remove short term bodge when refactoring BACKLIGHT_CUSTOM_DRIVER out
#ifdef BACKLIGHT_PIN
-# if defined(STM32F0XX) || defined(STM32F0xx)
-# pragma message("Backlight support for STMF072 has had limited testing, YMMV. If unsure, set 'BACKLIGHT_ENABLE = no' in your rules.mk")
-# endif
-
// GPIOV2 && GPIOV3
# ifndef BACKLIGHT_PAL_MODE
# define BACKLIGHT_PAL_MODE 2
diff --git a/quantum/backlight/backlight_avr.c b/quantum/backlight/backlight_avr.c
index 40291d3821..ce13f11184 100644
--- a/quantum/backlight/backlight_avr.c
+++ b/quantum/backlight/backlight_avr.c
@@ -1,11 +1,8 @@
#include "quantum.h"
#include "backlight.h"
+#include "backlight_driver_common.h"
#include "debug.h"
-#if !defined(BACKLIGHT_PIN) && !defined(BACKLIGHT_PINS)
-# error "Backlight pin/pins not defined. Please configure."
-#endif
-
// This logic is a bit complex, we support 3 setups:
//
// 1. Hardware PWM when backlight is wired to a PWM pin.
diff --git a/quantum/backlight/backlight_driver_common.c b/quantum/backlight/backlight_driver_common.c
new file mode 100644
index 0000000000..270a43c67e
--- /dev/null
+++ b/quantum/backlight/backlight_driver_common.c
@@ -0,0 +1,49 @@
+#include "quantum.h"
+#include "backlight.h"
+#include "backlight_driver_common.h"
+
+#if !defined(BACKLIGHT_PIN) && !defined(BACKLIGHT_PINS)
+# error "Backlight pin/pins not defined. Please configure."
+#endif
+
+#if defined(BACKLIGHT_PINS)
+static const pin_t backlight_pins[] = BACKLIGHT_PINS;
+# ifndef BACKLIGHT_LED_COUNT
+# define BACKLIGHT_LED_COUNT (sizeof(backlight_pins) / sizeof(pin_t))
+# endif
+
+# define FOR_EACH_LED(x) \
+ for (uint8_t i = 0; i < BACKLIGHT_LED_COUNT; i++) { \
+ pin_t backlight_pin = backlight_pins[i]; \
+ { x } \
+ }
+#else
+// we support only one backlight pin
+static const pin_t backlight_pin = BACKLIGHT_PIN;
+# define FOR_EACH_LED(x) x
+#endif
+
+static inline void backlight_on(pin_t backlight_pin) {
+#if BACKLIGHT_ON_STATE == 0
+ writePinLow(backlight_pin);
+#else
+ writePinHigh(backlight_pin);
+#endif
+}
+
+static inline void backlight_off(pin_t backlight_pin) {
+#if BACKLIGHT_ON_STATE == 0
+ writePinHigh(backlight_pin);
+#else
+ writePinLow(backlight_pin);
+#endif
+}
+
+void backlight_pins_init(void) {
+ // Setup backlight pin as output and output to off state.
+ FOR_EACH_LED(setPinOutput(backlight_pin); backlight_off(backlight_pin);)
+}
+
+void backlight_pins_on(void) { FOR_EACH_LED(backlight_on(backlight_pin);) }
+
+void backlight_pins_off(void) { FOR_EACH_LED(backlight_off(backlight_pin);) }
diff --git a/quantum/backlight/backlight_driver_common.h b/quantum/backlight/backlight_driver_common.h
new file mode 100644
index 0000000000..36e8a5fa6b
--- /dev/null
+++ b/quantum/backlight/backlight_driver_common.h
@@ -0,0 +1,7 @@
+#pragma once
+
+void backlight_pins_init(void);
+void backlight_pins_on(void);
+void backlight_pins_off(void);
+
+void breathing_task(void);
diff --git a/quantum/backlight/backlight_soft.c b/quantum/backlight/backlight_software.c
index 8552384a42..709304f559 100644
--- a/quantum/backlight/backlight_soft.c
+++ b/quantum/backlight/backlight_software.c
@@ -1,9 +1,6 @@
#include "quantum.h"
#include "backlight.h"
-
-#if !defined(BACKLIGHT_PIN) && !defined(BACKLIGHT_PINS)
-# error "Backlight pin/pins not defined. Please configure."
-#endif
+#include "backlight_driver_common.h"
#ifdef BACKLIGHT_BREATHING
# error "Backlight breathing is not available for software PWM. Please disable."