1 /*
2  * Copyright (c) 2021 Huawei Device Co., Ltd.
3  *
4  * HDF is dual licensed: you can use it either under the terms of
5  * the GPL, or the BSD license, at your option.
6  * See the LICENSE file in the root of this repository for complete details.
7  */
8 /**
9  * @addtogroup DAC
10  * @{
11  *
12  * @brief Provides Digital to analog converter (DAC) interfaces.
13  *
14  * This module allows a driver to perform operations on an DAC controller for accessing devices on the DAC channel,
15  * Including creating and destroying DAC controller handles and writing data
16  *
17  * @since 1.0
18  */
19 /**
20  * @file dac_if.h
21  *
22  * @brief Declares the standard DAC interface functions.
23  *
24  * @since 1.0
25  */
26 
27 #ifndef DAC_IF_H
28 #define DAC_IF_H
29 
30 #include "platform_if.h"
31 
32 #ifdef __cplusplus
33 #if __cplusplus
34 extern "C" {
35 #endif
36 #endif /* __cplusplus */
37 
38 struct DacIoMsg {
39     uint32_t number;
40     uint32_t channel;
41 };
42 
43  /**
44  * @brief Obtains the handle of an DAC controller.
45  *
46  * You must call this function before accessing the DAC CHANNEL.
47  *
48  * @param number Indicates the DAC controller ID.
49  *
50  * @return Returns the pointer to the {@link DevHandle} of the DAC controller if the operation is successful;
51  * returns <b>NULL</b> otherwise.
52  * @since 1.0
53  */
54 DevHandle DacOpen(uint32_t number);
55 
56  /**
57  * @brief Releases the handle of an DAC controller.
58  *
59  * If you no longer need to access the DAC controller, you should call this function to close its handle so as
60  * to release unused memory resources.
61  *
62  * @param handle Indicates the pointer to the device handle of the DAC controller.
63  *
64  * @since 1.0
65  */
66 void DacClose(DevHandle handle);
67 
68  /**
69  * @brief Start the DAC device for transmission and write the target value in the specified DAC channel.
70  *
71  * @param handle Indicates the pointer to the device handle of the DAC controller obtained via {@link DacOpen}.
72  * @param channel represents the channel through which the DAC transmits messages.
73  * @param val represents the set digital target value.
74  *
75  * @return Returns 0 if the operation is successful; Returns a negative value otherwise..
76  *
77  * @since 1.0
78  */
79 int32_t DacWrite(DevHandle handle, uint32_t channel, uint32_t val);
80 
81 /**
82  * @brief Enumerates DAC I/O commands.
83  *
84  * @since 1.0
85  */
86 enum DacIoCmd {
87     DAC_IO_READ = 0,
88     DAC_IO_OPEN,
89     DAC_IO_CLOSE,
90     DAC_IO_WRITE,
91 };
92 #ifdef __cplusplus
93 #if __cplusplus
94 }
95 #endif
96 #endif /* __cplusplus */
97 
98 #endif /* DAC_IF_H */
99