This document describes the reorganized firmware directory structure for improved maintainability and code organization.
Main source code directory, organized by functional subsystems:
-
drivers/- Hardware abstraction layer (HAL) driversuart.c- UART communication driverfdcan.c- FDCAN (CAN FD) communication driver
-
protocols/- Communication protocol implementationscan_simple.c- Simple CAN protocol for valve control
-
valve/- Valve control subsystemvalve_haptic.c- Haptic feedback controlvalve_physics.c- Physics simulation and modelingvalve_presets.c- Preset managementvalve_nvm.c- Non-volatile memory operationsvalve_filters.c- Signal filtering
-
network/- Network services and protocolsnet_init.c- Network initialization (formerly app_ethernet.c)stream_server.c- TCP streaming server (formerly ethernet_stream.c)http_server.c- HTTP infrastructure (split from ethernet_http.c)rest_api.c- REST API handlers (split from ethernet_http.c)ping.c- ICMP ping functionality
-
app/- Application-level interfacescli.c- Command-line interfaceperfmon.c- Performance monitoring
External libraries and vendor code:
lwip/- Lightweight TCP/IP stack (lwIP 2.2.1)stm32cube/- STMicroelectronics STM32Cube HAL and BSP
Header files, mirroring the src/ structure for clean includes.
Port-specific implementations (lwIP ports for STM32).
Linker scripts for different memory configurations.
MCU startup code and vector tables.
- Makefile: Configured for ARM GCC toolchain with MISRA-C compliance
- C_SOURCES: Updated to include all new subdirectory paths
- C_INCLUDES: Updated to include all new header paths
- Memory Usage: ~142KB FLASH (identical to pre-reorganization)
- Functional Separation: Code organized by purpose rather than mixing concerns
- Clear Naming: Explicit file names (e.g.,
rest_api.cvsethernet_http.c) - Third-Party Isolation: Vendor code separated from custom implementations
- Scalability: Easy to add new drivers, protocols, or features in appropriate directories
- Maintainability: Engineers can quickly locate relevant code by function