stdio.h 770 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. // SPDX-License-Identifier: BSD-2-Clause
  2. /*
  3. * Copyright (c) 2022 Matthias Schiffer <[email protected]>
  4. */
  5. #pragma once
  6. #include <serial.h>
  7. #include <types.h>
  8. static inline int getchar(void)
  9. {
  10. return serial_console_getchar();
  11. }
  12. static inline int tstc(void)
  13. {
  14. return serial_console_tstc();
  15. }
  16. static inline int putchar(char c)
  17. {
  18. if (c == '\n')
  19. serial_console_putchar('\r');
  20. serial_console_putchar(c);
  21. return 0;
  22. }
  23. int puts(const char *s);
  24. /* Utility functions */
  25. void put_u4(uint8_t v);
  26. void put_u8(uint8_t v);
  27. void put_u16(uint16_t v);
  28. void put_u32(uint32_t v);
  29. void put_ptr(const void *p);
  30. void put_array(const void *p, size_t l);
  31. #define put_with_label(label, put, value) do { \
  32. puts(label); \
  33. put(value); \
  34. puts("\n"); \
  35. } while (0)