Defines | |
#define | UART_BAUD_SELECT(baudRate, xtalCpu) ((xtalCpu)/((baudRate)*16l)-1) |
UART Baudrate Expression. | |
#define | UART_RX_BUFFER_SIZE 32 |
#define | UART_TX_BUFFER_SIZE 32 |
#define | P(s) ({static const char c[] __attribute__ ((progmem)) = s;c;}) |
#define | UART_FRAME_ERROR 0x0800 |
#define | UART_OVERRUN_ERROR 0x0400 |
#define | UART_BUFFER_OVERFLOW 0x0200 |
#define | UART_NO_DATA 0x0100 |
#define | uart_puts_P(__s) uart_puts_p(P(__s)) |
Macro to automatically put a string constant into program memory. | |
Functions | |
void | uart_init (unsigned int baudrate) |
Initialize UART and set baudrate. | |
unsigned int | uart_getc (void) |
Get received byte from ringbuffer. | |
void | uart_putc (unsigned char data) |
Put byte to ringbuffer for transmitting via UART. | |
void | uart_putc_hex (unsigned char data) |
void | uart_putdw_dec (uint32_t dw) |
void | uart_putw_dec (uint16_t dw) |
void | uart_puts (const char *s) |
Put string to ringbuffer for transmitting via UART. | |
void | uart_puts_p (const char *s) |
Put string from program memory to ringbuffer for transmitting via UART. |
#include <uart.h>
This library can be used to transmit and receive data through the built in UART.
An interrupt is generated when the UART has finished transmitting or receiving a byte. The interrupt handling routines use circular buffers for buffering received and transmitted data.
The UART_RX_BUFFER_SIZE and UART_TX_BUFFER_SIZE constants define the size of the circular buffers in bytes. Note that these constants must be a power of 2. You may need to adapt this size to your target and your application.
#define P | ( | s | ) | ({static const char c[] __attribute__ ((progmem)) = s;c;}) |
#define UART_BAUD_SELECT | ( | baudRate, | |||
xtalCpu | ) | ((xtalCpu)/((baudRate)*16l)-1) |
#define uart_puts_P | ( | __s | ) | uart_puts_p(P(__s)) |
#define UART_RX_BUFFER_SIZE 32 |
#define UART_TX_BUFFER_SIZE 32 |
unsigned int uart_getc | ( | void | ) |
Get received byte from ringbuffer.
Returns in the lower byte the received character and in the higher byte the last receive error. UART_NO_DATA is returned when no data is available.
void |
higher byte: last receive status
void uart_init | ( | unsigned int | baudrate | ) |
Initialize UART and set baudrate.
baudrate | Specify baudrate using macro UART_BAUD_SELECT() |
Referenced by main().
void uart_putc | ( | unsigned char | data | ) |
Put byte to ringbuffer for transmitting via UART.
data | byte to be transmitted |
Referenced by display_buffer(), main(), and sd_init().
void uart_putc_hex | ( | unsigned char | data | ) |
Referenced by print_disk_info(), and vs1011_test_vol_rw().
void uart_putdw_dec | ( | uint32_t | dw | ) |
Referenced by print_disk_info().
void uart_puts | ( | const char * | s | ) |
Put string to ringbuffer for transmitting via UART.
The string is buffered by the uart library in a circular buffer and one character at a time is transmitted to the UART using interrupts. Blocks if it can not write the whole string into the circular buffer.
s | string to be transmitted |
Referenced by display_buffer(), main(), print_disk_info(), and sd_init().
void uart_puts_p | ( | const char * | s | ) |
Put string from program memory to ringbuffer for transmitting via UART.
The string is buffered by the uart library in a circular buffer and one character at a time is transmitted to the UART using interrupts. Blocks if it can not write the whole string into the circular buffer.
s | program memory string to be transmitted |
void uart_putw_dec | ( | uint16_t | dw | ) |
Referenced by print_disk_info().