forked from mirrors/qmk_firmware
Loop based vusb_transfer_keyboard
This commit is contained in:
parent
8a27703ef4
commit
095b28e006
1 changed files with 16 additions and 11 deletions
|
@ -27,6 +27,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#include "host_driver.h"
|
#include "host_driver.h"
|
||||||
#include "vusb.h"
|
#include "vusb.h"
|
||||||
#include "bootloader.h"
|
#include "bootloader.h"
|
||||||
|
#include <util/delay.h>
|
||||||
|
|
||||||
|
|
||||||
static uint8_t vusb_keyboard_leds = 0;
|
static uint8_t vusb_keyboard_leds = 0;
|
||||||
|
@ -46,22 +47,26 @@ typedef struct {
|
||||||
|
|
||||||
static keyboard_report_t keyboard_report; // sent to PC
|
static keyboard_report_t keyboard_report; // sent to PC
|
||||||
|
|
||||||
|
#define VUSB_TRANSFER_KEYBOARD_MAX_TRIES 10
|
||||||
|
|
||||||
/* transfer keyboard report from buffer */
|
/* transfer keyboard report from buffer */
|
||||||
void vusb_transfer_keyboard(void)
|
void vusb_transfer_keyboard(void)
|
||||||
{
|
{
|
||||||
if (usbInterruptIsReady()) {
|
for (int i = 0; i < VUSB_TRANSFER_KEYBOARD_MAX_TRIES; i++) {
|
||||||
if (kbuf_head != kbuf_tail) {
|
if (usbInterruptIsReady()) {
|
||||||
usbSetInterrupt((void *)&kbuf[kbuf_tail], sizeof(report_keyboard_t));
|
if (kbuf_head != kbuf_tail) {
|
||||||
kbuf_tail = (kbuf_tail + 1) % KBUF_SIZE;
|
usbSetInterrupt((void *)&kbuf[kbuf_tail], sizeof(report_keyboard_t));
|
||||||
if (debug_keyboard) {
|
kbuf_tail = (kbuf_tail + 1) % KBUF_SIZE;
|
||||||
print("V-USB: kbuf["); pdec(kbuf_tail); print("->"); pdec(kbuf_head); print("](");
|
if (debug_keyboard) {
|
||||||
phex((kbuf_head < kbuf_tail) ? (KBUF_SIZE - kbuf_tail + kbuf_head) : (kbuf_head - kbuf_tail));
|
print("V-USB: kbuf["); pdec(kbuf_tail); print("->"); pdec(kbuf_head); print("](");
|
||||||
print(")\n");
|
phex((kbuf_head < kbuf_tail) ? (KBUF_SIZE - kbuf_tail + kbuf_head) : (kbuf_head - kbuf_tail));
|
||||||
|
print(")\n");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
usbPoll();
|
||||||
usbPoll();
|
_delay_ms(1);
|
||||||
vusb_transfer_keyboard();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue