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 dmclkOr install with a pre-configured setup for your board:
# Create a dependencies file (deps.dmd)
echo "dmclk@latest board/stm32f746g-disco.ini" > deps.dmd
# Install with configuration
dmf-get -d deps.dmd --config-dir ./configThe module includes ready-to-use configuration files for many popular STM32 boards and MCUs. See configs/README.md for the complete list.
- 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 |
The module includes ready-to-use configuration files for popular development boards and microcontrollers:
Development Boards:
- STM32F4DISCOVERY, STM32F429I-DISCOVERY
- NUCLEO-F401RE, NUCLEO-F411RE, NUCLEO-F446RE
- STM32F746G-DISCO, NUCLEO-F767ZI, STM32F769I-DISCOVERY
Microcontrollers:
- STM32F4 series: F401RE, F405RG, F407VG, F411RE, F429ZI, F439ZI, F446RE, F469NI
- STM32F7 series: F722RE, F746ZG, F767ZI, F769NI
For a complete list and usage instructions, see configs/README.md.
[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/
βββ configs/ # Pre-configured board and MCU configurations
β βββ board/ # Board-specific configurations
β βββ mcu/ # MCU-specific configurations
βββ 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