Software APIs
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 
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 
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(
27  CHECK_DIF_OK(dif_uart_init(
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 }