/** * @brief Notification of data removed from the input queue. */ static void inotify(GenericQueue *qp) { size_t n, maxsize; BulkUSBDriver *bdup = chQGetLink(qp); /* If the USB driver is not in the appropriate state then transactions must not be started.*/ if ((usbGetDriverStateI(bdup->config->usbp) != USB_ACTIVE) || (bdup->state != BDU_READY)) return; /* If there is in the queue enough space to hold at least one packet and a transaction is not yet started then a new transaction is started for the available space.*/ maxsize = bdup->config->usbp->epc[bdup->config->bulk_out]->out_maxsize; if (!usbGetReceiveStatusI(bdup->config->usbp, bdup->config->bulk_out) && ((n = chIQGetEmptyI(&bdup->iqueue)) >= maxsize)) { chSysUnlock(); n = (n / maxsize) * maxsize; usbPrepareQueuedReceive(bdup->config->usbp, bdup->config->bulk_out, &bdup->iqueue, n); chSysLock(); usbStartReceiveI(bdup->config->usbp, bdup->config->bulk_out); } }
/** * @brief Notification of data removed from the input queue. */ static void inotify(GenericQueue *qp) { size_t n, maxsize; SerialUSBDriver *sdup = chQGetLink(qp); /* If the USB driver is not in the appropriate state then transactions must not be started.*/ if (usbGetDriverStateI(sdup->config->usbp) != USB_ACTIVE) return; /* If there is in the queue enough space to hold at least one packet and a transaction is not yet started then a new transaction is started for the available space.*/ maxsize = sdup->config->usbp->epc[USB_CDC_DATA_AVAILABLE_EP]->out_maxsize; if (!usbGetReceiveStatusI(sdup->config->usbp, USB_CDC_DATA_AVAILABLE_EP) && ((n = chIQGetEmptyI(&sdup->iqueue)) >= maxsize)) { chSysUnlock(); n = (n / maxsize) * maxsize; usbPrepareQueuedReceive(sdup->config->usbp, USB_CDC_DATA_AVAILABLE_EP, &sdup->iqueue, n); chSysLock(); usbStartReceiveI(sdup->config->usbp, USB_CDC_DATA_AVAILABLE_EP); } }
/** * @brief Notification of data inserted into the output queue. */ static void onotify(GenericQueue *qp) { size_t n; SerialUSBDriver *sdup = chQGetLink(qp); /* If the USB driver is not in the appropriate state then transactions must not be started.*/ if (usbGetDriverStateI(sdup->config->usbp) != USB_ACTIVE) return; /* If there is not an ongoing transaction and the output queue contains data then a new transaction is started.*/ if (!usbGetTransmitStatusI(sdup->config->usbp, USB_CDC_DATA_REQUEST_EP) && ((n = chOQGetFullI(&sdup->oqueue)) > 0)) { chSysUnlock(); usbPrepareQueuedTransmit(sdup->config->usbp, USB_CDC_DATA_REQUEST_EP, &sdup->oqueue, n); chSysLock(); usbStartTransmitI(sdup->config->usbp, USB_CDC_DATA_REQUEST_EP); } }
/** * @brief Notification of data inserted into the output queue. */ static void onotify(GenericQueue *qp) { size_t n; BulkUSBDriver *bdup = chQGetLink(qp); /* If the USB driver is not in the appropriate state then transactions must not be started.*/ if ((usbGetDriverStateI(bdup->config->usbp) != USB_ACTIVE) || (bdup->state != BDU_READY)) return; /* If there is not an ongoing transaction and the output queue contains data then a new transaction is started.*/ if (!usbGetTransmitStatusI(bdup->config->usbp, bdup->config->bulk_in) && ((n = chOQGetFullI(&bdup->oqueue)) > 0)) { chSysUnlock(); usbPrepareQueuedTransmit(bdup->config->usbp, bdup->config->bulk_in, &bdup->oqueue, n); chSysLock(); usbStartTransmitI(bdup->config->usbp, bdup->config->bulk_in); } }