From 649b33d7783cf3021928534b7ae127e0a89e8807 Mon Sep 17 00:00:00 2001 From: Jack Humbert Date: Tue, 21 Jun 2016 22:39:54 -0400 Subject: Renames keyboard folder to keyboards, adds couple of tmk's fixes (#432) * fixes from tmk's repo * rename keyboard to keyboards --- keyboards/cluepad/backlight.c | 54 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 keyboards/cluepad/backlight.c (limited to 'keyboards/cluepad/backlight.c') diff --git a/keyboards/cluepad/backlight.c b/keyboards/cluepad/backlight.c new file mode 100644 index 000000000..a9caed1df --- /dev/null +++ b/keyboards/cluepad/backlight.c @@ -0,0 +1,54 @@ +#include +#include "backlight.h" +#include "led.h" + +#include "print.h" + +int pwm_level; + +void led_set_kb(uint8_t usb_led) +{ + print("led_set\n"); +} + +void init_backlight_pin(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; +} -- cgit v1.2.3-24-g4f1b