aboutsummaryrefslogtreecommitdiff
path: root/keyboard/kmac/backlight.c
diff options
context:
space:
mode:
authorWraul <wraul@dbox.se>2013-05-30 20:25:39 +0200
committertmk <nobody@nowhere>2013-06-22 17:23:37 +0900
commit43e5ca60af373cd0612a0ff51dccd7d784c4a6dd (patch)
treef5306eef68d21cf26dd190c914b522fb7df9fc52 /keyboard/kmac/backlight.c
parent1eb8523e9506c752fb726208d8853a82f06e6659 (diff)
downloadqmk_firmware-43e5ca60af373cd0612a0ff51dccd7d784c4a6dd.tar.gz
qmk_firmware-43e5ca60af373cd0612a0ff51dccd7d784c4a6dd.zip
Initial implementation for the KMAC
Diffstat (limited to 'keyboard/kmac/backlight.c')
-rw-r--r--keyboard/kmac/backlight.c58
1 files changed, 58 insertions, 0 deletions
diff --git a/keyboard/kmac/backlight.c b/keyboard/kmac/backlight.c
new file mode 100644
index 000000000..af38f658a
--- /dev/null
+++ b/keyboard/kmac/backlight.c
@@ -0,0 +1,58 @@
1/*
2Copyright 2013 Mathias Andersson <wraul@dbox.se>
3
4This program is free software: you can redistribute it and/or modify
5it under the terms of the GNU General Public License as published by
6the Free Software Foundation, either version 2 of the License, or
7(at your option) any later version.
8
9This program is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12GNU General Public License for more details.
13
14You should have received a copy of the GNU General Public License
15along with this program. If not, see <http://www.gnu.org/licenses/>.
16*/
17
18#include <avr/io.h>
19#include "backlight.h"
20
21/* Backlight pin configuration
22 * F-row: High PB1
23 * W: Low PB4
24 * A: Low PB2
25 * S: Low PB3
26 * D: Low PD7
27 */
28void backlight_set(uint8_t level)
29{
30 // Set as output.
31 DDRB |= (1<<1) | (1<<2) | (1<<3) | (1<<4);
32 DDRD |= (1<<7);
33
34 // F-row
35 if(level & (1<<0))
36 {
37 PORTB |= (1<<1);
38 }
39 else
40 {
41 PORTB &= ~(1<<1);
42 }
43 // WASD
44 if(level & (1<<1))
45 {
46 PORTB &= ~(1<<4);
47 PORTB &= ~(1<<2);
48 PORTB &= ~(1<<3);
49 PORTD &= ~(1<<7);
50 }
51 else
52 {
53 PORTB |= (1<<4);
54 PORTB |= (1<<2);
55 PORTB |= (1<<3);
56 PORTD |= (1<<7);
57 }
58}