Go to the documentation of this file.
42 #ifdef PREINIT_SUPPORTED
46 #ifdef MikroCCoreVersion
47 #if MikroCCoreVersion >= 1
52 #include "drv_digital_out.h"
53 #include "drv_digital_in.h"
54 #include "drv_i2c_master.h"
68 #define BRUSHLESS3_MAP_MIKROBUS( cfg, mikrobus ) \
69 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
70 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
71 cfg.dir = MIKROBUS( mikrobus, MIKROBUS_RST ); \
72 cfg.pwm = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
73 cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
80 #define BRUSHLESS3_OK 0
81 #define BRUSHLESS3_ERROR -1
84 #define BRUSHLESS3_I2C_ADDRESS 0x52
85 #define BRUSHLESS3_MAX_SPEED 0x1FF
86 #define BRUSHLESS3_DEF_FREQ 25000
92 #define BRUSHLESS3_SPEED_CTRL_1 0x00
93 #define BRUSHLESS3_SPEED_CTRL_2 0x01
94 #define BRUSHLESS3_DEV_CTRL 0x02
95 #define BRUSHLESS3_EE_CTRL 0x03
102 #define BRUSHLESS3_STATUS 0x10
103 #define BRUSHLESS3_MOTOR_SPEED_1 0x11
104 #define BRUSHLESS3_MOTOR_SPEED_2 0x12
105 #define BRUSHLESS3_MOTOR_PERIOD_1 0x13
106 #define BRUSHLESS3_MOTOR_PERIOD_2 0x14
107 #define BRUSHLESS3_MOTOR_KT_1 0x15
108 #define BRUSHLESS3_MOTOR_KT_2 0x16
109 #define BRUSHLESS3_IPD_POSITION 0x19
110 #define BRUSHLESS3_SUPPLY_VOLTAGE 0x1A
111 #define BRUSHLESS3_SPEED_CMD 0x1B
112 #define BRUSHLESS3_SPD_CMD_BUFFER 0x1C
113 #define BRUSHLESS3_FAULT_CODE 0x1E
120 #define BRUSHLESS3_MOTOR_PARAM_1 0x20
121 #define BRUSHLESS3_MOTOR_PARAM_2 0x21
122 #define BRUSHLESS3_MOTOR_PARAM_3 0x22
123 #define BRUSHLESS3_SYS_OPT_1 0x23
124 #define BRUSHLESS3_SYS_OPT_2 0x24
125 #define BRUSHLESS3_SYS_OPT_3 0x25
126 #define BRUSHLESS3_SYS_OPT_4 0x26
127 #define BRUSHLESS3_SYS_OPT_5 0x27
128 #define BRUSHLESS3_SYS_OPT_6 0x28
129 #define BRUSHLESS3_SYS_OPT_7 0x29
130 #define BRUSHLESS3_SYS_OPT_8 0x2A
131 #define BRUSHLESS3_SYS_OPT_9 0x2B
138 #define BRUSHLESS3_PARAM_START_EE_CTRL 0x40
139 #define BRUSHLESS3_PARAM_STOP_EE_CTRL 0x50
140 #define BRUSHLESS3_PARAM_MOTOR_PARAM_1 0x39
141 #define BRUSHLESS3_PARAM_MOTOR_PARAM_2 0x1E
142 #define BRUSHLESS3_PARAM_MOTOR_PARAM_3 0x3A
143 #define BRUSHLESS3_PARAM_SYS_OPT_1 0x08
144 #define BRUSHLESS3_PARAM_SYS_OPT_2 0x50
145 #define BRUSHLESS3_PARAM_SYS_OPT_3 0xDA
146 #define BRUSHLESS3_PARAM_SYS_OPT_4 0xB8
147 #define BRUSHLESS3_PARAM_SYS_OPT_5 0x10
148 #define BRUSHLESS3_PARAM_SYS_OPT_6 0x27
149 #define BRUSHLESS3_PARAM_SYS_OPT_7 0x37
150 #define BRUSHLESS3_PARAM_SYS_OPT_8 0x04
151 #define BRUSHLESS3_PARAM_SYS_OPT_9 0x0C
152 #define BRUSHLESS3_PARAM_DEV_CTRL 0xB6
669 #endif // _BRUSHLESS3_H_
err_t brushless3_set_an_mode(brushless3_t *ctx)
Set Analog mode function.
uint8_t slave_address
Definition: brushless3.h:178
err_t brushless3_pwm_start(brushless3_t *ctx)
Start PWM module.
pwm_t pwm
Definition: brushless3.h:174
uint8_t i2c_address
Definition: brushless3.h:199
err_t brushless3_check_fault_code(brushless3_t *ctx, uint8_t *fault_code)
Check fault code function.
err_t brushless3_default_cfg(brushless3_t *ctx)
Click Default Configuration function.
digital_out_t dir
Definition: brushless3.h:167
i2c_master_t i2c
Definition: brushless3.h:173
err_t brushless3_get_speed(brushless3_t *ctx, float *speed)
Get speed function.
err_t brushless3_get_vel_const(brushless3_t *ctx, float *velocity)
Get measured velocity constant function.
void brushless3_forward_direction(brushless3_t *ctx)
Set the direction of rotation in the forward direction function.
pin_name_t pwm
Definition: brushless3.h:190
err_t brushless3_init(brushless3_t *ctx, brushless3_cfg_t *cfg)
Initialization function.
err_t brushless3_get_supply_voltage(brushless3_t *ctx, float *voltage)
Get the supply voltage function.
err_t brushless3_set_speed_pwm(brushless3_t *ctx, uint16_t motor_speed_hz)
Set speed PWM function.
void brushless3_reverse_direction(brushless3_t *ctx)
Set the direction of rotation in the reverse direction function.
err_t brushless3_write_data(brushless3_t *ctx, uint8_t reg_addr, uint8_t write_data)
Write function.
err_t brushless3_dis_config(brushless3_t *ctx)
Disable the writing to the configuration registers function.
err_t brushless3_pwm_stop(brushless3_t *ctx)
Stop PWM module.
err_t brushless3_set_default_param(brushless3_t *ctx)
Set default parameter function.
err_t brushless3_copy_eeprom(brushless3_t *ctx)
Copy EEPROM data to register function.
err_t brushless3_get_period(brushless3_t *ctx, float *period)
Get motor period function.
pin_name_t scl
Definition: brushless3.h:188
err_t brushless3_read_data(brushless3_t *ctx, uint8_t reg_addr, uint8_t *read_data)
Read function.
err_t brushless3_check_motor_lock(brushless3_t *ctx, uint8_t *motor_lock)
Check indicate that the motor is locked function.
err_t brushless3_dis_sleep_mode(brushless3_t *ctx)
Disable entering into sleep or standby mode function.
err_t brushless3_dis_write_eeprom(brushless3_t *ctx)
Disable the writing to the EEPROM registers function.
digital_in_t int_pin
Definition: brushless3.h:170
err_t brushless3_set_speed(brushless3_t *ctx, uint16_t motor_speed_hz)
Set speed function.
err_t brushless3_get_speed_cmd(brushless3_t *ctx, float *speed_cmd)
Get the speed command ( % ) based on analog or PWM or I2C function.
err_t brushless3_check_sleep_mode(brushless3_t *ctx, uint8_t *sleep_mode)
Check indicate that device went into sleep or standby mode function.
uint32_t dev_pwm_freq
Definition: brushless3.h:197
void brushless3_cfg_setup(brushless3_cfg_t *cfg)
Config Object Initialization function.
err_t brushless3_set_duty_cycle(brushless3_t *ctx, float duty_cycle)
Generic sets PWM duty cycle.
pin_name_t sda
Definition: brushless3.h:189
err_t brushless3_en_write_eeprom(brushless3_t *ctx)
Enable the writing to the EEPROM registers function.
pin_name_t int_pin
Definition: brushless3.h:194
err_t brushless3_set_pwm_mode(brushless3_t *ctx)
Set PWM mode function.
err_t brushless3_en_prog_eeprom(brushless3_t *ctx)
Set prog key function.
uint8_t brushless3_get_int_pin(brushless3_t *ctx)
Get Interrupt pin state function.
err_t brushless3_check_over_temp(brushless3_t *ctx, uint8_t *over_temp)
Check indicate device temperature is over its limits function.
uint32_t i2c_speed
Definition: brushless3.h:198
Click ctx object definition.
Definition: brushless3.h:165
uint32_t pwm_freq
Definition: brushless3.h:177
err_t brushless3_en_config(brushless3_t *ctx)
Enable the writing to the configuration registers function.
Click configuration structure definition.
Definition: brushless3.h:186
pin_name_t dir
Definition: brushless3.h:193