Bouffalo SDK  1.0
Bouffalolab Software Development Kit
bflb_acomp.h
Go to the documentation of this file.
1 #ifndef _BFLB_ACOMP_H
2 #define _BFLB_ACOMP_H
3 
4 #include "bflb_core.h"
5 
17 #define AON_ACOMP0_ID 0
18 #define AON_ACOMP1_ID 1
19 
23 #define AON_ACOMP_SCALING_FACTOR_0P25 0x00
24 #define AON_ACOMP_SCALING_FACTOR_0P5 0x10
25 #define AON_ACOMP_SCALING_FACTOR_0P75 0x20
26 #define AON_ACOMP_SCALING_FACTOR_1 0x30
31 #define AON_ACOMP_CHAN_ADC0 0
32 #define AON_ACOMP_CHAN_ADC1 1
33 #define AON_ACOMP_CHAN_ADC2 2
34 #define AON_ACOMP_CHAN_ADC3 3
35 #define AON_ACOMP_CHAN_ADC4 4
36 #define AON_ACOMP_CHAN_ADC5 5
37 #define AON_ACOMP_CHAN_ADC6 6
38 #define AON_ACOMP_CHAN_ADC7 7
39 #define AON_ACOMP_CHAN_DACA 8
40 #define AON_ACOMP_CHAN_DACB 9
41 #define AON_ACOMP_CHAN_VREF_1P25V 10
42 #define AON_ACOMP_CHAN_VIO_X_SCALING_FACTOR_1 11
43 #define AON_ACOMP_CHAN_VIO_X_SCALING_FACTOR_2 12
44 #define AON_ACOMP_CHAN_VIO_X_SCALING_FACTOR_3 13
45 #define AON_ACOMP_CHAN_VIO_X_SCALING_FACTOR_4 14
46 #define AON_ACOMP_CHAN_VSS 15
51 #define AON_ACOMP_BIAS_POWER_MODE1 0
52 #define AON_ACOMP_BIAS_POWER_MODE2 1
53 #define AON_ACOMP_BIAS_POWER_MODE3 2
54 #define AON_ACOMP_BIAS_POWER_NONE 3
59 #define AON_ACOMP_HYSTERESIS_VOLT_NONE 0
60 #define AON_ACOMP_HYSTERESIS_VOLT_10MV 1
61 #define AON_ACOMP_HYSTERESIS_VOLT_20MV 2
62 #define AON_ACOMP_HYSTERESIS_VOLT_30MV 3
63 #define AON_ACOMP_HYSTERESIS_VOLT_40MV 4
64 #define AON_ACOMP_HYSTERESIS_VOLT_50MV 5
65 #define AON_ACOMP_HYSTERESIS_VOLT_60MV 6
66 #define AON_ACOMP_HYSTERESIS_VOLT_70MV 7
80 struct bflb_acomp_config_s {
81  uint8_t mux_en;
82  uint8_t pos_chan_sel;
83  uint8_t neg_chan_sel;
84  uint8_t vio_sel;
85  uint8_t scaling_factor;
86  uint8_t bias_prog;
89 };
90 
91 
92 #ifdef __cplusplus
93 extern "C" {
94 #endif
95 
102 void bflb_acomp_init(uint8_t acomp_id, const struct bflb_acomp_config_s *config);
103 
109 void bflb_acomp_enable(uint8_t acomp_id);
110 
116 void bflb_acomp_disable(uint8_t acomp_id);
117 
124 uint32_t bflb_acomp_get_result(uint8_t acomp_id);
125 
133 uint32_t bflb_acomp_gpio_2_chanid(uint32_t pin, uint32_t* channel);
134 
142 uint32_t bflb_acomp_chanid_2_gpio(uint32_t channel, uint32_t* pin);
143 
144 #ifdef __cplusplus
145 }
146 #endif
147 
156 #endif
void bflb_acomp_enable(uint8_t acomp_id)
Enable acomp.
uint8_t neg_chan_sel
Definition: bflb_acomp.h:83
uint8_t pos_chan_sel
Definition: bflb_acomp.h:82
uint8_t hysteresis_pos_volt
Definition: bflb_acomp.h:87
uint32_t bflb_acomp_gpio_2_chanid(uint32_t pin, uint32_t *channel)
gpio change adc_chan_id.
ACOMP configuration structure.
Definition: bflb_acomp.h:80
uint32_t bflb_acomp_get_result(uint8_t acomp_id)
Get acomp result.
void bflb_acomp_disable(uint8_t acomp_id)
Disable acomp.
void bflb_acomp_init(uint8_t acomp_id, const struct bflb_acomp_config_s *config)
Initialize acomp.
uint8_t hysteresis_neg_volt
Definition: bflb_acomp.h:88
uint8_t scaling_factor
Definition: bflb_acomp.h:85
uint32_t bflb_acomp_chanid_2_gpio(uint32_t channel, uint32_t *pin)
adc_chan_id change gpio index.