A DMOD (Dynamic Modular System) module for configuring and managing system clocks on embedded microcontrollers.
- Multiple Clock Sources: Internal RC oscillator, external crystal/oscillator, and hibernation clocks
- Dynamic Configuration: Runtime clock frequency adjustment
- Hardware Abstraction: Platform-independent API with hardware-specific implementations
- DMDRVI Integration: Full DMOD driver interface implementation
- STM32 Support: STM32F4 and STM32F7 families currently supported
- Extensible: Easy to add support for additional microcontroller families
Using dmf-get from the DMOD release package:
dmf-get install dmclk- Create a configuration file (
config.ini):
[dmclk]
source=external
target_frequency=84000000
tolerance=1000
oscillator_frequency=8000000- Use in your code:
#include "dmclk.h"
#include "dmdrvi.h"
#include "dmini.h"
// Load configuration and create device
dmini_context_t config = dmini_load("config.ini");
dmdrvi_dev_num_t dev_num = {0};
dmdrvi_context_t clk_ctx = dmclk_dmdrvi_create(config, &dev_num);
// Open and use the clock device
void* handle = dmclk_dmdrvi_open(clk_ctx, DMDRVI_O_RDONLY);
// Get current frequency
dmclk_frequency_t freq;
dmclk_dmdrvi_ioctl(clk_ctx, handle, dmclk_ioctl_cmd_get_frequency, &freq);
// Cleanup
dmclk_dmdrvi_close(clk_ctx, handle);
dmclk_dmdrvi_free(clk_ctx);
dmini_free(config);- CMake 3.18 or higher
- ARM GCC toolchain (for embedded targets)
- DMOD framework (automatically fetched)
# Configure for STM32F4
cmake -DDMCLK_MCU_SERIES=stm32f4 -B build
# Configure for STM32F7
cmake -DDMCLK_MCU_SERIES=stm32f7 -B build
# Build
cmake --build buildComprehensive documentation is available in the docs/ directory:
- dmclk.md - Module overview and architecture
- api-reference.md - Complete API documentation
- configuration.md - Configuration guide with examples
- port-implementation.md - Guide for adding hardware support
View documentation using dmf-man:
dmf-man dmclk # Main documentation
dmf-man dmclk api # API reference
dmf-man dmclk config # Configuration guide
dmf-man dmclk port # Port implementation guide| Platform | Status | Notes |
|---|---|---|
| STM32F4 | ✅ Supported | Full PLL configuration |
| STM32F7 | ✅ Supported | Full PLL configuration |
| Other STM32 | 🔧 In Progress | Easy to add using STM32 common code |
| Other MCUs | 📋 Planned | Contributions welcome |
[dmclk]
source=internal
target_frequency=16000000
tolerance=160000[dmclk]
source=external
target_frequency=84000000
tolerance=1000
oscillator_frequency=8000000[dmclk]
source=external
target_frequency=168000000
tolerance=1000
oscillator_frequency=8000000dmclk/
├── docs/ # Documentation (markdown format)
├── examples/ # Example configurations
├── include/ # Public headers
│ ├── dmclk.h # Main API
│ ├── dmclk_port.h # Port layer API
│ └── port/ # Port-specific headers
├── src/
│ ├── dmclk.c # Core implementation
│ └── port/ # Hardware-specific implementations
│ ├── stm32_common/ # Common STM32 code
│ ├── stm32f4/ # STM32F4 port
│ └── stm32f7/ # STM32F7 port
├── CMakeLists.txt # Build configuration
└── manifest.dmm # DMOD manifest
See Port Implementation Guide for detailed instructions on adding support for new microcontrollers.
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch
- Make your changes
- Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.
- Patryk Kubiak - Initial work
- DMOD - Dynamic Modular System framework
- DMINI - INI configuration parser for DMOD
- DMDRVI - DMOD Driver Interface
For issues, questions, or contributions:
- Open an issue on GitHub
- Check the documentation in
docs/ - Use
dmf-man dmclkfor command-line help