uart.c File Reference

library for UART communication (code) More...

Go to the source code of this file.

## Macros

#define | UART_ID 1
| USART peripheral.
#define | UART_BAUDRATE 921600
| serial baudrate, in bits per second (with 8N1 8 bits, no parity bit, 1 stop bit settings)

## Functions

void | uart_setup (void)
| setup UART peripheral
void | uart_putchar_blocking (char c)
| send character over UART (blocking) More...
void | uart_flush (void)
| ensure all data has been transmitted (blocking) More...
void | uart_putchar_nonblocking (char c)
| send character over UART (non-blocking) More...
void USART_ISR() | UART_ID (void)
| UART interrupt service routine called when data has been transmitted or received.

## Variables

static volatile uint8_t | tx_buffer [64] = {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

## Detailed Description

library for UART communication (code)

Author
  King Kévin kingk.nosp@m.evin.nosp@m.@cuvo.nosp@m.odoo.nosp@m..info

Date
  2016-2017

Note
  peripherals used: USART USART peripheral used for UART communication

Definition in file uart.c.

## Function Documentation

## uart_flush()

void uart_flush | ( | void |  | ) |

ensure all data has been transmitted (blocking)

Note
  block until all data has been transmitted

Definition at line 83 of file uart.c.

## uart_putchar_blocking()

void uart_putchar_blocking | ( | char | c | ) |

send character over UART (blocking)

Parameters

  [in] | c | character to send

Note
  blocks until character transmission started

Definition at line 77 of file uart.c.

## uart_putchar_nonblocking()

void uart_putchar_nonblocking | ( | char | c | ) |

send character over UART (non-blocking)

Parameters

  [in] | c | character to send

Note
  blocks if transmit buffer is full, else puts in buffer and returns

Definition at line 91 of file uart.c.