Skip to content

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

License

Notifications You must be signed in to change notification settings

RecursiveError/ClockHelper-zig

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ClockHelper

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

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