Skip to content
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

Wrong type '*mut u8' for bitfields instead of u8 #22

Open
Pr0gm4n opened this issue Jan 16, 2023 · 0 comments
Open

Wrong type '*mut u8' for bitfields instead of u8 #22

Pr0gm4n opened this issue Jan 16, 2023 · 0 comments

Comments

@Pr0gm4n
Copy link

Pr0gm4n commented Jan 16, 2023

The current type of the defined bitfields is *mut u8, a pointer type. It is not clear to me how they are supposed to be used like that. I would expect the bitmasks to be used, e.g., as:

unsafe {
    *UCSRB = TXEN | RXEN | RXCIE;
}

That doesn't work with pointers, though. I've found a workaround using core::intrinsics::transmute, casting it to an usize and subsequently cropping the value to an u8. But I really think that it is a bug in this library.

Do you agree? If so, I might take the time to create a PR to fix the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant