qleds.c
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #include "contiki.h"
00033
00034 #include "dev/leds.h"
00035
00036 #include <avr/io.h>
00037
00038 void
00039 leds_init(void)
00040 {
00041 #ifdef CB_GATEWAY
00042 DDRE |= LEDS_CONF_GREEN | LEDS_CONF_YELLOW;
00043 PORTE |= LEDS_CONF_GREEN | LEDS_CONF_YELLOW;
00044 #else
00045 DDRB |= LEDS_CONF_ORANGE | LEDS_CONF_GREEN;
00046 DDRE |= LEDS_CONF_RED | LEDS_CONF_YELLOW;
00047
00048 PORTB &= ~(LEDS_CONF_ORANGE | LEDS_CONF_GREEN);
00049 PORTE &= ~(LEDS_CONF_RED | LEDS_CONF_YELLOW);
00050 #endif
00051 }
00052
00053 void
00054 leds_on(unsigned char leds)
00055 {
00056 #ifdef CB_GATEWAY
00057 if (leds & LEDS_GREEN)
00058 PORTE &= ~LEDS_CONF_GREEN;
00059 if (leds & LEDS_YELLOW)
00060 PORTE &= ~LEDS_CONF_YELLOW;
00061 #else
00062 if (leds & LEDS_ORANGE)
00063 PORTB |= LEDS_CONF_ORANGE;
00064 if (leds & LEDS_GREEN)
00065 PORTB |= LEDS_CONF_GREEN;
00066
00067 if (leds & LEDS_RED)
00068 PORTE |= LEDS_CONF_RED;
00069 if (leds & LEDS_YELLOW)
00070 PORTE |= LEDS_CONF_YELLOW;
00071 #endif
00072 }
00073
00074 void
00075 leds_off(unsigned char leds)
00076 {
00077 #ifdef CB_GATEWAY
00078 if (leds & LEDS_GREEN)
00079 PORTE |= LEDS_CONF_GREEN;
00080 if (leds & LEDS_YELLOW)
00081 PORTE |= LEDS_CONF_YELLOW;
00082 #else
00083 if (leds & LEDS_ORANGE)
00084 PORTB &= ~LEDS_CONF_ORANGE;
00085 if (leds & LEDS_GREEN)
00086 PORTB &= ~LEDS_CONF_GREEN;
00087
00088 if (leds & LEDS_RED)
00089 PORTE &= ~LEDS_CONF_RED;
00090 if (leds & LEDS_YELLOW)
00091 PORTE &= ~LEDS_CONF_YELLOW;
00092 #endif
00093 }
00094
00095 void
00096 leds_toggle(unsigned char leds)
00097 {
00098
00099
00100
00101 asm(".global leds_invert\nleds_invert:\n");
00102
00103 #ifdef CB_GATEWAY
00104 if (leds & LEDS_GREEN)
00105 PORTE ^= ~LEDS_CONF_GREEN;
00106 if (leds & LEDS_YELLOW)
00107 PORTE ^= ~LEDS_CONF_YELLOW;
00108 #else
00109 if (leds & LEDS_ORANGE)
00110 PORTB ^= LEDS_CONF_ORANGE;
00111 if (leds & LEDS_GREEN)
00112 PORTB ^= LEDS_CONF_GREEN;
00113
00114 if (leds & LEDS_RED)
00115 PORTE ^= LEDS_CONF_RED;
00116 if (leds & LEDS_YELLOW)
00117 PORTE ^= LEDS_CONF_YELLOW;
00118 #endif
00119 }