-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathled.c
More file actions
40 lines (37 loc) · 1.02 KB
/
led.c
File metadata and controls
40 lines (37 loc) · 1.02 KB
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
#include "led.h"
// led control codes can be found in led.h
uint8_t get_led_state(void) {
uint32_t read_val;
read_hps_reg("led0",&read_val);
switch(read_val)
{
case 0x00070003:
return LED_STATE_INIT;
case 0x1:
return LED_STATE_READY;
case 0x8000a:
return LED_STATE_ERROR;
default:
PRINT(ERROR,"LED_STATE_UNKNOWN\n");
return LED_STATE_UNKNOWN;
}
}
void set_led_state(uint8_t state) {
switch(state)
{
case LED_STATE_INIT:
write_hps_reg("led1", 0x1); // Solid green
write_hps_reg("led0", 0x00070003); // Flashing green
break;
case LED_STATE_READY:
write_hps_reg("led1", 0x1);
write_hps_reg("led0", 0x1);
break;
case LED_STATE_ERROR:
write_hps_reg("led1", 0x1);
write_hps_reg("led0", 0x8000a);
break;
default:
PRINT(ERROR,"invalid arg for set_led_state()\n");
}
}