# analogdevicesinc/ad5940-examples architecture

> Architecture diagram of the GitHub repository analogdevicesinc/ad5940-examples, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/analogdevicesinc/ad5940-examples
- Repository: https://github.com/analogdevicesinc/ad5940-examples

## Overview

##### Main Components
- Hardware Platforms:
- AD5940/AD5941 Evaluation Boards: Two main types, one optimized for healthcare applications (EVAL-AD5940BIOZ) and the other for industrial/sensor applications (EVAL-AD5940ELEC). These boards include the AD5940 analog front end and the necessary sensor connectors.
- External Sensors and Peripherals: Depending on the application (e.g., ECG electrodes, gas sensors, pH sensors), these connect to the evaluation board.
- Microcontroller (MCU):
- Examples show projects for both ADICUP3029 and NUCLEO-F411, both of which serve as the MCU that communicates with the AD5940 via an SPI bus.
- Communication Interfaces:
- SPI Bus: Acts as the key interconnect between the MCU and AD5940.
- Software/Firmware Layers:
- AD5940 Driver Library (ad5940lib): Contains low-level functions and drivers for AD5940.
- Example Application Code: Each example (e.g., ADC, Amperometric, Impedance, ECG, etc.) layers on top of the driver and shows how to implement specific measurement routines.
- Porting/Hardware Abstraction Layer: Files such as ADICUP3029Port.c and NUCLEOF411Port.c mediate between the example code and the underlying MCU hardware.
- Development Environment (IDE): Although not a functional component in operation, note that development and debugging are performed in IAR or Keil (with ARM Compiler version requirements).

##### Establish the Relationships and Data Flow
- The Hardware Layer shows the sensors connecting to the Evaluation Board (which houses the AD5940).
- Data Path:
- Sensors feed analog signals into the AD5940.
- The AD5940 processes these signals and communicates with the MCU over SPI.
- The MCU, running the example firmware (which in turn integrates ad5940lib and port-specific code), processes the data.
- Processed data can then be relayed to external tools (e.g., SensorPal GUI) for visualization or further analysis.
- Control/Configuration Flow:
- The firmware controls the operation of the AD5940 through register-level commands delivered over SPI.
- Porting layers ensure that the SPI and other hardware-specific operations are correctly abstracted for different MCUs.

##### Architectural Patterns and Design Principles
- Layered Architecture:
- Hardware Abstraction: Separates low-level MCU port code (different for ADICUP3029 versus NUCLEO-F411) from the generic measurement routines.
- Reusable Library: ad5940lib acts as a common core that all examples use, ensuring code reuse and consistency.
- Modularity:
- Each example is self-contained, demonstrating specific use cases without interfering with others.
- Separation between the hardware configuration (documented in “doc”, “Schematics”, and “Application Notes”) and software examples.
- Extensibility:
- The example projects are structured to allow easy porting to different MCUs as indicated in the README.

##### Relevant Technologies
- Evaluation Boards: EVAL-AD5940BIOZ and EVAL-AD5940ELEC
- Microcontrollers: ADICUP3029 and NUCLEO-F411
- Communication: SPI (between MCU and AD5940)
- IDEs/Compilers: Keil (recommended), IAR, and ARM Compiler version 5 for ADuCM3029 porting requirements.
- Software library: ad5940lib

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Hardware Layer
    subgraph "Hardware Layer"
        A["External Sensors & Peripherals"]:::sensor
        B["Evaluation Board (AD5940 BIOZ/AD5940 ELEC)"]:::hardware
    end

    %% Communication Layer
    subgraph "Communication Layer"
        C["SPI Bus"]:::communication
    end

    %% MCU Layer
    subgraph "MCU Layer"
        D["MCU (ADICUP3029)"]:::mcu
        E["MCU (NUCLEO-F411)"]:::mcu
    end

    %% Software/Firmware Layer
    subgraph "Software/Firmware Layer"
        F["AD5940 Driver Library (ad5940lib)"]:::library
        G["Example Application Code (ADC, ECG, Amperometric, etc.)"]:::application
        H["ADICUP3029 Porting/HAL"]:::porting
        I["NUCLEO-F411 Porting/HAL"]:::porting
    end

    %% External Visualization
    J["External Tools (SensorPal GUI/Host PC)"]:::external

    %% Connections
    A -->|"feeds"| B
    B -->|"processes signals"| C
    C -->|"SPI comm"| D
    C -->|"SPI comm"| E
    D -->|"runs firmware"| F
    E -->|"runs firmware"| F
    D -->|"executes"| G
    E -->|"executes"| G
    F -->|"integrated in"| G
    G -->|"uses HAL"| H
    G -->|"uses HAL"| I
    G -->|"outputs data"| J

    %% Click Events
    click A "https://github.com/analogdevicesinc/ad5940-examples/tree/master/doc/Application Notes"
    click B "https://github.com/analogdevicesinc/ad5940-examples/tree/master/doc/Schematics/AD5940"
    click C "https://github.com/analogdevicesinc/ad5940-examples/tree/master/examples/AD5940_SPI"
    click D "https://github.com/analogdevicesinc/ad5940-examples/tree/master/examples/AD5940_ADC/ADICUP3029"
    click E "https://github.com/analogdevicesinc/ad5940-examples/tree/master/examples/AD5940_ADC/NUCLEO-F411"
    click F "https://github.com/analogdevicesinc/ad5940-examples/tree/master/examples/ad5940lib"
    click H "https://github.com/analogdevicesinc/ad5940-examples/blob/master/examples/AD5940_ADC/ADICUP3029/ADICUP3029Port.c"
    click I "https://github.com/analogdevicesinc/ad5940-examples/blob/master/examples/AD5940_ADC/NUCLEO-F411/NUCLEOF411Port.c"

    %% Styles
    classDef hardware fill:#f9e79f,stroke:#333,stroke-width:2px;
    classDef sensor fill:#fad7a0,stroke:#333,stroke-width:2px;
    classDef communication fill:#aed6f1,stroke:#333,stroke-width:2px;
    classDef mcu fill:#a9dfbf,stroke:#333,stroke-width:2px;
    classDef library fill:#f5b7b1,stroke:#333,stroke-width:2px;
    classDef application fill:#d7bde2,stroke:#333,stroke-width:2px;
    classDef porting fill:#f9e79f,stroke:#333,stroke-width:2px;
    classDef external fill:#f5cba7,stroke:#333,stroke-width:2px;
```
