forked from srnilssen/Arduino-Robot-2018
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLED.c
40 lines (33 loc) · 1.23 KB
/
LED.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
/************************************************************************/
// File: LED.c
// Author: Erlend Ese, NTNU Spring 2016
// Purpose: For debugging and status identification
//
// Port and pins defined in defines.h file
/************************************************************************/
/* AVR includes */
#include <avr/io.h>
/* Custom includes */
#include "LED.h"
/* Initialize LEDport pins as output */
void vLED_init(){
ledReg |= (1<<ledGREEN) | (1<<ledYELLOW) | (1<<ledRED);
}
/* Set a specific, single LED high */
void vLED_singleHigh(int ledCOLOR){
if (ledCOLOR == ledGREEN) ledPORT |= (1<<ledGREEN);
else if (ledCOLOR == ledYELLOW) ledPORT |= (1<<ledYELLOW);
else if (ledCOLOR == ledRED) ledPORT |= (1<<ledRED);
}
/* Set a specific, single LED low */
void vLED_singleLow(int ledCOLOR){
if (ledCOLOR == ledGREEN) ledPORT &= ~(1<<ledGREEN);
else if (ledCOLOR == ledYELLOW) ledPORT &= ~(1<<ledYELLOW);
else if (ledCOLOR == ledRED) ledPORT &= ~(1<<ledRED);
}
/* Toggle a single LED */
void vLED_toggle(int ledCOLOR){
if (ledCOLOR == ledGREEN) ledPORT ^= (1<<ledGREEN);
else if (ledCOLOR == ledYELLOW) ledPORT ^= (1<<ledYELLOW);
else if (ledCOLOR == ledRED) ledPORT ^= (1<<ledRED);
}