aboutsummaryrefslogtreecommitdiff
path: root/keyboard/retro_refit/retro_refit.c
diff options
context:
space:
mode:
Diffstat (limited to 'keyboard/retro_refit/retro_refit.c')
-rw-r--r--keyboard/retro_refit/retro_refit.c80
1 files changed, 80 insertions, 0 deletions
diff --git a/keyboard/retro_refit/retro_refit.c b/keyboard/retro_refit/retro_refit.c
new file mode 100644
index 000000000..e01b8956a
--- /dev/null
+++ b/keyboard/retro_refit/retro_refit.c
@@ -0,0 +1,80 @@
1#include "retro_refit.h"
2
3__attribute__ ((weak))
4void * matrix_init_user(void) {
5 // leave this function blank - it can be defined in a keymap file
6 return NULL;
7};
8
9__attribute__ ((weak))
10void * matrix_scan_user(void) {
11 // leave this function blank - it can be defined in a keymap file
12 return NULL;
13};
14
15__attribute__ ((weak))
16void * led_set_user(uint8_t usb_led) {
17 // leave this function blank - it can be defined in a keymap file
18 return NULL;
19};
20
21void * matrix_init_kb(void) {
22 // put your keyboard start-up code here
23 // runs once when the firmware starts up
24
25 // Disable status LED on KB, enable status LED on Teensy (KB_STATUS = !TEENSY_STATUS)
26 DDRD |= (1<<6);
27 PORTD |= (1<<6);
28
29 if (matrix_init_user) {
30 (*matrix_init_user)();
31 }
32 return NULL;
33};
34
35void * matrix_scan_kb(void) {
36 // put your looping keyboard code here
37 // runs every cycle (a lot)
38
39 if (matrix_scan_user) {
40 (*matrix_scan_user)();
41 }
42 return NULL;
43};
44
45void * led_set_kb(uint8_t usb_led) {
46 // put your keyboard LED indicator (ex: Caps Lock LED) toggling code here
47
48 if (usb_led & (1<<USB_LED_CAPS_LOCK)) {
49 // output low
50 DDRD |= (1<<0);
51 PORTD &= ~(1<<0);
52 } else {
53 // Hi-Z
54 DDRD &= ~(1<<0);
55 PORTD &= ~(1<<0);
56 }
57 if (usb_led & (1<<USB_LED_NUM_LOCK)) {
58 // output low
59 DDRD |= (1<<1);
60 PORTD &= ~(1<<1);
61 } else {
62 // Hi-Z
63 DDRD &= ~(1<<1);
64 PORTD &= ~(1<<1);
65 }
66 if (usb_led & (1<<USB_LED_SCROLL_LOCK)) {
67 // output low
68 DDRC |= (1<<6);
69 PORTC &= ~(1<<6);
70 } else {
71 // Hi-Z
72 DDRC &= ~(1<<6);
73 PORTC &= ~(1<<6);
74 }
75
76 if (led_set_user) {
77 (*led_set_user)(usb_led);
78 }
79 return NULL;
80}; \ No newline at end of file