From cd568297a41e5a6f2e130de82c07b6b789d34f4b Mon Sep 17 00:00:00 2001 From: root Date: Sat, 13 Jun 2015 13:08:23 +0100 Subject: add usb wakeup support, all keys up on bad data, and resend for parity errors --- app/consumer.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'app/consumer.c') diff --git a/app/consumer.c b/app/consumer.c index 79d25bb..b1b6290 100644 --- a/app/consumer.c +++ b/app/consumer.c @@ -99,13 +99,15 @@ consumer_send (uint16_t keys) /*Last byte is the power wakeup stuff that we don't yet support */ uint8_t buf[CONSUMER_EP_TXN_SIZE] = { keys & 0xff, keys >> 8 }; - usbd_ep_write_packet (usbd_dev, CONSUMER_EP, buf, sizeof (buf)); + if (!usb_is_suspended) + usbd_ep_write_packet (usbd_dev, CONSUMER_EP, buf, sizeof (buf)); } +static uint16_t keys; + void consumer_dispatch (int bit, int updown) { - static uint16_t keys; if (updown) keys |= bit; @@ -117,7 +119,14 @@ consumer_dispatch (int bit, int updown) printf ("CNS> %02x %02x\r\n", keys & 0xff, keys >> 8); #endif - consumer_send (keys); + usb_wakeup_host(); + consumer_send (keys); +} +void +consumer_error (void) +{ + keys = 0; + consumer_send (keys); } -- cgit v1.2.3