Teensy 4.1 core updated for C++20
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

ser_print.c 892B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #include "kinetis.h"
  2. #include "ser_print.h"
  3. #ifdef KINETISL
  4. // Simple polling-only Serial1 support for Teensy-LC
  5. // this is really only useful for extremely low-level troubleshooting
  6. void ser_write(uint8_t c)
  7. {
  8. while ((UART0_S1 & UART_S1_TDRE) == 0) /* wait */ ;
  9. UART0_D = c;
  10. }
  11. void ser_print(const char *p)
  12. {
  13. while (*p) {
  14. char c = *p++;
  15. if (c == '\n') ser_write('\r');
  16. ser_write(c);
  17. }
  18. }
  19. static void ser_print_hex1(unsigned int n)
  20. {
  21. n &= 15;
  22. if (n < 10) {
  23. ser_write('0' + n);
  24. } else {
  25. ser_write('A' - 10 + n);
  26. }
  27. }
  28. void ser_print_hex(unsigned int n)
  29. {
  30. ser_print_hex1(n >> 4);
  31. ser_print_hex1(n);
  32. }
  33. void ser_print_hex32(unsigned int n)
  34. {
  35. ser_print_hex(n >> 24);
  36. ser_print_hex(n >> 16);
  37. ser_print_hex(n >> 8);
  38. ser_print_hex(n);
  39. }
  40. #endif