]> git.donarmstrong.com Git - qmk_firmware.git/blob - keyboards/clueboard/17/17.c
Clueboard refresh (#4902)
[qmk_firmware.git] / keyboards / clueboard / 17 / 17.c
1 #include "17.h"
2
3 int pwm_level;
4
5 void 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
15 void led_set_kb(uint8_t usb_led) {
16     print("led_set\n");
17 }
18
19 void backlight_init_ports(void) {
20     // Set C7 to output
21     DDRC |= (1<<7);
22
23     // Initialize the timer
24     TC4H = 0x03;
25     OCR4C = 0xFF;
26     TCCR4A = 0b10000010;
27     TCCR4B = 0b00000001;
28 }
29
30 void backlight_set(uint8_t level) {
31     // Determine the PWM level
32     switch (level)
33     {
34         case 0:
35             // 33%
36             pwm_level = 0x54;
37             break;
38         case 1:
39             // 66%
40             pwm_level = 0xA8;
41             break;
42         case 2:
43             // 100%
44             pwm_level = 0xFF;
45             break;
46         case 3:
47             // 0%
48             pwm_level = 0x00;
49             break;
50         default:
51             xprintf("Unknown level: %d\n", level);
52     }
53
54     // Write the PWM level to the timer
55     TC4H = pwm_level >> 8;
56     OCR4A = 0xFF & pwm_level;
57 }