change USB for common files

This commit is contained in:
Edward Emelianov
2023-06-13 19:49:35 +03:00
parent 54155fdca9
commit 00913a7e80
47 changed files with 1558 additions and 1249 deletions

View File

@@ -1,6 +1,6 @@
/*
* This file is part of the pl2303 project.
* Copyright 2022 Edward V. Emelianov <edward.emelianoff@gmail.com>.
* Copyright 2023 Edward V. Emelianov <edward.emelianoff@gmail.com>.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -17,17 +17,19 @@
*/
#pragma once
#ifndef RINGBUFFER_H__
#define RINGBUFFER_H__
#include <stm32f1.h>
#include "usbhw.h"
typedef struct{
uint8_t *data; // data buffer
const int length; // its length
int head; // head index
int tail; // tail index
} ringbuffer;
// ring buffer size in bytes
#define RBSIZE (512)
// max reading portion size
#define BLOCKSIZE (USB_TXBUFSZ)
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);
int RB_read(char s[BLOCKSIZE]);
int RB_write(const char *str, int l);
#endif // RINGBUFFER_H__