Handle SVD files which don't define register reset values
Atmel's ARM chips omit the <resetValue> element for register descriptions. <resetValue> is used to generate a write function which doesn't have to read the initial value from a register in order to preserve it while modifying individual fields.
You can access the bits via modify
I have used @ecstatic-morse's branch to generate the code for an ATtiny2313. The generated code compiles, but doesn't contain .write() and .modify() at all.
@kunerd, I was wrongly using "ocd-rw" to determine whether registers were read only, when really this field tells the on chip debugger not to read or write to this register because of side effects.
@kunerd @ecstatic-morse is this an issue with the ATDF to SVD parser, or with svd2rust?
I'd like to close this if there is nothing to be done at the svd2rust level.
@jamesmunns: Yes this an issue with ATDF to SVD parser, but closing depends on the questions:
Do we want to have a separate
atdf2rustexecutable, or should.atdfsupport be added tosvd2rustdirectly. And if we choose the separate executable way, should it be part ofsvd2rustor should it life in it's own repo?
I prefer the former one (for the first question), but I think the questions have not really been answered, yet. See #184
@kunerd is there anything that #184 doesn't cover that this one does? AFAICT, svd2rust does handle registers without reset values (without <resetValue> elements), as long as they are marked as writable.
I will definitely follow #184 though (no opinions yet :) )
@jamesmunns Ahh, I missed the part with the ocd-rw above. So, I would say, this can be closed, but maybe you want to wait until @ecstatic-morse confirmed that, because he has done the implementation and I only tried to test it.
@ecstatic-morse any feedback?
This should be supported. The SVD spec allows <resetValue> to be missing. In the case that resetValue is missing we should not generate the reset method and we should modify the write method somehow because that makes use of resetValue.
I've come across this recently as I'm trying to use an Atmel provided SVD file which doesn't have <resetValue> for all registers.
I believe that with no reset value the reset and reset_value methods should be omitted and the write method should instead initialise w to 0 as in:
let mut w = W { bits: 0 };
See https://github.com/sjroe/svd2rust/tree/resetvalue for an example implementation.
I've pushed pull request #258 with a rebased version of #175 that also addresses the comments from @sjroe.
Closing due to write_with_zero. Reopen if you have better solution.