Keyboard firmwares for Atmel AVR and Cortex-M
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

sendchar_usart.c 1.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #include <stdint.h>
  2. #include "oddebug.h"
  3. #include "sendchar.h"
  4. /* from oddebug.h */
  5. #if defined UBRR
  6. # define ODDBG_UBRR UBRR
  7. #elif defined UBRRL
  8. # define ODDBG_UBRR UBRRL
  9. #elif defined UBRR0
  10. # define ODDBG_UBRR UBRR0
  11. #elif defined UBRR0L
  12. # define ODDBG_UBRR UBRR0L
  13. #endif
  14. #if defined UCR
  15. # define ODDBG_UCR UCR
  16. #elif defined UCSRB
  17. # define ODDBG_UCR UCSRB
  18. #elif defined UCSR0B
  19. # define ODDBG_UCR UCSR0B
  20. #endif
  21. #if defined TXEN
  22. # define ODDBG_TXEN TXEN
  23. #else
  24. # define ODDBG_TXEN TXEN0
  25. #endif
  26. #if defined USR
  27. # define ODDBG_USR USR
  28. #elif defined UCSRA
  29. # define ODDBG_USR UCSRA
  30. #elif defined UCSR0A
  31. # define ODDBG_USR UCSR0A
  32. #endif
  33. #if defined UDRE
  34. # define ODDBG_UDRE UDRE
  35. #else
  36. # define ODDBG_UDRE UDRE0
  37. #endif
  38. #if defined UDR
  39. # define ODDBG_UDR UDR
  40. #elif defined UDR0
  41. # define ODDBG_UDR UDR0
  42. #endif
  43. /* from oddebug.c */
  44. int8_t sendchar(uint8_t c)
  45. {
  46. while(!(ODDBG_USR & (1 << ODDBG_UDRE))); /* wait for data register empty */
  47. ODDBG_UDR = c;
  48. return 1;
  49. }