# andrea-cpu96/bare-metal-code architecture

> Architecture diagram of the GitHub repository andrea-cpu96/bare-metal-code, 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/andrea-cpu96/bare-metal-code
- Repository: https://github.com/andrea-cpu96/bare-metal-code

## Overview

This repository is a collection of independent STM32 firmware examples, not one integrated application. Its principal workflows are separate: sensor sampling, serial-to-ESP AT-command bridging, button debouncing, serial-command car control, and blocking UART echo. The excerpts show the main-loop calls for these examples; several implementations are unsampled, so their internal links are omitted rather than inferred.

Main entry points: [`ESP01/Src/main.c`](https://github.com/andrea-cpu96/bare-metal-code/blob/main/ESP01/Src/main.c) (AT command bridge), [`Remote_Controlled_Car/ESP01_WebCarController/Src/main.c`](https://github.com/andrea-cpu96/bare-metal-code/blob/main/Remote_Controlled_Car/ESP01_WebCarController/Src/main.c) (Command and motor control), [`uartInterface/Src/main.c`](https://github.com/andrea-cpu96/bare-metal-code/blob/main/uartInterface/Src/main.c) (UART echo loop), [`AM2302-DHT22/Src/main.c`](https://github.com/andrea-cpu96/bare-metal-code/blob/main/AM2302-DHT22/Src/main.c) (Sample loop)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_sensor["Sensor example"]
  node_sensor_main["Sample loop<br/>[main.c]"]
  node_sensor_reader["AM2302 reader<br/>[am2302.c]"]
  node_sensor_time["Timekeeping<br/>[systemfunctions.c]"]
  node_sensor_config["System setup<br/>[projectconf.c]"]
end

subgraph group_bridge["ESP serial bridge"]
  node_bridge_main["AT command bridge<br/>[main.c]"]
  node_bridge_uart["UART driver<br/>[uart.c]"]
  node_bridge_config["System setup<br/>[projectconf.c]"]
end

subgraph group_button["Button example"]
  node_button_main["Debounce state machine<br/>[main.c]"]
  node_button_ports["GPIO access<br/>[ports.c]"]
  node_button_time["Timekeeping<br/>[systemfunctions.c]"]
  node_button_config["System setup<br/>[projectconf.c]"]
end

subgraph group_car["Web car controller"]
  node_car_main["Command and motor control<br/>[main.c]"]
  node_car_uart["UART driver<br/>[uart.c]"]
  node_car_config["System setup<br/>[projectconf.c]"]
end

subgraph group_uart["UART example"]
  node_uart_main["UART echo loop<br/>[main.c]"]
  node_uart_driver["UART driver<br/>[uart.c]"]
  node_uart_config["System setup<br/>[projectconf.c]"]
end

node_dht22{{"DHT22 sensor"}}
node_serial_user(("Serial terminal"))
node_esp_module{{"ESP-01 module"}}
node_button_hardware{{"Button and LED"}}
node_car_controller(("Web car controller"))
node_motor_gpio{{"Motor GPIO"}}
node_uart_user(("Serial terminal"))

node_sensor_main -->|"initializes"| node_sensor_config
node_sensor_main -->|"checks interval"| node_sensor_time
node_sensor_main -->|"reads sensor"| node_sensor_reader
node_sensor_reader -.->|"reads data"| node_dht22
node_bridge_main -->|"initializes"| node_bridge_config
node_bridge_main -->|"configures UART"| node_bridge_uart
node_serial_user -.->|"enters commands"| node_bridge_main
node_bridge_main -->|"forwards commands"| node_esp_module
node_esp_module -->|"returns response"| node_bridge_main
node_bridge_main -->|"displays response"| node_serial_user
node_button_main -->|"initializes"| node_button_config
node_button_main -->|"checks and toggles"| node_button_ports
node_button_main -->|"checks debounce"| node_button_time
node_button_ports -.->|"accesses GPIO"| node_button_hardware
node_car_main -->|"initializes"| node_car_config
node_car_main -->|"configures UART"| node_car_uart
node_car_controller -.->|"sends commands"| node_car_main
node_car_main -->|"sets motor outputs"| node_motor_gpio
node_uart_main -->|"initializes system"| node_uart_config
node_uart_main -->|"uses UART"| node_uart_driver
node_uart_user -.->|"sends input"| node_uart_main
node_uart_main -->|"echoes input"| node_uart_user

click node_sensor_main "https://github.com/andrea-cpu96/bare-metal-code/blob/main/AM2302-DHT22/Src/main.c"
click node_sensor_reader "https://github.com/andrea-cpu96/bare-metal-code/blob/main/AM2302-DHT22/Src/am2302.c"
click node_sensor_time "https://github.com/andrea-cpu96/bare-metal-code/blob/main/AM2302-DHT22/Src/systemfunctions.c"
click node_sensor_config "https://github.com/andrea-cpu96/bare-metal-code/blob/main/AM2302-DHT22/Src/projectconf.c"
click node_bridge_main "https://github.com/andrea-cpu96/bare-metal-code/blob/main/ESP01/Src/main.c"
click node_bridge_uart "https://github.com/andrea-cpu96/bare-metal-code/blob/main/ESP01/Src/uart.c"
click node_bridge_config "https://github.com/andrea-cpu96/bare-metal-code/blob/main/ESP01/Src/projectconf.c"
click node_button_main "https://github.com/andrea-cpu96/bare-metal-code/blob/main/Ex_NonBlockingButton/Src/main.c"
click node_button_ports "https://github.com/andrea-cpu96/bare-metal-code/blob/main/Ex_NonBlockingButton/Src/ports.c"
click node_button_time "https://github.com/andrea-cpu96/bare-metal-code/blob/main/Ex_NonBlockingButton/Src/systemfunctions.c"
click node_button_config "https://github.com/andrea-cpu96/bare-metal-code/blob/main/Ex_NonBlockingButton/Src/projectconf.c"
click node_car_main "https://github.com/andrea-cpu96/bare-metal-code/blob/main/Remote_Controlled_Car/ESP01_WebCarController/Src/main.c"
click node_car_uart "https://github.com/andrea-cpu96/bare-metal-code/blob/main/Remote_Controlled_Car/ESP01_WebCarController/Src/uart.c"
click node_car_config "https://github.com/andrea-cpu96/bare-metal-code/blob/main/Remote_Controlled_Car/ESP01_WebCarController/Src/projectconf.c"
click node_uart_main "https://github.com/andrea-cpu96/bare-metal-code/blob/main/uartInterface/Src/main.c"
click node_uart_driver "https://github.com/andrea-cpu96/bare-metal-code/blob/main/uartInterface/Src/uart.c"
click node_uart_config "https://github.com/andrea-cpu96/bare-metal-code/blob/main/uartInterface/Src/projectconf.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_sensor_main,node_sensor_reader,node_sensor_time,node_sensor_config toneBlue
class node_bridge_main,node_bridge_uart,node_bridge_config toneAmber
class node_button_main,node_button_ports,node_button_time,node_button_config toneMint
class node_car_main,node_car_uart,node_car_config toneRose
class node_uart_main,node_uart_driver,node_uart_config,node_dht22,node_serial_user,node_esp_module,node_button_hardware,node_car_controller,node_motor_gpio,node_uart_user toneIndigo
```

## Components

### Sensor example

- [Sample loop](https://github.com/andrea-cpu96/bare-metal-code/blob/main/AM2302-DHT22/Src/main.c): `AM2302-DHT22/Src/main.c`
- [AM2302 reader](https://github.com/andrea-cpu96/bare-metal-code/blob/main/AM2302-DHT22/Src/am2302.c): `AM2302-DHT22/Src/am2302.c`
- [Timekeeping](https://github.com/andrea-cpu96/bare-metal-code/blob/main/AM2302-DHT22/Src/systemfunctions.c): `AM2302-DHT22/Src/systemfunctions.c`
- [System setup](https://github.com/andrea-cpu96/bare-metal-code/blob/main/AM2302-DHT22/Src/projectconf.c): `AM2302-DHT22/Src/projectconf.c`

### ESP serial bridge

- [AT command bridge](https://github.com/andrea-cpu96/bare-metal-code/blob/main/ESP01/Src/main.c): `ESP01/Src/main.c`
- [UART driver](https://github.com/andrea-cpu96/bare-metal-code/blob/main/ESP01/Src/uart.c): `ESP01/Src/uart.c`
- [System setup](https://github.com/andrea-cpu96/bare-metal-code/blob/main/ESP01/Src/projectconf.c): `ESP01/Src/projectconf.c`

### Button example

- [Debounce state machine](https://github.com/andrea-cpu96/bare-metal-code/blob/main/Ex_NonBlockingButton/Src/main.c): `Ex_NonBlockingButton/Src/main.c`
- [GPIO access](https://github.com/andrea-cpu96/bare-metal-code/blob/main/Ex_NonBlockingButton/Src/ports.c): `Ex_NonBlockingButton/Src/ports.c`
- [Timekeeping](https://github.com/andrea-cpu96/bare-metal-code/blob/main/Ex_NonBlockingButton/Src/systemfunctions.c): `Ex_NonBlockingButton/Src/systemfunctions.c`
- [System setup](https://github.com/andrea-cpu96/bare-metal-code/blob/main/Ex_NonBlockingButton/Src/projectconf.c): `Ex_NonBlockingButton/Src/projectconf.c`

### Web car controller

- [Command and motor control](https://github.com/andrea-cpu96/bare-metal-code/blob/main/Remote_Controlled_Car/ESP01_WebCarController/Src/main.c): `Remote_Controlled_Car/ESP01_WebCarController/Src/main.c`
- [UART driver](https://github.com/andrea-cpu96/bare-metal-code/blob/main/Remote_Controlled_Car/ESP01_WebCarController/Src/uart.c): `Remote_Controlled_Car/ESP01_WebCarController/Src/uart.c`
- [System setup](https://github.com/andrea-cpu96/bare-metal-code/blob/main/Remote_Controlled_Car/ESP01_WebCarController/Src/projectconf.c): `Remote_Controlled_Car/ESP01_WebCarController/Src/projectconf.c`

### UART example

- [UART echo loop](https://github.com/andrea-cpu96/bare-metal-code/blob/main/uartInterface/Src/main.c): `uartInterface/Src/main.c`
- [UART driver](https://github.com/andrea-cpu96/bare-metal-code/blob/main/uartInterface/Src/uart.c): `uartInterface/Src/uart.c`
- [System setup](https://github.com/andrea-cpu96/bare-metal-code/blob/main/uartInterface/Src/projectconf.c): `uartInterface/Src/projectconf.c`

### Other components

- **DHT22 sensor**
- **Serial terminal**
- **ESP-01 module**
- **Button and LED**
- **Web car controller**
- **Motor GPIO**
- **Serial terminal**

## Connections

- Sample loop → System setup: initializes (evidence: `AM2302-DHT22/Src/main.c`)
- Sample loop → Timekeeping: checks interval (evidence: `AM2302-DHT22/Src/main.c`)
- Sample loop → AM2302 reader: reads sensor (evidence: `AM2302-DHT22/Src/main.c`)
- AM2302 reader → DHT22 sensor: reads data
- AT command bridge → System setup: initializes (evidence: `ESP01/Src/main.c`)
- AT command bridge → UART driver: configures UART (evidence: `ESP01/Src/main.c`)
- Serial terminal → AT command bridge: enters commands
- AT command bridge → ESP-01 module: forwards commands (evidence: `ESP01/Src/main.c`)
- ESP-01 module → AT command bridge: returns response (evidence: `ESP01/Src/main.c`)
- AT command bridge → Serial terminal: displays response (evidence: `ESP01/Src/main.c`)
- Debounce state machine → System setup: initializes (evidence: `Ex_NonBlockingButton/Src/main.c`)
- Debounce state machine → GPIO access: checks and toggles (evidence: `Ex_NonBlockingButton/Src/main.c`)
- Debounce state machine → Timekeeping: checks debounce (evidence: `Ex_NonBlockingButton/Src/main.c`)
- GPIO access → Button and LED: accesses GPIO
- Command and motor control → System setup: initializes (evidence: `Remote_Controlled_Car/ESP01_WebCarController/Src/main.c`)
- Command and motor control → UART driver: configures UART (evidence: `Remote_Controlled_Car/ESP01_WebCarController/Src/main.c`)
- Web car controller → Command and motor control: sends commands
- Command and motor control → Motor GPIO: sets motor outputs (evidence: `Remote_Controlled_Car/ESP01_WebCarController/Src/main.c`)
- UART echo loop → System setup: initializes system (evidence: `uartInterface/Src/main.c`)
- UART echo loop → UART driver: uses UART (evidence: `uartInterface/Src/main.c`)
- Serial terminal → UART echo loop: sends input
- UART echo loop → Serial terminal: echoes input (evidence: `uartInterface/Src/main.c`)
