-
Notifications
You must be signed in to change notification settings - Fork 3
/
SWOStream.h
40 lines (33 loc) · 853 Bytes
/
SWOStream.h
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
#ifndef SWOSTREAM_H
#define SWOSTREAM_H
/*
* Arduino class to write to Serial Wire Output (SWO)
* 2020 Koen De Vleeschauwer
* No copyright asserted.
*/
#include <Print.h>
#if defined(ARDUINO_ARCH_SAM)
# include "SWOArduinoSAM.h"
#else
# include <stm32_def.h>
#endif
typedef enum {
SWO_Manchester = 0x1,
SWO_Async = 0x2,
} swoProtocolType;
class SWOStream : public Print {
private:
uint32_t channel;
public:
SWOStream(uint32_t swoSpeedBaud, swoProtocolType swoProtocol = SWO_Async,
uint32_t swoChannel = 0, bool swoEnable = true,
uint32_t cpuClockFreqHz = SystemCoreClock);
~SWOStream();
void setChannel(uint32_t swoChannel);
void enable(bool swoEnable);
virtual size_t write(uint8_t ch);
virtual size_t write(const uint8_t *buffer, size_t size);
virtual void flush();
};
#endif
/* not truncated */