-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathrp2040_serial_port.cc
36 lines (28 loc) · 1003 Bytes
/
rp2040_serial_port.cc
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
//---------------------------------------------------------------------------
#include "javelin/hal/serial_port.h"
#include "javelin/split/split_serial_buffer.h"
#include <tusb.h>
//---------------------------------------------------------------------------
#if JAVELIN_SPLIT && !JAVELIN_SPLIT_IS_MASTER
void SplitSerialBuffer::SplitSerialBufferData::OnDataReceived(const void *data,
size_t length) {
if (tud_cdc_connected()) {
tud_cdc_write(data, length);
tud_cdc_write_flush();
}
}
#endif
//---------------------------------------------------------------------------
void SerialPort::SendData(const uint8_t *data, size_t length) {
if (tud_cdc_connected()) {
tud_cdc_write(data, length);
tud_cdc_write_flush();
} else {
#if JAVELIN_SPLIT
if (Split::IsMaster()) {
SplitSerialBuffer::Add(data, length);
}
#endif
}
}
//---------------------------------------------------------------------------