Brian Silverman | df49fe3 | 2013-12-11 14:21:37 -0800 | [diff] [blame] | 1 | #ifndef CAPE_UART_BYTE_H_ |
| 2 | #define CAPE_UART_BYTE_H_ |
| 3 | |
| 4 | #include <stdint.h> |
| 5 | |
| 6 | // uart_common_configure must be called before this. |
| 7 | void uart_byte_configure(void); |
| 8 | |
| 9 | // Spins until 1 byte is received or some amount of time. The timeout is |
Brian Silverman | 176c676 | 2013-12-19 16:28:09 -0800 | [diff] [blame] | 10 | // timeout_count*(timeout_divider+1)/60MHz. |
Brian Silverman | 3aa0d54 | 2014-01-25 17:16:43 -0800 | [diff] [blame] | 11 | // The result is <0 for timeout/error or the received byte. |
| 12 | // errors: |
| 13 | // -1 timeout |
| 14 | // -2 parity |
| 15 | // -3 framing |
| 16 | // -4 noise detected |
| 17 | // -5 overrun |
Brian Silverman | df49fe3 | 2013-12-11 14:21:37 -0800 | [diff] [blame] | 18 | int uart_byte_receive(uint16_t timeout_count, uint16_t timeout_divider); |
| 19 | |
| 20 | // Spins until 1 byte can be written out. |
| 21 | void uart_byte_send(uint8_t value); |
| 22 | |
| 23 | #endif // CAPE_UART_BYTE_H_ |