mirror of
https://github.com/eddyem/stm32samples.git
synced 2025-12-06 02:35:23 +03:00
little fix in USB ringbuffer for STM32F103
This commit is contained in:
parent
a56bc1bf14
commit
fcf5e03338
@ -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": "",
|
||||
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@ -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__
|
||||
|
||||
@ -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?)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user