Skip to content
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

[libshiftavr] Use volatile addresses and members in callbacks #17

Open
pavly-gerges opened this issue Apr 26, 2023 · 0 comments
Open

[libshiftavr] Use volatile addresses and members in callbacks #17

pavly-gerges opened this issue Apr 26, 2023 · 0 comments
Labels
enhancement New feature or request shiftavr-core Core API stuff

Comments

@pavly-gerges
Copy link
Member

The [libuart] and [libadc] use only volatile protocol_callback* var in their callback instances which restricts the interrupt-safety to the actual instance of the callback and not the instance address and its members, so by changing it to volatile protocol_callback *volatile var and declaring the struct protocol_callback members to volatile, the interrupt-safety will include also asynchronous changes to the addresses and member states.

  1. The volatile protocol_callback* would add this feature:
volatile protocol_callback* internal_protocol_callback = ...;
protocol_callback finalize_callback = ...;

ISR(_xxx__vector) {
    //Adjusts the callback instance
    *internal_protocol_callback = finalize_callback;
}
  1. The protocol_callback *volatile would add this functionality:
protocol_callback *volatile internal_protocol_callback = ...;
protocol_callback *volatile finalize_callback = ...;

ISR(_xxx__vector) {
    //Adjusts the callback instance address to another one
    internal_protocol_callback = finalize_callback;
}
  1. The typedef struct { void (*volatile on_command)(vector); } protcol_callback; would add this functionality:
volatile protocol_callback *volatile internal_protocol_callback = ...;
volatile protocol_callback *volatile finalize_callback = ...;

ISR(_xxx__vector) {
    //Adjusts the callback instance address to another one
    internal_protocol_callback->on_command = finalize_callback->on_command;
}
@pavly-gerges pavly-gerges added enhancement New feature or request shiftavr-core Core API stuff labels Apr 26, 2023
@pavly-gerges pavly-gerges pinned this issue Apr 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request shiftavr-core Core API stuff
Projects
None yet
Development

No branches or pull requests

1 participant