]> git.gir.st - tmk_keyboard.git/blob - usb_extra.c
add audio controls from consumer page(HID)
[tmk_keyboard.git] / usb_extra.c
1 #include <avr/interrupt.h>
2 #include "usb_extra.h"
3
4 int8_t usb_extra_send(uint8_t bits)
5 {
6 uint8_t intr_state, timeout;
7
8 if (!usb_configured()) return -1;
9 intr_state = SREG;
10 cli();
11 UENUM = EXTRA_ENDPOINT;
12 timeout = UDFNUML + 50;
13 while (1) {
14 // are we ready to transmit?
15 if (UEINTX & (1<<RWAL)) break;
16 SREG = intr_state;
17 // has the USB gone offline?
18 if (!usb_configured()) return -1;
19 // have we waited too long?
20 if (UDFNUML == timeout) return -1;
21 // get ready to try checking again
22 intr_state = SREG;
23 cli();
24 UENUM = EXTRA_ENDPOINT;
25 }
26
27 UEDATX = 1; // report id
28 UEDATX = bits;
29
30 UEINTX = 0x3A;
31 SREG = intr_state;
32 return 0;
33 }
Imprint / Impressum