Software APIs
pinmux_config.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_LIB_TESTING_JSON_PINMUX_CONFIG_H_
6 #define OPENTITAN_SW_DEVICE_LIB_TESTING_JSON_PINMUX_CONFIG_H_
7 #include "sw/device/lib/ujson/ujson_derive.h"
8 #ifdef __cplusplus
9 extern "C" {
10 #endif
11 
12 #define MODULE_ID MAKE_MODULE_ID('j', 'p', 'x')
13 
14 // Dependencies between usjon structure definitions can be a little tricky:
15 // - If not generating an implementation, we can just include the dependency.
16 // - If generating an implementation, we instead include the dependency in
17 // the C file before setting UJSON_SERDE_IMPL.
18 //
19 // This avoids a lot of extra preprocessor ifs, undefs and defines.
20 #if UJSON_SERDE_IMPL == 0
21 #include "sw/device/lib/testing/json/pinmux.h"
22 #endif
23 // clang-format off
24 
25 #define STRUCT_PINMUX_INPUT_SELECTION(field, string) \
26  field(peripheral, pinmux_peripheral_in_t, 16) \
27  field(selector, pinmux_insel_t, 16)
28 UJSON_SERDE_STRUCT(PinmuxInputSelection, pinmux_input_selection_t,
29  STRUCT_PINMUX_INPUT_SELECTION);
30 
31 #define STRUCT_PINMUX_OUTPUT_SELECTION(field, string) \
32  field(mio, pinmux_mio_out_t, 16) \
33  field(selector, pinmux_outsel_t, 16)
34 UJSON_SERDE_STRUCT(PinmuxOutputSelection, pinmux_output_selection_t,
35  STRUCT_PINMUX_OUTPUT_SELECTION);
36 
37 #define STRUCT_PINMUX_CONFIG(field, string) \
38  field(input, pinmux_input_selection_t) \
39  field(output, pinmux_output_selection_t)
40 UJSON_SERDE_STRUCT(PinmuxConfig, pinmux_config_t, STRUCT_PINMUX_CONFIG);
41 
42 #undef MODULE_ID
43 
44 // clang-format on
45 #ifndef RUST_PREPROCESSOR_EMIT
47 /**
48  * Configure the pinmux with a specific configuration.
49  *
50  * This function is specific to top_earlgrey and top_englishbreakfast.
51  */
52 status_t pinmux_config(ujson_t *uj, dif_pinmux_t *pinmux);
53 #endif // RUST_PREPROCESSOR_EMIT
54 #ifdef __cplusplus
55 }
56 #endif
57 #endif // OPENTITAN_SW_DEVICE_LIB_TESTING_JSON_PINMUX_CONFIG_H_