diff options
| author | tmk <nobody@nowhere> | 2010-11-17 16:06:20 +0900 |
|---|---|---|
| committer | tmk <nobody@nowhere> | 2010-11-17 16:06:20 +0900 |
| commit | 02d955e9fecda610e9cb7f5317262b907614bf31 (patch) | |
| tree | 01a32f36bb17574f46c0d1848d87b0f750afdedc /usb_extra.c | |
| parent | 8240e606d4571624c7967d6acfa562d70ff3ab97 (diff) | |
| download | qmk_firmware-02d955e9fecda610e9cb7f5317262b907614bf31.tar.gz qmk_firmware-02d955e9fecda610e9cb7f5317262b907614bf31.zip | |
add audio controls from consumer page(HID)
Diffstat (limited to 'usb_extra.c')
| -rw-r--r-- | usb_extra.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/usb_extra.c b/usb_extra.c new file mode 100644 index 000000000..94c317d98 --- /dev/null +++ b/usb_extra.c | |||
| @@ -0,0 +1,33 @@ | |||
| 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 | } | ||
