blob: d323a7aa042b4c9c56b93ab0a980f2df65a42510 [file] [log] [blame]
Brian Silverman4787a6e2018-10-06 16:00:54 -07001#ifndef MOTORS_PRINT_SEMIHOSTING_H_
2#define MOTORS_PRINT_SEMIHOSTING_H_
3
Austin Schuh7fe04492022-01-02 13:37:21 -08004#include "absl/types/span.h"
Brian Silverman4787a6e2018-10-06 16:00:54 -07005#include "motors/print/print.h"
6
7namespace frc971 {
8namespace motors {
9
10// A printing implementation which uses the ARM semihosting interface. This
11// requries an attached debugger with software support.
12//
13// You have to do "arm semihosting enable" in openocd to enable this.
14// It also seems to be broken with the usb-tiny-h in the openocd version we're
15// using, but works fine with the st-link-v2.
16// It may also only work if you do this immediately after starting openocd.
17//
18// Note that this implementation has strange effects on timing even of
19// interrupts-disabled code and is in general extremely slow.
20class SemihostingPrinting final : public PrintingImplementation {
21 public:
22 SemihostingPrinting() = default;
23 ~SemihostingPrinting() override = default;
24
25 void Initialize() override {}
26
Austin Schuh7fe04492022-01-02 13:37:21 -080027 int WriteStdout(absl::Span<const char> buffer) override;
Brian Silverman4787a6e2018-10-06 16:00:54 -070028
29 // Could easily implement an optional WriteDebug which goes to a separate
30 // file if the name is filled out in the parameters.
31};
32
33} // namespace motors
34} // namespace frc971
35
36#endif // MOTORS_PRINT_SEMIHOSTING_H_