library for USART communication (code)
More...
Go to the source code of this file.
|
#define | USART_ID 1 |
| USART peripheral.
|
|
#define | USART_BAUDRATE 1500000 |
| serial baudrate, in bits per second (with 8N1 8 bits, no parity bit, 1 stop bit settings)
|
|
|
static uint8_t | rx_buffer [USART_BUFFER] = {0} |
| ring buffer for received data
|
|
static volatile uint8_t | rx_i = 0 |
| current position of read received data
|
|
static volatile uint8_t | rx_used = 0 |
| how much data has been received and not red
|
|
static uint8_t | tx_buffer [USART_BUFFER] = {0} |
| ring buffer for data to transmit
|
|
static volatile uint8_t | tx_i = 0 |
| current position of transmitted data
|
|
static volatile uint8_t | tx_used = 0 |
| how much data needs to be transmitted
|
|
volatile bool | usart_received = false |
| how many bytes available in the received buffer since last read
|
|
library for USART communication (code)
- Author
- King Kévin kingk.nosp@m.evin.nosp@m.@cuvo.nosp@m.odoo.nosp@m..info
- Date
- 2016
- Note
- peripherals used: USART USART peripheral used for UART communication
Definition in file usart.c.
◆ usart_flush()
void usart_flush |
( |
void |
| ) |
|
ensure all data has been transmitted (blocking)
- Note
- block until all data has been transmitted
Definition at line 91 of file usart.c.
◆ usart_getchar()
char usart_getchar |
( |
void |
| ) |
|
get character received over USART (blocking)
- Returns
- character received over USART
- Note
- blocks until character is received over USART when received buffer is empty
Definition at line 99 of file usart.c.
◆ usart_putchar_blocking()
void usart_putchar_blocking |
( |
char |
c | ) |
|
send character over USART (blocking)
- Parameters
-
- Note
- blocks until character transmission started
Definition at line 85 of file usart.c.
◆ usart_putchar_nonblocking()
void usart_putchar_nonblocking |
( |
char |
c | ) |
|
send character over USART (non-blocking)
- Parameters
-
- Note
- blocks if transmit buffer is full, else puts in buffer and returns
Definition at line 113 of file usart.c.