42#define CHIP_NAME "AMS AS5600"
43#define MANUFACTURER_NAME "AMS"
44#define SUPPLY_VOLTAGE_MIN 4.5f
45#define SUPPLY_VOLTAGE_MAX 5.5f
46#define MAX_CURRENT 100.0f
47#define TEMPERATURE_MIN -40.0f
48#define TEMPERATURE_MAX 125.0f
49#define DRIVER_VERSION 1000
54#define AS5600_ADDRESS 0x6C
59#define AS5600_REG_ZMCO 0x00
60#define AS5600_REG_ZPOS_H 0x01
61#define AS5600_REG_ZPOS_L 0x02
62#define AS5600_REG_MPOS_H 0x03
63#define AS5600_REG_MPOS_L 0x04
64#define AS5600_REG_MANG_H 0x05
65#define AS5600_REG_MANG_L 0x06
66#define AS5600_REG_CONF_H 0x07
67#define AS5600_REG_CONF_L 0x08
68#define AS5600_REG_RAW_ANGLE_H 0x0C
69#define AS5600_REG_RAW_ANGLE_L 0x0D
70#define AS5600_REG_ANGLE_H 0x0E
71#define AS5600_REG_ANGLE_L 0x0F
72#define AS5600_REG_STATUS 0x0B
73#define AS5600_REG_AGC 0x1A
74#define AS5600_REG_MAGNITUDE_H 0x1B
75#define AS5600_REG_MAGNITUDE_L 0x1C
76#define AS5600_REG_BURN 0xFF
89static uint8_t a_as5600_iic_read(
as5600_handle_t *handle, uint8_t reg, uint8_t *data, uint16_t len)
112static uint8_t a_as5600_iic_write(
as5600_handle_t *handle, uint8_t reg, uint8_t *data, uint16_t len)
146 handle->
debug_print(
"as5600: iic_init is null.\n");
152 handle->
debug_print(
"as5600: iic_deinit is null.\n");
158 handle->
debug_print(
"as5600: iic_read is null.\n");
164 handle->
debug_print(
"as5600: iic_write is null.\n");
170 handle->
debug_print(
"as5600: delay_ms is null.\n");
209 handle->
debug_print(
"as5600: iic deinit failed.\n");
245 handle->
debug_print(
"as5600: get raw angle failed.\n");
251 *angle_raw = (uint16_t)(((buf[0] >> 0) & 0xF) << 8) | buf[1];
252 *deg = (float)(*angle_raw ) * (360.0f / 4096.0f);
280 *reg = (uint16_t)(deg / (360.0f / 4096.0f));
307 *deg = (float)(reg) * (360.0f / 4096.0f);
338 handle->
debug_print(
"as5600: pos is over 0xFFF.\n");
343 buf[0] = (pos >> 8) & 0x0F;
344 buf[1] = (pos >> 0) & 0xFF;
347 handle->
debug_print(
"as5600: set start position failed.\n");
383 handle->
debug_print(
"as5600: get start position failed.\n");
389 *pos = (uint16_t)(((buf[0] >> 0) & 0xF) << 8) | buf[1];
421 handle->
debug_print(
"as5600: pos is over 0xFFF.\n");
426 buf[0] = (pos >> 8) & 0x0F;
427 buf[1] = (pos >> 0) & 0xFF;
430 handle->
debug_print(
"as5600: set stop position failed.\n");
466 handle->
debug_print(
"as5600: get stop position failed.\n");
472 *pos = (uint16_t)(((buf[0] >> 0) & 0xF) << 8) | buf[1];
504 handle->
debug_print(
"as5600: ang is over 0xFFF.\n");
509 buf[0] = (ang >> 8) & 0x0F;
510 buf[1] = (ang >> 0) & 0xFF;
513 handle->
debug_print(
"as5600: set max angle failed.\n");
549 handle->
debug_print(
"as5600: get max angle failed.\n");
555 *ang = (uint16_t)(((buf[0] >> 0) & 0xF) << 8) | buf[1];
669 prev |= threshold << 2;
977 prev |= hysteresis << 2;
1014 handle->
debug_print(
"as5600: get conf failed.\n");
1049 handle->
debug_print(
"as5600: get conf failed.\n");
1057 handle->
debug_print(
"as5600: set conf failed.\n");
1091 handle->
debug_print(
"as5600: get conf failed.\n");
1126 handle->
debug_print(
"as5600: get raw angle failed.\n");
1132 *ang = (uint16_t)(((buf[0] >> 0) & 0xF) << 8) | buf[1];
1164 handle->
debug_print(
"as5600: get angle failed.\n");
1170 *ang = (uint16_t)(((buf[0] >> 0) & 0xF) << 8) | buf[1];
1200 handle->
debug_print(
"as5600: get status failed.\n");
1270 handle->
debug_print(
"as5600: get magnitude failed.\n");
1276 *magnitude = (uint16_t)(((buf[0] >> 0) & 0xF) << 8) | buf[1];
1309 handle->
debug_print(
"as5600: set burn failed.\n");
1343 res = a_as5600_iic_write(handle, reg, buf, len);
1346 handle->
debug_print(
"as5600: write register failed.\n");
1380 res = a_as5600_iic_read(handle, reg, buf, len);
1383 handle->
debug_print(
"as5600: read register failed.\n");
#define AS5600_REG_RAW_ANGLE_H
#define AS5600_REG_MAGNITUDE_H
#define AS5600_REG_MPOS_H
#define AS5600_REG_ZPOS_H
#define SUPPLY_VOLTAGE_MAX
#define AS5600_REG_STATUS
#define AS5600_ADDRESS
chip address definition
#define AS5600_REG_CONF_L
#define MANUFACTURER_NAME
#define SUPPLY_VOLTAGE_MIN
#define AS5600_REG_CONF_H
#define CHIP_NAME
chip information definition
#define AS5600_REG_ANGLE_H
#define AS5600_REG_MANG_H
driver as5600 header file
uint8_t as5600_set_burn(as5600_handle_t *handle, as5600_burn_t burn)
set the burn
uint8_t as5600_read(as5600_handle_t *handle, uint16_t *angle_raw, float *deg)
read the magnetic angle
as5600_bool_t
as5600 bool enumeration definition
uint8_t as5600_get_fast_filter_threshold(as5600_handle_t *handle, as5600_fast_filter_threshold_t *threshold)
get the fast filter threshold
uint8_t as5600_get_status(as5600_handle_t *handle, uint8_t *status)
get the status
as5600_output_stage_t
as5600 output stage enumeration definition
uint8_t as5600_info(as5600_info_t *info)
get chip's information
uint8_t as5600_get_watch_dog(as5600_handle_t *handle, as5600_bool_t *enable)
get the watch dog status
uint8_t as5600_get_start_position(as5600_handle_t *handle, uint16_t *pos)
get the start position
as5600_pwm_frequency_t
as5600 pwm frequency enumeration definition
struct as5600_handle_s as5600_handle_t
as5600 handle structure definition
uint8_t as5600_set_fast_filter_threshold(as5600_handle_t *handle, as5600_fast_filter_threshold_t threshold)
set the fast filter threshold
uint8_t as5600_angle_convert_to_register(as5600_handle_t *handle, float deg, uint16_t *reg)
convert the angle to the register raw data
struct as5600_info_s as5600_info_t
as5600 information structure definition
as5600_power_mode_t
as5600 power mode enumeration definition
uint8_t as5600_get_pwm_frequency(as5600_handle_t *handle, as5600_pwm_frequency_t *freq)
get the pwm frequency
as5600_burn_t
as5600 burn enumeration definition
uint8_t as5600_angle_convert_to_data(as5600_handle_t *handle, uint16_t reg, float *deg)
convert the register raw data to the angle
uint8_t as5600_set_slow_filter(as5600_handle_t *handle, as5600_slow_filter_t filter)
set the slow filter
uint8_t as5600_get_slow_filter(as5600_handle_t *handle, as5600_slow_filter_t *filter)
get the slow filter
uint8_t as5600_get_power_mode(as5600_handle_t *handle, as5600_power_mode_t *mode)
get the power mode
uint8_t as5600_get_magnitude(as5600_handle_t *handle, uint16_t *magnitude)
get the magnitude
uint8_t as5600_set_hysteresis(as5600_handle_t *handle, as5600_hysteresis_t hysteresis)
set the hysteresis
uint8_t as5600_set_power_mode(as5600_handle_t *handle, as5600_power_mode_t mode)
set the power mode
as5600_slow_filter_t
as5600 slow filter enumeration definition
uint8_t as5600_set_stop_position(as5600_handle_t *handle, uint16_t pos)
set the stop position
uint8_t as5600_get_agc(as5600_handle_t *handle, uint8_t *agc)
get the automatic gain control
uint8_t as5600_set_start_position(as5600_handle_t *handle, uint16_t pos)
set the start position
uint8_t as5600_set_pwm_frequency(as5600_handle_t *handle, as5600_pwm_frequency_t freq)
set the pwm frequency
uint8_t as5600_set_max_angle(as5600_handle_t *handle, uint16_t ang)
set the max angle
uint8_t as5600_init(as5600_handle_t *handle)
initialize the chip
uint8_t as5600_get_max_angle(as5600_handle_t *handle, uint16_t *ang)
get the max angle
uint8_t as5600_set_watch_dog(as5600_handle_t *handle, as5600_bool_t enable)
enable or disable the watch dog
uint8_t as5600_get_angle(as5600_handle_t *handle, uint16_t *ang)
get the angle
uint8_t as5600_get_stop_position(as5600_handle_t *handle, uint16_t *pos)
get the stop position
uint8_t as5600_get_raw_angle(as5600_handle_t *handle, uint16_t *ang)
get the raw angle
uint8_t as5600_deinit(as5600_handle_t *handle)
close the chip
as5600_fast_filter_threshold_t
as5600 fast filter threshold enumeration definition
uint8_t as5600_set_output_stage(as5600_handle_t *handle, as5600_output_stage_t stage)
set the output stage
uint8_t as5600_get_hysteresis(as5600_handle_t *handle, as5600_hysteresis_t *hysteresis)
get the hysteresis
uint8_t as5600_get_output_stage(as5600_handle_t *handle, as5600_output_stage_t *stage)
get the output stage
as5600_hysteresis_t
as5600 hysteresis enumeration definition
uint8_t as5600_get_reg(as5600_handle_t *handle, uint8_t reg, uint8_t *buf, uint16_t len)
get the chip register
uint8_t as5600_set_reg(as5600_handle_t *handle, uint8_t reg, uint8_t *buf, uint16_t len)
set the chip register
void(* delay_ms)(uint32_t ms)
void(* debug_print)(const char *const fmt,...)
uint8_t(* iic_init)(void)
uint8_t(* iic_write)(uint8_t addr, uint8_t reg, uint8_t *buf, uint16_t len)
uint8_t(* iic_read)(uint8_t addr, uint8_t reg, uint8_t *buf, uint16_t len)
uint8_t(* iic_deinit)(void)
float supply_voltage_max_v
char manufacturer_name[32]
float supply_voltage_min_v