lynaghk / svd2zig

Generate Zig API from SVD register definitions.
MIT License
36 stars 2 forks source link

Fallback for missing register-level <access> #1

Closed simonschmidt closed 3 years ago

simonschmidt commented 3 years ago

In the SVD for stm32f103[1] there are registers where the <access> is declared per-field rather than for the whole register.

This caused nil instead of Register to be emitted:

pub const cr = nil(cr_val).init(0x40021000 + 0x0);

This change makes those register be treated like read-write even though some of the contained fields are read-only.

[1] https://www.st.com/resource/en/svd/stm32f1_svd.zip

lynaghk commented 3 years ago

Thanks for the patch! I think it'd be better to see if we can come up with an API that more honestly represents what the SVD tells us re: read/write access on field-by-field basis. I once I had to debug a bad register API and don't want to risk inflicting that on anyone who might be writing to a read-only register and then wondering why nothing is happening =D

Let's discuss in https://github.com/lynaghk/svd2zig/issues/2