Software APIs
sw
device
silicon_creator
manuf
tests
sram_empty_functest.c
1
// Copyright lowRISC contributors (OpenTitan project).
2
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
3
// SPDX-License-Identifier: Apache-2.0
4
5
#include <
stdint.h
>
6
7
#include "
sw/device/lib/arch/device.h
"
8
#include "
sw/device/lib/dif/dif_uart.h
"
9
#include "
sw/device/lib/runtime/log.h
"
10
#include "
sw/device/lib/runtime/print.h
"
11
#include "sw/device/lib/testing/pinmux_testutils.h"
12
#include "sw/device/lib/testing/test_framework/check.h"
13
#include "sw/device/lib/testing/test_framework/ottf_test_config.h"
14
#include "sw/device/lib/testing/test_framework/status.h"
15
16
#include "
hw/top_earlgrey/sw/autogen/top_earlgrey.h
"
17
18
OTTF_DEFINE_TEST_CONFIG();
19
20
static
dif_uart_t uart;
21
static
dif_pinmux_t pinmux;
22
23
bool
test_main
(
void
) {
24
// Initialize UART console.
25
CHECK_DIF_OK(dif_pinmux_init(
26
mmio_region_from_addr
(
TOP_EARLGREY_PINMUX_AON_BASE_ADDR
), &pinmux));
27
CHECK_DIF_OK(dif_uart_init(
28
mmio_region_from_addr
(
TOP_EARLGREY_UART0_BASE_ADDR
), &uart));
29
pinmux_testutils_init(&pinmux);
30
CHECK(
kUartBaudrate
<= UINT32_MAX,
"kUartBaudrate must fit in uint32_t"
);
31
CHECK(
kClockFreqPeripheralHz
<= UINT32_MAX,
32
"kClockFreqPeripheralHz must fit in uint32_t"
);
33
CHECK_DIF_OK(
dif_uart_configure
(
34
&uart, (
dif_uart_config_t
){
35
.baudrate = (uint32_t)
kUartBaudrate
,
36
.clk_freq_hz = (uint32_t)
kClockFreqPeripheralHz
,
37
.parity_enable =
kDifToggleDisabled
,
38
.parity =
kDifUartParityEven
,
39
.tx_enable =
kDifToggleEnabled
,
40
.rx_enable =
kDifToggleEnabled
,
41
}));
42
base_uart_stdout
(&uart);
43
44
LOG_INFO
(
"Hello OpenTitan! We are executing from SRAM."
);
45
46
// Make sure that the function returns so that the CRT can notify the host.
47
return
true
;
48
}
Return to
OpenTitan Documentation