- CDC line buffer size fixed
This commit is contained in:
		
							parent
							
								
									0adc9c8664
								
							
						
					
					
						commit
						ecc9b70710
					
				@ -19,6 +19,6 @@ target_sources(
 | 
			
		||||
    usb_driver.h
 | 
			
		||||
    usb.h
 | 
			
		||||
 | 
			
		||||
    utils/gen_queue.c
 | 
			
		||||
    utils/gen_queue.h
 | 
			
		||||
    # utils/gen_queue.c
 | 
			
		||||
    # utils/gen_queue.h
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
@ -72,7 +72,7 @@ int usb_cdc_process_and_return(USB_CallbackEvent *cbevt) {
 | 
			
		||||
                //MSG("%c\n", cbevt->data[0]);
 | 
			
		||||
                ret = 0;
 | 
			
		||||
 | 
			
		||||
                usbcore_write(cdcs.ep_assignments.data_ep, cbevt->data, cbevt->size); // echo
 | 
			
		||||
                //usbcore_write(cdcs.ep_assignments.data_ep, cbevt->data, cbevt->size); // echo
 | 
			
		||||
            }
 | 
			
		||||
            break;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
@ -62,7 +62,7 @@ typedef struct {
 | 
			
		||||
 | 
			
		||||
// ----------------
 | 
			
		||||
 | 
			
		||||
#define USB_CDC_PCKT_BUFSIZE (128)
 | 
			
		||||
#define USB_CDC_PCKT_BUFSIZE (64)
 | 
			
		||||
 | 
			
		||||
// ----------------
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										2
									
								
								usb.c
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								usb.c
									
									
									
									
									
								
							@ -5,7 +5,7 @@
 | 
			
		||||
#include "usb_common.h"
 | 
			
		||||
#include "usb_core_types.h"
 | 
			
		||||
 | 
			
		||||
#include "utils/gen_queue.h"
 | 
			
		||||
// #include "utils/gen_queue.h"
 | 
			
		||||
 | 
			
		||||
#include "desc/usb_desc.h"
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										39
									
								
								usb_driver.c
									
									
									
									
									
								
							
							
						
						
									
										39
									
								
								usb_driver.c
									
									
									
									
									
								
							@ -28,7 +28,7 @@ static uint8_t rx_buf[USB_MAX_FS_PCKT_SIZE_NON_ISOCHRONOUS] DWORD_ALIGN; // rece
 | 
			
		||||
 | 
			
		||||
#define USB_EVENT_QUEUE_LENGTH (16)
 | 
			
		||||
 | 
			
		||||
static uint8_t event_queue_mem[Q_REQ_MEM_SIZE_T(USB_EVENT_QUEUE_LENGTH, USBDRV_EventCompound)] DWORD_ALIGN; // backing memory for the event queue
 | 
			
		||||
// static uint8_t event_queue_mem[Q_REQ_MEM_SIZE_T(USB_EVENT_QUEUE_LENGTH, USBDRV_EventCompound)] DWORD_ALIGN; // backing memory for the event queue
 | 
			
		||||
 | 
			
		||||
static const char *FIFO_STATUS_STR[6] = {
 | 
			
		||||
    "GLOBAL OUT NAK",
 | 
			
		||||
@ -102,7 +102,7 @@ void usbdrv_init_global_state() {
 | 
			
		||||
    gs.rx_buf_level = 0;
 | 
			
		||||
 | 
			
		||||
    // initialize event queue
 | 
			
		||||
    gs.event_queue = Q_CREATE_T(USB_EVENT_QUEUE_LENGTH, USBDRV_EventCompound, event_queue_mem);
 | 
			
		||||
    // gs.event_queue = Q_CREATE_T(USB_EVENT_QUEUE_LENGTH, USBDRV_EventCompound, event_queue_mem);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// ---------------
 | 
			
		||||
@ -265,6 +265,7 @@ void usbdrv_build_fifo() {
 | 
			
		||||
        if (cfg->is_configured) {
 | 
			
		||||
            cfg->fifo_size = CEIL4(MAX(USB_MIN_GROSS_TX_FIFO_SIZE, cfg->max_packet_size)); // correct FIFO size if necessary
 | 
			
		||||
            cfg->fifo_address = next_fifo_addr;                                            // store FIFO address
 | 
			
		||||
            cfg->zlp_next = false;                                                         // clear ZLP next 
 | 
			
		||||
            next_fifo_addr += cfg->fifo_size;                                              // advance next address
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
@ -538,24 +539,24 @@ void usbdrv_set_address(uint8_t addr) {
 | 
			
		||||
// ----------------
 | 
			
		||||
 | 
			
		||||
// push event onto the event queue
 | 
			
		||||
void usbdrv_push_event(uint32_t evt_code, USBDRV_EventData *evt_data) {
 | 
			
		||||
    USBDRV_EventCompound evt_cpd;
 | 
			
		||||
    if (evt_data != NULL) {
 | 
			
		||||
        evt_cpd.data = *evt_data;
 | 
			
		||||
    }
 | 
			
		||||
    evt_cpd.code = evt_code;
 | 
			
		||||
    q_push(gs.event_queue, &evt_cpd);
 | 
			
		||||
}
 | 
			
		||||
// void usbdrv_push_event(uint32_t evt_code, USBDRV_EventData *evt_data) {
 | 
			
		||||
//     USBDRV_EventCompound evt_cpd;
 | 
			
		||||
//     if (evt_data != NULL) {
 | 
			
		||||
//         evt_cpd.data = *evt_data;
 | 
			
		||||
//     }
 | 
			
		||||
//     evt_cpd.code = evt_code;
 | 
			
		||||
//     q_push(gs.event_queue, &evt_cpd);
 | 
			
		||||
// }
 | 
			
		||||
 | 
			
		||||
// call this to process incoming events
 | 
			
		||||
void usbdrv_periodic_processing() {
 | 
			
		||||
    if ((gs.event_queue != NULL) && (q_avail(gs.event_queue))) {
 | 
			
		||||
        USBDRV_EventCompound evt_cpd;
 | 
			
		||||
        q_top(gs.event_queue, &evt_cpd);
 | 
			
		||||
        q_pop(gs.event_queue);
 | 
			
		||||
        usbdrv_process_event(evt_cpd.code, NULL);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
// // call this to process incoming events
 | 
			
		||||
// void usbdrv_periodic_processing() {
 | 
			
		||||
//     if ((gs.event_queue != NULL) && (q_avail(gs.event_queue))) {
 | 
			
		||||
//         USBDRV_EventCompound evt_cpd;
 | 
			
		||||
//         q_top(gs.event_queue, &evt_cpd);
 | 
			
		||||
//         q_pop(gs.event_queue);
 | 
			
		||||
//         usbdrv_process_event(evt_cpd.code, NULL);
 | 
			
		||||
//     }
 | 
			
		||||
// }
 | 
			
		||||
 | 
			
		||||
// ----------------
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -1,7 +1,7 @@
 | 
			
		||||
#ifndef CORE_USB_USB_DRIVER
 | 
			
		||||
#define CORE_USB_USB_DRIVER
 | 
			
		||||
 | 
			
		||||
#include "utils/gen_queue.h"
 | 
			
		||||
//#include "utils/gen_queue.h"
 | 
			
		||||
 | 
			
		||||
#include "usb_common_types.h"
 | 
			
		||||
 | 
			
		||||
@ -58,7 +58,7 @@ typedef struct {
 | 
			
		||||
    uint16_t state;                               // FSM state
 | 
			
		||||
    uint8_t *rx_buf;                              // pointer to the receive buffer (this way declaration can be separated)
 | 
			
		||||
    uint16_t rx_buf_level;                        // fill level of the rx buffer
 | 
			
		||||
    Queue *event_queue;                           // event queue
 | 
			
		||||
    // Queue *event_queue;                           // event queue
 | 
			
		||||
    uint8_t address;                              // device address
 | 
			
		||||
} USBDRV_GlobalState;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user