Bouffalo SDK  1.0
Bouffalolab Software Development Kit
bflb_dac.h
Go to the documentation of this file.
1 #ifndef _BFLB_DAC_H
2 #define _BFLB_DAC_H
3 
4 #include "bflb_core.h"
5 
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 
28 #define DAC_CHANNEL_A (1 << 0)
29 #define DAC_CHANNEL_B (1 << 1)
30 
38 /* output Voltage (0.2V~1.8V) = (1.8V-0.2V) * digital_val/x + 0.2V
39  * x = 1024 (BL602/BL702/BL808), x = 4096(BL616)
40 */
41 
42 #define DAC_VREF_INTERNAL 0
43 
44 /* output Voltage (0.1vref~0.9vref) = (0.9vref-0.1vref) * digital_val/x + 0.1vref
45  *
46  * x = 1024 (BL602/BL702/BL808), x = 4096(BL616)
47  *
48  * BL702/BL704/BL706 using GPIO7
49  * BL616/BL618 using GPIO28
50 */
51 #define DAC_VREF_EXTERNAL 1
52 
60 #define DAC_DMA_FORMAT_0
61 #define DAC_DMA_FORMAT_1
66 #ifdef __cplusplus
67 extern "C" {
68 #endif
69 
76 void bflb_dac_init(struct bflb_device_s *dev, uint8_t clk_div);
77 
83 void bflb_dac_deinit(struct bflb_device_s *dev);
84 
91 void bflb_dac_link_txdma(struct bflb_device_s *dev, bool enable);
92 
99 void bflb_dac_set_dma_format(struct bflb_device_s *dev, uint8_t format);
100 
107 void bflb_dac_channel_enable(struct bflb_device_s *dev, uint8_t ch);
108 
115 void bflb_dac_channel_disable(struct bflb_device_s *dev, uint8_t ch);
116 
124 void bflb_dac_set_value(struct bflb_device_s *dev, uint8_t ch, uint16_t value);
125 
126 #ifdef __cplusplus
127 }
128 #endif
129 
138 #endif
void bflb_dac_channel_disable(struct bflb_device_s *dev, uint8_t ch)
Disable dac channel.
void bflb_dac_deinit(struct bflb_device_s *dev)
Deinitialize dac.
void bflb_dac_link_txdma(struct bflb_device_s *dev, bool enable)
Enable dac tx dma.
void bflb_dac_channel_enable(struct bflb_device_s *dev, uint8_t ch)
Enable dac channel.
void bflb_dac_set_value(struct bflb_device_s *dev, uint8_t ch, uint16_t value)
Set dac output value.
void bflb_dac_init(struct bflb_device_s *dev, uint8_t clk_div)
Initialize dac frequence. Dac clk = 512K/clk_div, source clock must be 512K.
void bflb_dac_set_dma_format(struct bflb_device_s *dev, uint8_t format)
Set dac format in dma mode.