- EEM class indented

This commit is contained in:
Wiesner András 2024-06-25 07:17:29 +02:00
parent f6e3d48476
commit d140d7c183

View File

@ -83,7 +83,7 @@ int usb_eem_process_and_return(USB_CallbackEvent *cbevt) {
bfifo_push(&(eems.netbFifo), cbevt->data, cbevt->size); // store portion of netbound packet bfifo_push(&(eems.netbFifo), cbevt->data, cbevt->size); // store portion of netbound packet
usb_eem_push_event(EEM_EVT_NETBOUND_PCKT_RECEIVED); // push notification usb_eem_push_event(EEM_EVT_NETBOUND_PCKT_RECEIVED); // push notification
if (bfifo_get_free(&eems.netbFifo) < EEM_PCKT_SIZE) { // don't autoarm if OUT no more packets can be stored if (bfifo_get_free(&eems.netbFifo) < EEM_PCKT_SIZE) { // don't autoarm if OUT no more packets can be stored
eems.netbAutoArm = false; eems.netbAutoArm = false;
cbevt->arm_out_endpoint = false; cbevt->arm_out_endpoint = false;
} }
@ -91,23 +91,23 @@ int usb_eem_process_and_return(USB_CallbackEvent *cbevt) {
break; break;
case USB_CBEVT_IN: case USB_CBEVT_IN:
if (cbevt->ep == eems.data_ep) { // verify endpoint number if (cbevt->ep == eems.data_ep) { // verify endpoint number
if ((eems.hostbFrame != NULL) && (eems.hostbFrameIndex < eems.hostbFrameLength)) { // if there's something in the FIFO if ((eems.hostbFrame != NULL) && (eems.hostbFrameIndex < eems.hostbFrameLength)) { // if there's something in the FIFO
uint8_t *readPtr = ((uint8_t *)eems.hostbFrame) + eems.hostbFrameIndex; // calculate read pointer uint8_t *readPtr = ((uint8_t *)eems.hostbFrame) + eems.hostbFrameIndex; // calculate read pointer
uint16_t bytesLeft = eems.hostbFrameLength - eems.hostbFrameIndex; // calculate bytes left uint16_t bytesLeft = eems.hostbFrameLength - eems.hostbFrameIndex; // calculate bytes left
uint32_t writeSize = usbcore_schedule_transmission(eems.data_ep, readPtr, bytesLeft); // attempt to schedule transmission uint32_t writeSize = usbcore_schedule_transmission(eems.data_ep, readPtr, bytesLeft); // attempt to schedule transmission
//bool enableZLP = (bytesLeft < EEM_TRANSFER_UNIT) && ((bytesLeft % EEM_PCKT_SIZE) == 0); // ZLP transmission should be enabled if this was the last write and transfer size is integer multiple of the USB packet size // bool enableZLP = (bytesLeft < EEM_TRANSFER_UNIT) && ((bytesLeft % EEM_PCKT_SIZE) == 0); // ZLP transmission should be enabled if this was the last write and transfer size is integer multiple of the USB packet size
//cbevt->enable_autozlp = enableZLP; // cbevt->enable_autozlp = enableZLP;
eems.hostbFrameIndex += writeSize; // advance frame index eems.hostbFrameIndex += writeSize; // advance frame index
//MSG("U: %u T: %u\n", writeSize, bytesLeft); // MSG("U: %u T: %u\n", writeSize, bytesLeft);
// if (eems.hostbFrameIndex >= eems.hostbFrameLength) { // if (eems.hostbFrameIndex >= eems.hostbFrameLength) {
// MSG("---\n"); // MSG("---\n");
// } // }
} else { // no data is waiting for transmission } else { // no data is waiting for transmission
//usbcore_schedule_transmission(eems.data_ep, NULL, 0); // send ZLP // usbcore_schedule_transmission(eems.data_ep, NULL, 0); // send ZLP
} }
// if FIFO is empty or flushed, then send notification // if FIFO is empty or flushed, then send notification
@ -241,7 +241,7 @@ void usb_eem_process_hostbound() {
} }
// invalidate frame // invalidate frame
USB_EemFrame * oldEemFrame = eems.hostbFrame; USB_EemFrame *oldEemFrame = eems.hostbFrame;
eems.hostbFrame = NULL; eems.hostbFrame = NULL;
// release frame // release frame
@ -300,6 +300,10 @@ void usb_eem_ethernet_intercept_cb(EthInterface *intf, const RawPckt *rawPckt) {
} }
void usb_eem_set_intf(EthInterface *intf) { void usb_eem_set_intf(EthInterface *intf) {
if (!eems.initialized) {
return;
}
eems.intf = intf; // store interface eems.intf = intf; // store interface
ethinf_set_intercept_callback(intf, usb_eem_ethernet_intercept_cb); // set intercept callback ethinf_set_intercept_callback(intf, usb_eem_ethernet_intercept_cb); // set intercept callback
} }