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.c60
1 files changed, 60 insertions, 0 deletions
diff --git a/keyboards/clueboard/17/17.c b/keyboards/clueboard/17/17.c
new file mode 100644
index 000000000..f84e3253e
--- /dev/null
+++ b/keyboards/clueboard/17/17.c
@@ -0,0 +1,60 @@
1#include "17.h"
2
3int pwm_level;
4
5void matrix_init_kb(void) {
6 // put your keyboard start-up code here
7 // runs once when the firmware starts up
8 matrix_init_user();
9
10 // JTAG disable for PORT F. write JTD bit twice within four cycles.
11 MCUCR |= (1<<JTD);
12 MCUCR |= (1<<JTD);
13};
14
15void led_set_kb(uint8_t usb_led)
16{
17 print("led_set\n");
18}
19
20void backlight_init_ports(void)
21{
22 // Set C7 to output
23 DDRC |= (1<<7);
24
25 // Initialize the timer
26 TC4H = 0x03;
27 OCR4C = 0xFF;
28 TCCR4A = 0b10000010;
29 TCCR4B = 0b00000001;
30}
31
32void backlight_set(uint8_t level)
33{
34 // Determine the PWM level
35 switch (level)
36 {
37 case 0:
38 // 33%
39 pwm_level = 0x54;
40 break;
41 case 1:
42 // 66%
43 pwm_level = 0xA8;
44 break;
45 case 2:
46 // 100%
47 pwm_level = 0xFF;
48 break;
49 case 3:
50 // 0%
51 pwm_level = 0x00;
52 break;
53 default:
54 xprintf("Unknown level: %d\n", level);
55 }
56
57 // Write the PWM level to the timer
58 TC4H = pwm_level >> 8;
59 OCR4A = 0xFF & pwm_level;
60}