add hal or app level clock configuration (#62)

* add hal or app level clock configuration

* fix control flow and typo

* use hal.init(), thanks kuon for the improvement
wch-ch32v003
Matt Knight 2 years ago committed by GitHub
parent e6d6ca7092
commit 6bc3fc094b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -176,6 +176,15 @@ export fn microzig_main() noreturn {
if (info.Fn.calling_convention == .Async)
@compileError("TODO: Embedded event loop not supported yet. Please try again later.");
// A hal can export a default init function that runs before main for
// procedures like clock configuration. The user may override and customize
// this functionality by providing their own init function.
// function.
if (@hasDecl(app, "init"))
app.init()
else if (@hasDecl(hal, "init"))
hal.init();
if (@typeInfo(return_type) == .ErrorUnion) {
main() catch |err| {
// TODO:

@ -160,10 +160,11 @@ pub fn addEmbeddedExecutable(
exe.addPackage(chip_pkg);
exe.addPackage(cpu_pkg);
if (options.hal_package_path) |hal_package_path|
exe.addPackage(.{
.name = "hal",
.source = hal_package_path,
.source = if (options.hal_package_path) |hal_package_path|
hal_package_path
else .{ .path = root_path ++ "core/empty.zig" },
.dependencies = &.{pkgs.microzig},
});

Loading…
Cancel
Save