File tree Expand file tree Collapse file tree 1 file changed +34
-0
lines changed
Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change 2424
2525#include " Print.h"
2626
27+ #ifdef ARDUINO_ARCH_STM32
28+ #include < unistd.h>
29+ #include " uart.h"
30+ #if defined (VIRTIO_LOG)
31+ #include " virtio_log.h"
32+ #endif
33+ #endif
34+
2735using namespace arduino ;
2836
2937// Public Methods //////////////////////////////////////////////////////////////
@@ -248,6 +256,32 @@ size_t Print::println(const Printable& x)
248256 return n;
249257}
250258
259+ #ifdef ARDUINO_ARCH_STM32
260+ extern " C" {
261+ __attribute__ ((weak))
262+ int _write(int file, char *ptr, int len)
263+ {
264+ switch (file) {
265+ case STDOUT_FILENO:
266+ case STDERR_FILENO:
267+ /* Used for core_debug() */
268+ #if defined (VIRTIO_LOG)
269+ virtio_log ((uint8_t *)ptr, (uint32_t )len);
270+ #elif defined(HAL_UART_MODULE_ENABLED) && !defined(HAL_UART_MODULE_ONLY)
271+ uart_debug_write ((uint8_t *)ptr, (uint32_t )len);
272+ #endif
273+ break ;
274+ case STDIN_FILENO:
275+ break ;
276+ default :
277+ ((class Print *)file)->write ((uint8_t *)ptr, len);
278+ break ;
279+ }
280+ return len;
281+ }
282+ }
283+ #endif
284+
251285int Print::printf (const char *format, ...)
252286{
253287 va_list ap;
You can’t perform that action at this time.
0 commit comments