uart.h 1.1 KB

12345678910111213141516171819202122232425262728293031323334
  1. #ifndef __UART_H__
  2. #define __UART_H__
  3. #include "uart_hw.h"
  4. // Receive callback function signature
  5. typedef void (*UartRecv_cb)(char *buf, short len);
  6. // Initialize UARTs to the provided baud rates (115200 recommended). This also makes the os_printf
  7. // calls use uart1 for output (for debugging purposes)
  8. void uart_init(uint32 conf0, UartBautRate uart0_br, UartBautRate uart1_br);
  9. // Transmit a buffer of characters on UART0
  10. void uart0_tx_buffer(char *buf, uint16 len);
  11. void uart0_write_char(char c);
  12. STATUS uart_tx_one_char(uint8 uart, uint8 c);
  13. void uart1_write_char(char c);
  14. // Add a receive callback function, this is called on the uart receive task each time a chunk
  15. // of bytes are received. A small number of callbacks can be added and they are all called
  16. // with all new characters.
  17. void uart_add_recv_cb(UartRecv_cb cb);
  18. // Turn UART interrupts off and poll for nchars or until timeout hits
  19. uint16_t uart0_rx_poll(char *buff, uint16_t nchars, uint32_t timeout_us);
  20. void uart0_baud(int rate);
  21. void uart0_config(uint8_t data_bits, uint8_t parity, uint8_t stop_bits);
  22. void uart_config(uint8 uart_no, UartBautRate baudrate, uint32 conf0);
  23. #endif /* __UART_H__ */