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