blob: c35ab9b544b3fabf9e3c01ba21d5be3633a7eadc [file] [log] [blame]
lowRISC Contributors802543a2019-08-31 12:12:56 +01001// Copyright lowRISC contributors.
2// Licensed under the Apache License, Version 2.0, see LICENSE for details.
3// SPDX-License-Identifier: Apache-2.0
4
Miguel Young de la Sota960fd8e2020-01-14 13:52:13 -05005#ifndef OPENTITAN_SW_DEVICE_LIB_UART_H_
6#define OPENTITAN_SW_DEVICE_LIB_UART_H_
lowRISC Contributors802543a2019-08-31 12:12:56 +01007
Miguel Young de la Sota30eb41a2019-12-12 15:25:50 -06008#include <stddef.h>
lowRISC Contributors802543a2019-08-31 12:12:56 +01009#include <stdint.h>
10
Miguel Young de la Sota30eb41a2019-12-12 15:25:50 -060011#include "sw/device/lib/base/print.h"
12
lowRISC Contributors802543a2019-08-31 12:12:56 +010013void uart_send_char(char c);
Tim Shepardae281b62019-10-17 10:33:33 -040014
15/**
16 * Send unsigned int over UART
17 */
lowRISC Contributors802543a2019-08-31 12:12:56 +010018void uart_send_uint(uint32_t n, int size);
19void uart_init(unsigned int baud);
Tim Shepardae281b62019-10-17 10:33:33 -040020
21/**
22 * Send a NULL-terminated string over UART
23 */
lowRISC Contributors802543a2019-08-31 12:12:56 +010024void uart_send_str(char *str);
Tim Shepardae281b62019-10-17 10:33:33 -040025
Miguel Young de la Sota30eb41a2019-12-12 15:25:50 -060026extern const buffer_sink_t uart_stdout;
27
Tim Shepardae281b62019-10-17 10:33:33 -040028/**
29 * Receive a single character from UART
30 *
31 * @param c received character, caller-allocated
32 * @return 0 on success, -1 if no data is available
33 */
lowRISC Contributors802543a2019-08-31 12:12:56 +010034int uart_rcv_char(char *c);
35
Miguel Young de la Sota960fd8e2020-01-14 13:52:13 -050036#endif // OPENTITAN_SW_DEVICE_LIB_UART_H_