-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Toggle-only access policy support? #14
Comments
Hi @stephenwhittle I first want to confirm what this issue is about. Say we have a register of the form:
Assuming Field A and Field B are "write 1 to toggle" the issue is that if you
while you would want to have:
Can you confirm that my understanding is correct? I can think of several ways to As a side note, it is possible to read the register memory (for both packed and
Note that similar functions are also available in previous cppreg versions but |
Yes, you're correct in your understanding of the issue at hand. Thanks for the reminder re cppreg versions too - I'm using it as a submodule and had somehow forgotten to update. It might be worth mentioning |
Ok I created #15 and documentation will be updated very soon. Regarding this issue a few comments first:
Your approach (reading the whole register and managing the writes through The other solution is to add more logic to the register implementation with custom access policies but this will be less generic than the "managed register" approach and will take more time as I would have to think on how to do it in practice. |
The managed register idea sounds like the best way to accomplish this in an extensible way, so that gets my vote. I was just really dreading having to manage this single register CMSIS-style to avoid messing up the toggles :) |
Sounds good; will add the manager register implementation as soon as possible. |
I'm working on refactoring a small USB stack for STM32 to avoid its dependencies (CMSIS, HAL etc) and have my own svd->cppreg header generation flow which is working great.
However, the STM32 USB registers, specifically the endpoint registers, have a number of fields which are toggle-only (ie read is permitted, write 1 to flip) mixed in with normal read-write fields.
Would it be feasible to devise an access policy which changes the way cppreg attempts to maintain the value of a field?
Writing the existing value back, as I presume the existing implementation would do (to try to preserve the value of the toggle fields) when I'm trying to write to a normal field in the same register, will cause all the toggles to flip if they are currently set.
Happy to entertain other suggestions, too of course. CMSIS handles this just fine by forcing all toggle field values to 0 during read-modify-write, but to do the same I'd have to be able to read the entire packed register at once, then do a merge_write to all fields, and packed registers don't support read().
Looking over the documentation it seems that perhaps a modification of the shadow register functionality could achieve this, too?
The text was updated successfully, but these errors were encountered: