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