1 #ifndef _BFLB_DAC_H
2 #define _BFLB_DAC_H
3 
4 #include "bflb_core.h"
5 
6 /** @addtogroup LHAL
7   * @{
8   */
9 
10 /** @addtogroup DAC
11   * @{
12   */
13 
14 /** @defgroup DAC_CLK_DIV dac clock div definition
15   * @{
16   */
17 #define DAC_CLK_DIV_16 0
18 #define DAC_CLK_DIV_32 1
19 #define DAC_CLK_DIV_64 3
20 #define DAC_CLK_DIV_1  4
21 /**
22   * @}
23   */
24 
25 /** @defgroup DAC_CHANNEL dac channel select
26   * @{
27   */
28 #define DAC_CHANNEL_A (1 << 0)
29 #define DAC_CHANNEL_B (1 << 1)
30 /**
31   * @}
32   */
33 
34 #ifdef __cplusplus
35 extern "C" {
36 #endif
37 
38 /**
39  * @brief Initialize dac frequence.
40  *
41  * @param [in] dev device handle
42  * @param [in] frequence dac clock div, use @ref DAC_CLK_DIV
43  */
44 void bflb_dac_init(struct bflb_device_s *dev, uint8_t clk_div);
45 
46 /**
47  * @brief Deinitialize dac.
48  *
49  * @param [in] dev device handle
50  */
51 void bflb_dac_deinit(struct bflb_device_s *dev);
52 
53 /**
54  * @brief Enable dac tx dma.
55  *
56  * @param [in] dev device handle
57  * @param [in] enable true means enable, otherwise disable.
58  */
59 void bflb_dac_link_txdma(struct bflb_device_s *dev, bool enable);
60 
61 /**
62  * @brief Enable dac channel.
63  *
64  * @param [in] dev device handle
65  * @param [in] ch channel number
66  */
67 void bflb_dac_channel_enable(struct bflb_device_s *dev, uint8_t ch);
68 
69 /**
70  * @brief Disable dac channel.
71  *
72  * @param [in] dev device handle
73  * @param [in] ch channel number
74  */
75 void bflb_dac_channel_disable(struct bflb_device_s *dev, uint8_t ch);
76 
77 /**
78  * @brief Set dac output value
79  *
80  * @param [in] dev device handle
81  * @param [in] ch channel number
82  * @param [in] value output value
83  */
84 void bflb_dac_set_value(struct bflb_device_s *dev, uint8_t ch, uint16_t value);
85 
86 #ifdef __cplusplus
87 }
88 #endif
89 
90 /**
91   * @}
92   */
93 
94 /**
95   * @}
96   */
97 
98 #endif