Skip to content
This repository has been archived by the owner on Feb 17, 2024. It is now read-only.

Work around ziglang/zig #17882 #31

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/hals/STM32F303.zig
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,9 @@ pub fn Uart(comptime index: usize, comptime pins: micro.uart.Pins) type {
pub fn rx(self: Self) u8 {
while (!self.can_read()) {} // Wait till the data is received
const data_with_parity_bit: u9 = USART1.RDR.read().RDR;
return @as(u8, @intCast(data_with_parity_bit & self.parity_read_mask));
const result: u8 = @intCast(data_with_parity_bit & self.parity_read_mask);
std.mem.doNotOptimizeAway(result); // work around https://github.com/ziglang/zig/issues/17882
return result;
}
};
}
Expand Down Expand Up @@ -568,7 +570,9 @@ pub fn SpiBus(comptime index: usize) type {
// read
var data_read = SPI1.DR.raw;
_ = SPI1.SR.read(); // clear overrun flag
const dr_lsb = @as([dr_byte_size]u8, @bitCast(data_read))[0];
const dr: [dr_byte_size]u8 = @bitCast(data_read);
std.mem.doNotOptimizeAway(dr); // work around https://github.com/ziglang/zig/issues/17882
const dr_lsb = dr[0];
debug_print("Received: {X:2} (DR = {X:8}).\r\n", .{ dr_lsb, data_read });
if (optional_read_pointer) |read_pointer| read_pointer.* = dr_lsb;
}
Expand Down