Line data Source code
1 1 : /*
2 : * Copyright 2025 NXP
3 : *
4 : * SPDX-License-Identifier: Apache-2.0
5 : */
6 :
7 : /**
8 : * @file
9 : * @ingroup opamp_interface
10 : * @brief Main header file for OPAMP (Operational Amplifier) driver API.
11 : */
12 :
13 : #ifndef ZEPHYR_INCLUDE_DRIVERS_OPAMP_H_
14 : #define ZEPHYR_INCLUDE_DRIVERS_OPAMP_H_
15 :
16 : /**
17 : * @brief Interfaces for operational amplifiers (OPAMP).
18 : * @defgroup opamp_interface OPAMP
19 : * @since 4.3
20 : * @version 0.1.0
21 : * @ingroup io_interfaces
22 : * @{
23 : */
24 :
25 : #include <zephyr/dt-bindings/opamp/opamp.h>
26 : #include <zephyr/device.h>
27 : #include <errno.h>
28 :
29 : #ifdef __cplusplus
30 : extern "C" {
31 : #endif
32 :
33 : /** @brief OPAMP gain factors. */
34 1 : enum opamp_gain {
35 : OPAMP_GAIN_1_7 = 0, /**< x 1/7. */
36 : OPAMP_GAIN_1_3, /**< x 1/3. */
37 : OPAMP_GAIN_1, /**< x 1. */
38 : OPAMP_GAIN_5_3, /**< x 5/3. */
39 : OPAMP_GAIN_2, /**< x 2. */
40 : OPAMP_GAIN_11_5, /**< x 11/5. */
41 : OPAMP_GAIN_3, /**< x 3. */
42 : OPAMP_GAIN_4, /**< x 4. */
43 : OPAMP_GAIN_13_3, /**< x 13/3. */
44 : OPAMP_GAIN_7, /**< x 7. */
45 : OPAMP_GAIN_8, /**< x 8. */
46 : OPAMP_GAIN_15, /**< x 15. */
47 : OPAMP_GAIN_16, /**< x 16. */
48 : OPAMP_GAIN_31, /**< x 31. */
49 : OPAMP_GAIN_32, /**< x 32. */
50 : OPAMP_GAIN_33, /**< x 33. */
51 : OPAMP_GAIN_63, /**< x 63. */
52 : OPAMP_GAIN_64, /**< x 64. */
53 : };
54 :
55 : /**
56 : * @cond INTERNAL_HIDDEN
57 : *
58 : * For internal use only, skip these in public documentation.
59 : */
60 :
61 : typedef int (*opamp_api_set_gain_t)(const struct device *dev, enum opamp_gain gain);
62 :
63 : __subsystem struct opamp_driver_api {
64 : opamp_api_set_gain_t set_gain;
65 : };
66 :
67 : /** @endcond */
68 :
69 : /**
70 : * @brief Set opamp gain.
71 : *
72 : * @param dev Pointer to the device structure for the driver instance.
73 : * @param gain Opamp gain, refer to enum @ref opamp_gain.
74 : *
75 : * @retval 0 If opamp gain has been successfully set.
76 : * @retval -errno Negative errno in case of failure.
77 : */
78 1 : __syscall int opamp_set_gain(const struct device *dev, enum opamp_gain gain);
79 :
80 : static inline int z_impl_opamp_set_gain(const struct device *dev, enum opamp_gain gain)
81 : {
82 : return DEVICE_API_GET(opamp, dev)->set_gain(dev, gain);
83 : }
84 :
85 : #ifdef __cplusplus
86 : }
87 : #endif
88 :
89 : /** @} */
90 :
91 : #include <zephyr/syscalls/opamp.h>
92 :
93 : #endif /* ZEPHYR_INCLUDE_DRIVERS_OPAMP_H_ */
|