49#define ADMT4000_REG_RST 0x00
52#define ADMT4000_AGP_REG_CNVPAGE 0x01
53#define ADMT4000_AGP_REG_ABSANGLE 0x03
54#define ADMT4000_AGP_REG_DGIO 0x04
55#define ADMT4000_AGP_REG_ANGLE 0x05
56#define ADMT4000_AGP_REG_FAULT 0x06
59#define ADMT4000_00_REG_SINE 0x10
60#define ADMT4000_00_REG_COSINE 0x11
61#define ADMT4000_00_REG_RADIUS 0x18
62#define ADMT4000_00_REG_TMP 0x20
65#define ADMT4000_02_REG_GENERAL 0x10
66#define ADMT4000_02_REG_DIGIOEN 0x12
67#define ADMT4000_02_REG_ANGLECK 0x13
68#define ADMT4000_02_REG_CNVCNT 0x14
69#define ADMT4000_02_REG_H1MAG 0x15
70#define ADMT4000_02_REG_H1PH 0x16
71#define ADMT4000_02_REG_H2MAG 0x17
72#define ADMT4000_02_REG_H2PH 0x18
73#define ADMT4000_02_REG_H3MAG 0x19
74#define ADMT4000_02_REG_H3PH 0x1A
75#define ADMT4000_02_REG_H8MAG 0x1B
76#define ADMT4000_02_REG_H8PH 0x1C
77#define ADMT4000_02_REG_ECCEDC 0x1D
78#define ADMT4000_02_REG_UNIQD0 0x1E
79#define ADMT4000_02_REG_UNIQD1 0x1F
80#define ADMT4000_02_REG_UNIQD2 0x20
81#define ADMT4000_02_REG_UNIQD3 0x21
82#define ADMT4000_02_REG_ECCDIS 0x23
85#define ADMT4000_RW_MASK NO_OS_GENMASK(5, 0)
86#define ADMT4000_WR_EN NO_OS_BIT(6)
87#define ADMT4000_FAULT_MASK NO_OS_BIT(7)
88#define ADMT4000_LIFE_CTR NO_OS_GENMASK(6, 5)
89#define ADMT4000_RCV_CRC NO_OS_GENMASK(4, 0)
91#define ADMT4000_MIN_PAGE 0x00
92#define ADMT4000_MAX_PAGE 0x02
94#define ADMT4000_DIGIO3FNC_MASK NO_OS_BIT(3)
95#define ADMT4000_DIGIO0FNC_MASK NO_OS_BIT(0)
98#define ADMT4000_LOW_BYTE NO_OS_GENMASK(7, 0)
99#define ADMT4000_HI_BYTE NO_OS_GENMASK(15, 8)
102#define ADMT4000_CNV_EDGE_MASK NO_OS_GENMASK(15, 14)
103#define ADMT4000_PAGE_MASK NO_OS_GENMASK(4, 0)
104#define ADMT4000_FALLING_EDGE 0x00
105#define ADMT4000_RISING_EDGE 0x3
108#define ADMT4000_ABS_ANGLE_MASK NO_OS_GENMASK(15, 0)
109#define ADMT4000_TURN_CNT_MASK NO_OS_GENMASK(15, 10)
110#define ADMT4000_QUARTER_TURN_CNT_MASK NO_OS_GENMASK(15, 8)
111#define ADMT4000_ABS_ANGLE_ANGLE_MASK NO_OS_GENMASK(9, 0)
115#define ADMT4000_INVALID_TURN 0x53
118#define ADMT4000_MAX_GPIO_INDEX 5
119#define ADMT4000_GPIO_LOGIC(x) NO_OS_BIT(x)
122#define ADMT4000_ANGLE_MASK NO_OS_GENMASK(15, 4)
125#define ADMT4000_ALL_FAULTS NO_OS_GENMASK(15, 0)
126#define ADMT4000_AGP_INDIV_FAULT(x) NO_OS_BIT((x))
129#define ADMT4000_ANGLE_STAT_MASK NO_OS_BIT(0)
132#define ADMT4000_RAW_ANGLE_MASK NO_OS_GENMASK(15, 2)
133#define ADMT4000_RAW_COSINE_MASK NO_OS_GENMASK(15, 2)
134#define ADMT4000_RAW_SINE_MASK NO_OS_GENMASK(15, 2)
135#define ADMT4000_NEW_DATA_MASK NO_OS_BIT(0)
138#define ADMT4000_RADIUS_MASK NO_OS_GENMASK(15, 1)
141#define ADMT4000_TEMP_MASK NO_OS_GENMASK(15, 4)
144#define ADMT4000_STORAGE_BIT7 NO_OS_BIT(7)
145#define ADMT4000_STORAGE_BIT6 NO_OS_BIT(6)
146#define ADMT4000_STORAGE_BIT5_3 NO_OS_GENMASK(5, 3)
147#define ADMT4000_STORAGE_BIT2_0 NO_OS_GENMASK(2, 0)
148#define ADMT4000_STORAGE_MASK_BIT7 NO_OS_BIT(15)
149#define ADMT4000_STORAGE_MASK_BIT6 NO_OS_BIT(11)
150#define ADMT4000_STORAGE_MASK_BIT5_3 NO_OS_GENMASK(8, 6)
151#define ADMT4000_STORAGE_MASK_BIT2_0 NO_OS_GENMASK(3, 1)
152#define ADMT4000_STORAGE_MASK_FULL ADMT4000_STORAGE_MASK_BIT7 | \
153 ADMT4000_STORAGE_MASK_BIT6 | \
154 ADMT4000_STORAGE_MASK_BIT5_3 | \
155 ADMT4000_STORAGE_MASK_BIT2_0
157#define ADMT4000_CONV_SYNC_MODE_MASK NO_OS_GENMASK(14, 13)
158#define ADMT4000_ANGL_FILT_MASK NO_OS_BIT(12)
159#define ADMT4000_H8_CTRL_MASK NO_OS_BIT(10)
160#define ADMT4000_CNV_MODE_MASK NO_OS_BIT(0)
163#define ADMT4000_DIG_IO_EN(x) NO_OS_BIT(8 + (x))
164#define ADMT4000_GPIO_FUNC(x) NO_OS_BIT(x)
167#define ADMT4000_CNV_CTR_MASK NO_OS_GENMASK(7, 0)
170#define ADMT4000_H_11BIT_MAG_MASK NO_OS_GENMASK(10, 0)
171#define ADMT4000_11BIT_MAX 2047
172#define ADMT4000_H_12BIT_PHA_MASK NO_OS_GENMASK(11, 0)
173#define ADMT4000_12BIT_MAX 4095
176#define ADMT4000_H_8BIT_MAG_MASK NO_OS_GENMASK(7, 0)
177#define ADMT4000_8BIT_MAX 127
180#define ADMT4000_ECC_CFG1 NO_OS_GENMASK(15, 8)
181#define ADMT4000_ECC_CFG0 NO_OS_GENMASK(7, 0)
184#define ADMT4000_ID0_MASK NO_OS_GENMASK(14, 0)
185#define ADMT4000_ID_PROD_MASK NO_OS_GENMASK(10, 8)
186#define ADMT4000_ID_SUPPLY_MASK NO_OS_GENMASK(7, 6)
187#define ADMT4000_ID_ASIL_MASK NO_OS_GENMASK(5, 3)
188#define ADMT4000_ID_SIL_REV_MASK NO_OS_GENMASK(2, 0)
191#define ADMT4000_ECC_EN_COMM 0x0000
192#define ADMT4000_ECC_DIS_COMM 0x4D54
195#define ADMT4000_FULL_TURN_DEGREES 360
196#define ADMT4000_ABS_ANGLE_RES 1024
197#define ADMT4000_ANGLE_RES 4096
200#define ADMT4000_TURN_CNT_THRES 0x35
201#define ADMT4000_TURN_CNT_TWOS 64
202#define ADMT4000_QUARTER_TURNS_MAX 215
203#define ADMT4000_QUARTER_TURNS_RES 256
206#define ADMT4000_TEMP_OFFSET -1168
207#define ADMT4000_TEMP_SCALE_MILLIS 15660
210#define ADMT4000_RADIUS_RES 924
212#define ADMT4000_HMAG_SCALER 0.009046f
214#define ADMT4000_HPHA_SCALER 0.087891f
218#define ADMT4000_GPIO_SETTLE_DELAY_MS 10
220#define ADMT4000_CNV_PULSE_WIDTH_US 1
222#define ADMT4000_CONVERSION_DELAY_MS 20
224#define ADMT4000_STARTUP_TIME_MS 10
226#define ADMT4000_RESET_HOLD_TIME_MS 1
229#define ADMT4000_MAX_CRC_BIT_LEN 25
386 float *scaled_mag,
float *scaled_phase);
407 uint16_t *reg_data, uint8_t *verif);
415 uint16_t update_mask, uint16_t update_val);
struct ad7616_init_param init_param
Definition ad7616_sdz.c:106
int admt4000_temp_raw_to_scaled(uint16_t temp_raw, float *temp)
Convert raw temperature value to scaled temperature (degrees Celsius).
Definition admt4000.c:1081
admt4000_vdd
Definition admt4000.h:243
@ ADMT4000_3P3V
Definition admt4000.h:244
@ ADMT4000_5V
Definition admt4000.h:245
int admt4000_set_harmonics_calib(struct admt4000_dev *device, const struct admt4000_harmonics_calib *calib)
Set all harmonic configurations in a single operation.
Definition admt4000.c:1965
int admt4000_get_conv_sync_mode(struct admt4000_dev *device, enum admt4000_conv_sync_mode *mode)
Obtains conversion synchronization mode.
Definition admt4000.c:1371
int admt4000_reinitialize(struct admt4000_dev *device)
Reinitialize device using stored configuration.
Definition admt4000.c:138
int admt4000_set_conv_mode(struct admt4000_dev *device, bool is_one_shot)
Configures the conversion mode: one shot or continuous.
Definition admt4000.c:1460
int admt4000_get_gpio(struct admt4000_dev *device, uint8_t gpio, bool *logic)
Get status of selected GPIO.
Definition admt4000.c:915
int admt4000_quarter_turns_cnt(uint8_t raw_turns, int16_t *quarter_turns)
Convert raw quarter turn count to equivalent signed value.
Definition admt4000.c:824
int admt4000_get_angle_filt(struct admt4000_dev *device, bool *is_filtered)
Gets current filter setting.
Definition admt4000.c:1246
int admt4000_hard_reset(struct admt4000_dev *device)
Perform hardware reset via reset pin.
Definition admt4000.c:151
int admt4000_set_angle_filt(struct admt4000_dev *device, bool is_filtered)
Sets the filter setting.
Definition admt4000.c:1273
int admt4000_get_radius(struct admt4000_dev *device, uint16_t *radius, bool *is_new_data)
Get RADIUS vector value.
Definition admt4000.c:1007
int admt4000_get_harmonic(struct admt4000_dev *device, uint8_t harmonic, struct admt4000_harmonic_coeff *config)
Get harmonic configuration (magnitude and phase together).
Definition admt4000.c:1784
int admt4000_get_faults(struct admt4000_dev *device, uint16_t *faults)
Get all fault flags from the fault register.
Definition admt4000.c:986
admt4000_conversion_mode
Definition admt4000.h:258
@ ADMT4000_ONE_SHOT
Definition admt4000.h:260
@ ADMT4000_CONTINUOUS
Definition admt4000.h:259
admt4000_harmonic_corr_src
Definition admt4000.h:253
@ ADMT4000_USER
Definition admt4000.h:255
@ ADMT4000_FACTORY
Definition admt4000.h:254
int admt4000_set_gpio(struct admt4000_dev *device, uint8_t gpio, bool logic)
Configure selected GPIO.
Definition admt4000.c:942
int admt4000_harmonic_scaled_to_raw(uint32_t scaled_mag, uint32_t scaled_phase, struct admt4000_harmonic_coeff *raw_coeff)
Convert scaled harmonic values to raw coefficients.
Definition admt4000.c:1152
int admt4000_radius_raw_to_scaled(uint16_t raw_radius, float *radius)
Convert raw RADIUS value to scaled mV/V.
Definition admt4000.c:1038
int admt4000_set_h8_ctrl(struct admt4000_dev *device, enum admt4000_harmonic_corr_src source)
Sets 8th harmonic correction source.
Definition admt4000.c:1336
int admt4000_get_sin(struct admt4000_dev *device, int16_t *val, bool *is_new_data)
Retrieve the sine value from the ADMT4000 device. This function reads the sine portion of the AMR ang...
Definition admt4000.c:882
int admt4000_get_cnv_cnt(struct admt4000_dev *device, uint8_t *cnt)
Get current conversion count.
Definition admt4000.c:1690
int admt4000_get_temp(struct admt4000_dev *device, uint16_t *temp)
Get raw temperature reading.
Definition admt4000.c:1054
int admt4000_reg_write(struct admt4000_dev *device, uint8_t reg_addr, uint16_t reg_data)
Writes data to a certain ADMT400x Register.
Definition admt4000.c:604
int admt4000_set_conv_sync_mode(struct admt4000_dev *device, enum admt4000_conv_sync_mode mode)
Configures conversion synchronization mode.
Definition admt4000.c:1399
int admt4000_get_cos(struct admt4000_dev *device, int16_t *val, bool *is_new_data)
Get the cosine value from the ADMT4000 device. This function reads the cosine portion of the AMR angl...
Definition admt4000.c:847
int admt4000_reg_read(struct admt4000_dev *device, uint8_t reg_addr, uint16_t *reg_data, uint8_t *verif)
Reads data from a certain ADMT400x Register.
Definition admt4000.c:562
admt4000_faults
Definition admt4000.h:231
@ ADMT4000_FAULT_VDD_OV
Definition admt4000.h:233
@ ADMT4000_FAULT_VDRIVE_UV
Definition admt4000.h:234
@ ADMT4000_FAULT_GMR_REF_RES
Definition admt4000.h:238
@ ADMT4000_FAULT_VDD_UV
Definition admt4000.h:232
@ ADMT4000_FAULT_VDRIVE_OV
Definition admt4000.h:235
@ ADMT4000_FAULT_TURN_CTRS
Definition admt4000.h:239
@ ADMT4000_FAULT_NVM_CRC
Definition admt4000.h:236
@ ADMT4000_FAULT_AMR_RAD_AMP
Definition admt4000.h:240
@ ADMT4000_FAULT_ECC_DOUBLE
Definition admt4000.h:237
int admt4000_get_raw_turns_and_angle(struct admt4000_dev *device, uint8_t *turns, uint16_t *angle)
Get the number of turns and angle information (Raw).
Definition admt4000.c:794
int admt4000_angle_raw_to_scaled(uint16_t raw_angle, float *scaled_angle)
Convert raw angle value to scaled degrees.
Definition admt4000.c:1108
int admt4000_harmonic_raw_to_scaled(const struct admt4000_harmonic_coeff *raw_coeff, float *scaled_mag, float *scaled_phase)
Convert raw harmonic coefficients to scaled format.
Definition admt4000.c:1130
int admt4000_gpio_config(struct admt4000_dev *device, uint8_t gpio, bool alt_mode, bool output_en, bool init_state)
Configure GPIO mode, direction, and initial state.
Definition admt4000.c:1556
int admt4000_get_harmonics_calib(struct admt4000_dev *device, struct admt4000_harmonics_calib *calib)
Get all harmonic configurations in a single operation.
Definition admt4000.c:1931
int admt4000_remove(struct admt4000_dev *device)
Free the resources allocated by admt4000_init().
Definition admt4000.c:291
int admt4000_get_h8_ctrl(struct admt4000_dev *device, enum admt4000_harmonic_corr_src *source)
Gets 8th harmonic correction source.
Definition admt4000.c:1307
int admt4000_get_id(struct admt4000_dev *device, uint8_t id_num, uint16_t *id)
Read Unique ID from register/s.
Definition admt4000.c:1718
int admt4000_init(struct admt4000_dev **device, struct admt4000_init_param *init_param)
Initializes the admt4000.
Definition admt4000.c:189
int admt4000_reg_update(struct admt4000_dev *device, uint8_t reg_addr, uint16_t update_mask, uint16_t update_val)
Updates the contents of selected register.
Definition admt4000.c:637
int admt4000_toggle_cnv(struct admt4000_dev *device)
Toggle the CNV to stop/start conversion.
Definition admt4000.c:697
int admt4000_set_storage_config(struct admt4000_dev *device, uint8_t storage)
Sets storage general config.
Definition admt4000.c:1205
admt4000_conv_sync_mode
Definition admt4000.h:248
@ ADMT4000_SEQ_CTRL
Definition admt4000.h:249
@ ADMT4000_START_EDGE
Definition admt4000.h:250
int admt4000_clear_all_faults(struct admt4000_dev *device)
Clear all faults from fault registers.
Definition admt4000.c:971
int admt4000_get_conv_mode(struct admt4000_dev *device, bool *is_one_shot)
Obtains the conversion mode.
Definition admt4000.c:1433
int admt4000_get_gpio_func(struct admt4000_dev *device, uint8_t gpio, bool *alt_mode)
Get current GPIO function configuration.
Definition admt4000.c:1670
int admt4000_raw_angle_read(struct admt4000_dev *device, uint16_t *angle_data)
Reads ANGLE and ABSANGLE register contents in 1 CS frame.
Definition admt4000.c:742
int admt4000_set_harmonic(struct admt4000_dev *device, uint8_t harmonic, const struct admt4000_harmonic_coeff *config)
Set harmonic configuration (magnitude and phase together).
Definition admt4000.c:1850
int admt4000_get_storage_config(struct admt4000_dev *device, uint8_t *storage)
Gets storage general config.
Definition admt4000.c:1171
Header file of GPIO Interface.
Header file of SPI Interface.
Header file of utility functions.
ADMT4000 device descriptor.
Definition admt4000.h:351
struct no_os_gpio_desc * gpio_cnv_desc
Definition admt4000.h:359
struct no_os_gpio_desc * gpio_fault_desc
Definition admt4000.h:363
struct no_os_gpio_desc * gpio_reset_desc
Definition admt4000.h:357
struct no_os_spi_desc * spi_desc
Definition admt4000.h:353
struct no_os_gpio_desc * gpio_acalc_desc
Definition admt4000.h:361
struct admt4000_init_param default_config
Definition admt4000.h:355
struct admt4000_gpio gpios[6]
Definition admt4000.h:374
uint8_t current_page
Definition admt4000.h:367
bool is_one_shot
Definition admt4000.h:377
bool page_cache_valid
Definition admt4000.h:370
GPIO initialization parameters.
Definition admt4000.h:306
bool alt_mode
Definition admt4000.h:308
bool init_state
Definition admt4000.h:312
bool output_en
Definition admt4000.h:310
GPIO state and configuration.
Definition admt4000.h:293
bool alt_mode
Definition admt4000.h:297
bool output_en
Definition admt4000.h:299
bool logic_state
Definition admt4000.h:295
Harmonic calibration coefficient.
Definition admt4000.h:267
uint16_t magnitude_raw
Definition admt4000.h:269
uint16_t phase_raw
Definition admt4000.h:271
Harmonic calibration data for all harmonics.
Definition admt4000.h:278
struct admt4000_harmonic_coeff h3
Definition admt4000.h:284
struct admt4000_harmonic_coeff h1
Definition admt4000.h:280
struct admt4000_harmonic_coeff h2
Definition admt4000.h:282
struct admt4000_harmonic_coeff h8
Definition admt4000.h:286
ADMT4000 initialization parameters.
Definition admt4000.h:319
struct no_os_gpio_init_param gpio_fault_ip
Definition admt4000.h:333
struct admt4000_gpio_init_param admt4000_gpio_ip[6]
Definition admt4000.h:344
struct no_os_gpio_init_param gpio_reset_ip
Definition admt4000.h:324
struct no_os_spi_init_param spi_init_param
Definition admt4000.h:321
struct no_os_gpio_init_param gpio_acalc_ip
Definition admt4000.h:330
struct no_os_gpio_init_param gpio_cnv_ip
Definition admt4000.h:327
Definition ad9361_util.h:63
Structure holding the GPIO descriptor.
Definition no_os_gpio.h:84
Structure holding the parameters for GPIO initialization.
Definition no_os_gpio.h:67
Structure holding SPI descriptor.
Definition no_os_spi.h:180
Structure holding the parameters for SPI initialization.
Definition no_os_spi.h:128