summaryrefslogtreecommitdiff
path: root/color.c
blob: 980697948f5df11cc4a7a07a865b81ec7ed8b05d (plain)
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
43
44
#include "color.h"
#include <stdint.h>


void set_color(uint8_t color) {
	switch (color) {
		case RED:
      GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3, 0x2);
			break;
		case BLUE:
      GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3, 0x4);
			break;
		case GREEN:
      GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3, 0x8);
			break;
		case YELLOW:
      GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3, 0xA);
			break;
		case WHITE:
      GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3, 0xe);
			break;
	}
}

void toggle_color(uint8_t color) {
	switch (color) {
		case RED:
      GPIO_PORTF_DATA_R ^= LED_RED;
			break;
		case BLUE:
      GPIO_PORTF_DATA_R ^= LED_BLUE;
			break;
		case GREEN:
      GPIO_PORTF_DATA_R ^= LED_GREEN;
			break;
		case WHITE:
      GPIO_PORTF_DATA_R ^= (LED_RED | LED_BLUE | LED_GREEN);
			break;
	}
}

void reset_color() {
	PORTF &= 0x11;
}