Software APIs
demos.h
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 #ifndef OPENTITAN_SW_DEVICE_EXAMPLES_DEMOS_H_
6 #define OPENTITAN_SW_DEVICE_EXAMPLES_DEMOS_H_
7 
8 #include <stdint.h>
9 
12 
13 /**
14  * This header provides a small library of reuseable demos for use with
15  * OpenTitan example code.
16  */
17 
18 /**
19  * Runs a small demo on the GPIO pins to show that things are working.
20  *
21  * @param gpio the GPIO device to actuate.
22  */
23 void demo_gpio_startup(dif_gpio_t *gpio);
24 
25 /**
26  * Executes a step of a GPIO -> LOG echo demo, by diffing
27  * the previous GPIO state with the current state, and reporting
28  * the difference.
29  *
30  * The new state is returned, so it can be passed in on the next
31  * iteration.
32  *
33  * @param gpio the GPIO device to pull bits from.
34  * @param prev_gpio_state the previous GPIO state to diff against.
35  * @return the new GPIO state.
36  */
37 uint32_t demo_gpio_to_log_echo(dif_gpio_t *gpio, uint32_t prev_gpio_state);
38 
39 /**
40  * Attempts to read characters from UART and immediately echo them back,
41  * as well as to write its bits to GPIO pins 8-15.
42  *
43  * @param uart the UART device to actuate.
44  * @param gpio the GPIO device to actuate.
45  */
46 void demo_uart_to_uart_and_gpio_echo(dif_uart_t *uart, dif_gpio_t *gpio);
47 
48 #endif // OPENTITAN_SW_DEVICE_EXAMPLES_DEMOS_H_