Commit bacfe8b8 authored by Paul Sokolovsky's avatar Paul Sokolovsky

cmd-keypad: Exit also on key press on serial/USB connection.

"keypad" command so far assumes rather adhoc keyboard map, and effectively
locks up otherwise. Allow to break out of it from host connection.
parent a02ae82f
......@@ -59,9 +59,9 @@ int cmd_keypad(int argc, char **argv)
int end = 0;
uint32_t key_state[18] = {0};
printf("Press %c on keypad to exit\n",
printf("Press %c on keypad or any key on serial to exit\n",
key_vals[ARRAY_SIZE(key_vals) - 2]);
while (!end) {
while (!end && !serial_available()) {
int key;
for (key = 0; key < (ARRAY_SIZE(key_vals) - 1); key++) {
......
......@@ -9,6 +9,7 @@ void serial_puth(uint32_t hex, int digits); /* Put hex */
void serial_write(const void *d, int bytes);
uint8_t serial_getc(void);
int serial_available(void);
int serial_print_hex(const void *bfr, int count);
int serial_read(void *data, int bytes);
......
......@@ -100,6 +100,12 @@ uint8_t serial_getc(void)
return uart_getreg(UART_RBR);
}
/* Return true if there's pending received char */
int serial_available(void)
{
return uart_getreg(UART_LSR) & 0x01;
}
int serial_puts(const void *s)
{
const char *str = s;
......@@ -279,6 +285,12 @@ uint8_t serial_getc(void)
return recv_bfr[recv_offset++];
}
int serial_available(void)
{
usb_handle_irqs(1);
return recv_size != 0;
}
int serial_puts(const void *s)
{
const char *str = s;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment