]> git.gir.st - tmk_keyboard.git/blob - orphan/kmac/backlight.c
Move some projects to 'orphan' directory
[tmk_keyboard.git] / orphan / kmac / backlight.c
1 /*
2 Copyright 2013 Mathias Andersson <wraul@dbox.se>
3
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 2 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along 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 */
28 void 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 }
Imprint / Impressum