# stephenj4xx/stm32-morsesenderpart architecture

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

- Interactive diagram: https://gitdiagram.com/stephenj4xx/stm32-morsesenderpart
- Repository: https://github.com/stephenj4xx/stm32-morsesenderpart

## Overview

This STM32F407 firmware receives a complete message over UART, treats a period as the terminator, then encodes and transmits the message as timed Morse signaling on GPIO. The principal application logic is in Core/Src/main.c; peripheral initialization is split across the generated Core/Src modules. The README documents the workflow and hardware interfaces. Source excerpts do not show the full Morse lookup or GPIO timing routines, so those relationships are documented rather than independently verified in their implementations.

Main entry points: [`Core/Src/main.c`](https://github.com/stephenj4xx/stm32-morsesenderpart/blob/main/Core/Src/main.c) (Main controller), [`Core/Src/usart.c`](https://github.com/stephenj4xx/stm32-morsesenderpart/blob/main/Core/Src/usart.c) (USART2 interface), [`Core/Src/gpio.c`](https://github.com/stephenj4xx/stm32-morsesenderpart/blob/main/Core/Src/gpio.c) (GPIO signaling), [`Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal.h`](https://github.com/stephenj4xx/stm32-morsesenderpart/blob/main/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal.h) (STM32 HAL)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Application workflow"]
  node_controller["Main controller<br/>[main.c]"]
  node_capture["UART capture<br/>[main.c]"]
  node_buffer["Message buffer<br/>[main.c]"]
  node_terminator["End detection<br/>[main.c]"]
  node_morse["Morse encoding<br/>[main.c]"]
  node_timing["Signal timing<br/>[main.c]"]
end

subgraph group_periph["Peripheral interfaces"]
  node_uart["USART2 interface<br/>[usart.c]"]
  node_gpio["GPIO signaling<br/>[gpio.c]"]
end

subgraph group_platform["Hardware platform"]
  node_hal["STM32 HAL<br/>[stm32f4xx_hal.h]"]
  node_mcu["STM32F407<br/>[stm32f407xx.h]"]
end

node_pc(("PC terminal"))
node_adapter["USB-UART adapter"]
node_receiver["Morse receiver"]

node_pc -->|"sends text"| node_adapter
node_adapter -->|"serial input"| node_uart
node_controller -->|"initializes"| node_uart
node_uart -->|"receives bytes"| node_capture
node_capture -->|"stores bytes"| node_buffer
node_buffer -->|"checks period"| node_terminator
node_controller -->|"copies complete message"| node_buffer
node_controller -->|"calls encoder"| node_morse
node_morse -->|"forms timed symbols"| node_timing
node_timing -->|"drives signal"| node_gpio
node_controller -->|"initializes"| node_gpio
node_gpio -->|"transmits Morse"| node_receiver
node_hal -.->|"supports peripherals"| node_mcu

click node_controller "https://github.com/stephenj4xx/stm32-morsesenderpart/blob/main/Core/Src/main.c"
click node_capture "https://github.com/stephenj4xx/stm32-morsesenderpart/blob/main/Core/Src/main.c"
click node_buffer "https://github.com/stephenj4xx/stm32-morsesenderpart/blob/main/Core/Src/main.c"
click node_terminator "https://github.com/stephenj4xx/stm32-morsesenderpart/blob/main/Core/Src/main.c"
click node_morse "https://github.com/stephenj4xx/stm32-morsesenderpart/blob/main/Core/Src/main.c"
click node_timing "https://github.com/stephenj4xx/stm32-morsesenderpart/blob/main/Core/Src/main.c"
click node_uart "https://github.com/stephenj4xx/stm32-morsesenderpart/blob/main/Core/Src/usart.c"
click node_gpio "https://github.com/stephenj4xx/stm32-morsesenderpart/blob/main/Core/Src/gpio.c"
click node_hal "https://github.com/stephenj4xx/stm32-morsesenderpart/blob/main/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal.h"
click node_mcu "https://github.com/stephenj4xx/stm32-morsesenderpart/blob/main/Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f407xx.h"

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_controller,node_capture,node_buffer,node_terminator,node_morse,node_timing toneBlue
class node_uart,node_gpio toneAmber
class node_hal,node_mcu toneMint
class node_pc,node_adapter,node_receiver toneIndigo
```

## Components

### Application workflow

- [Main controller](https://github.com/stephenj4xx/stm32-morsesenderpart/blob/main/Core/Src/main.c): `Core/Src/main.c`
- [UART capture](https://github.com/stephenj4xx/stm32-morsesenderpart/blob/main/Core/Src/main.c): `Core/Src/main.c`
- [Message buffer](https://github.com/stephenj4xx/stm32-morsesenderpart/blob/main/Core/Src/main.c): `Core/Src/main.c`
- [End detection](https://github.com/stephenj4xx/stm32-morsesenderpart/blob/main/Core/Src/main.c): `Core/Src/main.c`
- [Morse encoding](https://github.com/stephenj4xx/stm32-morsesenderpart/blob/main/Core/Src/main.c): `Core/Src/main.c`
- [Signal timing](https://github.com/stephenj4xx/stm32-morsesenderpart/blob/main/Core/Src/main.c): `Core/Src/main.c`

### Peripheral interfaces

- [USART2 interface](https://github.com/stephenj4xx/stm32-morsesenderpart/blob/main/Core/Src/usart.c): `Core/Src/usart.c`
- [GPIO signaling](https://github.com/stephenj4xx/stm32-morsesenderpart/blob/main/Core/Src/gpio.c): `Core/Src/gpio.c`

### Hardware platform

- [STM32 HAL](https://github.com/stephenj4xx/stm32-morsesenderpart/blob/main/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal.h): `Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal.h`
- [STM32F407](https://github.com/stephenj4xx/stm32-morsesenderpart/blob/main/Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f407xx.h): `Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f407xx.h`

### Other components

- **PC terminal**
- **USB-UART adapter**
- **Morse receiver**

## Connections

- PC terminal → USB-UART adapter: sends text
- USB-UART adapter → USART2 interface: serial input
- Main controller → USART2 interface: initializes (evidence: `Core/Src/main.c`)
- USART2 interface → UART capture: receives bytes (evidence: `Core/Src/main.c`)
- UART capture → Message buffer: stores bytes (evidence: `Core/Src/main.c`)
- Message buffer → End detection: checks period (evidence: `Core/Src/main.c`)
- Main controller → Message buffer: copies complete message (evidence: `Core/Src/main.c`)
- Main controller → Morse encoding: calls encoder (evidence: `Core/Src/main.c`)
- Morse encoding → Signal timing: forms timed symbols (evidence: `Core/Src/main.c`)
- Signal timing → GPIO signaling: drives signal
- Main controller → GPIO signaling: initializes (evidence: `Core/Src/main.c`)
- GPIO signaling → Morse receiver: transmits Morse
- STM32 HAL → STM32F407: supports peripherals
