mirror of
https://github.com/eddyem/stm32samples.git
synced 2026-03-22 01:31:21 +03:00
USB CDC on STM32G0B1 works
This commit is contained in:
@@ -119,14 +119,19 @@ static int readto(ringbuffer *b, uint8_t byte, uint8_t *s, int len){
|
||||
* @brief RB_readto fill array `s` with data until byte `byte` (with it)
|
||||
* @param b - ringbuffer
|
||||
* @param byte - check byte
|
||||
* @param s - buffer to write data
|
||||
* @param len - length of `s`
|
||||
* @param s - buffer to write data or NULL to clear data
|
||||
* @param len - length of `s` or 0 to clear data
|
||||
* @return amount of bytes written (negative, if len<data in buffer or buffer is busy)
|
||||
*/
|
||||
int RB_readto(ringbuffer *b, uint8_t byte, uint8_t *s, int len){
|
||||
if(!b || b->busy || !s || len < 1) return -1;
|
||||
if(!b || b->busy) return -1;
|
||||
b->busy = 1;
|
||||
int n = readto(b, byte, s, len);
|
||||
int n = 0;
|
||||
if(s && len > 0){
|
||||
n = readto(b, byte, s, len);
|
||||
}else{
|
||||
incr(b, &b->head, lento(b, byte)); // just throw data out
|
||||
}
|
||||
b->busy = 0;
|
||||
return n;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user