forked from vogelchr/avr_cobalt_panel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcobalt_leds.c
42 lines (33 loc) · 1.34 KB
/
cobalt_leds.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/* ----------------------------------------------------------------------------
This file is part of avr_cobalt_panel.
(c) 2012 Christian Vogel <[email protected]>
avr_cobalt_panel is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
avr_cobalt_panel is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
For a copy of the GNU General Public License see http://www.gnu.org/licenses/.
---------------------------------------------------------------------------- */
#include "cobalt_leds.h"
#include <stdio.h>
#include <avr/io.h>
#include <avr/interrupt.h>
void cobalt_leds_init(){
cli();
DDRB |= 0x07; /* PB0 = Web, PB1 = Disk, PB2 = Logo */
DDRD |= 0x3c; /* PD2..PD5 */
sei();
cobalt_leds_set(0);
}
void cobalt_leds_set(uint8_t leds){
leds ^= (COBALT_LED_DISK | COBALT_LED_NET | COBALT_LED_LOGO );
cli();
/* Web, Disk, Logo on portb, not inverted */
PORTB = (PORTB & ~ 0x07) | ( leds & 0x07);
/* upper 4 bits leds correspond to bits D2..D5 */
PORTD = (PORTD & ~ 0x3c) | ( 0x3c & (leds >> 2) );
sei();
}