From 43443ee9ba206b0963c49123bd03c250ed8e7b26 Mon Sep 17 00:00:00 2001 From: root Date: Sun, 7 Jun 2015 01:33:33 +0100 Subject: finished! --- app/consumer.c | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) (limited to 'app/consumer.c') diff --git a/app/consumer.c b/app/consumer.c index 044c15b..c61c4cc 100644 --- a/app/consumer.c +++ b/app/consumer.c @@ -58,7 +58,7 @@ static const struct const struct usb_endpoint_descriptor consumer_endpoint = { .bLength = USB_DT_ENDPOINT_SIZE, .bDescriptorType = USB_DT_ENDPOINT, - .bEndpointAddress = 0x82, + .bEndpointAddress = CONSUMER_EP, .bmAttributes = USB_ENDPOINT_ATTR_INTERRUPT, .wMaxPacketSize = 2, .bInterval = 0x1 //0x20, @@ -91,3 +91,34 @@ consumer_get_descriptor (uint8_t ** buf, uint16_t * len) *len = sizeof (consumer_report_descriptor); } + + +static void +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)); +} + +void consumer_dispatch(int bit,int updown) +{ +static uint16_t keys; + +if (updown) + keys|=bit; +else + keys &= ~bit; + + +#ifdef DEBUG +printf("CNS> %02x %02x\r\n",keys & 0xff, keys >>8 ); +#endif + +consumer_send(keys); + + +} + + -- cgit v1.2.3