summaryrefslogtreecommitdiffstats
path: root/keyboards/cluepad/cluepad.c
diff options
context:
space:
mode:
authorDidier Loiseau <didierloiseau+git@gmail.com>2016-09-11 01:26:47 +0200
committerDidier Loiseau <didierloiseau+git@gmail.com>2016-09-11 01:26:47 +0200
commitb9014c757599ca288be07629ad1d00ef66c033f1 (patch)
treeba056e704e76327c597e25d1be200c4c991efeb8 /keyboards/cluepad/cluepad.c
parent60a826923d5a6b0dbe416b0837608149ab82e470 (diff)
parent5010df3d8b68a53c382b853c7c2e45922975b631 (diff)
downloadqmk_firmware-b9014c757599ca288be07629ad1d00ef66c033f1.tar.gz
qmk_firmware-b9014c757599ca288be07629ad1d00ef66c033f1.tar.xz
Merge remote-tracking branch 'remotes/jackhumbert/master' into bépo
Diffstat (limited to 'keyboards/cluepad/cluepad.c')
-rw-r--r--keyboards/cluepad/cluepad.c60
1 files changed, 60 insertions, 0 deletions
diff --git a/keyboards/cluepad/cluepad.c b/keyboards/cluepad/cluepad.c
new file mode 100644
index 000000000..1867b617f
--- /dev/null
+++ b/keyboards/cluepad/cluepad.c
@@ -0,0 +1,60 @@
+#include "cluepad.h"
+
+int pwm_level;
+
+void matrix_init_kb(void) {
+ // put your keyboard start-up code here
+ // runs once when the firmware starts up
+ matrix_init_user();
+
+ // JTAG disable for PORT F. write JTD bit twice within four cycles.
+ MCUCR |= (1<<JTD);
+ MCUCR |= (1<<JTD);
+};
+
+void led_set_kb(uint8_t usb_led)
+{
+ print("led_set\n");
+}
+
+void backlight_init_ports(void)
+{
+ // Set C7 to output
+ DDRC |= (1<<7);
+
+ // Initialize the timer
+ TC4H = 0x03;
+ OCR4C = 0xFF;
+ TCCR4A = 0b10000010;
+ TCCR4B = 0b00000001;
+}
+
+void backlight_set(uint8_t level)
+{
+ // Determine the PWM level
+ switch (level)
+ {
+ case 0:
+ // 33%
+ pwm_level = 0x54;
+ break;
+ case 1:
+ // 66%
+ pwm_level = 0xA8;
+ break;
+ case 2:
+ // 100%
+ pwm_level = 0xFF;
+ break;
+ case 3:
+ // 0%
+ pwm_level = 0x00;
+ break;
+ default:
+ xprintf("Unknown level: %d\n", level);
+ }
+
+ // Write the PWM level to the timer
+ TC4H = pwm_level >> 8;
+ OCR4A = 0xFF & pwm_level;
+}