Right now, svd2rust has no provisions for providing a safe bits() function which accesses the entire register (and not just a field), because the generics bits() function for writing a register is- correctlymarked as unsafe!
To avoid having application writers have to place unsafe code in their application, I propose some standardized function to safely access all the bits of a register, as a unit, when svd2rust can prove that no invalid values can be written into a register.
svd2rust could either prove this info by reading the WriteConstraint field of a Register type, or keeping a running tally of which bits are stated to be valid in children (fieldType) of the fieldsType sequence.
This is useful for RMW GPIO registers (direction, value, etc) and setting timer values for countdown all at once, without having to chain proxies together for each individual bit.
The CMSIS SVD Specification allows
WriteConstraint
fields to be applied to aRegister
type, and not just its fields:Right now,
svd2rust
has no provisions for providing a safebits()
function which accesses the entire register (and not just a field), because the genericsbits()
function for writing a register is- correctly marked as unsafe!To avoid having application writers have to place unsafe code in their application, I propose some standardized function to safely access all the bits of a register, as a unit, when
svd2rust
can prove that no invalid values can be written into a register.svd2rust
could either prove this info by reading theWriteConstraint
field of aRegister
type, or keeping a running tally of which bits are stated to be valid in children (fieldType
) of thefieldsType
sequence.This is useful for RMW GPIO registers (direction, value, etc) and setting timer values for countdown all at once, without having to chain proxies together for each individual bit.