Skip to content

ADMT4000 Calibration Kit Support#2856

Open
kister-jimenez wants to merge 6 commits intomainfrom
staging/admt4000
Open

ADMT4000 Calibration Kit Support#2856
kister-jimenez wants to merge 6 commits intomainfrom
staging/admt4000

Conversation

@kister-jimenez
Copy link
Copy Markdown
Collaborator

@kister-jimenez kister-jimenez commented Jan 21, 2026

Pull Request Description

These changes provide support to the ADMT4000 Calibration Kit. The ADMT4000 Calibration Kit contains the ADMT4000 and a motor controller, which in this case is a TMC5240. This also support the variant without the motor controller.

The examples are as follows:
Basic Example - Contains simple firmware exercising some of the ADMT4000 driver APIs.
IIO Trigger Example - Exposes an IIOD. This one is a bit different as I included the use of the board EEPROM so that the firmware and the SDP-K1 can be discoverable in ACE/Eval Studio. The TMC5240 is also instantiated but can include/excluded via make arguments. There is also another IIO driver to expose the GPIOs used for the board that is not part of the chip. This is done so that the ADMT4000 IIO driver can be reused.

PR Type

  • Bug fix (change that fixes an issue)
  • New feature (change that adds new functionality)
  • Breaking change (has dependencies in other repos or will cause CI to fail)

PR Checklist

  • I have followed the Coding style guidelines
  • I have complied with the Submission Checklist
  • I have performed a self-review of the changes
  • I have commented my code, at least hard-to-understand parts
  • I have build all projects affected by the changes in this PR
  • I have tested in hardware affected projects, at the relevant boards
  • I have signed off all commits from this PR
  • I have updated the documentation (wiki pages, ReadMe etc), if applies

@kister-jimenez kister-jimenez mentioned this pull request Jan 21, 2026
10 tasks
@kister-jimenez kister-jimenez changed the title Staging/admt4000 ADMT4000 Calibration Kit Support Jan 21, 2026
@buha
Copy link
Copy Markdown
Contributor

buha commented Mar 11, 2026

@kister-jimenez i think this is a well made PR, however, could you please check the CI output logs to fix those errors ?

  • run astyle on each commit
  • see what issues are there in docs and drivers build

Also, is the Draft label necessary ? I think you can remove it but maybe you have a reason for keeping it ?

@kister-jimenez
Copy link
Copy Markdown
Collaborator Author

@kister-jimenez i think this is a well made PR, however, could you please check the CI output logs to fix those errors ?

  • run astyle on each commit
  • see what issues are there in docs and drivers build

Also, is the Draft label necessary ? I think you can remove it but maybe you have a reason for keeping it ?

I was planning to complete first the TMC5240 PR before moving this to the active. I'm a bit not sure on the approach I did for the TMC library so I split the PR.

@RaduSabau1
Copy link
Copy Markdown
Collaborator

Since the TMC related commits are already into main, I think you can reset them and rebase upon main.

@kister-jimenez
Copy link
Copy Markdown
Collaborator Author

V2:

  • Major refactor on the drivers, formula, formatting, APIs.
  • Added documentation for the driver and project.
  • removed the TMC5240 commits (merged in separate PR)
  • Added basic example

Copy link
Copy Markdown
Contributor

@edelweiseescala edelweiseescala left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello sir kit, I just have some question about some flags for the board info library.

Also, some files do not have new line at the end.

#define DEVICE_NAME "EVAL-ADMT4000ARD1Z"
#define DEVICE_VENDOR "Analog Devices"
#ifndef FW_VERSION
#define FW_VERSION "1.0.0"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keeping FW_version might be confusing, FIRMWARE_VERSION is the one used by get_iio_context_attributes_ex

DEVICE_NAME and DEVICE_VENDOR information is from the eeprom, maybe should also be dropped.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed DEVICE_NAME and DEVICE_VENDOR. I kept the FIRMWARE_VERSION since this is not of part of the information in the EEPROM.

INCS += $(PROJECT)/src/common/common_data.h

# Add firmware version definition
CFLAGS += -DFIRMWARE_VERSION=\"$(FIRMWARE_VERSION)\" No newline at end of file
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we keep this here or move it to the src.mk

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed this.

@kister-jimenez kister-jimenez force-pushed the staging/admt4000 branch 3 times, most recently from 2ceeae2 to e9877a3 Compare April 10, 2026 18:37
@kister-jimenez
Copy link
Copy Markdown
Collaborator Author

kister-jimenez commented Apr 11, 2026

V3:

  • Fixed no newline at EoF.
  • Removed unused macro defines.
  • Addressed CI issues (remaining issues may not be related)

@jcroleda
Copy link
Copy Markdown
Contributor

Hello sir Kit,

Just a couple minor suggestions:

* writing registers, computing CRC, ECC encoding, and more.
* @author Marc Sosa (marcpaolo.sosa@analog.com)
* @author Jose Ramon San Buenaventura (jose.sanbuenaventura@analog.com)
* @author Louijie Compo (louijie.compo@analog.com)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* @author Louijie Compo (louijie.compo@analog.com)
* @author Louijie Compo (louijie.compo@analog.com)
* @author Kister Jimenez (kister.jimenez@analog.com)

ditto for other file headers

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did not write this driver and only did a little cleanup. I wanted to avoid having too many names in the driver.

Comment thread drivers/position/admt4000/admt4000.c Outdated
Comment thread drivers/position/admt4000/admt4000.c Outdated
Comment thread drivers/position/admt4000/admt4000.c Outdated
Comment thread drivers/position/admt4000/admt4000.c Outdated
Comment thread drivers/position/admt4000/admt4000.c Outdated
Comment thread drivers/position/admt4000/admt4000.c
temp = no_os_field_get(ADMT4000_LIFE_CTR | ADMT4000_FAULT_MASK,
buf[3 + 4 * i]);

*angle_data = no_os_get_unaligned_be16(buf + 1 + 4 * i);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

Suggested change
*angle_data = no_os_get_unaligned_be16(buf + 1 + 4 * i);
*angle_data = no_os_get_unaligned_be16(buf + 1 + ADMT4000_ANGLE_BUF_IDX(i));

Comment thread drivers/position/admt4000/admt4000.c Outdated
Comment thread drivers/position/admt4000/admt4000.c Outdated
Comment thread drivers/position/admt4000/admt4000.c Outdated
Comment thread drivers/position/admt4000/admt4000.c
Comment thread drivers/position/admt4000/iio_admt4000.c Outdated
Comment thread drivers/position/admt4000/iio_admt4000.c
Comment thread drivers/position/admt4000/iio_admt4000.c Outdated
Comment thread drivers/position/admt4000/iio_admt4000.c Outdated
Comment thread projects/admt4000/src/common/iio_admt_evb.c Outdated
Comment thread projects/admt4000/src/common/common_data.h Outdated
Comment thread projects/admt4000/src/examples/basic/basic_example.c Outdated
Comment thread projects/admt4000/src/platform/stm32/main.c Outdated
Comment thread drivers/position/admt4000/iio_admt4000.c Fixed
Comment thread drivers/position/admt4000/iio_admt4000.c Fixed
@kister-jimenez
Copy link
Copy Markdown
Collaborator Author

V4:

  • Refactored crc computation. Converted to static inline including the ecc and hamming functions since only used internally.
  • addressed most magic numbers.
  • addressed unused variables, typos, and formatting issues.

Copy link
Copy Markdown
Contributor

@jemfgeronimo jemfgeronimo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM overall. Minor comments on formatting and small cleanups.

Comment thread drivers/position/admt4000/admt4000.c Outdated
Comment on lines +125 to +129
ret = admt4000_toggle_cnv(device);
if (ret)
return ret;

return 0;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
ret = admt4000_toggle_cnv(device);
if (ret)
return ret;
return 0;
return admt4000_toggle_cnv(device);

Comment thread drivers/position/admt4000/admt4000.c Outdated
*/
static int admt4000_compute_crc(uint32_t data_in, uint8_t *crc_ret)
{

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unnecessary empty line.


if (xor)
crc ^= 0x04;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unnecessary empty line.

Comment thread drivers/position/admt4000/admt4000.c Outdated
return -EINVAL;

ret = admt4000_reg_read(device, reg_addr, &temp, NULL);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unnecessary empty line.

Comment thread drivers/position/admt4000/admt4000.c Outdated
ret = admt4000_reg_update(device, ADMT4000_AGP_REG_CNVPAGE,
ADMT4000_PAGE_MASK,
no_os_field_prep(ADMT4000_PAGE_MASK, page));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unnecessary empty line.

Comment thread drivers/position/admt4000/admt4000.c Outdated
ADMT4000_RISING_EDGE);
ret = admt4000_reg_update(device, ADMT4000_AGP_REG_CNVPAGE,
ADMT4000_CNV_EDGE_MASK, temp);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can remove empty line.

Comment thread drivers/position/admt4000/admt4000.c Outdated
ADMT4000_FALLING_EDGE);
ret = admt4000_reg_update(device, ADMT4000_AGP_REG_CNVPAGE,
ADMT4000_CNV_EDGE_MASK, temp);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can remove empty line.

13);

if (is_new_data)
*is_new_data = (bool)no_os_field_get(ADMT4000_NEW_DATA_MASK, raw_val);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
*is_new_data = (bool)no_os_field_get(ADMT4000_NEW_DATA_MASK, raw_val);
*is_new_data = !!no_os_field_get(ADMT4000_NEW_DATA_MASK, raw_val);

Optional: My preference only, could use !! to normalize to boolean, but (bool) is also fine.

admt4000_conv_sync_mode_avail[i]);
if (ret < 0 || ret >= (int)(len - length))
return -ENOMEM;
length += ret;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add empty line before this.

admt4000_harmonic_corr_src_avail[i]);
if (ret < 0 || ret >= (int)(len - length))
return -ENOMEM;
length += ret;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add empty line before this.

Copy link
Copy Markdown
Contributor

@edelweiseescala edelweiseescala left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have no more question regarding how to read the eeprom. I just found this one issue on documentation

Comment thread drivers/position/admt4000/README.rst Outdated
ADMT4000 IIO Driver Initialization Example
------------------------------------------

.. code-block:: bash
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be

Suggested change
.. code-block:: bash
.. code-block:: c

@kister-jimenez kister-jimenez force-pushed the staging/admt4000 branch 2 times, most recently from c47ff30 to 223c912 Compare April 20, 2026 12:18
@kister-jimenez
Copy link
Copy Markdown
Collaborator Author

V5:

  • Minor formatting
  • fix minor typo in code block
  • remove register address limits on register read/write/update.

@buha
Copy link
Copy Markdown
Contributor

buha commented Apr 20, 2026

@kister-jimenez please rebase and then we can perhaps merge

Add the Precision Converters Library as a git submodule. This library
provides functions for reading EEPROM ID information from the boards.

Signed-off-by: Kister Genesis Jimenez <kister.jimenez@analog.com>
Signed-off-by: Kister Genesis Jimenez <kister.jimenez@analog.com>
Signed-off-by: Kister Genesis Jimenez <kister.jimenez@analog.com>
Signed-off-by: Kister Genesis Jimenez <kister.jimenez@analog.com>
Signed-off-by: Kister Genesis Jimenez <kister.jimenez@analog.com>
Add project documentation for the ADMT4000 example project.

Signed-off-by: Kister Genesis Jimenez <kister.jimenez@analog.com>
@kister-jimenez
Copy link
Copy Markdown
Collaborator Author

V6:

  • rebased to main.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants