stdout_helpers.c 675 B

1234567891011121314151617181920212223242526
  1. #include <string.h>
  2. #include <unistd.h>
  3. #include "py/mpconfig.h"
  4. #include "py/mphal.h"
  5. /*
  6. * Extra stdout functions
  7. * These can be either optimized for a particular port, or reference
  8. * implementation below can be used.
  9. */
  10. // Send "cooked" string of given length, where every occurrence of
  11. // LF character is replaced with CR LF.
  12. void mp_hal_stdout_tx_strn_cooked(const char *str, size_t len) {
  13. while (len--) {
  14. if (*str == '\n') {
  15. mp_hal_stdout_tx_strn("\r", 1);
  16. }
  17. mp_hal_stdout_tx_strn(str++, 1);
  18. }
  19. }
  20. // Send zero-terminated string
  21. void mp_hal_stdout_tx_str(const char *str) {
  22. mp_hal_stdout_tx_strn(str, strlen(str));
  23. }