]> git.donarmstrong.com Git - qmk_firmware.git/blob - keyboards/clueboard_66/rev3/rev3.c
Clueboard 60% support (#1746)
[qmk_firmware.git] / keyboards / clueboard_66 / rev3 / rev3.c
1 #include "rev3.h"
2 #include <avr/io.h>
3 #include "backlight.h"
4 #include "print.h"
5
6 void matrix_init_kb(void) {
7         // put your keyboard start-up code here
8         // runs once when the firmware starts up
9         matrix_init_user();
10         led_init_ports();
11
12     // JTAG disable for PORT F. write JTD bit twice within four cycles.
13     MCUCR |= (1<<JTD);
14     MCUCR |= (1<<JTD);
15 }
16
17
18 void matrix_scan_kb(void) {
19     matrix_scan_user();
20 }
21
22 void backlight_init_ports(void) {
23     print("init_backlight_pin()\n");
24     // Set our LED pins as output
25     DDRD |= (1<<6); // Esc
26     DDRB |= (1<<7); // Page Up
27     DDRD |= (1<<4); // Arrows
28
29     // Set our LED pins low
30     PORTD &= ~(1<<6); // Esc
31     PORTB &= ~(1<<7); // Page Up
32     PORTD &= ~(1<<4); // Arrows
33 }
34
35 void backlight_set(uint8_t level) {
36     if ( level == 0 ) {
37         // Turn off light
38         PORTD |= (1<<6); // Esc
39         PORTB |= (1<<7); // Page Up
40         PORTD |= (1<<4); // Arrows
41     } else {
42         // Turn on light
43         PORTD &= ~(1<<6); // Esc
44         PORTB &= ~(1<<7); // Page Up
45         PORTD &= ~(1<<4); // Arrows
46     }
47 }
48
49 void led_init_ports() {
50     // * Set our LED pins as output
51     DDRB |= (1<<4);
52 }
53
54 void led_set_kb(uint8_t usb_led) {
55     DDRB |= (1<<4);
56     if (usb_led & (1<<USB_LED_CAPS_LOCK)) {
57         // Turn capslock on
58         PORTB |= (1<<4);
59     } else {
60         // Turn capslock off
61         PORTB &= ~(1<<4);
62     }
63 }