Go to the documentation of this file.
35 #include "drv_digital_out.h"
36 #include "drv_digital_in.h"
37 #include "drv_i2c_master.h"
39 #include "drv_analog_in.h"
61 #define BRUSHLESS23_REG_STATUS 0x00
62 #define BRUSHLESS23_REG_USER_ID 0x01
63 #define BRUSHLESS23_REG_STOP_DUTY 0x02
64 #define BRUSHLESS23_REG_START_DUTY 0x03
65 #define BRUSHLESS23_REG_CHANGE_DUTY 0x04
66 #define BRUSHLESS23_REG_MAX_DUTY 0x05
67 #define BRUSHLESS23_REG_START_RPM_MSB 0x06
68 #define BRUSHLESS23_REG_START_RPM_LSB 0x07
69 #define BRUSHLESS23_REG_8 0x08
70 #define BRUSHLESS23_REG_9 0x09
71 #define BRUSHLESS23_REG_10 0x0A
72 #define BRUSHLESS23_REG_11 0x0B
73 #define BRUSHLESS23_REG_KIX_KI 0x0C
74 #define BRUSHLESS23_REG_KPX_KP 0x0D
75 #define BRUSHLESS23_REG_14 0x0E
76 #define BRUSHLESS23_REG_15 0x0F
77 #define BRUSHLESS23_REG_16 0x10
78 #define BRUSHLESS23_REG_17 0x11
79 #define BRUSHLESS23_REG_18 0x12
80 #define BRUSHLESS23_REG_19 0x13
81 #define BRUSHLESS23_REG_TRE_PRETIP_TIP 0x14
82 #define BRUSHLESS23_REG_LA_FMAX_FST 0x15
83 #define BRUSHLESS23_REG_FPWM_DEADTIME 0x16
84 #define BRUSHLESS23_REG_ISD_OCP_SRC_SINK 0x17
85 #define BRUSHLESS23_REG_COMP_HYS 0x18
86 #define BRUSHLESS23_REG_SLAVE_ADRS 0x19
87 #define BRUSHLESS23_REG_SPD_MSB 0x1B
88 #define BRUSHLESS23_REG_SPD_LSB 0x1C
89 #define BRUSHLESS23_REG_HZ_CNT_MSB 0x1D
90 #define BRUSHLESS23_REG_HZ_CNT_LSB 0x1E
91 #define BRUSHLESS23_REG_NVM_W_R 0x56
92 #define BRUSHLESS23_REG_NVM_ST 0x57
110 #define BRUSHLESS23_DUTY_CYCLE_MIN_PCT 0.0
111 #define BRUSHLESS23_DUTY_CYCLE_MAX_PCT 1.0
112 #define BRUSHLESS23_START_DUTY_MIN_PCT 0.0
113 #define BRUSHLESS23_START_DUTY_20_PCT 0.2
114 #define BRUSHLESS23_START_DUTY_MAX_PCT 0.498
115 #define BRUSHLESS23_STOP_DUTY_MIN_PCT 0.0
116 #define BRUSHLESS23_STOP_DUTY_18_PCT 0.18
117 #define BRUSHLESS23_STOP_DUTY_MAX_PCT 0.496
118 #define BRUSHLESS23_MAX_DUTY_MIN_PCT 0.502
119 #define BRUSHLESS23_MAX_DUTY_90_PCT 0.9
120 #define BRUSHLESS23_MAX_DUTY_MAX_PCT 1.0
121 #define BRUSHLESS23_CHANGE_DUTY_MIN_PCT 0.004
122 #define BRUSHLESS23_CHANGE_DUTY_90_PCT 0.9
123 #define BRUSHLESS23_CHANGE_DUTY_MAX_PCT 0.996
124 #define BRUSHLESS23_START_RPM_MIN_PCT 0.0
125 #define BRUSHLESS23_START_RPM_10_PCT 0.1
126 #define BRUSHLESS23_START_RPM_MAX_PCT 0.498
127 #define BRUSHLESS23_SPEED_SLOP_1_MSB 0x0F
128 #define BRUSHLESS23_SPEED_SLOP_1_LSB 0xF8
129 #define BRUSHLESS23_SPEED_SLOP_2_MSB 0x15
130 #define BRUSHLESS23_SPEED_SLOP_2_LSB 0xF0
131 #define BRUSHLESS23_OPEN_LOOP 0x01
132 #define BRUSHLESS23_TSPSEL_PWM_DUTY 0x10
133 #define BRUSHLESS23_ALERTINV_LOW 0x02
134 #define BRUSHLESS23_NO_STOP_BIT_MASK 0x80
140 #define BRUSHLESS23_DIR_CW 0
141 #define BRUSHLESS23_DIR_CCW 1
147 #define BRUSHLESS23_SBY_STANDBY 0
148 #define BRUSHLESS23_SBY_NORMAL_OPERATION 1
154 #define BRUSHLESS23_SPEED_FREQUENCY 250000.0
161 #define BRUSHLESS23_DEVICE_ADDRESS_ID2ID1_00 0x29
162 #define BRUSHLESS23_DEVICE_ADDRESS_ID2ID1_01 0x29
163 #define BRUSHLESS23_DEVICE_ADDRESS_ID2ID1_10 0x2D
164 #define BRUSHLESS23_DEVICE_ADDRESS_ID2ID1_11 0x32
170 #define BRUSHLESS23_DEF_FREQ 5000
188 #define BRUSHLESS23_MAP_MIKROBUS( cfg, mikrobus ) \
189 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
190 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
191 cfg.sby = MIKROBUS( mikrobus, MIKROBUS_CS ); \
192 cfg.cmo = MIKROBUS( mikrobus, MIKROBUS_AN ); \
193 cfg.dir = MIKROBUS( mikrobus, MIKROBUS_RST ); \
194 cfg.spd = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
195 cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
538 #endif // BRUSHLESS23_H
float vref
Definition: brushless23.h:245
uint8_t i2c_address
Definition: brushless23.h:242
err_t brushless23_read_register(brushless23_t *ctx, uint8_t reg, uint8_t *data_out)
Brushless 23 read register function.
digital_in_t int_pin
Definition: brushless23.h:211
void brushless23_set_sby_pin(brushless23_t *ctx, uint8_t state)
Brushless 23 set sby pin function.
err_t brushless23_set_start_duty(brushless23_t *ctx, float duty_cycle)
Brushless 23 set start duty function.
err_t brushless23_pwm_set_duty_cycle(brushless23_t *ctx, float duty_cycle)
Brushless 23 sets PWM duty cycle.
analog_in_resolution_t resolution
Definition: brushless23.h:244
pin_name_t dir
Definition: brushless23.h:237
err_t brushless23_pwm_stop(brushless23_t *ctx)
Brushless 23 stop PWM module.
err_t brushless23_read_an_pin_voltage(brushless23_t *ctx, float *data_out)
Brushless 23 read AN pin voltage level function.
Brushless 23 Click configuration object.
Definition: brushless23.h:231
err_t brushless23_set_change_duty(brushless23_t *ctx, float duty_cycle)
Brushless 23 set change duty function.
pin_name_t sby
Definition: brushless23.h:235
Brushless 23 Click context object.
Definition: brushless23.h:205
pin_name_t cmo
Definition: brushless23.h:236
void brushless23_cfg_setup(brushless23_cfg_t *cfg)
Brushless 23 configuration object setup function.
err_t brushless23_set_duty_cycle(brushless23_t *ctx, float duty_cycle)
Brushless 23 set duty cycle function.
@ BRUSHLESS23_OK
Definition: brushless23.h:255
analog_in_t adc
Definition: brushless23.h:216
err_t brushless23_set_start_rpm(brushless23_t *ctx, float duty_cycle)
Brushless 23 set start rpm function.
uint32_t dev_pwm_freq
Definition: brushless23.h:243
err_t brushless23_read_an_pin_value(brushless23_t *ctx, uint16_t *data_out)
Brushless 23 read AN pin value function.
void brushless23_switch_direction(brushless23_t *ctx)
Brushless 23 switch direction function.
uint8_t slave_address
Definition: brushless23.h:222
err_t brushless23_default_cfg(brushless23_t *ctx)
Brushless 23 default configuration function.
pin_name_t int_pin
Definition: brushless23.h:239
pin_name_t scl
Definition: brushless23.h:232
@ BRUSHLESS23_ERROR
Definition: brushless23.h:256
uint8_t brushless23_get_int_pin(brushless23_t *ctx)
Brushless 22 get int pin function.
uint32_t i2c_speed
Definition: brushless23.h:241
err_t brushless23_set_max_duty(brushless23_t *ctx, float duty_cycle)
Brushless 23 set max duty function.
uint32_t pwm_freq
Definition: brushless23.h:219
err_t brushless23_write_register(brushless23_t *ctx, uint8_t reg, uint8_t data_in)
Brushless 23 write register function.
i2c_master_t i2c
Definition: brushless23.h:214
brushless23_return_value_t
Brushless 23 Click return value data.
Definition: brushless23.h:254
pin_name_t spd
Definition: brushless23.h:238
pwm_t pwm
Definition: brushless23.h:215
void brushless23_set_direction(brushless23_t *ctx, uint8_t dir)
Brushless 23 set direction function.
digital_out_t sby
Definition: brushless23.h:207
err_t brushless23_get_motor_speed(brushless23_t *ctx, float *motor_speed_hz)
Brushless 23 get motor speed function.
err_t brushless23_init(brushless23_t *ctx, brushless23_cfg_t *cfg)
Brushless 23 initialization function.
err_t brushless23_set_stop_duty(brushless23_t *ctx, float duty_cycle)
Brushless 23 set stop duty function.
err_t brushless23_pwm_start(brushless23_t *ctx)
Brushless 23 start PWM module.
digital_out_t dir
Definition: brushless23.h:208
pin_name_t sda
Definition: brushless23.h:233