Skip to content
This repository was archived by the owner on Oct 24, 2024. It is now read-only.
This repository was archived by the owner on Oct 24, 2024. It is now read-only.

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

@pavly-gerges

Description

@pavly-gerges

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;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions