# protocentral/healthypi-move-fw architecture

> Architecture diagram of the GitHub repository protocentral/healthypi-move-fw, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-09-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/protocentral/healthypi-move-fw
- Repository: https://github.com/protocentral/healthypi-move-fw

## Overview

##### Project type and purpose
- This is an embedded-firmware project for the HealthyPi Move vital-signs monitoring wrist device. It runs on an nRF5340 SoC under the Zephyr RTOS and implements sensing (ECG, PPG, SpO₂, BPT, GSR, temperature), data storage, UI, and wireless communication (BLE/HPI).

##### File structure
- Top level:
- app/           – The main application, built on Zephyr, containing modules (algorithms, state machines, UI, data, log, FS, BLE, HPI, battery, power-mgmt)
- drivers/       – Zephyr driver layer for sensors (MAX30001, MAX30208, MAX32664, BMI323HPI), display (sh8601), input, RTC
- boards/        – Board-specific device tree and Kconfig files for the nRF5340 CPU application and network cores
- dts/           – Device-tree bindings for sensors and peripherals
- scripts/, build.sh, flash.sh – Build, flashing, and workflow scripts
- zephyr/ + west.yml – Zephyr SDK integration and module configuration
- sysbuild/      – Build profiles for MCUBoot bootloader, inter-processor RPC (ipc_radio)

##### README for additional insights
- Confirms Zephyr RTOS base, MCUBoot secure boot, nRF Connect toolchain support, and end-to-end build/flash process.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Boot Layer
    subgraph "Boot"
        MCUBoot["MCUBoot Bootloader\n(Secure/Non-secure)"]:::boot
    end

    %% Core OS Layer
    subgraph "Core OS"
        Zephyr["Zephyr RTOS Kernel"]:::os
    end

    %% HAL / Board Support
    subgraph "HAL / Board Support"
        BSP["BSP / HAL"]:::hal
    end

    %% Drivers Layer
    subgraph "Drivers"
        I2C["I2C/SPI/ADC Buses"]:::hal
        subgraph "Sensor Drivers"
            S1["MAX30001"]:::hal
            S2["MAX30208"]:::hal
            S3["MAX32664C/D"]:::hal
            S4["BMI323HPI"]:::hal
        end
        Display["SH8601 Display Driver"]:::hal
        InputDrv["Touch/Button Driver"]:::hal
        RTC["RTC Driver"]:::hal
    end

    %% Application Modules
    subgraph "Application Modules"
        Main["Main (app/src/main.c)"]:::app
        subgraph "Data & Processing"
            DataMod["Sensor Data Module"]:::app
            Algos["Algorithm Module"]:::app
            subgraph "State Machines"
                SMF_ECG["smf_ecg"]:::app
                SMF_ECG_BIOZ["smf_ecg_bioz"]:::app
                SMF_PPG["smf_ppg"]:::app
                SMF_DISPLAY["smf_display"]:::app
            end
        end
        FSMod["File System Module"]:::app
        LogMod["Logging Module"]:::app
        CmdMod["Command Module"]:::app
        subgraph "HPI Interface"
            HPI_SYS["HPI System Module"]:::app
            HPI_USER["HPI User Settings API"]:::app
            HPI_STORE["HPI Settings Store"]:::app
            HPI_ZBUS["HPI zbus Channels"]:::app
        end
        BLE["BLE Communication Module"]:::app
        BattMod["Battery & Power-Management"]:::app
        HWHelpers["HW Helpers & Abstraction"]:::app
        UI["UI Layer (LVGL)"]:::app
    end

    %% Peripherals / External
    subgraph "Peripherals & External"
        Sensors["Sensors (ECG, PPG, SpO₂, BPT, GSR, Temp)"]:::ext
        DisplayHW["SH8601 Display"]:::ext
        InputHW["Touch/Button"]:::ext
        RTC_HW["RV8263 RTC"]:::ext
        Flash["QSPI Flash"]:::ext
        Phone["BLE Wireless Link"]:::ext
        Host["HPI (USB/Serial)"]:::ext
        BatteryHW["Battery"]:::ext
    end

    %% Connections
    MCUBoot -->|"Loads"| Zephyr
    Zephyr -->|"OS Services"| BSP
    Zephyr -->|"Drivers APIs"| I2C
    BSP --> I2C
    I2C --> S1 & S2 & S3 & S4
    I2C -->|"ADC"| BattMod
    I2C --> RTC
    I2C --> Display
    Display --> DisplayHW
    InputDrv --> InputHW
    RTC --> RTC_HW
    I2C --> Sensors
    S1 & S2 & S3 & S4 -->|"Publish Data"| DataMod
    DataMod -->|"Feed"| Algos
    Algos -->|"Events"| LogMod
    Algos -->|"Store"| FSMod
    DataMod -->|"Live Data"| UI
    DataMod -->|"Stream"| BLE
    DataMod -->|"Sync"| HPI_SYS
    UI --> UI
    BLE --> Phone
    HPI_SYS --> Host
    CmdMod --> HPI_SYS
    HPI_USER --> CmdMod
    HPI_STORE --> HPI_SYS
    HPI_ZBUS --> HPI_SYS
    FSMod --> Flash
    LogMod --> Flash
    RTC --> FSMod
    BattMod --> BatteryHW
    BattMod --> LogMod
    HWHelpers --> I2C
    Main --> DataMod
    Main --> Algos
    Main --> FSMod
    Main --> LogMod
    Main --> CmdMod
    Main --> BLE
    Main --> BattMod
    Main --> HWHelpers
    Main --> UI

    %% Click Events
    click MCUBoot "https://github.com/protocentral/healthypi-move-fw/tree/main/app/sysbuild/mcuboot"
    click Zephyr "https://github.com/protocentral/healthypi-move-fw/blob/main/zephyr/module.yml"
    click Zephyr "https://github.com/protocentral/healthypi-move-fw/blob/main/west.yml"
    click Zephyr "https://github.com/protocentral/healthypi-move-fw/blob/main/CMakeLists.txt"
    click Zephyr "https://github.com/protocentral/healthypi-move-fw/tree/main/Kconfig"
    click BSP "https://github.com/protocentral/healthypi-move-fw/tree/main/boards/protocentral/healthypi_move"
    click S1 "https://github.com/protocentral/healthypi-move-fw/tree/main/drivers/sensor/max30001"
    click S2 "https://github.com/protocentral/healthypi-move-fw/tree/main/drivers/sensor/max30208"
    click S3 "https://github.com/protocentral/healthypi-move-fw/tree/main/drivers/sensor/max32664c"
    click S4 "https://github.com/protocentral/healthypi-move-fw/tree/main/drivers/sensor/bmi323hpi"
    click Display "https://github.com/protocentral/healthypi-move-fw/blob/main/drivers/display/display_sh8601.c"
    click InputDrv "https://github.com/protocentral/healthypi-move-fw/blob/main/drivers/input/input_chsc5816.c"
    click RTC "https://github.com/protocentral/healthypi-move-fw/blob/main/drivers/rtc/rtc_rv8263.c"
    click DataMod "https://github.com/protocentral/healthypi-move-fw/blob/main/app/src/data_module.c"
    click Algos "https://github.com/protocentral/healthypi-move-fw/blob/main/app/src/algos.c"
    click SMF_ECG_BIOZ "https://github.com/protocentral/healthypi-move-fw/blob/main/app/src/sm/smf_ecg_bioz.c"
    click SMF_PPG "https://github.com/protocentral/healthypi-move-fw/blob/main/app/src/sm/smf_ppg_finger.c"
    click SMF_DISPLAY "https://github.com/protocentral/healthypi-move-fw/blob/main/app/src/sm/smf_display.c"
    click FSMod "https://github.com/protocentral/healthypi-move-fw/blob/main/app/src/fs_module.c"
    click LogMod "https://github.com/protocentral/healthypi-move-fw/blob/main/app/src/log_module.c"
    click CmdMod "https://github.com/protocentral/healthypi-move-fw/blob/main/app/src/cmd_module.c"
    click HPI_SYS "https://github.com/protocentral/healthypi-move-fw/blob/main/app/src/hpi_sys_module.c"
    click HPI_USER "https://github.com/protocentral/healthypi-move-fw/blob/main/app/src/hpi_user_settings_api.c"
    click HPI_STORE "https://github.com/protocentral/healthypi-move-fw/blob/main/app/src/hpi_settings_store.c"
    click HPI_ZBUS "https://github.com/protocentral/healthypi-move-fw/blob/main/app/src/hpi_zbus_channels.c"
    click BLE "https://github.com/protocentral/healthypi-move-fw/blob/main/app/src/ble_module.c"
    click BattMod "https://github.com/protocentral/healthypi-move-fw/blob/main/app/src/battery_module.c"
    click HWHelpers "https://github.com/protocentral/healthypi-move-fw/blob/main/app/src/hw_helpers.c"
    click UI "https://github.com/protocentral/healthypi-move-fw/tree/main/app/src/ui"
    click Main "https://github.com/protocentral/healthypi-move-fw/blob/main/app/src/main.c"
    click Flash "https://github.com/protocentral/healthypi-move-fw/blob/main/app/qspi_w25.ini"

    %% Styles
    classDef boot fill:#cccccc,stroke:#333,stroke-width:1px;
    classDef os fill:#a0c4ff,stroke:#333,stroke-width:1px;
    classDef hal fill:#c8e6c9,stroke:#333,stroke-width:1px;
    classDef app fill:#ffe0b2,stroke:#333,stroke-width:1px;
    classDef ext fill:#fff9c4,stroke:#333,stroke-width:1px;
```
