- merge: usb_driver.c conflicts fixed
This commit is contained in:
		
						commit
						d671bac4af
					
				
							
								
								
									
										145
									
								
								class/cdc.c
									
									
									
									
									
								
							
							
						
						
									
										145
									
								
								class/cdc.c
									
									
									
									
									
								
							@ -11,7 +11,7 @@
 | 
				
			|||||||
#include <cmsis_gcc.h>
 | 
					#include <cmsis_gcc.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// state
 | 
					// state
 | 
				
			||||||
static USB_CdcState cdcs = { 0 };
 | 
					static USB_CdcState cdcs = {0};
 | 
				
			||||||
static uint8_t tx_buffer[USB_CDC_PCKT_BUFSIZE];
 | 
					static uint8_t tx_buffer[USB_CDC_PCKT_BUFSIZE];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define USB_CDC_FIFO_MEM_SIZE (3072) // FIXME: ez vagy a blocking FIFO bugos
 | 
					#define USB_CDC_FIFO_MEM_SIZE (3072) // FIXME: ez vagy a blocking FIFO bugos
 | 
				
			||||||
@ -19,7 +19,7 @@ static uint8_t tx_buffer[USB_CDC_PCKT_BUFSIZE];
 | 
				
			|||||||
static uint8_t fifo_mem[USB_CDC_FIFO_MEM_SIZE];
 | 
					static uint8_t fifo_mem[USB_CDC_FIFO_MEM_SIZE];
 | 
				
			||||||
static BFifo fifo;
 | 
					static BFifo fifo;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void usb_cdc_read_callback(const uint8_t * data, uint32_t size);
 | 
					void usb_cdc_read_callback(const uint8_t *data, uint32_t size);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void usb_cdc_init(const USB_CdcAssignments *as) {
 | 
					void usb_cdc_init(const USB_CdcAssignments *as) {
 | 
				
			||||||
    // clear the structure
 | 
					    // clear the structure
 | 
				
			||||||
@ -38,81 +38,88 @@ void usb_cdc_init(const USB_CdcAssignments *as) {
 | 
				
			|||||||
    // initialize buffer
 | 
					    // initialize buffer
 | 
				
			||||||
    bfifo_create(&fifo, fifo_mem, USB_CDC_FIFO_MEM_SIZE);
 | 
					    bfifo_create(&fifo, fifo_mem, USB_CDC_FIFO_MEM_SIZE);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // initialize an all-0 interrupt
 | 
				
			||||||
 | 
					    cdcs.interrupt_data = 0;
 | 
				
			||||||
 | 
					    cdcs.interrupt_pending = true;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // from now on CDC is considered initialized
 | 
					    // from now on CDC is considered initialized
 | 
				
			||||||
    cdcs.initialized = true;
 | 
					    cdcs.initialized = true;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
//static uint8_t replyBuf[sizeof(USB_Cdc_LineCodingStruct)];
 | 
					// static uint8_t replyBuf[sizeof(USB_Cdc_LineCodingStruct)];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int usb_cdc_process_and_return(USB_CallbackEvent *cbevt) {
 | 
					int usb_cdc_process_and_return(USB_CallbackEvent *cbevt) {
 | 
				
			||||||
    int ret = -1;
 | 
					    int ret = -1;
 | 
				
			||||||
    switch (cbevt->type) {
 | 
					    switch (cbevt->type) {
 | 
				
			||||||
        case USB_CBEVT_UNKNOWN_REQ: {
 | 
					    case USB_CBEVT_UNKNOWN_REQ: {
 | 
				
			||||||
            switch (cbevt->setup_request->bRequest) {
 | 
					        switch (cbevt->setup_request->bRequest) {
 | 
				
			||||||
                case USB_CDC_SET_LINE_CODING: // set line coding
 | 
					        case USB_CDC_SET_LINE_CODING: // set line coding
 | 
				
			||||||
                    memcpy(&cdcs.line_coding, cbevt->data, sizeof(USB_Cdc_LineCodingStruct));
 | 
					            memcpy(&cdcs.line_coding, cbevt->data, sizeof(USB_Cdc_LineCodingStruct));
 | 
				
			||||||
                    //MSG("%u\n", cdcs.line_coding.dwDTERate);
 | 
					            // MSG("%u\n", cdcs.line_coding.dwDTERate);
 | 
				
			||||||
                    ret = 0;
 | 
					            ret = 0;
 | 
				
			||||||
                    break;
 | 
					 | 
				
			||||||
                case USB_CDC_GET_LINE_CODING: // get line coding
 | 
					 | 
				
			||||||
                    cbevt->reply_data = (const uint8_t *) &cdcs.line_coding; // expert move: pass the pointer, no copying
 | 
					 | 
				
			||||||
                    cbevt->reply_size = sizeof(USB_Cdc_LineCodingStruct);
 | 
					 | 
				
			||||||
                    cbevt->reply_valid = true; // the reply has been set to something valid
 | 
					 | 
				
			||||||
                    ret = 0;
 | 
					 | 
				
			||||||
                    break;
 | 
					 | 
				
			||||||
                case USB_CDC_SEND_BREAK: // send break
 | 
					 | 
				
			||||||
                    // do nothing
 | 
					 | 
				
			||||||
                    ret = 0;
 | 
					 | 
				
			||||||
                    break;
 | 
					 | 
				
			||||||
                case USB_CDC_SET_CONTROL_LINE_STATE: // set control line state
 | 
					 | 
				
			||||||
                    memcpy(&cdcs.control_line_state, cbevt->data, sizeof(USB_Cdc_ControlLineStateStruct));
 | 
					 | 
				
			||||||
                    //MSG("%u\n", cdcs.control_line_state.D);
 | 
					 | 
				
			||||||
                    ret = 0;
 | 
					 | 
				
			||||||
                    break;
 | 
					 | 
				
			||||||
                default:
 | 
					 | 
				
			||||||
                    break;
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            // send a ZLP reply
 | 
					 | 
				
			||||||
            if (ret != -1) {
 | 
					 | 
				
			||||||
                cbevt->reply_data = NULL;
 | 
					 | 
				
			||||||
                cbevt->reply_size = 0;
 | 
					 | 
				
			||||||
                cbevt->reply_valid = true;
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            break;
 | 
					            break;
 | 
				
			||||||
        }
 | 
					        case USB_CDC_GET_LINE_CODING:                               // get line coding
 | 
				
			||||||
 | 
					            cbevt->reply_data = (const uint8_t *)&cdcs.line_coding; // expert move: pass the pointer, no copying
 | 
				
			||||||
        case USB_CBEVT_OUT: {
 | 
					            cbevt->reply_size = sizeof(USB_Cdc_LineCodingStruct);
 | 
				
			||||||
            if (cbevt->ep == cdcs.ep_assignments.data_ep) {
 | 
					            cbevt->reply_valid = true; // the reply has been set to something valid
 | 
				
			||||||
                //MSG("%c\n", cbevt->data[0]);
 | 
					            ret = 0;
 | 
				
			||||||
                ret = 0;
 | 
					            break;
 | 
				
			||||||
 | 
					        case USB_CDC_SEND_BREAK: // send break
 | 
				
			||||||
                usb_cdc_read_callback(cbevt->data, cbevt->size);
 | 
					            // do nothing
 | 
				
			||||||
                //usbcore_schedule_transmission(cdcs.ep_assignments.data_ep, cbevt->data, cbevt->size); // echo
 | 
					            ret = 0;
 | 
				
			||||||
            }
 | 
					            break;
 | 
				
			||||||
 | 
					        case USB_CDC_SET_CONTROL_LINE_STATE: // set control line state
 | 
				
			||||||
 | 
					            memcpy(&cdcs.control_line_state, cbevt->data, sizeof(USB_Cdc_ControlLineStateStruct));
 | 
				
			||||||
 | 
					            // MSG("%u\n", cdcs.control_line_state.D);
 | 
				
			||||||
 | 
					            ret = 0;
 | 
				
			||||||
            break;
 | 
					            break;
 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        case USB_CBEVT_IN: {
 | 
					 | 
				
			||||||
            if (cbevt->ep == cdcs.ep_assignments.control_ep) { // if notification feeding is requested
 | 
					 | 
				
			||||||
                usbcore_schedule_transmission(cdcs.ep_assignments.control_ep, NULL, 0); // send ZLP
 | 
					 | 
				
			||||||
                ret = 0;
 | 
					 | 
				
			||||||
            } else if (cbevt->ep == cdcs.ep_assignments.data_ep) { // if data are requested
 | 
					 | 
				
			||||||
                //usbcore_schedule_transmission(cdcs.ep_assignments.data_ep, NULL, 0); // send ZLP
 | 
					 | 
				
			||||||
                ret = 0;
 | 
					 | 
				
			||||||
                
 | 
					 | 
				
			||||||
                // read from the fifo
 | 
					 | 
				
			||||||
                uint32_t readSize = bfifo_read(&fifo, tx_buffer, USB_CDC_PCKT_BUFSIZE);
 | 
					 | 
				
			||||||
                if (readSize > 0) {
 | 
					 | 
				
			||||||
                    uint32_t writeSize = usbcore_schedule_transmission(cdcs.ep_assignments.data_ep, tx_buffer, readSize); // write data acquired from the buffer
 | 
					 | 
				
			||||||
                    bfifo_pop(&fifo, writeSize, 0); // pop with no blocking
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        default:
 | 
					        default:
 | 
				
			||||||
            break;
 | 
					            break;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // send a ZLP reply
 | 
				
			||||||
 | 
					        if (ret != -1) {
 | 
				
			||||||
 | 
					            cbevt->reply_data = NULL;
 | 
				
			||||||
 | 
					            cbevt->reply_size = 0;
 | 
				
			||||||
 | 
					            cbevt->reply_valid = true;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        break;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    case USB_CBEVT_OUT: {
 | 
				
			||||||
 | 
					        if (cbevt->ep == cdcs.ep_assignments.data_ep) {
 | 
				
			||||||
 | 
					            // MSG("%c\n", cbevt->data[0]);
 | 
				
			||||||
 | 
					            ret = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            usb_cdc_read_callback(cbevt->data, cbevt->size);
 | 
				
			||||||
 | 
					            // usbcore_schedule_transmission(cdcs.ep_assignments.data_ep, cbevt->data, cbevt->size); // echo
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        break;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    case USB_CBEVT_IN: {
 | 
				
			||||||
 | 
					        if (cbevt->ep == cdcs.ep_assignments.control_ep) { // if notification feeding is requested
 | 
				
			||||||
 | 
					            if (cdcs.interrupt_pending) {
 | 
				
			||||||
 | 
					                usbcore_schedule_transmission(cdcs.ep_assignments.control_ep, (const uint8_t *)&(cdcs.interrupt_data), sizeof(uint16_t)); // send ZLP
 | 
				
			||||||
 | 
					                cdcs.interrupt_pending = false;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            ret = 0;
 | 
				
			||||||
 | 
					        } else if (cbevt->ep == cdcs.ep_assignments.data_ep) { // if data are requested
 | 
				
			||||||
 | 
					            // usbcore_schedule_transmission(cdcs.ep_assignments.data_ep, NULL, 0); // send ZLP
 | 
				
			||||||
 | 
					            ret = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            // read from the fifo
 | 
				
			||||||
 | 
					            uint32_t readSize = bfifo_read(&fifo, tx_buffer, USB_CDC_PCKT_BUFSIZE);
 | 
				
			||||||
 | 
					            if (readSize > 0) {
 | 
				
			||||||
 | 
					                uint32_t writeSize = usbcore_schedule_transmission(cdcs.ep_assignments.data_ep, tx_buffer, readSize); // write data acquired from the buffer
 | 
				
			||||||
 | 
					                bfifo_pop(&fifo, writeSize, 0);                                                                       // pop with no blocking
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    default:
 | 
				
			||||||
 | 
					        break;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return ret;
 | 
					    return ret;
 | 
				
			||||||
@ -122,15 +129,15 @@ int usb_cdc_process_and_return(USB_CallbackEvent *cbevt) {
 | 
				
			|||||||
//    usb_cdc_process_and_return(cbevt);
 | 
					//    usb_cdc_process_and_return(cbevt);
 | 
				
			||||||
// }
 | 
					// }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void usb_cdc_write(const uint8_t * data, uint32_t size) {
 | 
					void usb_cdc_write(const uint8_t *data, uint32_t size) {
 | 
				
			||||||
    if (cdcs.initialized) {
 | 
					    if (cdcs.initialized) {
 | 
				
			||||||
        bfifo_push_all(&fifo, data, size);
 | 
					        bfifo_push_all(&fifo, data, size);
 | 
				
			||||||
        usbcore_wake_up_endpoint(cdcs.ep_assignments.data_ep, USB_IN);
 | 
					        usbcore_wake_up_endpoint(cdcs.ep_assignments.data_ep, USB_IN);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
__attribute__((weak)) void usb_cdc_read_callback(const uint8_t * data, uint32_t size) {
 | 
					__attribute__((weak)) void usb_cdc_read_callback(const uint8_t *data, uint32_t size) {
 | 
				
			||||||
    (void) data;
 | 
					    (void)data;
 | 
				
			||||||
    (void) size;
 | 
					    (void)size;
 | 
				
			||||||
    return;
 | 
					    return;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@ -50,6 +50,8 @@ typedef struct {
 | 
				
			|||||||
    USB_CdcAssignments ep_assignments; // endpoint assignments
 | 
					    USB_CdcAssignments ep_assignments; // endpoint assignments
 | 
				
			||||||
    USB_Cdc_LineCodingStruct line_coding; // line coding
 | 
					    USB_Cdc_LineCodingStruct line_coding; // line coding
 | 
				
			||||||
    USB_Cdc_ControlLineStateStruct control_line_state; // control line state
 | 
					    USB_Cdc_ControlLineStateStruct control_line_state; // control line state
 | 
				
			||||||
 | 
					    uint16_t interrupt_data; // data sent though the next transfer on the notification element
 | 
				
			||||||
 | 
					    bool interrupt_pending; // interrupt data is valid and should be send in the next cycle
 | 
				
			||||||
    bool initialized; // CDC is initialized
 | 
					    bool initialized; // CDC is initialized
 | 
				
			||||||
} USB_CdcState;
 | 
					} USB_CdcState;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										30
									
								
								class/eem.c
									
									
									
									
									
								
							
							
						
						
									
										30
									
								
								class/eem.c
									
									
									
									
									
								
							@ -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
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -169,6 +169,9 @@ void usbdrv_init_global_state() {
 | 
				
			|||||||
#endif
 | 
					#endif
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ---------------
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef USB_HIGH_SPEED
 | 
					#ifdef USB_HIGH_SPEED
 | 
				
			||||||
__weak void usbdrv_ulpi_init() {
 | 
					__weak void usbdrv_ulpi_init() {
 | 
				
			||||||
    return;
 | 
					    return;
 | 
				
			||||||
@ -240,6 +243,10 @@ void usbdrv_periph_init() {
 | 
				
			|||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					    (uint32_t *)(((uint32_t)USBG) + 0x028), // DIEPTXF0
 | 
				
			||||||
 | 
					    (uint32_t *)(((uint32_t)USBG) + 0x104), // DIEPTXF1
 | 
				
			||||||
 | 
					    (uint32_t *)(((uint32_t)USBG) + 0x108), // DIEPTXF2
 | 
				
			||||||
 | 
					    (uint32_t *)(((uint32_t)USBG) + 0x10C), // DIEPTXF3
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    CLEAR_BIT(USBG->GCCFG, USB_OTG_GCCFG_PWRDWN); // power down the peripheral
 | 
					    CLEAR_BIT(USBG->GCCFG, USB_OTG_GCCFG_PWRDWN); // power down the peripheral
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -752,7 +759,7 @@ uint32_t usbdrv_arm_IN_endpoint(uint8_t ep, const uint8_t *data, uint16_t len) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
// arm OUT endpoint
 | 
					// arm OUT endpoint
 | 
				
			||||||
uint32_t usbdrv_arm_OUT_endpoint(uint8_t ep, uint8_t size) {
 | 
					uint32_t usbdrv_arm_OUT_endpoint(uint8_t ep, uint8_t size) {
 | 
				
			||||||
    // arm endpoint only if it was not armed before OR if it's the EP0 OUT which is always enabled, but responds NAK after a successful transfer
 | 
					    // arm endpoint only if it was not armed before
 | 
				
			||||||
    if (READ_BIT(USBOUTEP[ep].DOEPCTL, USB_OTG_DOEPCTL_EPENA)) {
 | 
					    if (READ_BIT(USBOUTEP[ep].DOEPCTL, USB_OTG_DOEPCTL_EPENA)) {
 | 
				
			||||||
        return 0;
 | 
					        return 0;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user