LibDriver AS5600
Loading...
Searching...
No Matches
driver_as5600.h
Go to the documentation of this file.
1
36
37#ifndef DRIVER_AS5600_H
38#define DRIVER_AS5600_H
39
40#include <stdio.h>
41#include <stdint.h>
42#include <string.h>
43
44#ifdef __cplusplus
45extern "C"{
46#endif
47
53
58
62typedef enum
63{
67
78
89
99
110
121
136
140typedef enum
141{
142 AS5600_STATUS_MD = (1 << 5),
143 AS5600_STATUS_ML = (1 << 4),
144 AS5600_STATUS_MH = (1 << 3),
146
158
162typedef struct as5600_handle_s
163{
164 uint8_t (*iic_init)(void);
165 uint8_t (*iic_deinit)(void);
166 uint8_t (*iic_read)(uint8_t addr, uint8_t reg, uint8_t *buf, uint16_t len);
167 uint8_t (*iic_write)(uint8_t addr, uint8_t reg, uint8_t *buf, uint16_t len);
168 void (*delay_ms)(uint32_t ms);
169 void (*debug_print)(const char *const fmt, ...);
170 uint8_t inited;
172
188
192
199
206#define DRIVER_AS5600_LINK_INIT(HANDLE, STRUCTURE) memset(HANDLE, 0, sizeof(STRUCTURE))
207
214#define DRIVER_AS5600_LINK_IIC_INIT(HANDLE, FUC) (HANDLE)->iic_init = FUC
215
222#define DRIVER_AS5600_LINK_IIC_DEINIT(HANDLE, FUC) (HANDLE)->iic_deinit = FUC
223
230#define DRIVER_AS5600_LINK_IIC_READ(HANDLE, FUC) (HANDLE)->iic_read = FUC
231
238#define DRIVER_AS5600_LINK_IIC_WRITE(HANDLE, FUC) (HANDLE)->iic_write = FUC
239
246#define DRIVER_AS5600_LINK_DELAY_MS(HANDLE, FUC) (HANDLE)->delay_ms = FUC
247
254#define DRIVER_AS5600_LINK_DEBUG_PRINT(HANDLE, FUC) (HANDLE)->debug_print = FUC
255
259
266
275uint8_t as5600_info(as5600_info_t *info);
276
287uint8_t as5600_init(as5600_handle_t *handle);
288
299uint8_t as5600_deinit(as5600_handle_t *handle);
300
313uint8_t as5600_read(as5600_handle_t *handle, uint16_t *angle_raw, float *deg);
314
326uint8_t as5600_angle_convert_to_register(as5600_handle_t *handle, float deg, uint16_t *reg);
327
339uint8_t as5600_angle_convert_to_data(as5600_handle_t *handle, uint16_t reg, float *deg);
340
353uint8_t as5600_set_start_position(as5600_handle_t *handle, uint16_t pos);
354
366uint8_t as5600_get_start_position(as5600_handle_t *handle, uint16_t *pos);
367
380uint8_t as5600_set_stop_position(as5600_handle_t *handle, uint16_t pos);
381
393uint8_t as5600_get_stop_position(as5600_handle_t *handle, uint16_t *pos);
394
407uint8_t as5600_set_max_angle(as5600_handle_t *handle, uint16_t ang);
408
420uint8_t as5600_get_max_angle(as5600_handle_t *handle, uint16_t *ang);
421
433uint8_t as5600_set_watch_dog(as5600_handle_t *handle, as5600_bool_t enable);
434
446uint8_t as5600_get_watch_dog(as5600_handle_t *handle, as5600_bool_t *enable);
447
460
473
486
499
512
525
538
551
564
576uint8_t as5600_get_hysteresis(as5600_handle_t *handle, as5600_hysteresis_t *hysteresis);
577
590
603
615uint8_t as5600_get_raw_angle(as5600_handle_t *handle, uint16_t *ang);
616
628uint8_t as5600_get_angle(as5600_handle_t *handle, uint16_t *ang);
629
641uint8_t as5600_get_status(as5600_handle_t *handle, uint8_t *status);
642
654uint8_t as5600_get_agc(as5600_handle_t *handle, uint8_t *agc);
655
667uint8_t as5600_get_magnitude(as5600_handle_t *handle, uint16_t *magnitude);
668
680uint8_t as5600_set_burn(as5600_handle_t *handle, as5600_burn_t burn);
681
685
692
706uint8_t as5600_set_reg(as5600_handle_t *handle, uint8_t reg, uint8_t *buf, uint16_t len);
707
721uint8_t as5600_get_reg(as5600_handle_t *handle, uint8_t reg, uint8_t *buf, uint16_t len);
722
726
730
731#ifdef __cplusplus
732}
733#endif
734
735#endif
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
as5600_status_t
as5600 status enumeration definition
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
@ AS5600_BOOL_TRUE
@ AS5600_BOOL_FALSE
@ AS5600_OUTPUT_STAGE_PWM
@ AS5600_OUTPUT_STAGE_ANALOG_FULL
@ AS5600_OUTPUT_STAGE_ANALOG_REDUCED
@ AS5600_PWM_FREQUENCY_230HZ
@ AS5600_PWM_FREQUENCY_115HZ
@ AS5600_PWM_FREQUENCY_460HZ
@ AS5600_PWM_FREQUENCY_920HZ
@ AS5600_STATUS_MH
@ AS5600_STATUS_MD
@ AS5600_STATUS_ML
@ AS5600_POWER_MODE_LPM1
@ AS5600_POWER_MODE_LPM2
@ AS5600_POWER_MODE_LPM3
@ AS5600_POWER_MODE_NOM
@ AS5600_BURN_CMD1
@ AS5600_BURN_SETTING
@ AS5600_BURN_ANGLE
@ AS5600_BURN_CMD2
@ AS5600_BURN_CMD3
@ AS5600_SLOW_FILTER_8X
@ AS5600_SLOW_FILTER_2X
@ AS5600_SLOW_FILTER_16X
@ AS5600_SLOW_FILTER_4X
@ AS5600_FAST_FILTER_THRESHOLD_7LSB
@ AS5600_FAST_FILTER_THRESHOLD_24LSB
@ AS5600_FAST_FILTER_THRESHOLD_21LSB
@ AS5600_FAST_FILTER_THRESHOLD_9LSB
@ AS5600_FAST_FILTER_THRESHOLD_6LSB
@ AS5600_FAST_FILTER_THRESHOLD_10LSB
@ AS5600_FAST_FILTER_THRESHOLD_18LSB
@ AS5600_FAST_FILTER_THRESHOLD_SLOW_FILTER_ONLY
@ AS5600_HYSTERESIS_2LSB
@ AS5600_HYSTERESIS_OFF
@ AS5600_HYSTERESIS_1LSB
@ AS5600_HYSTERESIS_3LSB
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
as5600 handle structure definition
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)
as5600 information structure definition
float supply_voltage_max_v
uint32_t driver_version
char manufacturer_name[32]
float supply_voltage_min_v
char chip_name[32]