uart.h File Reference

Low-level UART peripheral driver interface definition. More...

Detailed Description

Low-level UART peripheral driver interface definition.

Author
Hauke Petersen hauke.nosp@m..pet.nosp@m.ersen.nosp@m.@fu-.nosp@m.berli.nosp@m.n.de

Definition in file uart.h.

#include <errno.h>
#include <limits.h>
#include <stddef.h>
#include <stdint.h>
#include "periph_cpu.h"
#include "periph_conf.h"
+ Include dependency graph for uart.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  uart_isr_ctx_t
 Interrupt context for a UART device. More...
 

Macros

#define CONFIG_UART_DMA_THRESHOLD_BYTES   8
 Threshold under which polling transfers are used instead of DMA TODO: determine at run-time based on baudrate.
 
#define UART_UNDEF   (UINT_FAST8_MAX)
 Default UART undefined value.
 
#define UART_DEV(x)   (x)
 Default UART device access macro.
 

Typedefs

typedef uint_fast8_t uart_t
 Define default UART type identifier.
 
typedef void(* uart_rx_cb_t) (void *arg, uint8_t data)
 Signature for receive interrupt callback. More...
 
typedef void(* uart_rxstart_cb_t) (void *arg)
 Signature for receive start condition interrupt callback. More...
 

Enumerations

enum  {
  UART_OK = 0 , UART_NODEV = -ENODEV , UART_NOBAUD = -ENOTSUP , UART_NOMODE = -ENOTSUP ,
  UART_INTERR = -EIO
}
 Possible UART return values. More...
 
enum  uart_parity_t {
  UART_PARITY_NONE = 0 , UART_PARITY_EVEN = 2 , UART_PARITY_ODD = 3 , UART_PARITY_MARK = 0x10 | UART_INVALID_MODE ,
  UART_PARITY_SPACE = 0x20 | UART_INVALID_MODE , UART_PARITY_NONE , UART_PARITY_EVEN , UART_PARITY_ODD ,
  UART_PARITY_MARK , UART_PARITY_SPACE
}
 Definition of possible parity modes. More...
 
enum  uart_data_bits_t {
  UART_DATA_BITS_5 = 0x10 | UART_INVALID_MODE , UART_DATA_BITS_6 = 0x20 | UART_INVALID_MODE , UART_DATA_BITS_7 = 0 , UART_DATA_BITS_8 = 1 ,
  UART_DATA_BITS_5 , UART_DATA_BITS_6 , UART_DATA_BITS_7 , UART_DATA_BITS_8
}
 Definition of possible data bits lengths in a UART frame. More...
 
enum  uart_stop_bits_t { UART_STOP_BITS_1 = 0 , UART_STOP_BITS_2 = 1 , UART_STOP_BITS_1 , UART_STOP_BITS_2 }
 Definition of possible stop bits lengths in a UART frame. More...
 

Functions

int uart_init (uart_t uart, uint32_t baud, uart_rx_cb_t rx_cb, void *arg)
 Initialize and acquire a given UART device. More...
 
void uart_deinit_pins (uart_t uart)
 Change the pins of the given UART back to plain GPIO functionality. More...
 
void uart_init_pins (uart_t uart)
 Initialize the used UART pins, i.e. More...
 
gpio_t uart_pin_rx (uart_t uart)
 Get the RX pin of the given UART. More...
 
gpio_t uart_pin_tx (uart_t uart)
 Get the TX pin of the given UART. More...
 
gpio_t uart_pin_cts (uart_t uart)
 Get the CTS pin of the given UART. More...
 
gpio_t uart_pin_rts (uart_t uart)
 Get the RTS pin of the given UART. More...
 
void uart_rxstart_irq_configure (uart_t uart, uart_rxstart_cb_t cb, void *arg)
 Configure the function that will be called when a start condition is detected. More...
 
void uart_rxstart_irq_enable (uart_t uart)
 Enable the RX start interrupt. More...
 
void uart_rxstart_irq_disable (uart_t uart)
 Disable the RX start interrupt. More...
 
void uart_collision_detect_enable (uart_t uart)
 Enables collision detection check of the UART. More...
 
void uart_collision_detect_disable (uart_t uart)
 Disables collision detection check of the UART. More...
 
bool uart_collision_detected (uart_t uart)
 Disables collision detection check of the UART. More...
 
int uart_mode (uart_t uart, uart_data_bits_t data_bits, uart_parity_t parity, uart_stop_bits_t stop_bits)
 Setup parity, data and stop bits for a given UART device. More...
 
void uart_write (uart_t uart, const uint8_t *data, size_t len)
 Write data from the given buffer to the specified UART device. More...
 
void uart_poweron (uart_t uart)
 Power on and acquire the given UART device. More...
 
void uart_poweroff (uart_t uart)
 Power off and release the given UART device. More...
 
void uart_enable_tx (uart_t uart)
 Enable the TX line one the given UART. More...
 
void uart_disable_tx (uart_t uart)
 Disable the TX line one the given UART. More...