-
Notifications
You must be signed in to change notification settings - Fork 164
start basic h7 support #852
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
RecursiveError
wants to merge
3
commits into
ZigEmbeddedGroup:main
Choose a base branch
from
RecursiveError:h7_rcc
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| // This is an example RCC configuration for the STM32H723 | ||
| // Configurations and procedures may vary for other targets | ||
|
|
||
| const std = @import("std"); | ||
| const microzig = @import("microzig"); | ||
| const hal = microzig.hal; | ||
| const pins = hal.pins; | ||
| const rcc = hal.rcc; | ||
| const PWR = microzig.chip.peripherals.PWR; | ||
|
|
||
| //set Master Clock Output(MCO) pins | ||
| const global_pins = pins.GlobalConfiguration{ | ||
| .GPIOA = .{ | ||
| .PIN8 = .{ | ||
| .mode = .{ | ||
| .alternate_function = .{ | ||
| .afr = .AF0, | ||
| }, | ||
| }, | ||
| .name = "MCO1", | ||
| }, | ||
| }, | ||
| .GPIOC = .{ | ||
| .PIN9 = .{ | ||
| .mode = .{ | ||
| .alternate_function = .{ .afr = .AF0 }, | ||
| }, | ||
| .name = "MCO2", | ||
| }, | ||
| }, | ||
| }; | ||
|
|
||
| pub fn main() !void { | ||
|
|
||
| // set inital power state | ||
| PWR.CR3.modify(.{ | ||
| .LDOEN = 1, | ||
| .SDEN = 1, | ||
| }); | ||
|
|
||
| //configure cpu clock to 550 Mhz | ||
| _ = try rcc.apply(.{ | ||
| .HSE_VALUE = 25_000_000, | ||
| .PLLSource = .RCC_PLLSOURCE_HSE, | ||
| .DIVM1 = 5, | ||
| .DIVN1 = 110, | ||
| .DIVP1 = 1, | ||
| .DIVQ1 = 10, | ||
| .SYSCLKSource = .RCC_SYSCLKSOURCE_PLLCLK, | ||
| .RCC_MCO1Source = .RCC_MCO1SOURCE_PLL1QCLK, | ||
| .RCC_MCO2Source = .RCC_MCO2SOURCE_LSICLK, | ||
| .RCC_MCODiv2 = .RCC_MCODIV_10, | ||
| .RCC_MCODiv1 = .RCC_MCODIV_10, | ||
| .D2PPRE2 = .RCC_APB2_DIV2, | ||
| .D2PPRE1 = .RCC_APB1_DIV2, | ||
| .D3PPRE = .RCC_APB4_DIV2, | ||
| .D1PPRE = .RCC_APB3_DIV2, | ||
| .HPRE = .RCC_HCLK_DIV2, | ||
| .flags = .{ | ||
| .MCO1Config = true, | ||
| .MCO2Config = true, | ||
| .HSEOscillator = true, | ||
| }, | ||
| }); | ||
|
|
||
| //apply pins config | ||
| _ = global_pins.apply(); | ||
|
|
||
| while (true) {} | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| const std = @import("std"); | ||
| const microzig = @import("microzig"); | ||
|
|
||
| pub const systick_timer = @import("./common/systick_timer.zig"); | ||
| pub const systick = @import("./common/systick.zig"); | ||
| pub const gpio = @import("./common/gpio_v2.zig"); | ||
| pub const pins = @import("./common/pins_v2.zig"); | ||
| pub const rcc = @import("./STM32H723/rcc.zig"); | ||
|
|
||
| pub fn get_sys_clk() u32 { | ||
| return @intFromFloat(rcc.current_clocks.SysCLKOutput); | ||
| } | ||
|
|
||
| pub fn get_systick_clk() u32 { | ||
| return @intFromFloat(rcc.current_clocks.CortexSysOutput); | ||
| } | ||
|
|
||
| pub var Reset_Reason: rcc.ResetReason = .unknown; | ||
| pub fn init() void { | ||
| const reset = rcc.get_reset_reason(); | ||
| Reset_Reason = reset; | ||
|
|
||
| // force default configuration; required for clock configuration | ||
| // Power control (PWR) 6.4.1 System supply startup - page: 238 RM0468 Rev 3 | ||
| if (reset == .power_on) { | ||
| microzig.chip.peripherals.PWR.CR3.raw = 0x0000_0046; | ||
| } | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion: Rename
Reset_ReasontoResetReason, it should be more in line with our style guidelines. This automation is not perfect so take it with a grain of salt.