Merge pull request #1481 from mjrgh/patch-2

Fix interrupt handler for endpoints > 2
pull/1503/head
Martin Kojtal 2016-01-15 07:41:28 +00:00
commit 0b57f8a29a
1 changed files with 7 additions and 6 deletions

View File

@ -491,6 +491,7 @@ void USBHAL::usbisr(void) {
uint32_t num = (USB0->STAT >> 4) & 0x0F;
uint32_t dir = (USB0->STAT >> 3) & 0x01;
uint32_t ev_odd = (USB0->STAT >> 2) & 0x01;
int endpoint = (num << 1) | dir;
// setup packet
if ((num == 0) && (TOK_PID((EP_BDT_IDX(num, dir, ev_odd))) == SETUP_TOKEN)) {
@ -507,9 +508,9 @@ void USBHAL::usbisr(void) {
if (num == 0)
EP0out();
else {
epComplete |= (1 << EP(num));
if ((instance->*(epCallback[EP(num) - 2]))()) {
epComplete &= ~(1 << EP(num));
epComplete |= EP(endpoint);
if ((instance->*(epCallback[endpoint - 2]))()) {
epComplete &= ~EP(endpoint);
}
}
}
@ -524,9 +525,9 @@ void USBHAL::usbisr(void) {
}
}
else {
epComplete |= (1 << (EP(num) + 1));
if ((instance->*(epCallback[EP(num) + 1 - 2]))()) {
epComplete &= ~(1 << (EP(num) + 1));
epComplete |= EP(endpoint);
if ((instance->*(epCallback[endpoint - 2]))()) {
epComplete &= ~EP(endpoint);
}
}
}