static char usbdev_resource_read(void *env, int *error) { if (!usb_ready) { if (error != NULL) { *error = -1; } return 0; } if (error != NULL) { *error = 0; } while (ring_buf_empty(&ep_rx.rx)) { if (task_switching && !IPSR()) { release(&usbdev_semaphore); SVC(SVC_YIELD); acquire(&usbdev_semaphore); } } char c = (char) ep_rx.rx.buf[ep_rx.rx.start]; ep_rx.rx.start = (ep_rx.rx.start + 1) % ep_rx.rx.len; return c; }
unsigned int vector_current_irq(void) { return (unsigned int)IPSR() - 16; }