# smotlaq/lora architecture

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

- Interactive diagram: https://gitdiagram.com/smotlaq/lora
- Repository: https://github.com/smotlaq/lora

## Overview

This repository is an STM32 firmware example and reusable C driver for an SX1278-based LoRa module. The firmware configures the MCU and radio, starts continuous reception, then repeatedly transmits and receives packets. The driver also exposes radio configuration, power control, sleep/mode access and RSSI estimation. The excerpts show the application entry points and portions of the register/SPI implementation; additional capabilities and their public workflow are documented in the README, but unsampled implementation details are not inferred.

Main entry points: [`Src/main.c`](https://github.com/smotlaq/lora/blob/master/Src/main.c) (Application Loop), [`LoRa/LoRa.c`](https://github.com/smotlaq/lora/blob/master/LoRa/LoRa.c) (Register Access), [`Inc/main.h`](https://github.com/smotlaq/lora/blob/master/Inc/main.h) (Board Pins), [`Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal.c`](https://github.com/smotlaq/lora/blob/master/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal.c) (HAL Initialization)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_firmware["STM32 Firmware"]
  node_main["Application Loop<br/>[main.c]"]
  node_board["Board Pins<br/>[main.h]"]
end

subgraph group_radio["LoRa Radio Driver"]
  node_radio_config["Radio Settings<br/>[LoRa.c]"]
  node_radio_init["Radio Initialization<br/>[LoRa.c]"]
  node_register_io["Register Access<br/>[LoRa.c]"]
  node_modem_config["Modem Configuration<br/>[LoRa.c]"]
  node_transmit["Packet Transmit<br/>[LoRa.c]"]
  node_receive_mode["Continuous Receive<br/>[LoRa.c]"]
  node_receive["Packet Receive<br/>[LoRa.c]"]
  node_radio_metrics["RSSI Estimate<br/>[LoRa.c]"]
  node_power_features["Power Controls<br/>[LoRa.c]"]
end

subgraph group_hal["Hardware Abstraction"]
  node_hal_init["HAL Initialization<br/>[stm32f4xx_hal.c]"]
  node_hal_spi["SPI Peripheral"]
  node_hal_gpio["GPIO Peripheral"]
end

node_user(("Firmware User"))
node_sx1278{{"SX1278 Module"}}

node_user -->|"runs firmware"| node_main
node_main -->|"initializes HAL"| node_hal_init
node_main -->|"uses pin definitions"| node_board
node_main -->|"sets parameters"| node_radio_config
node_main -->|"initializes radio"| node_radio_init
node_radio_init -.->|"configures registers"| node_register_io
node_radio_config -.->|"applies settings"| node_modem_config
node_main -->|"starts receiving"| node_receive_mode
node_main -->|"sends packets"| node_transmit
node_main -->|"reads packets"| node_receive
node_main -.->|"queries signal"| node_radio_metrics
node_main -.->|"selects power modes"| node_power_features
node_register_io -->|"transfers registers"| node_hal_spi
node_register_io -->|"controls chip select"| node_hal_gpio
node_register_io -->|"accesses registers"| node_sx1278
node_transmit -->|"transmits packets"| node_sx1278
node_receive -->|"reads packet data"| node_sx1278
node_radio_metrics -->|"reads signal level"| node_sx1278

click node_main "https://github.com/smotlaq/lora/blob/master/Src/main.c"
click node_board "https://github.com/smotlaq/lora/blob/master/Inc/main.h"
click node_radio_config "https://github.com/smotlaq/lora/blob/master/LoRa/LoRa.c"
click node_radio_init "https://github.com/smotlaq/lora/blob/master/LoRa/LoRa.c"
click node_register_io "https://github.com/smotlaq/lora/blob/master/LoRa/LoRa.c"
click node_modem_config "https://github.com/smotlaq/lora/blob/master/LoRa/LoRa.c"
click node_transmit "https://github.com/smotlaq/lora/blob/master/LoRa/LoRa.c"
click node_receive_mode "https://github.com/smotlaq/lora/blob/master/LoRa/LoRa.c"
click node_receive "https://github.com/smotlaq/lora/blob/master/LoRa/LoRa.c"
click node_radio_metrics "https://github.com/smotlaq/lora/blob/master/LoRa/LoRa.c"
click node_power_features "https://github.com/smotlaq/lora/blob/master/LoRa/LoRa.c"
click node_hal_init "https://github.com/smotlaq/lora/blob/master/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal.c"
click node_hal_spi "https://github.com/smotlaq/lora/blob/master/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_spi.c"
click node_hal_gpio "https://github.com/smotlaq/lora/blob/master/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_gpio.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_main,node_board,node_user toneBlue
class node_radio_config,node_radio_init,node_register_io,node_modem_config,node_transmit,node_receive_mode,node_receive,node_radio_metrics,node_power_features toneAmber
class node_hal_init,node_hal_spi,node_hal_gpio toneMint
class node_sx1278 toneIndigo
```

## Components

### STM32 Firmware

- [Application Loop](https://github.com/smotlaq/lora/blob/master/Src/main.c): `Src/main.c`
- [Board Pins](https://github.com/smotlaq/lora/blob/master/Inc/main.h): `Inc/main.h`

### LoRa Radio Driver

- [Radio Settings](https://github.com/smotlaq/lora/blob/master/LoRa/LoRa.c): `LoRa/LoRa.c`
- [Radio Initialization](https://github.com/smotlaq/lora/blob/master/LoRa/LoRa.c): `LoRa/LoRa.c`
- [Register Access](https://github.com/smotlaq/lora/blob/master/LoRa/LoRa.c): `LoRa/LoRa.c`
- [Modem Configuration](https://github.com/smotlaq/lora/blob/master/LoRa/LoRa.c): `LoRa/LoRa.c`
- [Packet Transmit](https://github.com/smotlaq/lora/blob/master/LoRa/LoRa.c): `LoRa/LoRa.c`
- [Continuous Receive](https://github.com/smotlaq/lora/blob/master/LoRa/LoRa.c): `LoRa/LoRa.c`
- [Packet Receive](https://github.com/smotlaq/lora/blob/master/LoRa/LoRa.c): `LoRa/LoRa.c`
- [RSSI Estimate](https://github.com/smotlaq/lora/blob/master/LoRa/LoRa.c): `LoRa/LoRa.c`
- [Power Controls](https://github.com/smotlaq/lora/blob/master/LoRa/LoRa.c): `LoRa/LoRa.c`

### Hardware Abstraction

- [HAL Initialization](https://github.com/smotlaq/lora/blob/master/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal.c): `Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal.c`
- [SPI Peripheral](https://github.com/smotlaq/lora/blob/master/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_spi.c): `Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_spi.c`
- [GPIO Peripheral](https://github.com/smotlaq/lora/blob/master/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_gpio.c): `Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_gpio.c`

### Other components

- **Firmware User**
- **SX1278 Module**

## Connections

- Firmware User → Application Loop: runs firmware (evidence: `README.md`)
- Application Loop → HAL Initialization: initializes HAL (evidence: `Src/main.c`)
- Application Loop → Board Pins: uses pin definitions (evidence: `Src/main.c`)
- Application Loop → Radio Settings: sets parameters (evidence: `README.md`)
- Application Loop → Radio Initialization: initializes radio (evidence: `Src/main.c`)
- Radio Initialization → Register Access: configures registers (evidence: `LoRa/LoRa.c`)
- Radio Settings → Modem Configuration: applies settings (evidence: `LoRa/LoRa.c`)
- Application Loop → Continuous Receive: starts receiving (evidence: `Src/main.c`)
- Application Loop → Packet Transmit: sends packets (evidence: `Src/main.c`)
- Application Loop → Packet Receive: reads packets (evidence: `README.md`)
- Application Loop → RSSI Estimate: queries signal
- Application Loop → Power Controls: selects power modes
- Register Access → SPI Peripheral: transfers registers (evidence: `LoRa/LoRa.c`)
- Register Access → GPIO Peripheral: controls chip select (evidence: `LoRa/LoRa.c`)
- Register Access → SX1278 Module: accesses registers (evidence: `README.md`)
- Packet Transmit → SX1278 Module: transmits packets (evidence: `README.md`)
- Packet Receive → SX1278 Module: reads packet data (evidence: `README.md`)
- RSSI Estimate → SX1278 Module: reads signal level (evidence: `README.md`)
