]>
git.gir.st - tmk_keyboard.git/blob - pjrc/usb_extra.c
1 #include <util/delay.h>
2 #include <avr/interrupt.h>
7 int8_t usb_extra_send(uint8_t report_id
, uint16_t data
)
9 uint8_t intr_state
, timeout
;
11 if (!usb_configured()) return -1;
14 UENUM
= EXTRA_ENDPOINT
;
15 timeout
= UDFNUML
+ 50;
17 // are we ready to transmit?
18 if (UEINTX
& (1<<RWAL
)) break;
20 // has the USB gone offline?
21 if (!usb_configured()) return -1;
22 // have we waited too long?
23 if (UDFNUML
== timeout
) return -1;
24 // get ready to try checking again
27 UENUM
= EXTRA_ENDPOINT
;
32 UEDATX
= (data
>>8)&0xFF;
39 int8_t usb_extra_consumer_send(uint16_t bits
)
41 return usb_extra_send(REPORT_ID_CONSUMER
, bits
);
44 int8_t usb_extra_system_send(uint16_t bits
)
46 return usb_extra_send(REPORT_ID_SYSTEM
, bits
);