# cn-vik/pwm-protocol-data-driven architecture

> Architecture diagram of the GitHub repository cn-vik/pwm-protocol-data-driven, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/cn-vik/pwm-protocol-data-driven
- Repository: https://github.com/cn-vik/pwm-protocol-data-driven

## Overview

This is an STM32F103 firmware example for a data-driven PWM protocol, with an RGB color-cycling loop as its visible application workflow. The main loop initializes GPIO, DMA, and TIM1, then selects RGB colors through the PWM protocol interface. Protocol internals and interrupt/DMA behavior were not excerpted, so those implementation relationships are left unverified rather than treated as confirmed calls.

Main entry points: [`project/stm32f103_LL_keil/Core/Src/main.c`](https://github.com/cn-vik/pwm-protocol-data-driven/blob/main/project/stm32f103_LL_keil/Core/Src/main.c) (Firmware loop), [`project/stm32f103_LL_keil/Core/Src/protocol_pwm.c`](https://github.com/cn-vik/pwm-protocol-data-driven/blob/main/project/stm32f103_LL_keil/Core/Src/protocol_pwm.c) (PWM encoding), [`project/stm32f103_LL_keil/Core/Src/protocol_pwm.h`](https://github.com/cn-vik/pwm-protocol-data-driven/blob/main/project/stm32f103_LL_keil/Core/Src/protocol_pwm.h) (PWM interface), [`project/stm32f103_LL_keil/Core/Src/dma.c`](https://github.com/cn-vik/pwm-protocol-data-driven/blob/main/project/stm32f103_LL_keil/Core/Src/dma.c) (DMA setup)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Application"]
  node_runtime["Firmware loop<br/>[main.c]"]
  node_common["Application definitions<br/>[main.h]"]
end

subgraph group_protocol["PWM Protocol"]
  node_pwm["PWM encoding<br/>[protocol_pwm.c]"]
  node_pwm_interface["PWM interface<br/>[protocol_pwm.h]"]
end

subgraph group_peripherals["MCU Peripherals"]
  node_gpio["GPIO setup<br/>[gpio.c]"]
  node_dma["DMA setup<br/>[dma.c]"]
  node_timer["TIM1 setup<br/>[tim.c]"]
end

node_rgb_led(("RGB LED"))

node_runtime -->|"uses definitions"| node_common
node_runtime -->|"initializes"| node_gpio
node_runtime -->|"initializes"| node_dma
node_runtime -->|"initializes"| node_timer
node_runtime -->|"calls color setter"| node_pwm_interface
node_pwm_interface -.->|"implemented by"| node_pwm
node_pwm -.->|"configures PWM"| node_timer
node_pwm -.->|"transfers data"| node_dma
node_pwm -.->|"drives colors"| node_rgb_led

click node_runtime "https://github.com/cn-vik/pwm-protocol-data-driven/blob/main/project/stm32f103_LL_keil/Core/Src/main.c"
click node_common "https://github.com/cn-vik/pwm-protocol-data-driven/blob/main/project/stm32f103_LL_keil/Core/Inc/main.h"
click node_pwm "https://github.com/cn-vik/pwm-protocol-data-driven/blob/main/project/stm32f103_LL_keil/Core/Src/protocol_pwm.c"
click node_pwm_interface "https://github.com/cn-vik/pwm-protocol-data-driven/blob/main/project/stm32f103_LL_keil/Core/Src/protocol_pwm.h"
click node_gpio "https://github.com/cn-vik/pwm-protocol-data-driven/blob/main/project/stm32f103_LL_keil/Core/Src/gpio.c"
click node_dma "https://github.com/cn-vik/pwm-protocol-data-driven/blob/main/project/stm32f103_LL_keil/Core/Src/dma.c"
click node_timer "https://github.com/cn-vik/pwm-protocol-data-driven/blob/main/project/stm32f103_LL_keil/Core/Src/tim.c"

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_runtime,node_common toneBlue
class node_pwm,node_pwm_interface toneAmber
class node_gpio,node_dma,node_timer toneMint
class node_rgb_led toneIndigo
```

## Components

### Application

- [Firmware loop](https://github.com/cn-vik/pwm-protocol-data-driven/blob/main/project/stm32f103_LL_keil/Core/Src/main.c): `project/stm32f103_LL_keil/Core/Src/main.c`
- [Application definitions](https://github.com/cn-vik/pwm-protocol-data-driven/blob/main/project/stm32f103_LL_keil/Core/Inc/main.h): `project/stm32f103_LL_keil/Core/Inc/main.h`

### PWM Protocol

- [PWM encoding](https://github.com/cn-vik/pwm-protocol-data-driven/blob/main/project/stm32f103_LL_keil/Core/Src/protocol_pwm.c): `project/stm32f103_LL_keil/Core/Src/protocol_pwm.c`
- [PWM interface](https://github.com/cn-vik/pwm-protocol-data-driven/blob/main/project/stm32f103_LL_keil/Core/Src/protocol_pwm.h): `project/stm32f103_LL_keil/Core/Src/protocol_pwm.h`

### MCU Peripherals

- [GPIO setup](https://github.com/cn-vik/pwm-protocol-data-driven/blob/main/project/stm32f103_LL_keil/Core/Src/gpio.c): `project/stm32f103_LL_keil/Core/Src/gpio.c`
- [DMA setup](https://github.com/cn-vik/pwm-protocol-data-driven/blob/main/project/stm32f103_LL_keil/Core/Src/dma.c): `project/stm32f103_LL_keil/Core/Src/dma.c`
- [TIM1 setup](https://github.com/cn-vik/pwm-protocol-data-driven/blob/main/project/stm32f103_LL_keil/Core/Src/tim.c): `project/stm32f103_LL_keil/Core/Src/tim.c`

### Other components

- **RGB LED**

## Connections

- Firmware loop → Application definitions: uses definitions (evidence: `project/stm32f103_LL_keil/Core/Src/main.c`)
- Firmware loop → GPIO setup: initializes (evidence: `project/stm32f103_LL_keil/Core/Src/main.c`)
- Firmware loop → DMA setup: initializes (evidence: `project/stm32f103_LL_keil/Core/Src/main.c`)
- Firmware loop → TIM1 setup: initializes (evidence: `project/stm32f103_LL_keil/Core/Src/main.c`)
- Firmware loop → PWM interface: calls color setter (evidence: `project/stm32f103_LL_keil/Core/Src/main.c`)
- PWM interface → PWM encoding: implemented by
- PWM encoding → TIM1 setup: configures PWM
- PWM encoding → DMA setup: transfers data
- PWM encoding → RGB LED: drives colors
