Show mmc0 activity by DISK I/O Board LED on HPS screen.

This commit is contained in:
sorgelig
2019-06-09 18:59:21 +08:00
parent ff2eba83bc
commit a8c0573802

View File

@@ -2387,8 +2387,9 @@ static void input_cb(struct input_event *ev, struct input_absinfo *absinfo, int
}
#define CMD_FIFO "/dev/MiSTer_cmd"
#define LED_MONITOR "/sys/class/leds/hps_led0/brightness_hw_changed"
static struct pollfd pool[NUMDEV + 2];
static struct pollfd pool[NUMDEV + 3];
int input_test(int getchar)
{
@@ -2411,6 +2412,10 @@ int input_test(int getchar)
pool[NUMDEV+1].fd = open(CMD_FIFO, O_RDWR | O_NONBLOCK);
pool[NUMDEV+1].events = POLLIN;
pool[NUMDEV + 2].fd = open(LED_MONITOR, O_RDONLY);
pool[NUMDEV + 2].events = POLLPRI;
state++;
}
@@ -2625,9 +2630,18 @@ int input_test(int getchar)
state++;
}
static unsigned long led_to = 0;
if (state == 2)
{
int return_value = poll(pool, NUMDEV + 2, (is_menu_core() && video_fb_state()) ? 25 : 0);
int timeout = 0, extrapoll = 2;
if (is_menu_core() && video_fb_state())
{
timeout = 25;
if (pool[NUMDEV + 2].fd > 0) extrapoll = 3;
}
int return_value = poll(pool, NUMDEV + extrapoll, timeout);
if (return_value < 0)
{
printf("ERR: poll\n");
@@ -2998,6 +3012,27 @@ int input_test(int getchar)
else if (!strncmp(cmd, "load_core ", 10)) fpga_load_rbf(cmd + 10);
}
}
if ((pool[NUMDEV + 2].fd >= 0) && (pool[NUMDEV + 2].revents & POLLPRI))
{
//printf("revents = %x\n", pool[NUMDEV + 2].revents);
pool[NUMDEV + 2].revents = 0;
static char status[16];
int len = read(pool[NUMDEV + 2].fd, status, sizeof(status) - 1);
lseek(pool[NUMDEV + 2].fd, 0, SEEK_SET);
if (len)
{
status[len] = 0;
//printf("led: %s", status);
if (status[0] != '0' && is_menu_core() && video_fb_state())
{
//printf("led: on\n");
if (!led_to) user_io_8bit_set_status(0x80, 0x80);
led_to = GetTimer(40);
}
}
}
}
if (cur_leds != leds_state)
@@ -3025,6 +3060,13 @@ int input_test(int getchar)
}
}
if (led_to && CheckTimer(led_to))
{
//printf("led: off\n");
led_to = 0;
user_io_8bit_set_status(0, 0x80);
}
return 0;
}