UART

The UART driver currently supports one TX-only UART instance mapped to pin D1/TX with a configurable baudrate.

Note that the UART is clocked from a rather inaccurate RC-oscillator. Therefore, baudrates may differ significantly from the specified value.

Example usage

 1#include "riotee.h"
 2#include "riotee_timing.h"
 3#include "riotee_uart.h"
 4#include "printf.h"
 5
 6/* This gets called after every reset */
 7void lateinit(void) {
 8  riotee_uart_init(PIN_D1, RIOTEE_UART_BAUDRATE_1000000);
 9  printf("Hello Riotee!\r\n");
10}
11
12int main(void) {
13  int counter = 0;
14  for (;;) {
15    printf("Loop: %d\r\n", counter++);
16    riotee_sleep_ms(1000);
17  }
18}

API reference

enum riotee_uart_baudrate_t

Values:

enumerator RIOTEE_UART_BAUDRATE_1200

1200 baud (actual rate: 1205)

enumerator RIOTEE_UART_BAUDRATE_2400

2400 baud (actual rate: 2396)

enumerator RIOTEE_UART_BAUDRATE_4800

4800 baud (actual rate: 4808)

enumerator RIOTEE_UART_BAUDRATE_9600

9600 baud (actual rate: 9598)

enumerator RIOTEE_UART_BAUDRATE_14400

14400 baud (actual rate: 14414)

enumerator RIOTEE_UART_BAUDRATE_19200

19200 baud (actual rate: 19208)

enumerator RIOTEE_UART_BAUDRATE_28800

28800 baud (actual rate: 28829)

enumerator RIOTEE_UART_BAUDRATE_31250

31250 baud

enumerator RIOTEE_UART_BAUDRATE_38400

38400 baud (actual rate: 38462)

enumerator RIOTEE_UART_BAUDRATE_56000

56000 baud (actual rate: 55944)

enumerator RIOTEE_UART_BAUDRATE_57600

57600 baud (actual rate: 57762)

enumerator RIOTEE_UART_BAUDRATE_76800

76800 baud (actual rate: 76923)

enumerator RIOTEE_UART_BAUDRATE_115200

115200 baud (actual rate: 115942)

enumerator RIOTEE_UART_BAUDRATE_230400

230400 baud (actual rate: 231884)

enumerator RIOTEE_UART_BAUDRATE_250000

250000 baud

enumerator RIOTEE_UART_BAUDRATE_460800

460800 baud (actual rate: 470588)

enumerator RIOTEE_UART_BAUDRATE_921600

921600 baud (actual rate: 941176)

enumerator RIOTEE_UART_BAUDRATE_1000000

1Mega baud

void riotee_uart_init(uint32_t pseltxd, riotee_uart_baudrate_t baudrate)

Initializes UART peripheral.

Parameters:
  • pseltxd – UART TX pin.

  • baudrate – UART baudrate.

void riotee_uart_set_baudrate(riotee_uart_baudrate_t baudrate)

Sets baudrate of UART peripheral.

Parameters:

baudrate – UART baudrate.

void _putchar(char character)

Outputs a character over UART.

Blocks in a critical section until done.

riotee_putc(x)

Outputs a character over UART.

Blocks in a critical section until done.