Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/sphinx/source/projects/eval/eval-adhv4710.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.. include:: ../../../../../projects/eval-adhv4710/README.rst
10 changes: 9 additions & 1 deletion drivers/amplifiers/adhv4710/adhv4710.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@
#include <errno.h>
#include <math.h>

/* Per-variant constants, indexed by enum adhv4710_type */
static const struct adhv4710_chip_info chip_info[] = {
[ID_ADHV4710] = { .version_product = ADHV4710_VERSION_PRODUCT },
[ID_ADHV4711] = { .version_product = ADHV4711_VERSION_PRODUCT },
};

/**
* @brief Initialize the device.
* @param device - The device structure.
Expand All @@ -69,6 +75,8 @@ int adhv4710_init(struct adhv4710_dev **device,
if (!dev)
return -ENOMEM;

dev->id = init_param.id;

/* SPI Initialization */
ret = no_os_spi_init(&dev->spi_desc,
init_param.spi_init);
Expand All @@ -85,7 +93,7 @@ int adhv4710_init(struct adhv4710_dev **device,
if (ret)
goto error_spi;

if (reg_val != ADHV4710_VERSION_PRODUCT) {
if (reg_val != chip_info[dev->id].version_product) {
ret = -ENXIO;
goto error_spi;
}
Expand Down
25 changes: 25 additions & 0 deletions drivers/amplifiers/adhv4710/adhv4710.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
/* Version product */
#define ADHV4710_SILICON_REV 0x4
#define ADHV4710_VERSION_PRODUCT 0x46
#define ADHV4711_VERSION_PRODUCT 0x47

/* ADHV4710 Register Map */
/* 8 BIT REGISTERS */
Expand Down Expand Up @@ -127,6 +128,26 @@
#define ADHV4710_INCREASE_I 1
#define ADHV4710_DECREASE_I 0

/**
* @enum adhv4710_type
* @brief Supported device variants.
*/
enum adhv4710_type {
/** ADHV4710 */
ID_ADHV4710,
/** ADHV4711 */
ID_ADHV4711,
};

/**
* @struct adhv4710_chip_info
* @brief Per-variant constants.
*/
struct adhv4710_chip_info {
/** Expected value of the CTRL_REG_26 chip-id register */
uint8_t version_product;
};

/**
* @struct adhv4710_init_param
* @brief ADHV4710 Device initialization parameters.
Expand All @@ -136,6 +157,8 @@ struct adhv4710_init_param {
struct no_os_spi_init_param *spi_init;
/** GPIO RESET descriptor used to reset device (HW reset) */
struct no_os_gpio_init_param *gpio_reset;
/** Device variant */
enum adhv4710_type id;
};

/**
Expand All @@ -147,6 +170,8 @@ struct adhv4710_dev {
struct no_os_spi_desc *spi_desc;
/** GPIO RESET descriptor used to reset device (HW reset) */
struct no_os_gpio_desc *gpio_reset;
/** Device variant */
enum adhv4710_type id;
};

/* Initialize the device. */
Expand Down
138 changes: 138 additions & 0 deletions projects/eval-adhv4710/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
EVAL-ADHV4710 no-OS Example Project
===================================

.. no-os-doxygen::

.. contents:: Table of Contents
:depth: 3

Supported Evaluation Boards
----------------------------

* `EVAL-ADHV4710 <https://www.analog.com/ADHV4710>`_
* `EVAL-ADHV4711 <https://www.analog.com/ADHV4711>`_

Overview
--------

The ADHV4710 and ADHV4711 are high voltage, high precision amplifiers
controlled over an SPI interface. The two parts are variants of the same
device and share the same register map and control logic; they differ
only in the value reported by the product-version (chip-id) register
(``CTRL_REG_26``): ``0x46`` for the ADHV4710 and ``0x47`` for the
ADHV4711. A single no-OS driver (``drivers/amplifiers/adhv4710``)
supports both variants, selected at initialization time.

The firmware initializes the amplifier, configures its overcurrent
(source and sink), overvoltage (positive and negative) and
overtemperature protection limits, and then periodically polls the alarm
status register, reporting any triggered protection over UART and
re-enabling the amplifier from a latched shutdown.

Applications
------------

* High voltage signal conditioning
* Piezoelectric transducer and MEMS driving
* Programmable power supplies
* Automated test equipment (ATE)

Selecting the Device Variant
----------------------------

The driver distinguishes the two parts through the ``id`` field of
``struct adhv4710_init_param``, using ``enum adhv4710_type``:

.. code-block:: c

enum adhv4710_type {
ID_ADHV4710,
ID_ADHV4711,
};

At initialization the driver reads ``CTRL_REG_26`` and validates it
against the expected product-version value for the selected variant
(returning ``-ENXIO`` on mismatch). The variant used by the example is
controlled by the ``ADHV4710_DEV_ID`` macro in the
`Project Common Data Path <https://github.com/analogdevicesinc/no-OS/tree/main/projects/eval-adhv4710/src/common>`__:

.. code-block:: c

/* Device variant: ID_ADHV4710 or ID_ADHV4711 */
#define ADHV4710_DEV_ID ID_ADHV4710

Set this to ``ID_ADHV4711`` when running against an ADHV4711 board.

Hardware Specifications
------------------------

Board Connections
~~~~~~~~~~~~~~~~~~~

The evaluation board is controlled over a 4-wire SPI interface plus a
GPIO used for hardware reset. The example also toggles a user LED to
indicate liveness. The SPI, reset and LED pins are defined in the
`Project Platform Configuration Path <https://github.com/analogdevicesinc/no-OS/tree/main/projects/eval-adhv4710/src/platform>`__.

No-OS Build Setup
-----------------

Please see: `No-OS Build Guide <https://wiki.analog.com/resources/no-os/build>`_

No-OS Supported Examples
------------------------

The initialization data used in the example is taken out from the
`Project Common Data Path <https://github.com/analogdevicesinc/no-OS/tree/main/projects/eval-adhv4710/src/common>`__.

The macros used in Common Data are defined in platform specific files
found in the
`Project Platform Configuration Path <https://github.com/analogdevicesinc/no-OS/tree/main/projects/eval-adhv4710/src/platform>`__.

ADHV4710 example
~~~~~~~~~~~~~~~~~

The ``adhv4710_example`` initializes the UART console and the SPI
interface, performs a hardware reset of the amplifier, and initializes
the device for the variant selected by ``ADHV4710_DEV_ID``. It then
clears the shutdown latch, enables all alarm latches, programs the
nominal quiescent current, and configures the overcurrent (source and
sink), overvoltage (positive and negative) and overtemperature
protection limits from the user-defined values in ``common_data.h``.

In its main loop the example periodically reads the alarm status
register (``CTRL_REG_14``), prints any triggered protection over UART,
clears the latched alarm flags, and re-enables the amplifier from
shutdown when required, toggling the user LED each cycle.

No-OS Supported Platforms
-------------------------

Maxim Platform
~~~~~~~~~~~~~~

Used Hardware
^^^^^^^^^^^^^

* `EVAL-ADHV4710 <https://www.analog.com/ADHV4710>`_ or
`EVAL-ADHV4711 <https://www.analog.com/ADHV4711>`_
* `MAX32690EVKIT <https://www.analog.com/MAX32690>`_

Connections
^^^^^^^^^^^

Connect the evaluation board to the MAX32690 SPI pins (CS, MOSI, MISO,
SCLK), the reset GPIO and ground/power as configured in the platform
files.

Build Command
^^^^^^^^^^^^^

.. code-block:: bash

# to delete current build
make reset

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.

can you please document the new build system rather than the old one ? all maxim projects are currently transitioning, there is a big PR currently open #3184 and if you add a README.md, new build system should be documented

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.

# to build the project
make PLATFORM=maxim TARGET=max32690
# to flash the code
make run
3 changes: 3 additions & 0 deletions projects/eval-adhv4710/src/common/common_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ extern struct no_os_gpio_init_param gpio_reset_ip;
/* check for triggered alarms interval */
#define READ_INTERVAL 2000000

/* Device variant: ID_ADHV4710 or ID_ADHV4711 */
#define ADHV4710_DEV_ID ID_ADHV4710

/* Setup values for ADHV4710 */
/* Current resolution */
#define ADHV4710_CURRENT_RESOLUTION 15.625
Expand Down
3 changes: 3 additions & 0 deletions projects/eval-adhv4710/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@ int main(void)
/* Init the reset */
adhv4710_ip.gpio_reset = &gpio_reset_ip;

/* Select the device variant */
adhv4710_ip.id = ADHV4710_DEV_ID;

no_os_uart_stdio(uart_desc);

pr_info("\n");
Expand Down
Loading