aboutsummaryrefslogtreecommitdiff
path: root/keyboards/clueboard/17/17.c
diff options
context:
space:
mode:
Diffstat (limited to 'keyboards/clueboard/17/17.c')
-rw-r--r--keyboards/clueboard/17/17.c43
1 files changed, 43 insertions, 0 deletions
diff --git a/keyboards/clueboard/17/17.c b/keyboards/clueboard/17/17.c
new file mode 100644
index 000000000..44b55a323
--- /dev/null
+++ b/keyboards/clueboard/17/17.c
@@ -0,0 +1,43 @@
1#include "17.h"
2
3int pwm_level;
4
5void backlight_init_ports(void) {
6 // Set C7 to output
7 DDRC |= (1<<7);
8
9 // Initialize the timer
10 TC4H = 0x03;
11 OCR4C = 0xFF;
12 TCCR4A = 0b10000010;
13 TCCR4B = 0b00000001;
14}
15
16void backlight_set(uint8_t level) {
17 // Determine the PWM level
18 switch (level)
19 {
20 case 0:
21 // 33%
22 pwm_level = 0x54;
23 break;
24 case 1:
25 // 66%
26 pwm_level = 0xA8;
27 break;
28 case 2:
29 // 100%
30 pwm_level = 0xFF;
31 break;
32 case 3:
33 // 0%
34 pwm_level = 0x00;
35 break;
36 default:
37 xprintf("Unknown level: %d\n", level);
38 }
39
40 // Write the PWM level to the timer
41 TC4H = pwm_level >> 8;
42 OCR4A = 0xFF & pwm_level;
43}