- driver: only poll FIFO free space if transmission size > 0
- CDC: buffer size increased
This commit is contained in:
		
							parent
							
								
									4cf5fb77fe
								
							
						
					
					
						commit
						8ef6249e01
					
				@ -12,11 +12,13 @@
 | 
			
		||||
static USB_CdcState cdcs = { 0 };
 | 
			
		||||
static uint8_t tx_buffer[USB_CDC_PCKT_BUFSIZE];
 | 
			
		||||
 | 
			
		||||
#define USB_CDC_FIFO_MEM_SIZE (2048)
 | 
			
		||||
#define USB_CDC_FIFO_MEM_SIZE (3072) // FIXME: ez vagy a blocking FIFO bugos
 | 
			
		||||
 | 
			
		||||
static uint8_t fifo_mem[USB_CDC_FIFO_MEM_SIZE];
 | 
			
		||||
static BFifo fifo;
 | 
			
		||||
 | 
			
		||||
void usb_cdc_read_callback(const uint8_t * data, uint32_t size);
 | 
			
		||||
 | 
			
		||||
void usb_cdc_init(const USB_CdcAssignments *as) {
 | 
			
		||||
    // clear the structure
 | 
			
		||||
    memset(&cdcs, 0, sizeof(USB_CdcState));
 | 
			
		||||
 | 
			
		||||
@ -476,7 +476,10 @@ uint32_t usbdrv_arm_IN_endpoint(uint8_t ep, const uint8_t *data, uint16_t len) {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // determine final write size
 | 
			
		||||
    uint32_t freeSize = USBINEP[ep].DTXFSTS * sizeof(uint32_t); // get free transmit buffer size
 | 
			
		||||
    uint32_t freeSize = 0;
 | 
			
		||||
    if (len > 0) { // only poll DTXFSTS if (len > 0) (see datasheet)
 | 
			
		||||
        freeSize = USBINEP[ep].DTXFSTS * sizeof(uint32_t); // get free transmit buffer size
 | 
			
		||||
    }
 | 
			
		||||
    uint16_t writeSize = MIN(freeSize, len); // limit transmit size to free size
 | 
			
		||||
 | 
			
		||||
    // calculate packet count based on max packet size
 | 
			
		||||
@ -486,10 +489,10 @@ uint32_t usbdrv_arm_IN_endpoint(uint8_t ep, const uint8_t *data, uint16_t len) {
 | 
			
		||||
        packet_count = writeSize / mps + (((writeSize % mps) > 0) ? 1 : 0);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // set zlp_next if transmission size is integer multiple of max packet size
 | 
			
		||||
    // set zlp_next if transmission size is integer multiple of max packet size6
 | 
			
		||||
    gs.ep_IN[ep].zlp_next = (writeSize > 0) && ((writeSize % mps) == 0);
 | 
			
		||||
 | 
			
		||||
    // program DIEPTSIZ with transfer length (TODO: currently only a single transfer!)
 | 
			
		||||
    // program DIEPTSIZ with transfer length
 | 
			
		||||
    USBINEP[ep].DIEPTSIZ = (packet_count << USB_OTG_DIEPTSIZ_PKTCNT_Pos) | writeSize;
 | 
			
		||||
 | 
			
		||||
    // enable endpoint and cancel responding NAK
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user