blob: 58f5e343e5c1bb60b12d250ee7507788499d978b [file] [log] [blame]
Zane Shelley465e0b32019-04-17 10:15:39 -05001#pragma once
2
Zane Shelleyca4b2f42019-08-30 15:48:40 -05003/**
4 * @file hei_user_interface.hpp
5 *
Zane Shelley7649b8b2020-05-08 20:12:35 -05006 * The process for actions like hardware register access will vary per user
Zane Shelleyca4b2f42019-08-30 15:48:40 -05007 * application. Therefore, the user application must define all of the APIs
Zane Shelley7649b8b2020-05-08 20:12:35 -05008 * declared in this header file.
Zane Shelleyca4b2f42019-08-30 15:48:40 -05009 */
10
Zane Shelley3a02e242020-05-08 16:25:36 -050011#include <stdlib.h>
12
13#include <hei_chip.hpp>
Zane Shelley2d4981a2020-06-04 14:32:45 -050014#include <hei_types.hpp>
Zane Shelley465e0b32019-04-17 10:15:39 -050015
Zane Shelley814b1e32019-06-17 20:55:04 -050016namespace libhei
17{
18
19/**
Zane Shelleyca4b2f42019-08-30 15:48:40 -050020 * @brief Performs a hardware register read operation.
21 *
Zane Shelley11b89942019-11-07 11:07:28 -060022 * @param i_chip The target chip for the register access. It is provided to
23 * the isolator by the user application via the isolator main
24 * APIs.
Zane Shelleyca4b2f42019-08-30 15:48:40 -050025 *
Zane Shelleyca4b2f42019-08-30 15:48:40 -050026 * @param i_regType The user application may support different types of
27 * registers. This value is provided to the isolator by the
28 * user application via the Chip Data Files. The user
29 * application is responsible for knowing what to do with this
30 * parameter.
31 *
Zane Shelley2d4981a2020-06-04 14:32:45 -050032 * @param i_address The register address, which is provided to the isolator by
33 * the user application via the Chip Data Files. This is a 1,
34 * 2, 4, or 8 byte value (right justified) as defined by the
35 * register type.
36 *
37 * @param o_value The returned register value. This is a 1, 2, 4, or 8 byte
38 * value (right justified) as defined by the register type.
Zane Shelleyca4b2f42019-08-30 15:48:40 -050039 *
Zane Shelley2f4aa912020-05-08 14:28:18 -050040 * @return false => register access was successful
41 * true => hardware access failure
42 * Note that in the case of a failure, the user application is
43 * responsible for reporting why the register access failed.
Zane Shelley814b1e32019-06-17 20:55:04 -050044 */
Zane Shelley2d4981a2020-06-04 14:32:45 -050045bool registerRead(const Chip& i_chip, RegisterType_t i_regType,
46 uint64_t i_address, uint64_t& o_value);
Zane Shelley814b1e32019-06-17 20:55:04 -050047
Ben Tyner7b3420b2020-05-11 10:52:07 -050048#ifdef __HEI_ENABLE_HW_WRITE
Zane Shelley814b1e32019-06-17 20:55:04 -050049
50/**
Zane Shelleyca4b2f42019-08-30 15:48:40 -050051 * @brief Performs a hardware register write operation.
52 *
Zane Shelley11b89942019-11-07 11:07:28 -060053 * @param i_chip The target chip for the register access. It is provided to
54 * the isolator by the user application via the isolator main
55 * APIs.
Zane Shelleyca4b2f42019-08-30 15:48:40 -050056 *
Zane Shelleyca4b2f42019-08-30 15:48:40 -050057 * @param i_regType The user application may support different types of
58 * registers. This value is provided to the isolator by the
59 * user application via the Chip Data Files. The user
60 * application is responsible for knowing what to do with this
61 * parameter.
62 *
Zane Shelley2d4981a2020-06-04 14:32:45 -050063 * @param i_address The register address, which is provided to the isolator by
64 * the user application via the Chip Data Files. This is a 1,
65 * 2, 4, or 8 byte value (right justified) as defined by the
66 * register type.
67 *
68 * @param i_value The register value to write. This is a 1, 2, 4, or 8 byte
69 * value (right justified) as defined by the register type.
Zane Shelleyca4b2f42019-08-30 15:48:40 -050070 *
Zane Shelley2f4aa912020-05-08 14:28:18 -050071 * @return false => register access was successful
72 * true => hardware access failure
73 * Note that in the case of a failure, the user application is
74 * responsible for reporting why the register access failed.
Zane Shelley814b1e32019-06-17 20:55:04 -050075 */
Zane Shelley2d4981a2020-06-04 14:32:45 -050076bool registerWrite(const Chip& i_chip, RegisterType_t i_regType,
77 uint64_t i_address, uint64_t i_value);
Zane Shelley814b1e32019-06-17 20:55:04 -050078
Ben Tyner7b3420b2020-05-11 10:52:07 -050079#endif // __HEI_ENABLE_HW_WRITE
Zane Shelley814b1e32019-06-17 20:55:04 -050080
Zane Shelley7649b8b2020-05-08 20:12:35 -050081/**
82 * @brief Prints an informational trace/log.
83 *
84 * This is similar to printing a single line of text to stdout. Example
85 * implementation:
86 * void hei_inf(char* format, ...)
87 * {
88 * va_list args;
89 * va_start(args, format);
90 * vfprintf(stdout, format, args);
91 * va_end(args);
92 * fprintf(stdout, "\n");
93 * }
94 *
95 * @param i_format The string format and variatic arguments.
96 */
97void hei_inf(char* i_format, ...);
98
99/**
100 * @brief Prints an error trace/log.
101 *
102 * This is similar to printing a single line of text to stderr. Example
103 * implementation:
104 * void hei_inf(char* format, ...)
105 * {
106 * va_list args;
107 * va_start(args, format);
108 * vfprintf(stderr, format, args);
109 * va_end(args);
110 * fprintf(stderr, "\n");
111 * }
112 *
113 * @param i_format The string format and variatic arguments.
114 */
115void hei_err(char* i_format, ...);
116
Zane Shelley814b1e32019-06-17 20:55:04 -0500117} // end namespace libhei