change F303's Makefile to version control; fixed bugs in F303 usb ringbuffer, add two buffers like in F0x2

This commit is contained in:
Edward Emelianov
2023-01-18 21:03:56 +03:00
parent 5230ad14e3
commit 7f9057b65c
22 changed files with 544 additions and 174 deletions

View File

@@ -20,14 +20,20 @@
#ifndef RINGBUFFER_H__
#define RINGBUFFER_H__
#include "usbhw.h"
#include <stm32f3.h>
// ring buffer size in bytes
#define RBSIZE (512)
// max reading portion size
#define BLOCKSIZE (USB_TXBUFSZ)
typedef struct{
uint8_t *data; // data buffer
const int length; // its length
int head; // head index
int tail; // tail index
} ringbuffer;
int RB_read(char s[BLOCKSIZE]);
void RB_write(const char *str, int l);
int RB_read(ringbuffer *b, uint8_t *s, int len);
int RB_readto(ringbuffer *b, uint8_t byte, uint8_t *s, int len);
int RB_hasbyte(ringbuffer *b, uint8_t byte);
int RB_write(ringbuffer *b, const uint8_t *str, int l);
int RB_datalen(ringbuffer *b);
void RB_clearbuf(ringbuffer *b);
#endif // RINGBUFFER_H__