I'm looking into implementing driver for mcp2515, and I'm trying to create nice SPI registers abstraction.
The issue is that for many operations (eg. marking irq as acknowledged) require use of "Bit Modify" operations (to prevent race conditions, eg when device receive message between read and write operation to registers).
This require executing bit modify operation with bit mask (what bits we want to set) and new value (bits outside bit mask are ignored).
The issue that I'm having is how to create register, set some bit fields there, and then get mask for modified fields.
I'm looking into implementing driver for mcp2515, and I'm trying to create nice SPI registers abstraction.
The issue is that for many operations (eg. marking irq as acknowledged) require use of "Bit Modify" operations (to prevent race conditions, eg when device receive message between read and write operation to registers).
This require executing bit modify operation with bit mask (what bits we want to set) and new value (bits outside bit mask are ignored).
The issue that I'm having is how to create register, set some bit fields there, and then get mask for modified fields.