lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 1 | // 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 Sota | 960fd8e | 2020-01-14 13:52:13 -0500 | [diff] [blame] | 5 | #ifndef OPENTITAN_SW_DEVICE_LIB_UART_H_ |
| 6 | #define OPENTITAN_SW_DEVICE_LIB_UART_H_ |
lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 7 | |
Miguel Young de la Sota | 30eb41a | 2019-12-12 15:25:50 -0600 | [diff] [blame] | 8 | #include <stddef.h> |
lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 9 | #include <stdint.h> |
| 10 | |
Miguel Young de la Sota | 30eb41a | 2019-12-12 15:25:50 -0600 | [diff] [blame] | 11 | #include "sw/device/lib/base/print.h" |
| 12 | |
lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 13 | void uart_send_char(char c); |
Tim Shepard | ae281b6 | 2019-10-17 10:33:33 -0400 | [diff] [blame] | 14 | |
| 15 | /** |
| 16 | * Send unsigned int over UART |
| 17 | */ |
lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 18 | void uart_send_uint(uint32_t n, int size); |
| 19 | void uart_init(unsigned int baud); |
Tim Shepard | ae281b6 | 2019-10-17 10:33:33 -0400 | [diff] [blame] | 20 | |
| 21 | /** |
| 22 | * Send a NULL-terminated string over UART |
| 23 | */ |
lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 24 | void uart_send_str(char *str); |
Tim Shepard | ae281b6 | 2019-10-17 10:33:33 -0400 | [diff] [blame] | 25 | |
Miguel Young de la Sota | 30eb41a | 2019-12-12 15:25:50 -0600 | [diff] [blame] | 26 | extern const buffer_sink_t uart_stdout; |
| 27 | |
Tim Shepard | ae281b6 | 2019-10-17 10:33:33 -0400 | [diff] [blame] | 28 | /** |
| 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 Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 34 | int uart_rcv_char(char *c); |
| 35 | |
Miguel Young de la Sota | 960fd8e | 2020-01-14 13:52:13 -0500 | [diff] [blame] | 36 | #endif // OPENTITAN_SW_DEVICE_LIB_UART_H_ |