![]() |
no-OS
|
Header Implementation of ADMT4000 Driver. More...
Classes | |
| struct | admt4000_harmonic_coeff |
| Harmonic calibration coefficient. More... | |
| struct | admt4000_harmonics_calib |
| Harmonic calibration data for all harmonics. More... | |
| struct | admt4000_gpio |
| GPIO state and configuration. More... | |
| struct | admt4000_gpio_init_param |
| GPIO initialization parameters. More... | |
| struct | admt4000_init_param |
| ADMT4000 initialization parameters. More... | |
| struct | admt4000_dev |
| ADMT4000 device descriptor. More... | |
Enumerations | |
| enum | admt4000_faults { ADMT4000_FAULT_VDD_UV = 0 , ADMT4000_FAULT_VDD_OV , ADMT4000_FAULT_VDRIVE_UV , ADMT4000_FAULT_VDRIVE_OV , ADMT4000_FAULT_NVM_CRC = 5 , ADMT4000_FAULT_ECC_DOUBLE = 7 , ADMT4000_FAULT_GMR_REF_RES = 9 , ADMT4000_FAULT_TURN_CTRS = 13 , ADMT4000_FAULT_AMR_RAD_AMP } |
| enum | admt4000_vdd { ADMT4000_3P3V , ADMT4000_5V } |
| enum | admt4000_conv_sync_mode { ADMT4000_SEQ_CTRL = 0 , ADMT4000_START_EDGE = 3 } |
| enum | admt4000_harmonic_corr_src { ADMT4000_FACTORY = 0 , ADMT4000_USER = 1 } |
| enum | admt4000_conversion_mode { ADMT4000_CONTINUOUS = 0 , ADMT4000_ONE_SHOT = 1 } |
Functions | |
| int | admt4000_angle_raw_to_scaled (uint16_t raw_angle, float *scaled_angle) |
| Convert raw angle value to scaled degrees. | |
| 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. | |
| 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. | |
| int | admt4000_reinitialize (struct admt4000_dev *device) |
| Reinitialize device using stored configuration. | |
| int | admt4000_hard_reset (struct admt4000_dev *device) |
| Perform hardware reset via reset pin. | |
| int | admt4000_init (struct admt4000_dev **device, struct admt4000_init_param *init_param) |
| Initializes the admt4000. | |
| int | admt4000_remove (struct admt4000_dev *device) |
| Free the resources allocated by admt4000_init(). | |
| 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. | |
| int | admt4000_reg_write (struct admt4000_dev *device, uint8_t reg_addr, uint16_t reg_data) |
| Writes data to a certain ADMT400x Register. | |
| 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. | |
| int | admt4000_toggle_cnv (struct admt4000_dev *device) |
| Toggle the CNV to stop/start conversion. | |
| int | admt4000_raw_angle_read (struct admt4000_dev *device, uint16_t *angle_data) |
| Reads ANGLE and ABSANGLE register contents in 1 CS frame. | |
| 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). | |
| int | admt4000_quarter_turns_cnt (uint8_t raw_turns, int16_t *quarter_turns) |
| Convert raw quarter turn count to equivalent signed value. | |
| int | admt4000_get_gpio (struct admt4000_dev *device, uint8_t gpio, bool *logic) |
| Get status of selected GPIO. | |
| int | admt4000_set_gpio (struct admt4000_dev *device, uint8_t gpio, bool logic) |
| Configure selected GPIO. | |
| int | admt4000_clear_all_faults (struct admt4000_dev *device) |
| Clear all faults from fault registers. | |
| int | admt4000_get_faults (struct admt4000_dev *device, uint16_t *faults) |
| Get all fault flags from the fault register. | |
| int | admt4000_get_radius (struct admt4000_dev *device, uint16_t *radius, bool *is_new_data) |
| Get RADIUS vector value. | |
| int | admt4000_radius_raw_to_scaled (uint16_t raw_radius, float *radius) |
| Convert raw RADIUS value to scaled mV/V. | |
| int | admt4000_get_temp (struct admt4000_dev *device, uint16_t *temp) |
| Get raw temperature reading. | |
| int | admt4000_temp_raw_to_scaled (uint16_t temp_raw, float *temp) |
| Convert raw temperature value to scaled temperature (degrees Celsius). | |
| int | admt4000_get_storage_config (struct admt4000_dev *device, uint8_t *storage) |
| Gets storage general config. | |
| int | admt4000_set_storage_config (struct admt4000_dev *device, uint8_t storage) |
| Sets storage general config. | |
| int | admt4000_get_conv_sync_mode (struct admt4000_dev *device, enum admt4000_conv_sync_mode *mode) |
| Obtains conversion synchronization mode. | |
| int | admt4000_set_conv_sync_mode (struct admt4000_dev *device, enum admt4000_conv_sync_mode mode) |
| Configures conversion synchronization mode. | |
| int | admt4000_get_angle_filt (struct admt4000_dev *device, bool *is_filtered) |
| Gets current filter setting. | |
| int | admt4000_set_angle_filt (struct admt4000_dev *device, bool is_filtered) |
| Sets the filter setting. | |
| int | admt4000_get_h8_ctrl (struct admt4000_dev *device, enum admt4000_harmonic_corr_src *source) |
| Gets 8th harmonic correction source. | |
| int | admt4000_set_h8_ctrl (struct admt4000_dev *device, enum admt4000_harmonic_corr_src source) |
| Sets 8th harmonic correction source. | |
| int | admt4000_get_conv_mode (struct admt4000_dev *device, bool *is_one_shot) |
| Obtains the conversion mode. | |
| int | admt4000_set_conv_mode (struct admt4000_dev *device, bool is_one_shot) |
| Configures the conversion mode: one shot or continuous. | |
| 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. | |
| int | admt4000_get_gpio_func (struct admt4000_dev *device, uint8_t gpio, bool *alt_mode) |
| Get current GPIO function configuration. | |
| int | admt4000_get_cnv_cnt (struct admt4000_dev *device, uint8_t *cnt) |
| Get current conversion count. | |
| int | admt4000_get_id (struct admt4000_dev *device, uint8_t id_num, uint16_t *id) |
| Read Unique ID from register/s. | |
| 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 angle sensor without post- processing. | |
| 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 angle sensor without post- processing. | |
| int | admt4000_get_harmonic (struct admt4000_dev *device, uint8_t harmonic, struct admt4000_harmonic_coeff *config) |
| Get harmonic configuration (magnitude and phase together). | |
| int | admt4000_set_harmonic (struct admt4000_dev *device, uint8_t harmonic, const struct admt4000_harmonic_coeff *config) |
| Set harmonic configuration (magnitude and phase together). | |
| int | admt4000_get_harmonics_calib (struct admt4000_dev *device, struct admt4000_harmonics_calib *calib) |
| Get all harmonic configurations in a single operation. | |
| int | admt4000_set_harmonics_calib (struct admt4000_dev *device, const struct admt4000_harmonics_calib *calib) |
| Set all harmonic configurations in a single operation. | |
Header Implementation of ADMT4000 Driver.
Copyright 2026(c) Analog Devices, Inc.
SPDX-License-Identifier: BSD-3-Clause
| #define ADMT4000_00_REG_COSINE 0x11 |
| #define ADMT4000_00_REG_RADIUS 0x18 |
| #define ADMT4000_00_REG_SINE 0x10 |
| #define ADMT4000_00_REG_TMP 0x20 |
| #define ADMT4000_02_REG_ANGLECK 0x13 /* ECC0 */ |
| #define ADMT4000_02_REG_CNVCNT 0x14 |
| #define ADMT4000_02_REG_DIGIOEN 0x12 /* ECC0 */ |
| #define ADMT4000_02_REG_ECCDIS 0x23 |
| #define ADMT4000_02_REG_ECCEDC 0x1D |
| #define ADMT4000_02_REG_GENERAL 0x10 /* ECC0 */ |
| #define ADMT4000_02_REG_H1MAG 0x15 /* ECC0 */ |
| #define ADMT4000_02_REG_H1PH 0x16 /* ECC0 */ |
| #define ADMT4000_02_REG_H2MAG 0x17 /* ECC0 */ |
| #define ADMT4000_02_REG_H2PH 0x18 /* ECC0 */ |
| #define ADMT4000_02_REG_H3MAG 0x19 /* ECC1/0 */ |
| #define ADMT4000_02_REG_H3PH 0x1A /* ECC1 */ |
| #define ADMT4000_02_REG_H8MAG 0x1B /* ECC1 */ |
| #define ADMT4000_02_REG_H8PH 0x1C /* ECC1 */ |
| #define ADMT4000_02_REG_UNIQD0 0x1E |
| #define ADMT4000_02_REG_UNIQD1 0x1F |
| #define ADMT4000_02_REG_UNIQD2 0x20 |
| #define ADMT4000_02_REG_UNIQD3 0x21 |
| #define ADMT4000_11BIT_MAX 2047 |
| #define ADMT4000_12BIT_MAX 4095 |
| #define ADMT4000_8BIT_MAX 127 |
| #define ADMT4000_ABS_ANGLE_ANGLE_MASK NO_OS_GENMASK(9, 0) |
| #define ADMT4000_ABS_ANGLE_MASK NO_OS_GENMASK(15, 0) |
| #define ADMT4000_ABS_ANGLE_RES 1024 |
| #define ADMT4000_AGP_INDIV_FAULT | ( | x | ) |
| #define ADMT4000_AGP_REG_ABSANGLE 0x03 |
| #define ADMT4000_AGP_REG_ANGLE 0x05 |
| #define ADMT4000_AGP_REG_CNVPAGE 0x01 |
| #define ADMT4000_AGP_REG_DGIO 0x04 |
| #define ADMT4000_AGP_REG_FAULT 0x06 |
| #define ADMT4000_ALL_FAULTS NO_OS_GENMASK(15, 0) |
| #define ADMT4000_ANGL_FILT_MASK NO_OS_BIT(12) |
| #define ADMT4000_ANGLE_MASK NO_OS_GENMASK(15, 4) |
| #define ADMT4000_ANGLE_RES 4096 |
| #define ADMT4000_ANGLE_STAT_MASK NO_OS_BIT(0) |
| #define ADMT4000_CNV_CTR_MASK NO_OS_GENMASK(7, 0) |
| #define ADMT4000_CNV_EDGE_MASK NO_OS_GENMASK(15, 14) |
| #define ADMT4000_CNV_MODE_MASK NO_OS_BIT(0) |
| #define ADMT4000_CNV_PULSE_WIDTH_US 1 |
| #define ADMT4000_CONV_SYNC_MODE_MASK NO_OS_GENMASK(14, 13) |
| #define ADMT4000_CONVERSION_DELAY_MS 20 |
| #define ADMT4000_DIG_IO_EN | ( | x | ) |
| #define ADMT4000_DIGIO0FNC_MASK NO_OS_BIT(0) |
| #define ADMT4000_DIGIO3FNC_MASK NO_OS_BIT(3) |
| #define ADMT4000_ECC_CFG0 NO_OS_GENMASK(7, 0) |
| #define ADMT4000_ECC_CFG1 NO_OS_GENMASK(15, 8) |
| #define ADMT4000_ECC_DIS_COMM 0x4D54 |
| #define ADMT4000_ECC_EN_COMM 0x0000 |
| #define ADMT4000_FALLING_EDGE 0x00 |
| #define ADMT4000_FAULT_MASK NO_OS_BIT(7) |
| #define ADMT4000_FULL_TURN_DEGREES 360 |
| #define ADMT4000_GPIO_FUNC | ( | x | ) |
| #define ADMT4000_GPIO_LOGIC | ( | x | ) |
| #define ADMT4000_GPIO_SETTLE_DELAY_MS 10 |
| #define ADMT4000_H8_CTRL_MASK NO_OS_BIT(10) |
| #define ADMT4000_H_11BIT_MAG_MASK NO_OS_GENMASK(10, 0) |
| #define ADMT4000_H_12BIT_PHA_MASK NO_OS_GENMASK(11, 0) |
| #define ADMT4000_H_8BIT_MAG_MASK NO_OS_GENMASK(7, 0) |
| #define ADMT4000_HI_BYTE NO_OS_GENMASK(15, 8) |
| #define ADMT4000_HMAG_SCALER 0.009046f |
| #define ADMT4000_HPHA_SCALER 0.087891f |
| #define ADMT4000_ID0_MASK NO_OS_GENMASK(14, 0) |
| #define ADMT4000_ID_ASIL_MASK NO_OS_GENMASK(5, 3) |
| #define ADMT4000_ID_PROD_MASK NO_OS_GENMASK(10, 8) |
| #define ADMT4000_ID_SIL_REV_MASK NO_OS_GENMASK(2, 0) |
| #define ADMT4000_ID_SUPPLY_MASK NO_OS_GENMASK(7, 6) |
| #define ADMT4000_INVALID_TURN 0x53 |
| #define ADMT4000_LIFE_CTR NO_OS_GENMASK(6, 5) |
| #define ADMT4000_LOW_BYTE NO_OS_GENMASK(7, 0) |
| #define ADMT4000_MAX_CRC_BIT_LEN 25 |
| #define ADMT4000_MAX_GPIO_INDEX 5 |
| #define ADMT4000_MAX_PAGE 0x02 |
| #define ADMT4000_MIN_PAGE 0x00 |
| #define ADMT4000_NEW_DATA_MASK NO_OS_BIT(0) |
| #define ADMT4000_PAGE_MASK NO_OS_GENMASK(4, 0) |
| #define ADMT4000_QUARTER_TURN_CNT_MASK NO_OS_GENMASK(15, 8) |
| #define ADMT4000_QUARTER_TURNS_MAX 215 |
| #define ADMT4000_QUARTER_TURNS_RES 256 |
| #define ADMT4000_RADIUS_MASK NO_OS_GENMASK(15, 1) |
| #define ADMT4000_RADIUS_RES 924 |
| #define ADMT4000_RAW_ANGLE_MASK NO_OS_GENMASK(15, 2) |
| #define ADMT4000_RAW_COSINE_MASK NO_OS_GENMASK(15, 2) |
| #define ADMT4000_RAW_SINE_MASK NO_OS_GENMASK(15, 2) |
| #define ADMT4000_RCV_CRC NO_OS_GENMASK(4, 0) |
| #define ADMT4000_REG_RST 0x00 |
| #define ADMT4000_RESET_HOLD_TIME_MS 1 |
| #define ADMT4000_RISING_EDGE 0x3 |
| #define ADMT4000_RW_MASK NO_OS_GENMASK(5, 0) |
| #define ADMT4000_STARTUP_TIME_MS 10 |
| #define ADMT4000_STORAGE_BIT2_0 NO_OS_GENMASK(2, 0) |
| #define ADMT4000_STORAGE_BIT5_3 NO_OS_GENMASK(5, 3) |
| #define ADMT4000_STORAGE_BIT6 NO_OS_BIT(6) |
| #define ADMT4000_STORAGE_BIT7 NO_OS_BIT(7) |
| #define ADMT4000_STORAGE_MASK_BIT2_0 NO_OS_GENMASK(3, 1) |
| #define ADMT4000_STORAGE_MASK_BIT5_3 NO_OS_GENMASK(8, 6) |
| #define ADMT4000_STORAGE_MASK_BIT6 NO_OS_BIT(11) |
| #define ADMT4000_STORAGE_MASK_BIT7 NO_OS_BIT(15) |
| #define ADMT4000_STORAGE_MASK_FULL |
| #define ADMT4000_TEMP_MASK NO_OS_GENMASK(15, 4) |
| #define ADMT4000_TEMP_OFFSET -1168 |
| #define ADMT4000_TEMP_SCALE_MILLIS 15660 |
| #define ADMT4000_TURN_CNT_MASK NO_OS_GENMASK(15, 10) |
| #define ADMT4000_TURN_CNT_THRES 0x35 |
| #define ADMT4000_TURN_CNT_TWOS 64 |
| #define ADMT4000_WR_EN NO_OS_BIT(6) |
| enum admt4000_faults |
| enum admt4000_vdd |
| int admt4000_angle_raw_to_scaled | ( | uint16_t | raw_angle, |
| float * | scaled_angle ) |
Convert raw angle value to scaled degrees.
Convert raw angle value to scaled degrees
| raw_angle | - Input raw angle value |
| scaled_angle | - Output scaled angle in degrees |
Scales raw angle register value to physical units using device-specific resolution factors. Angle: raw * 360 / 4096 (for 12-bit angle resolution)
| int admt4000_clear_all_faults | ( | struct admt4000_dev * | device | ) |
Clear all faults from fault registers.
Clear all fault flags
| device | - The device structure. |
| int admt4000_get_angle_filt | ( | struct admt4000_dev * | device, |
| bool * | is_filtered ) |
Gets current filter setting.
Get angle filter status
| device | - The device structure. |
| is_filtered | - Stores the logic level of the filter enable bit. |
| int admt4000_get_cnv_cnt | ( | struct admt4000_dev * | device, |
| uint8_t * | cnt ) |
Get current conversion count.
Get conversion count value
| device | - The device structure. |
| cnt | - Stores the count data. |
| int admt4000_get_conv_mode | ( | struct admt4000_dev * | device, |
| bool * | is_one_shot ) |
Obtains the conversion mode.
Get conversion mode
| device | - The device structure. |
| is_one_shot | - Stores the conversion mode bit value. |
| int admt4000_get_conv_sync_mode | ( | struct admt4000_dev * | device, |
| enum admt4000_conv_sync_mode * | mode ) |
Obtains conversion synchronization mode.
Get conversion synchronization mode
| device | - The device structure. |
| mode | - The conversion synchronization mode configured. |
| 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 angle sensor without post- processing.
Get cosine value
| device | - The device structure. |
| val | - Pointer to a variable where cosine value will be stored. |
| is_new_data | - Optional pointer to store new data flag (can be NULL). |
| int admt4000_get_faults | ( | struct admt4000_dev * | device, |
| uint16_t * | faults ) |
Get all fault flags from the fault register.
Get fault register value
| device | - The device structure. |
| faults | - Pointer to store the fault register value. |
| int admt4000_get_gpio | ( | struct admt4000_dev * | device, |
| uint8_t | gpio, | ||
| bool * | logic ) |
Get status of selected GPIO.
Get GPIO logic level
| device | - The device structure. |
| gpio | - GPIO number (0 to 5). |
| logic | - Stores the truth value of selected GPIO. |
| int admt4000_get_gpio_func | ( | struct admt4000_dev * | device, |
| uint8_t | gpio, | ||
| bool * | alt_mode ) |
Get current GPIO function configuration.
Get GPIO function configuration
| device | - The device structure. |
| gpio | - GPIO number (0-5). |
| alt_mode | - Pointer to store result (true = alt, false = normal). |
| int admt4000_get_h8_ctrl | ( | struct admt4000_dev * | device, |
| enum admt4000_harmonic_corr_src * | source ) |
Gets 8th harmonic correction source.
Get H8 harmonic coefficient source
| device | - The device structure. |
| source | - The harmonic correction source. |
| int admt4000_get_harmonic | ( | struct admt4000_dev * | device, |
| uint8_t | harmonic, | ||
| struct admt4000_harmonic_coeff * | config ) |
Get harmonic configuration (magnitude and phase together).
Get harmonic calibration coefficients
| device | - The device structure. |
| harmonic | - Harmonic number (1, 2, 3, or 8). |
| config | - Output structure for magnitude and phase. |
| int admt4000_get_harmonics_calib | ( | struct admt4000_dev * | device, |
| struct admt4000_harmonics_calib * | calib ) |
Get all harmonic configurations in a single operation.
Get all harmonic calibration data
| device | - The device structure. |
| calib | - Output structure for all 4 harmonics (1, 2, 3, 8). |
| int admt4000_get_id | ( | struct admt4000_dev * | device, |
| uint8_t | id_num, | ||
| uint16_t * | id ) |
Read Unique ID from register/s.
Read device ID register
| device | - The device structure. |
| id_num | - The ID register to read from. |
| id | - Stores the ID value read. |
| int admt4000_get_radius | ( | struct admt4000_dev * | device, |
| uint16_t * | radius, | ||
| bool * | is_new_data ) |
Get RADIUS vector value.
Get radius raw data
| device | - The device structure. |
| radius | - Stores the radius value read. |
| is_new_data | - Optional pointer to store new data flag (can be NULL). |
| 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).
Get raw turns and angle data
| device | - The device structure. |
| turns | - Stores the number of turns read (Raw). |
| angle | - Stores the angle values read (Raw, extracted). |
| 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 angle sensor without post- processing.
Get sine value
| device | - The device structure. |
| val | - Pointer to a variable where sine value will be stored. |
| is_new_data | - Optional pointer to store new data flag (can be NULL). |
| int admt4000_get_storage_config | ( | struct admt4000_dev * | device, |
| uint8_t * | storage ) |
Gets storage general config.
Get storage configuration bits
| device | - The device structure. |
| storage | - Stores the storage bits read. |
| int admt4000_get_temp | ( | struct admt4000_dev * | device, |
| uint16_t * | temp ) |
Get raw temperature reading.
Get raw temperature value
| device | - The device structure. |
| temp | - Raw temperature ADC value. |
| 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.
Configure GPIO mode, direction, and initial state
GPIO Functions
The ADMT4000 has 6 GPIO pins (GPIO0-GPIO5) that can be configured as either:
Alternate Functions:
When a GPIO is in alternate function mode:
GPIO direction defaults to input mode at init time. If direction configured at init conflicts with the selected alternate function, alternate function's required direction takes precedence.
| device | - The device structure. |
| gpio | - GPIO number (0-5). |
| alt_mode | - Alternate function flag (true = alt, false = normal). |
| output_en | - Direction flag (true = output, false = input). Ignored in alt mode. |
| init_state | - Initial output state (true = high, false = low). Only applied if output_en is true and alt_mode is false. |
| int admt4000_hard_reset | ( | struct admt4000_dev * | device | ) |
Perform hardware reset via reset pin.
Perform hardware reset via reset pin
| device | - The device structure. |
| 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.
Convert raw harmonic coefficients to scaled format
| raw_coeff | - Input raw calibration coefficients |
| scaled_mag | - Output scaled magnitude |
| scaled_phase | - Output scaled phase |
Scales raw register values to physical units using device-specific resolution factors. Magnitude: raw * 0.005493/0.6072 Phase: raw * 0.087891
| 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.
Convert scaled harmonic values to raw coefficients
| scaled_mag | - Input scaled magnitude |
| scaled_phase | - Input scaled phase |
| raw_coeff | - Output raw calibration coefficients |
Inverse conversion for writing scaled values to hardware registers. Uses CORDIC scaler (0.6072) to compensate for hardware scaling.
| int admt4000_init | ( | struct admt4000_dev ** | device, |
| struct admt4000_init_param * | init_param ) |
Initializes the admt4000.
Initialize the ADMT4000 device
| device | - The device structure. |
| init_param | - The structure for the device initial parameters. |
| int admt4000_quarter_turns_cnt | ( | uint8_t | raw_turns, |
| int16_t * | quarter_turns ) |
Convert raw quarter turn count to equivalent signed value.
Convert raw quarter turn count to signed value
| raw_turns | - Raw quarter turn count read from device. |
| quarter_turns | - Pointer to store the signed quarter turn count. |
| int admt4000_radius_raw_to_scaled | ( | uint16_t | raw_radius, |
| float * | radius ) |
Convert raw RADIUS value to scaled mV/V.
Convert raw radius value to scaled mV/V
| raw_radius | - Raw RADIUS value. |
| radius | - Stores Magnitude value (mV/V). |
| int admt4000_raw_angle_read | ( | struct admt4000_dev * | device, |
| uint16_t * | angle_data ) |
Reads ANGLE and ABSANGLE register contents in 1 CS frame.
Get raw angle data from ABSANGLE and ANGLE registers
| device | - The device structure. |
| angle_data | - Stores data read from the registers. |
| 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.
Read from an ADMT4000 register
| device | - The device structure. |
| reg_addr | - Address of the register. |
| reg_data | - Stores data read from the register. |
| verif | - Stores the Fault, and CRC bits returned. |
| 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.
Read-modify-write an ADMT4000 register field
| device | - The device structure. |
| reg_addr | - Address of the register. |
| update_mask | - Mask to update to selected register bit/s. |
| update_val | - Value used to update on selected register. |
| int admt4000_reg_write | ( | struct admt4000_dev * | device, |
| uint8_t | reg_addr, | ||
| uint16_t | reg_data ) |
Writes data to a certain ADMT400x Register.
Write to an ADMT4000 register
| device | - The device structure. |
| reg_addr | - Address of the register. |
| reg_data | - Data to write to the chosen register (16 bit wide). |
| int admt4000_reinitialize | ( | struct admt4000_dev * | device | ) |
Reinitialize device using stored configuration.
Reinitialize device using stored configuration
Convenience function to restore device configuration after magnetic reset or power cycle events using the parameters from initial initialization.
| device | - The device structure. |
| int admt4000_remove | ( | struct admt4000_dev * | device | ) |
Free the resources allocated by admt4000_init().
Free resources allocated by admt4000_init()
| device | - The device structure. |
| int admt4000_set_angle_filt | ( | struct admt4000_dev * | device, |
| bool | is_filtered ) |
Sets the filter setting.
Set angle filter enable
| device | - The device structure. |
| is_filtered | - Set true to enable filter, false otherwise. |
| int admt4000_set_conv_mode | ( | struct admt4000_dev * | device, |
| bool | is_one_shot ) |
Configures the conversion mode: one shot or continuous.
Set conversion mode
| device | - The device structure. |
| is_one_shot | - Set to true for one shot setting, false otherwise. |
| int admt4000_set_conv_sync_mode | ( | struct admt4000_dev * | device, |
| enum admt4000_conv_sync_mode | mode ) |
Configures conversion synchronization mode.
Set conversion synchronization mode
| device | - The device structure. |
| mode | - The conversion synchronization mode to configure. |
| int admt4000_set_gpio | ( | struct admt4000_dev * | device, |
| uint8_t | gpio, | ||
| bool | logic ) |
Configure selected GPIO.
Set GPIO logic level
| device | - The device structure. |
| gpio | - GPIO number (0 to 5). |
| logic | - Logic level to set for GPIO. |
| int admt4000_set_h8_ctrl | ( | struct admt4000_dev * | device, |
| enum admt4000_harmonic_corr_src | source ) |
Sets 8th harmonic correction source.
Set H8 harmonic coefficient source
| device | - The device structure. |
| source | - The harmonic correction source. |
| int admt4000_set_harmonic | ( | struct admt4000_dev * | device, |
| uint8_t | harmonic, | ||
| const struct admt4000_harmonic_coeff * | config ) |
Set harmonic configuration (magnitude and phase together).
Set harmonic calibration coefficients
| device | - The device structure. |
| harmonic | - Harmonic number (1, 2, 3, or 8). |
| config | - Input structure for magnitude and phase. |
| int admt4000_set_harmonics_calib | ( | struct admt4000_dev * | device, |
| const struct admt4000_harmonics_calib * | calib ) |
Set all harmonic configurations in a single operation.
Set all harmonic calibration data
| device | - The device structure. |
| calib | - Input structure for all 4 harmonics (1, 2, 3, 8). |
| int admt4000_set_storage_config | ( | struct admt4000_dev * | device, |
| uint8_t | storage ) |
Sets storage general config.
Set storage configuration bits
| device | - The device structure. |
| storage | - Data to write on storage bits. |
| int admt4000_temp_raw_to_scaled | ( | uint16_t | temp_raw, |
| float * | temp ) |
Convert raw temperature value to scaled temperature (degrees Celsius).
Convert raw temperature to degrees Celsius
| temp_raw | - Raw temperature ADC value. |
| temp | - Temperature data (degrees Celsius). |
| int admt4000_toggle_cnv | ( | struct admt4000_dev * | device | ) |
Toggle the CNV to stop/start conversion.
Toggle the CNV pin to trigger conversion
| device | - The device structure. |