# nasrullo-m/rpio architecture

> Architecture diagram of the GitHub repository nasrullo-m/rpio, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-05). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/nasrullo-m/rpio
- Repository: https://github.com/nasrullo-m/rpio

## Overview

RPIO is a Raspberry Pi GPIO and DMA-PWM library. Applications use its Python API for pin setup, input/output, and callbacks; GPIO access is handled by a native extension, while the interrupt manager watches kernel GPIO interfaces and TCP sockets and dispatches callbacks. PWM has a Python convenience layer over native bindings and a C implementation; a Servo helper builds on that API. The README also advertises command-line tools. The graph reflects documented capabilities and shown calls; unsampled CLI and PWM internals limit evidence for their connections.

Main entry points: [`source/RPIO/__init__.py`](https://github.com/nasrullo-m/rpio/blob/master/source/RPIO/__init__.py) (RPIO API), [`source/RPIO/_RPIO.py`](https://github.com/nasrullo-m/rpio/blob/master/source/RPIO/_RPIO.py) (Interrupt manager), [`source/c_gpio/py_gpio.c`](https://github.com/nasrullo-m/rpio/blob/master/source/c_gpio/py_gpio.c) (GPIO extension), [`source/RPIO/PWM/__init__.py`](https://github.com/nasrullo-m/rpio/blob/master/source/RPIO/PWM/__init__.py) (PWM Python API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["Python API"]
  node_rpio_api["RPIO API<br/>[__init__.py]"]
  node_interrupt_manager["Interrupt manager<br/>[_RPIO.py]"]
end

subgraph group_gpio["GPIO runtime"]
  node_gpio_extension["GPIO extension<br/>[py_gpio.c]"]
  node_gpio_native["GPIO register access<br/>[c_gpio.c]"]
  node_board_detection["Board detection<br/>[cpuinfo.c]"]
end

subgraph group_pwm["PWM runtime"]
  node_pwm_api["PWM Python API<br/>[__init__.py]"]
  node_servo_helper["Servo helper<br/>[__init__.py]"]
  node_pwm_binding["PWM native binding<br/>[pwm_py.c]"]
  node_pwm_engine["DMA PWM engine<br/>[pwm.c]"]
  node_servod["Servo daemon<br/>[servod.c]"]
end

subgraph group_tools["Command-line tools"]
  node_rpio_cli["rpio command"]
  node_curses_cli["rpio-curses command"]
end

node_application(("Application"))
node_gpio_hardware(("Raspberry Pi GPIO"))
node_kernel_gpio["Kernel GPIO interfaces"]
node_tcp_clients(("TCP clients"))
node_pwm_hardware(("PWM hardware"))

node_application -->|"calls"| node_rpio_api
node_rpio_api -->|"delegates GPIO"| node_gpio_extension
node_gpio_extension -->|"calls"| node_gpio_native
node_gpio_native -->|"accesses registers"| node_gpio_hardware
node_gpio_extension -.->|"detects board"| node_board_detection
node_rpio_api -->|"delegates callbacks"| node_interrupt_manager
node_interrupt_manager -->|"monitors interfaces"| node_kernel_gpio
node_interrupt_manager -->|"accepts connections"| node_tcp_clients
node_application -->|"uses PWM"| node_pwm_api
node_pwm_api -->|"calls"| node_pwm_binding
node_servo_helper -->|"configures pulses"| node_pwm_api
node_pwm_binding -->|"calls"| node_pwm_engine
node_pwm_engine -.->|"drives PWM"| node_pwm_hardware
node_application -->|"runs"| node_rpio_cli
node_application -->|"runs"| node_curses_cli

click node_rpio_api "https://github.com/nasrullo-m/rpio/blob/master/source/RPIO/__init__.py"
click node_interrupt_manager "https://github.com/nasrullo-m/rpio/blob/master/source/RPIO/_RPIO.py"
click node_gpio_extension "https://github.com/nasrullo-m/rpio/blob/master/source/c_gpio/py_gpio.c"
click node_gpio_native "https://github.com/nasrullo-m/rpio/blob/master/source/c_gpio/c_gpio.c"
click node_board_detection "https://github.com/nasrullo-m/rpio/blob/master/source/c_gpio/cpuinfo.c"
click node_pwm_api "https://github.com/nasrullo-m/rpio/blob/master/source/RPIO/PWM/__init__.py"
click node_servo_helper "https://github.com/nasrullo-m/rpio/blob/master/source/RPIO/PWM/__init__.py"
click node_pwm_binding "https://github.com/nasrullo-m/rpio/blob/master/source/c_pwm/pwm_py.c"
click node_pwm_engine "https://github.com/nasrullo-m/rpio/blob/master/source/c_pwm/pwm.c"
click node_servod "https://github.com/nasrullo-m/rpio/blob/master/source/c_pwm/servod.c"
click node_rpio_cli "https://github.com/nasrullo-m/rpio/blob/master/source/scripts/rpio"
click node_curses_cli "https://github.com/nasrullo-m/rpio/blob/master/source/scripts/rpio-curses"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_rpio_api,node_interrupt_manager,node_tcp_clients toneBlue
class node_gpio_extension,node_gpio_native,node_board_detection toneAmber
class node_pwm_api,node_servo_helper,node_pwm_binding,node_pwm_engine,node_servod toneMint
class node_rpio_cli,node_curses_cli toneRose
class node_application,node_gpio_hardware,node_kernel_gpio,node_pwm_hardware toneIndigo
```

## Components

### Python API

- [RPIO API](https://github.com/nasrullo-m/rpio/blob/master/source/RPIO/__init__.py): `source/RPIO/__init__.py`
- [Interrupt manager](https://github.com/nasrullo-m/rpio/blob/master/source/RPIO/_RPIO.py): `source/RPIO/_RPIO.py`

### GPIO runtime

- [GPIO extension](https://github.com/nasrullo-m/rpio/blob/master/source/c_gpio/py_gpio.c): `source/c_gpio/py_gpio.c`
- [GPIO register access](https://github.com/nasrullo-m/rpio/blob/master/source/c_gpio/c_gpio.c): `source/c_gpio/c_gpio.c`
- [Board detection](https://github.com/nasrullo-m/rpio/blob/master/source/c_gpio/cpuinfo.c): `source/c_gpio/cpuinfo.c`

### PWM runtime

- [PWM Python API](https://github.com/nasrullo-m/rpio/blob/master/source/RPIO/PWM/__init__.py): `source/RPIO/PWM/__init__.py`
- [Servo helper](https://github.com/nasrullo-m/rpio/blob/master/source/RPIO/PWM/__init__.py): `source/RPIO/PWM/__init__.py`
- [PWM native binding](https://github.com/nasrullo-m/rpio/blob/master/source/c_pwm/pwm_py.c): `source/c_pwm/pwm_py.c`
- [DMA PWM engine](https://github.com/nasrullo-m/rpio/blob/master/source/c_pwm/pwm.c): `source/c_pwm/pwm.c`
- [Servo daemon](https://github.com/nasrullo-m/rpio/blob/master/source/c_pwm/servod.c): `source/c_pwm/servod.c`

### Command-line tools

- [rpio command](https://github.com/nasrullo-m/rpio/blob/master/source/scripts/rpio): `source/scripts/rpio`
- [rpio-curses command](https://github.com/nasrullo-m/rpio/blob/master/source/scripts/rpio-curses): `source/scripts/rpio-curses`

### Other components

- **Application**
- **Raspberry Pi GPIO**
- **Kernel GPIO interfaces**
- **TCP clients**
- **PWM hardware**

## Connections

- Application → RPIO API: calls (evidence: `README.rst`)
- RPIO API → GPIO extension: delegates GPIO (evidence: `source/RPIO/__init__.py`)
- GPIO extension → GPIO register access: calls (evidence: `source/c_gpio/py_gpio.c`)
- GPIO register access → Raspberry Pi GPIO: accesses registers (evidence: `source/c_gpio/c_gpio.c`)
- GPIO extension → Board detection: detects board
- RPIO API → Interrupt manager: delegates callbacks (evidence: `source/RPIO/__init__.py`)
- Interrupt manager → Kernel GPIO interfaces: monitors interfaces (evidence: `source/RPIO/_RPIO.py`)
- Interrupt manager → TCP clients: accepts connections (evidence: `source/RPIO/_RPIO.py`)
- Application → PWM Python API: uses PWM (evidence: `README.rst`)
- PWM Python API → PWM native binding: calls (evidence: `source/RPIO/PWM/__init__.py`)
- Servo helper → PWM Python API: configures pulses (evidence: `source/RPIO/PWM/__init__.py`)
- PWM native binding → DMA PWM engine: calls (evidence: `source/c_pwm/pwm_py.c`)
- DMA PWM engine → PWM hardware: drives PWM
- Application → rpio command: runs (evidence: `README.rst`)
- Application → rpio-curses command: runs (evidence: `README.rst`)
