Conversation
|
r? @therealprof (rust_highfive has picked a reviewer for you, use r? to override) |
|
cc @therealprof
Now all right. It also depends on #358. |
ef62cc3 to
9fd21ec
Compare
|
cc @Disasm |
|
@therealprof I've rebased this on master. Test, please. |
| impl<U, REG> Reg<U, REG> | ||
| where | ||
| Self: Writable, | ||
| U: Copy + Default |
There was a problem hiding this comment.
Is this Default equals to "returns zero"?
There was a problem hiding this comment.
Yes, it is for bool, u8, u16 u32 and u64.
There was a problem hiding this comment.
Yes, but these types are not enforced I guess
There was a problem hiding this comment.
They are enforced by size type of register or field.
There was a problem hiding this comment.
But it's possible to create a wrapper with the same size and a custom Default impl that returns reset value, for example
There was a problem hiding this comment.
How? All fields are private. You can get register only from peripheral as it was before.
|
|
It was auto-implementation? |
|
Yes, I think that was due to the inner |
|
As discussed on Matrix, documentation becomes even more difficult to understand with this change: it's unclear how to read and write registers, also there is no information about field variants. |
|
TBH I'm not too sure whether we really need that |
|
@therealprof Yes, but it's better to have |
|
error[E0658]: negative trait bounds are not yet fully implemented; use marker types for now What to do with this? |
|
I think that PhantomData with some weird type can help |
|
Can you write how you see implementation for |
|
Seems like |
|
I've added |
|
What you mean |
|
@burrbull It's no longer accessible from the register documentation pages. Only on upper levels. |
Can you show example? |
|
spi0::RegisterBlock -> CTRLR0 -> R -> WORK_MODER |
|
Here is one breaking change (#354). Reader now have same as writer: And now you can use this enum for both read and write: let v = spi.ctrl0.read().work_mode().variant();
...
spi.ctrl0.write(|w| w.work_mode().variant(v)); // Before now incompatible types error was here. |
|
@therealprof I can't find where is source of this documentation https://docs.rs/svd2rust ? |
|
@burrbull You mean |
src/generate/generic.rs
Outdated
| ///Register size | ||
| type Size; | ||
| ///Reset value of the register | ||
| fn reset_value() -> Self::Size; |
There was a problem hiding this comment.
This associated type name is debatable, but I'm not going to force my point of view here.
There was a problem hiding this comment.
I've changed Size on Type
|
|
||
| let doc = format!("`read()` method returns [{0}::R]({0}::R) reader structure", &name_sc); | ||
| if can_read { | ||
| out.push(quote! { |
There was a problem hiding this comment.
Why not move the let doc = ... inside the if clause? Should be cheaper to compute and avoids the risk of accidentally using it in a wrong context.
| }); | ||
| } | ||
| let doc = format!("`write(|w| ..)` method takes [{0}::W]({0}::W) writer structure", &name_sc); | ||
| if can_write { |
|
Also please rebase and make sure the commits have a meaningful commit message. |
|
Rebased. |
|
bors try |
tryBuild succeeded |
|
@Disasm Still happy? |
|
@therealprof yes, looks good. |
|
In general, I'd improve documentation for generic methods (read/write/...), replacing references to the book with short examples. |
|
bors r+ |
Build succeeded |


Rebased and reopened.