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.
 
 
 
 

55 lines
1.7 KiB

  1. #ifndef UART_H
  2. #define UART_H
  3. #include "config.h"
  4. /* Init */
  5. void uart_init(int uart, int32_t rate);
  6. /* Blocking sends */
  7. void uart_put(int uart, uint8_t x);
  8. void uart_put_string(int uart, const char *s);
  9. void uart_crlf(int uart);
  10. void uart_put_hex(int uart, uint8_t x);
  11. void uart_put_hex16(int uart, uint16_t x);
  12. void uart_put_hex32(int uart, uint32_t x);
  13. void uart_put_bin(int uart, uint8_t x);
  14. void uart_put_dec(int uart, int32_t x);
  15. void uart_put_float(int uart, float x);
  16. /* Blocking receives */
  17. uint8_t uart_get(int uart);
  18. /* Return true if get/put would not block */
  19. int uart_can_get(int uart);
  20. int uart_can_put(int uart);
  21. /* Helpers to work with a specific uart */
  22. #define uart1_init(x) uart_init(1, x)
  23. #define uart1_can_get() uart_can_get(1)
  24. #define uart1_get() uart_get(1)
  25. #define uart1_put(x) uart_put(1,x)
  26. #define uart1_put_string(x) uart_put_string(1,x)
  27. #define uart1_crlf() uart_crlf(1)
  28. #define uart1_put_hex(x) uart_put_hex(1,x)
  29. #define uart1_put_hex16(x) uart_put_hex16(1,x)
  30. #define uart1_put_hex32(x) uart_put_hex32(1,x)
  31. #define uart1_put_bin(x) uart_put_bin(1,x)
  32. #define uart1_put_dec(x) uart_put_dec(1,x)
  33. #define uart1_put_float(x) uart_put_float(1,x)
  34. #define uart2_init(x) uart_init(2, x)
  35. #define uart2_can_get() uart_can_get(2)
  36. #define uart2_get() uart_get(2)
  37. #define uart2_put(x) uart_put(2,x)
  38. #define uart2_put_string(x) uart_put_string(2,x)
  39. #define uart2_crlf() uart_crlf(2)
  40. #define uart2_put_hex(x) uart_put_hex(2,x)
  41. #define uart2_put_hex16(x) uart_put_hex16(2,x)
  42. #define uart2_put_hex32(x) uart_put_hex32(2,x)
  43. #define uart2_put_bin(x) uart_put_bin(2,x)
  44. #define uart2_put_dec(x) uart_put_dec(2,x)
  45. #define uart2_put_float(x) uart_put_float(2,x)
  46. #endif