uart.h 859 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #ifndef _UART_H
  2. #define _UART_H
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6. #include "FreeRTOS.h"
  7. #include "semphr.h"
  8. #include "circ_buf.h"
  9. typedef enum {
  10. UART_ID0 = 0,
  11. UART_ID1,
  12. UART_ID2,
  13. UART_ID3,
  14. UART_NUM,
  15. } eUartID;
  16. typedef struct {
  17. uint32_t id;
  18. uint32_t regbase;
  19. int fifosize;
  20. struct circ_buf rxbuf;
  21. struct circ_buf txbuf;
  22. SemaphoreHandle_t xMutex;
  23. SemaphoreHandle_t xRev;
  24. SemaphoreHandle_t xSend;
  25. }UartPort_t;
  26. extern void vDebugConsoleInitialise(void);
  27. extern UartPort_t *xUartOpen(uint32_t id);
  28. extern void vUartInit(UartPort_t *uap, uint32_t baud, uint32_t flags);
  29. extern void vUartClose(UartPort_t *uap);
  30. extern int iUartWrite(UartPort_t *uap, uint8_t *buf, size_t len, TickType_t xBlockTime);
  31. int iUartRead(UartPort_t *uap, uint8_t *buf, size_t len, TickType_t xBlockTime);
  32. int uart_rx_demo(void);
  33. #ifdef __cplusplus
  34. }
  35. #endif
  36. #endif