mirror of
https://github.com/eddyem/stm32samples.git
synced 2025-12-06 10:45:11 +03:00
little fix in USB ringbuffer for STM32F103
This commit is contained in:
parent
a56bc1bf14
commit
fcf5e03338
@ -314,6 +314,7 @@
|
|||||||
],
|
],
|
||||||
"rule_severities": {
|
"rule_severities": {
|
||||||
"bus_definition_conflict": "error",
|
"bus_definition_conflict": "error",
|
||||||
|
"bus_entry_needed": "error",
|
||||||
"bus_label_syntax": "error",
|
"bus_label_syntax": "error",
|
||||||
"bus_to_bus_conflict": "error",
|
"bus_to_bus_conflict": "error",
|
||||||
"bus_to_net_conflict": "error",
|
"bus_to_net_conflict": "error",
|
||||||
@ -406,7 +407,7 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"meta": {
|
"meta": {
|
||||||
"version": 0
|
"version": 2
|
||||||
},
|
},
|
||||||
"net_colors": null
|
"net_colors": null
|
||||||
},
|
},
|
||||||
@ -422,6 +423,7 @@
|
|||||||
"page_layout_descr_file": ""
|
"page_layout_descr_file": ""
|
||||||
},
|
},
|
||||||
"schematic": {
|
"schematic": {
|
||||||
|
"annotate_start_num": 0,
|
||||||
"drawing": {
|
"drawing": {
|
||||||
"default_bus_thickness": 12.0,
|
"default_bus_thickness": 12.0,
|
||||||
"default_junction_size": 40.0,
|
"default_junction_size": 40.0,
|
||||||
@ -435,20 +437,24 @@
|
|||||||
"intersheets_ref_show": false,
|
"intersheets_ref_show": false,
|
||||||
"intersheets_ref_suffix": "",
|
"intersheets_ref_suffix": "",
|
||||||
"junction_size_choice": 3,
|
"junction_size_choice": 3,
|
||||||
|
"label_size_ratio": 0.3,
|
||||||
"pin_symbol_size": 25.0,
|
"pin_symbol_size": 25.0,
|
||||||
"text_offset_ratio": 0.3
|
"text_offset_ratio": 0.3
|
||||||
},
|
},
|
||||||
"legacy_lib_dir": "",
|
"legacy_lib_dir": "",
|
||||||
"legacy_lib_list": [],
|
"legacy_lib_list": [],
|
||||||
"meta": {
|
"meta": {
|
||||||
"version": 0
|
"version": 1
|
||||||
},
|
},
|
||||||
"net_format_name": "Pcbnew",
|
"net_format_name": "Pcbnew",
|
||||||
"ngspice": {
|
"ngspice": {
|
||||||
|
"fix_include_paths": true,
|
||||||
|
"fix_passive_vals": false,
|
||||||
"meta": {
|
"meta": {
|
||||||
"version": 0
|
"version": 0
|
||||||
},
|
},
|
||||||
"model_mode": 0
|
"model_mode": 0,
|
||||||
|
"workbook_filename": ""
|
||||||
},
|
},
|
||||||
"page_layout_descr_file": "",
|
"page_layout_descr_file": "",
|
||||||
"plot_directory": "",
|
"plot_directory": "",
|
||||||
|
|||||||
@ -63,7 +63,7 @@ int RB_read(char s[BLOCKSIZE]){
|
|||||||
return _1st;
|
return _1st;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int addportion(const char *str, int l){
|
int RB_write(const char *str, int l){
|
||||||
int r = restlen();
|
int r = restlen();
|
||||||
if(l > r) l = r;
|
if(l > r) l = r;
|
||||||
if(!l) return 0;
|
if(!l) return 0;
|
||||||
@ -77,13 +77,3 @@ static int addportion(const char *str, int l){
|
|||||||
return 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)
|
#define BLOCKSIZE (USB_TXBUFSZ)
|
||||||
|
|
||||||
int RB_read(char s[BLOCKSIZE]);
|
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__
|
#endif // RINGBUFFER_H__
|
||||||
|
|||||||
@ -40,12 +40,18 @@ void send_next(){
|
|||||||
|
|
||||||
// put `buf` into queue to send
|
// put `buf` into queue to send
|
||||||
void USB_send(const char *buf){
|
void USB_send(const char *buf){
|
||||||
if(!buf) return;
|
if(!buf || !usbON) return;
|
||||||
int len = 0;
|
int len = 0;
|
||||||
const char *b = buf;
|
const char *b = buf;
|
||||||
while(*b++) ++len;
|
while(*b++) ++len;
|
||||||
if(!usbON || !len) return;
|
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?)
|
// interrupt IN handler (never used?)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user