blob: 85da470660cbc2db1626de69b326b4958e7738e2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
/**
* @file usbserial.hpp
* @brief Wrapper for ChibiOS's SerialUSBDriver.
*
* Copyright (C) 2023 Clyne Sullivan
*
* Distributed under the GNU GPL v3 or later. You should have received a copy of
* the GNU General Public License along with this program.
* If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef STMDSP_USBSERIAL_HPP_
#define STMDSP_USBSERIAL_HPP_
#include "usbcfg.h"
class USBSerial
{
public:
/**
* Prepares for USB serial communication.
*/
static void begin();
/**
* Returns true if input data has been received.
*/
static bool isActive();
/**
* Reads received input data into the given buffer.
* @param buffer Buffer to store input data.
* @param count Number of bytes to read.
* @return Number of bytes actually read.
*/
static size_t read(unsigned char *buffer, size_t count);
/**
* Writes data to serial output.
* @param buffer Buffer of output data.
* @param count Number of bytes to write.
* @return Number of bytes actually written.
*/
static size_t write(const unsigned char *buffer, size_t count);
private:
static SerialUSBDriver *m_driver;
};
#endif // STMDSP_USBSERIAL_HPP_
|