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 F1_testbrd 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,14 +17,33 @@
*/
#pragma once
#include "hardware.h"
#include "ringbuffer.h"
#include "usbhw.h"
#define BUFFSIZE (64)
// sizes of ringbuffers for outgoing and incoming data
#define RBOUTSZ (512)
#define RBINSZ (512)
#define USND(str) do{USB_send((uint8_t*)str, sizeof(str)-1);}while(0)
#define usb_newline() USB_putbyte('\n')
#define USND(s) do{USB_sendstr(s); USB_putbyte('\n');}while(0)
void USB_setup();
void usb_proc();
void USB_send(const uint8_t *buf, uint16_t len);
void USB_send_blk(const uint8_t *buf, uint16_t len);
uint8_t USB_receive(uint8_t *buf);
#if 0
#define STR_HELPER(s) #s
#define STR(s) STR_HELPER(s)
#ifdef EBUG
#define DBG(str) do{USB_sendstr(__FILE__ " (L" STR(__LINE__) "): " str); newline();}while(0)
#else
#define DBG(str)
#endif
#endif
extern volatile ringbuffer rbout, rbin;
extern volatile uint8_t bufisempty, bufovrfl;
void send_next();
int USB_sendall();
int USB_send(const uint8_t *buf, int len);
int USB_putbyte(uint8_t byte);
int USB_sendstr(const char *string);
int USB_receive(uint8_t *buf, int len);
int USB_receivestr(char *buf, int len);