Skip to content

RecursiveError/ClockHelper-zig

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ClockHelper

ClockHelper is a utility to facilitate clock management on STM32 microcontrollers.

Note:

ClockHelper is in the early stages of development, configurations may be incorrect/incomplete. In case of errors, feel free to open an issue.

CLI tool

clock helper comes with a utility to transcribe configurations generated by CubeMX (.ioc files) into configurations for embedded Zig projects

to create an executable of this tool: zig build clock_helper --release=safe

usage: clock_helper -i <ioc file> -o <out file>

usage

To use it, it's very simple:

Choose a controller from the list:

const ClockHelper = @import("ClockHelper");

const STM32F103x = ClockHelper.@"STM32F103C(8-B)Tx";

Create a clock using the settings you want to use:

const config = STM32F103x.Config{};
const Clock = STM32F103x.ClockTree.init_comptime(config);

And that's it, ClockHelper will give you the clock value of each peripheral for this setting, and it will also warn you if a setting is invalid!

const std = @import("std");
const ClockHelper = @import("ClockHelper");

const STM32F103x = ClockHelper.@"STM32F103C(8-B)Tx";

const config = STM32F103x.Config{};
const Clock = STM32F103x.ClockTree.init_comptime(config);
const conf_text = ClockHelper.print_clock_configs(config);

pub fn main() !void {
    std.debug.print("Corrent Config:\n{s}\n", .{conf_text.*});

    std.debug.print(
        \\Corrent OutClocks:
        \\SysClock: {d}Mhz
        \\AHB Clock: {d}Mhz
        \\APB1 Clock: {d}Mhz
        \\APB2 Clock: {d}Mhz
        \\
    , .{
        (Clock.SysCLKOutput.get_comptime() / 1_000_000),
        (Clock.AHBOutput.get_comptime() / 1_000_000),
        (Clock.APB1Output.get_comptime() / 1_000_000),
        (Clock.APB2Output.get_comptime() / 1_000_000),
    });
}

About

ClockHelper is a utility to facilitate clock management on STM32 microcontrollers.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages