svd2rust converts a microcontroller’s System View Description (SVD) into Rust source for a Peripheral Access Crate (PAC). The generated API names peripherals, registers, and fields, replacing hand-written pointers and offsets with strongly typed access. This helps scale memory-mapped peripheral access across a device. section 5.3.2
<register name="ODR" addressOffset="0x0C">
<description>Output Data Register</description>
<fields>
<field name="ODR0" bitOffset="0" bitWidth="1" access="read-write"/>
<!-- ... -->
</fields>
</register>
An SVD register entry describes a register’s offset and fields; svd2rust uses such device descriptions as input. section 5.3.2
svd2rust -i STM32F103.svd
Run the generator on a vendor SVD file. Producing a complete PAC crate may require additional crate-structuring steps. section 5.3.2
Generated PACs expose peripherals through a Peripherals struct, whose take() method provides exclusive access. Register APIs offer read, write, and modify operations. For example, a GPIO BSRR write can set or reset pins without a read-modify-write cycle; modify is useful when other register fields must be preserved. section 5.3.3
Generation has practical limits and alternatives:
- Output quality depends on the SVD, which may omit data or contain errors. section 5.3.2
- Many projects use a published PAC maintained by an ecosystem group; some device families also have alternative data and generation pipelines. section 5.3.2
STM32F1 GPIO
A generated STM32F1 PAC can configure GPIO and write the BSRR register through typed methods such as bsrr().write(|w| w.br13().set_bit()). section 5.3.3
