Go to the documentation of this file.
35 #include "mikrosdk_version.h"
38 #if mikroSDK_GET_VERSION < 20800ul
39 #include "rcu_delays.h"
45 #include "drv_digital_out.h"
46 #include "drv_digital_in.h"
48 #include "drv_i2c_master.h"
70 #define BRUSHLESS10_DAC_REG_DEVICE_CONFIG 0x01
71 #define BRUSHLESS10_DAC_REG_STATUS_TRIGGER 0x02
72 #define BRUSHLESS10_DAC_REG_BRDCAST 0x03
73 #define BRUSHLESS10_DAC_REG_DACA_DATA_LA 0x08
74 #define BRUSHLESS10_DAC_REG_DACB_DATA_MIN_SP 0x09
75 #define BRUSHLESS10_DAC_REG_DACC_DATA_SEL_LD 0x0A
76 #define BRUSHLESS10_DAC_REG_DACD_DATA_FPWM 0x0B
77 #define BRUSHLESS10_DAC_REG_DACE_DATA_SEL_LA 0x0C
78 #define BRUSHLESS10_DAC_REG_DACF_DATA_SEL_FG 0x0D
79 #define BRUSHLESS10_DAC_REG_DACG_DATA_SEL_SP 0x0E
80 #define BRUSHLESS10_DAC_REG_DACH_DATA_CW_CCW 0x0F
98 #define BRUSHLESS10_DAC_CHA_LA 0
99 #define BRUSHLESS10_DAC_CHB_MIN_SP 1
100 #define BRUSHLESS10_DAC_CHC_SEL_LD 2
101 #define BRUSHLESS10_DAC_CHD_FPWM 3
102 #define BRUSHLESS10_DAC_CHE_SEL_LA 4
103 #define BRUSHLESS10_DAC_CHF_SEL_FG 5
104 #define BRUSHLESS10_DAC_CHG_SEL_SP 6
105 #define BRUSHLESS10_DAC_CHH_CW_CCW 7
111 #define BRUSHLESS10_LA0_STEP_0 88
112 #define BRUSHLESS10_LA0_STEP_1 234
113 #define BRUSHLESS10_LA0_STEP_2 332
114 #define BRUSHLESS10_LA0_STEP_3 430
115 #define BRUSHLESS10_LA0_STEP_4 527
116 #define BRUSHLESS10_LA0_STEP_5 625
117 #define BRUSHLESS10_LA0_STEP_6 723
118 #define BRUSHLESS10_LA0_STEP_7 820
119 #define BRUSHLESS10_LA0_STEP_8 918
120 #define BRUSHLESS10_LA0_STEP_9 1016
121 #define BRUSHLESS10_LA0_STEP_10 1113
122 #define BRUSHLESS10_LA0_STEP_11 1211
123 #define BRUSHLESS10_LA0_STEP_12 1309
124 #define BRUSHLESS10_LA0_STEP_13 1406
125 #define BRUSHLESS10_LA0_STEP_14 1504
126 #define BRUSHLESS10_LA0_STEP_15 1602
127 #define BRUSHLESS10_LA0_STEP_16 1699
128 #define BRUSHLESS10_LA0_STEP_17 1797
129 #define BRUSHLESS10_LA0_STEP_18 1894
130 #define BRUSHLESS10_LA0_STEP_19 1992
131 #define BRUSHLESS10_LA0_STEP_20 2090
132 #define BRUSHLESS10_LA0_STEP_21 2187
133 #define BRUSHLESS10_LA0_STEP_22 2285
134 #define BRUSHLESS10_LA0_STEP_23 2383
135 #define BRUSHLESS10_LA0_STEP_24 2480
136 #define BRUSHLESS10_LA0_STEP_25 2578
137 #define BRUSHLESS10_LA0_STEP_26 2676
138 #define BRUSHLESS10_LA0_STEP_27 2773
139 #define BRUSHLESS10_LA0_STEP_28 2871
140 #define BRUSHLESS10_LA0_STEP_29 2969
141 #define BRUSHLESS10_LA0_STEP_30 3066
142 #define BRUSHLESS10_LA0_STEP_31 4062
143 #define BRUSHLESS10_LA1_STEP_0 234
144 #define BRUSHLESS10_LA1_STEP_1 673
145 #define BRUSHLESS10_LA1_STEP_2 1064
146 #define BRUSHLESS10_LA1_STEP_3 1455
147 #define BRUSHLESS10_LA1_STEP_4 1845
148 #define BRUSHLESS10_LA1_STEP_5 2236
149 #define BRUSHLESS10_LA1_STEP_6 2627
150 #define BRUSHLESS10_LA1_STEP_7 3916
156 #define BRUSHLESS10_MIN_SP_STEP_0 136
157 #define BRUSHLESS10_MIN_SP_STEP_1 478
158 #define BRUSHLESS10_MIN_SP_STEP_2 869
159 #define BRUSHLESS10_MIN_SP_STEP_3 1259
160 #define BRUSHLESS10_MIN_SP_STEP_4 1650
161 #define BRUSHLESS10_MIN_SP_STEP_5 2041
162 #define BRUSHLESS10_MIN_SP_STEP_6 2431
163 #define BRUSHLESS10_MIN_SP_STEP_7 2822
164 #define BRUSHLESS10_MIN_SP_STEP_8 3916
170 #define BRUSHLESS10_FPWM_STEP_0 478
171 #define BRUSHLESS10_FPWM_STEP_1 1455
172 #define BRUSHLESS10_FPWM_STEP_2 2431
173 #define BRUSHLESS10_FPWM_STEP_3 3965
179 #define BRUSHLESS10_SEL_LD_STEP_0 478
180 #define BRUSHLESS10_SEL_LD_STEP_1 1455
181 #define BRUSHLESS10_SEL_LD_STEP_2 2431
182 #define BRUSHLESS10_SEL_LD_STEP_3 3965
188 #define BRUSHLESS10_SEL_FG_STEP_0 967
189 #define BRUSHLESS10_SEL_FG_STEP_1 3476
195 #define BRUSHLESS10_SEL_SP_STEP_0 478
196 #define BRUSHLESS10_SEL_SP_STEP_1 1943
197 #define BRUSHLESS10_SEL_SP_STEP_2 3965
203 #define BRUSHLESS10_SEL_LA_STEP_0 478
204 #define BRUSHLESS10_SEL_LA_STEP_1 1943
205 #define BRUSHLESS10_SEL_LA_STEP_2 3965
211 #define BRUSHLESS10_CW_CCW_0 0
212 #define BRUSHLESS10_CW_CCW_1 5000
218 #define BRUSHLESS10_DAC_VREF 5000
219 #define BRUSHLESS10_DAC_RESOLUTION 256
220 #define BRUSHLESS10_DAC_ROUND_TO_INT 0.5f
226 #define BRUSHLESS10_DAC_CONFIG_PDN_ALL 0x0100
227 #define BRUSHLESS10_DAC_CONFIG_PDN_CHA 0x0001
228 #define BRUSHLESS10_DAC_CONFIG_PDN_CHB 0x0002
229 #define BRUSHLESS10_DAC_CONFIG_PDN_CHC 0x0004
230 #define BRUSHLESS10_DAC_CONFIG_PDN_CHD 0x0008
231 #define BRUSHLESS10_DAC_CONFIG_PDN_CHE 0x0010
232 #define BRUSHLESS10_DAC_CONFIG_PDN_CHF 0x0020
233 #define BRUSHLESS10_DAC_CONFIG_PDN_CHG 0x0040
234 #define BRUSHLESS10_DAC_CONFIG_PDN_CHH 0x0080
235 #define BRUSHLESS10_DAC_CONFIG_ENABLE_ALL_CH 0x0000
241 #define BRUSHLESS10_DAC_DEVICE_ID 0x0500
242 #define BRUSHLESS10_DAC_DEVICE_ID_MASK 0x0FC0
243 #define BRUSHLESS10_DAC_SW_RESET 0x000A
249 #define BRUSHLESS10_DEF_FREQ 50000
256 #define BRUSHLESS10_DAC_DEVICE_ADDRESS_BROADCAST 0x47
257 #define BRUSHLESS10_DAC_DEVICE_ADDRESS_0 0x48
258 #define BRUSHLESS10_DAC_DEVICE_ADDRESS_1 0x49
276 #define BRUSHLESS10_MAP_MIKROBUS( cfg, mikrobus ) \
277 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
278 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
279 cfg.pwm = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
280 cfg.fg_out = MIKROBUS( mikrobus, MIKROBUS_AN ); \
281 cfg.brake = MIKROBUS( mikrobus, MIKROBUS_RST ); \
282 cfg.ld_out = MIKROBUS( mikrobus, MIKROBUS_INT );
570 #endif // BRUSHLESS10_H
pin_name_t scl
Definition: brushless10.h:321
err_t brushless10_default_cfg(brushless10_t *ctx)
Brushless 10 default configuration function.
Brushless 10 Click configuration object.
Definition: brushless10.h:319
uint8_t brushless10_get_fg_out_pin(brushless10_t *ctx)
Brushless 10 get fg out pin function.
digital_out_t brake
Definition: brushless10.h:294
err_t brushless10_dac_write(brushless10_t *ctx, uint8_t reg, uint16_t data_in)
Brushless 10 DAC write function.
digital_in_t ld_out
Definition: brushless10.h:298
uint8_t brushless10_get_ld_out_pin(brushless10_t *ctx)
Brushless 10 get ld out pin function.
pin_name_t sda
Definition: brushless10.h:322
@ BRUSHLESS10_ERROR
Definition: brushless10.h:344
pin_name_t brake
Definition: brushless10.h:327
err_t brushless10_dac_set_data(brushless10_t *ctx, uint8_t channel, uint8_t data_in)
Brushless 10 DAC set data function.
pin_name_t ld_out
Definition: brushless10.h:328
err_t brushless10_pwm_stop(brushless10_t *ctx)
Brushless 10 stop PWM module.
void brushless10_cfg_setup(brushless10_cfg_t *cfg)
Brushless 10 configuration object setup function.
uint32_t dev_pwm_freq
Definition: brushless10.h:331
err_t brushless10_set_duty_cycle(brushless10_t *ctx, float duty_cycle)
Brushless 10 sets PWM duty cycle.
void brushless10_release_brake(brushless10_t *ctx)
Brushless 10 release brake function.
void brushless10_pull_brake(brushless10_t *ctx)
Brushless 10 pull brake function.
err_t brushless10_dac_read(brushless10_t *ctx, uint8_t reg, uint16_t *data_out)
Brushless 10 DAC read function.
uint32_t i2c_speed
Definition: brushless10.h:332
uint32_t pwm_freq
Definition: brushless10.h:304
err_t brushless10_pwm_start(brushless10_t *ctx)
Brushless 10 start PWM module.
err_t brushless10_dac_sw_reset(brushless10_t *ctx)
Brushless 10 DAC sw reset function.
i2c_master_t i2c
Definition: brushless10.h:307
uint8_t slave_address
Definition: brushless10.h:310
pwm_t pwm
Definition: brushless10.h:301
brushless10_return_value_t
Brushless 10 Click return value data.
Definition: brushless10.h:342
uint8_t i2c_address
Definition: brushless10.h:333
err_t brushless10_dac_check_com(brushless10_t *ctx)
Brushless 10 DAC check com function.
err_t brushless10_dac_set_vout(brushless10_t *ctx, uint8_t channel, uint16_t vout_mv)
Brushless 10 DAC set vout function.
pin_name_t fg_out
Definition: brushless10.h:326
Brushless 10 Click context object.
Definition: brushless10.h:292
@ BRUSHLESS10_OK
Definition: brushless10.h:343
err_t brushless10_init(brushless10_t *ctx, brushless10_cfg_t *cfg)
Brushless 10 initialization function.
pin_name_t pwm
Definition: brushless10.h:323
digital_in_t fg_out
Definition: brushless10.h:297