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 <stddef.h>
#include <stdint.h>
#include <limits.h>
#include "periph_cpu.h"
#include "periph_conf.h"
#include "periph/dev_enums.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 UART_UNDEF   (UINT_MAX)
 Default UART undefined value.
 
#define UART_DEV(x)   (x)
 Default UART device access macro.
 

Typedefs

typedef unsigned int uart_t
 Define default UART type identifier.
 
typedef void(* uart_rx_cb_t) (void *arg, uint8_t data)
 Signature for receive interrupt callback. More...
 

Enumerations

enum  {
  UART_OK = 0, UART_NODEV = -1, UART_NOBAUD = -2, UART_INTERR = -3,
  UART_NOMODE = -4
}
 Possible UART return values. More...
 
enum  uart_parity_t {
  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 = 0x5, UART_DATA_BITS_6 = 0x6, UART_DATA_BITS_7 = 0x7, UART_DATA_BITS_8 = 0x0,
  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, UART_STOP_BITS_2 }
 Definition of possible stop bits lengths in a UART frame. More...
 

Functions

int uart_init (uart_t uart, uint32_t baudrate, uart_rx_cb_t rx_cb, void *arg)
 Initialize a given UART device. 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 the given UART device. More...
 
void uart_poweroff (uart_t uart)
 Power off the given UART device. More...