Skip to content

Use atomic register access for RESETS instead of read-modify-write #966

@ilovefurnaces

Description

@ilovefurnaces

RP2040 Datasheet (2.1.2) states that most peripheral registers can be accessed atomically (bitwise) using offsets: 0 (normal access), 0x1000 (XOR), 0x2000 (bitmask set), 0x3000 (bitmask clear). That allows registers to be accessed concurrently without any synchronization. But currently rp2040-hal uses read-modify-write sequences to RESETS register to reset devices, which is hard to synchronize and is completely unneeded. Atomic accesses should eliminate the need to have &mut RESETS to initialize a peripheral. C pico SDK already uses atomic accesses to hardware registers to do that.

A problem I can see is that rp2040-pac, doesn't support this without pointer arithmetic. But i think that adding convenience functions for that wouldn't be very hard.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions