Closed duskmoon314 closed 2 years ago
r? @reitermarkus
(rust-highfive has picked a reviewer for you, use r? to override)
Looks good for me in general. Need advanced test in CI with SVD containing peripheral array. (possibly already present, need to check)
@therealprof any comments?
Need advanced test in CI with SVD containing peripheral array. (possibly already present, need to check)
It seems that CI use SVD in posborne/cmsis-svd to test. I try searching dim
in this repo and cannot find a showcase of a peripheral array. May need to find a real example or build up one for testing.
ci failed: pattern bindings after an
@
are unstable
I use p @ Peripheral::Array(_, dim)
to extract dim_element
and keep the p: MaybeArray<PeripheralInfo>
at the same time. It is stable after 1.56. I will try to find out an alternative.
My mistake. I don't need to bind it. 🤣
for future reference. If you need to break msrv, do it ;)
I think I have misunderstood how ArrayProxy
works. The current design cannot use ArrayProxy
to calculate the address since ArrayProxy
uses these lines:
let base = self as *const Self as usize;
let address = base + S * index;
&*(address as *const T)
But the generated code when const_generic
is false
seems to work fine. And the usage in this way is the same as describing peripherals separately in the svd file. (I rearrange the svd file that I am maintaining locally and test a simple case.)
For now, I think maybe there is no need to provide something like ArrayProxy
for peripheral arrays. Any suggestions?
For now, I think maybe there is no need to provide something like
ArrayProxy
for peripheral arrays. Any suggestions?
Instead of ArrayProxy
you could just create independent instances like if they are just derivedFrom
first one.
Instead of
ArrayProxy
you could just create independent instances like if they are justderivedFrom
the first one.
Yes. For now, the generated code is only organized in this way.
Though I think there is no problem, I still want to ask if there are any suggestions.
I don't have suggestions now. Except missing CI test.
bors r+
Brief Intro
close issue: #492
Design
Notice: This is my first try of implement this feature. Please provide suggestions for this PR to better implement this feature.
This PR aims to achieve what issue #492 is asking for. This PR implements a basic try of generating codes depending on the
const_generic
flag.Let's say we have an svd file with descriptions of peripherals like this:
If the
const_generic
isfalse
, there is noArrayProxy
. So I generate separate structs and only one mod:NOTICE: The following design is actually incorrect and has been removed. See the following comment.
I also add the support of using
name_of
onMaybeArray<PeripheralInfo>
to achieve this implementation.Well, I haven't fully tested this implementation yet. So there may be problems that need to be solved.