uart.h 1.4 KB

1234567891011121314151617181920212223242526272829303132
  1. #ifndef __SW_FIFO__
  2. #define __SW_FIFO__
  3. #include <stdint.h>
  4. #define FIFO_BUFFER_SIZE 128 // software buffer size (in bytes)
  5. //typedef uint8_t unsigned char
  6. // UART data transmit function
  7. // - checks if there's room in the transmit sw buffer
  8. // - if there's room, it transfers data byte to sw buffer
  9. // - automatically handles "uart_tx_buffer_full_flag"
  10. // - sets the overflow flag upon software buffer overflow (doesn't overwrite existing data)
  11. // - if this is the first data byte in the buffer, it enables the "hw buffer empty" interrupt
  12. void uart_send_byte(uint8_t byte);
  13. volatile extern uint8_t uart_rx_fifo_not_empty_flag; // this flag is automatically set and cleared by the software buffer
  14. volatile extern uint8_t uart_rx_fifo_full_flag; // this flag is automatically set and cleared by the software buffer
  15. volatile extern uint8_t uart_rx_fifo_ovf_flag; // this flag is not automatically cleared by the software buffer
  16. volatile extern uint8_t uart_tx_fifo_full_flag; // this flag is automatically set and cleared by the software buffer
  17. volatile extern uint8_t uart_tx_fifo_ovf_flag; // this flag is not automatically cleared by the software buffer
  18. volatile extern uint8_t uart_tx_fifo_not_empty_flag; // this flag is automatically set and cleared by the software buffer
  19. void usartInterrupt(void);
  20. int serialAvailable();
  21. unsigned char serialRead(void);
  22. #endif