Repository navigation
Conversation
0d40861 to
12368e7
Compare
12368e7 to
3539584
Compare
|
I tested this PR with #655 with https://github.com/ferrous-systems/rust-training/tree/main/example-code/qemu-thumbv7em. Async and interrupt using examples were running fine. I'll probably add some tests to verify priority setting/reading as well because pointer magic was used there.. |
b797433 to
624d62f
Compare
|
Marking as draft because I think these are breaking changes and we need to avoid those right now. Also it now has merge conflicts. |
|
I thought |
|
Near future, for some value of near. But we don't have a stable branch for v0.7-only changes, so I'd like to keep non-0.7 things out of the main branch. |
303076e to
1b1ac81
Compare
|
The NVIC field of the peripheral singleton is now a ZST type, using the new derive-mmio owned handles. I still kept the NVIC code to be a run-time created driver wrapping a regular MMIO handle. I think this solution is cleaner because it also allows providing Deref and DerefMut impls to the inner MMIO handle, reflecting that this is a low-level driver. I also moved the NVIC declaration to the nvic module now. It is still re-exported inside the peripheral top module. |
1b1ac81 to
f627086
Compare
89fbc8a to
7a1dbc8
Compare
7a1dbc8 to
15f776a
Compare
| pub struct RegisterBlock { | ||
| /// Interrupt Set-Enable | ||
| pub iser: [RW<u32>; NVIC::BITMAP_WORDS], | ||
| iser: [u32; NVIC::BITMAP_WORDS], |
There was a problem hiding this comment.
PureRead, Write - but not modify
(reading gives you the current enable state)
|
|
||
| /// Interrupt Clear-Enable | ||
| pub icer: [RW<u32>; NVIC::BITMAP_WORDS], | ||
| icer: [u32; NVIC::BITMAP_WORDS], |
There was a problem hiding this comment.
I think Write is fine here - you can read icer but it gives you the same value as iser. But certainly we should disable Modify.
There was a problem hiding this comment.
Yeah.. reading is very confusing. I agree with only adding Write
|
|
||
| /// Interrupt Set-Pending | ||
| pub ispr: [RW<u32>; NVIC::BITMAP_WORDS], | ||
| ispr: [u32; NVIC::BITMAP_WORDS], |
|
|
||
| /// Interrupt Clear-Pending | ||
| pub icpr: [RW<u32>; NVIC::BITMAP_WORDS], | ||
| icpr: [u32; NVIC::BITMAP_WORDS], |
| #[cfg(armv8m)] | ||
| /// Interrupt Target Non-secure (only present on Arm v8-M) | ||
| pub itns: [RW<u32>; NVIC::BITMAP_WORDS], | ||
| itns: [u32; NVIC::BITMAP_WORDS], |
There was a problem hiding this comment.
I'd expressly mark this as PureRead, Write, Modify to make it clear that it is a read-modify-write register, not a foo-set/foo-clear register pair.
| /// architecture. | ||
| #[cfg(not(armv6m))] | ||
| pub ipr: [RW<u8>; 496], | ||
| ipr: [u32; 124], |
There was a problem hiding this comment.
What's the reason for changing from 8-bit to 32-bit fields here? I think it makes sense to have this as an array of 8-bit values because it avoids a read-modify-write cycle if you only change one 8-bit value. As the (now deleted) comment notes, the hardware was designed for this?
There was a problem hiding this comment.
Probably because i thought I have to use u32 here (can not mix word sizes in one reg block). I will implement it with u8.
| #[cfg(not(armv6m))] | ||
| { | ||
| let nr = interrupt.number(); | ||
| let ipr_ptr = self.pointer_to_ipr_start() as *mut u8; |
There was a problem hiding this comment.
I think we should be avoiding raw pointer operations here. Doesn't derive-mmio give array access functions we can use?
There was a problem hiding this comment.
yes, if IPR uses [u8; 496] that is the better solution.
The primary advantage is that
derive-mmiodoes not create shared references to MMIO likeVolatileCell/volatile_registerdoes.