pulp-runtime/drivers/include/host_uart.h
Luigi Ghionda dfd91b93a1 Add UART drivers in case this is a host peripheral to differentiate them from those that make use of udma
This mod is tailored for Astral and its host, Cheshire, whose basic funcitons are reused.
This enables printing from the cluster.
2025-01-26 12:47:37 +01:00

40 lines
1.1 KiB
C

// Copyright 2022 ETH Zurich and University of Bologna.
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
// SPDX-License-Identifier: Apache-2.0
//
// Nils Wistoff <nwistoff@iis.ee.ethz.ch>
// Paul Scheffler <paulsc@iis.ee.ethz.ch>
#pragma once
#include <stdint.h>
// Register offsets
#define UART_RBR_REG_OFFSET 0
#define UART_THR_REG_OFFSET 0
#define UART_INTR_ENABLE_REG_OFFSET 4
#define UART_INTR_IDENT_REG_OFFSET 8
#define UART_FIFO_CONTROL_REG_OFFSET 8
#define UART_LINE_CONTROL_REG_OFFSET 12
#define UART_MODEM_CONTROL_REG_OFFSET 16
#define UART_LINE_STATUS_REG_OFFSET 20
#define UART_MODEM_STATUS_REG_OFFSET 24
#define UART_DLAB_LSB_REG_OFFSET 0
#define UART_DLAB_MSB_REG_OFFSET 4
// Register fields
#define UART_LINE_STATUS_DATA_READY_BIT 0
#define UART_LINE_STATUS_THR_EMPTY_BIT 5
#define UART_LINE_STATUS_TMIT_EMPTY_BIT 6
int uart_read_ready(void *uart_base);
void uart_write(void *uart_base, uint8_t byte);
void uart_write_str(void *uart_base, void *src, uint64_t len);
void uart_write_flush(void *uart_base);
uint8_t uart_read(void *uart_base);
void uart_read_str(void *uart_base, void *dst, uint64_t len);