Skip to content

Commit

Permalink
EXTI fields renamed to reflect Registers' names (Issue #2)
Browse files Browse the repository at this point in the history
  • Loading branch information
lucas-yotsui committed Aug 12, 2024
1 parent c32cdf9 commit 9411775
Showing 1 changed file with 18 additions and 30 deletions.
48 changes: 18 additions & 30 deletions hal/stmicro/stm32f411cc/interrupts.zig
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ pub inline fn register_interrupt_handler(comptime callback: anytype, source: Int
}

const EXTI = packed struct {
const IMR = packed struct(u32) {
IMR: packed struct(u32) {
line_0: bool,
line_1: bool,
line_2: bool,
Expand All @@ -176,9 +176,8 @@ const EXTI = packed struct {
line_21: bool,
line_22: bool,
_reserved2: u9,
};

const EMR = packed struct(u32) {
},
EMR: packed struct(u32) {
line_0: bool,
line_1: bool,
line_2: bool,
Expand All @@ -202,9 +201,8 @@ const EXTI = packed struct {
line_21: bool,
line_22: bool,
_reserved2: u9,
};

const RTSR = packed struct(u32) {
},
RTSR: packed struct(u32) {
line_0: bool,
line_1: bool,
line_2: bool,
Expand All @@ -228,9 +226,8 @@ const EXTI = packed struct {
line_21: bool,
line_22: bool,
_reserved2: u9,
};

const FTSR = packed struct(u32) {
},
FTSR: packed struct(u32) {
line_0: bool,
line_1: bool,
line_2: bool,
Expand All @@ -254,9 +251,8 @@ const EXTI = packed struct {
line_21: bool,
line_22: bool,
_reserved2: u9,
};

const SWIER = packed struct(u32) {
},
SWIER: packed struct(u32) {
line_0: bool,
line_1: bool,
line_2: bool,
Expand All @@ -280,9 +276,8 @@ const EXTI = packed struct {
line_21: bool,
line_22: bool,
_reserved2: u9,
};

const PR = packed struct(u32) {
},
PR: packed struct(u32) {
line_0: bool,
line_1: bool,
line_2: bool,
Expand All @@ -306,27 +301,20 @@ const EXTI = packed struct {
line_21: bool,
line_22: bool,
_reserved2: u9,
};

imr: IMR,
emr: EMR,
rtsr: RTSR,
ftsr: FTSR,
swier: SWIER,
pr: PR,
},
};

pub const exti: *volatile EXTI = @ptrFromInt(0x40013C00);

test "field_offsets" {
const expect = @import("std").testing.expect;

try expect(@offsetOf(EXTI, "imr") == 0x00);
try expect(@offsetOf(EXTI, "emr") == 0x04);
try expect(@offsetOf(EXTI, "rtsr") == 0x08);
try expect(@offsetOf(EXTI, "ftsr") == 0x0C);
try expect(@offsetOf(EXTI, "swier") == 0x10);
try expect(@offsetOf(EXTI, "pr") == 0x14);
try expect(@offsetOf(EXTI, "IMR") == 0x00);
try expect(@offsetOf(EXTI, "EMR") == 0x04);
try expect(@offsetOf(EXTI, "RTSR") == 0x08);
try expect(@offsetOf(EXTI, "FTSR") == 0x0C);
try expect(@offsetOf(EXTI, "SWIER") == 0x10);
try expect(@offsetOf(EXTI, "PR") == 0x14);
}

// Pointer to the top of the stack. It isn't really a function
Expand Down

0 comments on commit 9411775

Please sign in to comment.