From fcf5e0333836a566fb1cc0102e376585304c21e0 Mon Sep 17 00:00:00 2001 From: Edward Emelianov Date: Wed, 31 Aug 2022 14:48:21 +0300 Subject: [PATCH] little fix in USB ringbuffer for STM32F103 --- F0:F030,F042,F072/usbcan/kicad/stm32.kicad_pro | 12 +++++++++--- F1:F103/PL2303_ringbuffer/ringbuffer.c | 12 +----------- F1:F103/PL2303_ringbuffer/ringbuffer.h | 2 +- F1:F103/PL2303_ringbuffer/usb.c | 10 ++++++++-- 4 files changed, 19 insertions(+), 17 deletions(-) diff --git a/F0:F030,F042,F072/usbcan/kicad/stm32.kicad_pro b/F0:F030,F042,F072/usbcan/kicad/stm32.kicad_pro index 484357d..5cc8242 100644 --- a/F0:F030,F042,F072/usbcan/kicad/stm32.kicad_pro +++ b/F0:F030,F042,F072/usbcan/kicad/stm32.kicad_pro @@ -314,6 +314,7 @@ ], "rule_severities": { "bus_definition_conflict": "error", + "bus_entry_needed": "error", "bus_label_syntax": "error", "bus_to_bus_conflict": "error", "bus_to_net_conflict": "error", @@ -406,7 +407,7 @@ } ], "meta": { - "version": 0 + "version": 2 }, "net_colors": null }, @@ -422,6 +423,7 @@ "page_layout_descr_file": "" }, "schematic": { + "annotate_start_num": 0, "drawing": { "default_bus_thickness": 12.0, "default_junction_size": 40.0, @@ -435,20 +437,24 @@ "intersheets_ref_show": false, "intersheets_ref_suffix": "", "junction_size_choice": 3, + "label_size_ratio": 0.3, "pin_symbol_size": 25.0, "text_offset_ratio": 0.3 }, "legacy_lib_dir": "", "legacy_lib_list": [], "meta": { - "version": 0 + "version": 1 }, "net_format_name": "Pcbnew", "ngspice": { + "fix_include_paths": true, + "fix_passive_vals": false, "meta": { "version": 0 }, - "model_mode": 0 + "model_mode": 0, + "workbook_filename": "" }, "page_layout_descr_file": "", "plot_directory": "", diff --git a/F1:F103/PL2303_ringbuffer/ringbuffer.c b/F1:F103/PL2303_ringbuffer/ringbuffer.c index 1b485b5..f2b5f9f 100644 --- a/F1:F103/PL2303_ringbuffer/ringbuffer.c +++ b/F1:F103/PL2303_ringbuffer/ringbuffer.c @@ -63,7 +63,7 @@ int RB_read(char s[BLOCKSIZE]){ return _1st; } -static int addportion(const char *str, int l){ +int RB_write(const char *str, int l){ int r = restlen(); if(l > r) l = r; if(!l) return 0; @@ -77,13 +77,3 @@ static int addportion(const char *str, int l){ return l; } -void RB_write(const char *str, int l){ - if(!str || !*str) return; - if(!usbON) return; - while(l){ - if(tx_succesfull) send_next(); - int a = addportion(str, l); - l -= a; - str += a; - } -} diff --git a/F1:F103/PL2303_ringbuffer/ringbuffer.h b/F1:F103/PL2303_ringbuffer/ringbuffer.h index 3e8f004..404fcbb 100644 --- a/F1:F103/PL2303_ringbuffer/ringbuffer.h +++ b/F1:F103/PL2303_ringbuffer/ringbuffer.h @@ -28,6 +28,6 @@ #define BLOCKSIZE (USB_TXBUFSZ) int RB_read(char s[BLOCKSIZE]); -void RB_write(const char *str, int l); +int RB_write(const char *str, int l); #endif // RINGBUFFER_H__ diff --git a/F1:F103/PL2303_ringbuffer/usb.c b/F1:F103/PL2303_ringbuffer/usb.c index ec1a463..f39a217 100644 --- a/F1:F103/PL2303_ringbuffer/usb.c +++ b/F1:F103/PL2303_ringbuffer/usb.c @@ -40,12 +40,18 @@ void send_next(){ // put `buf` into queue to send void USB_send(const char *buf){ - if(!buf) return; + if(!buf || !usbON) return; int len = 0; const char *b = buf; while(*b++) ++len; if(!usbON || !len) return; - RB_write(buf, len); // this is a blocking procedure if there's too little free memory in buffer + int l = len; + while(l){ + if(tx_succesfull) send_next(); + int a = RB_write(buf, l); + l -= a; + buf += a; + } } // interrupt IN handler (never used?)