Register
A register is a singular piece of addressable memory stored on the device that can be written and/or read.
It defines an operation on the block it’s part of. Register functionality is implemented in the runtime through the RegisterOperation which can be used to read/write/modify the register.
Example usage:
let mut device = MyDevice::new(DeviceInterface::new());
device.foo().write(|reg| reg.set_bar(12345))?;
assert_eq!(device.foo().read()?.bar(), 12345);
Example
/// doc comment line
register Example[8 stride 4] {
address: 0,
access: RW,
address-overlap: allow,
reset: [12, 34],
fields: MyFieldset,
}
Table
| Property | Value |
|---|---|
| Identifier namespace | Operation |
| Supports repeat | yes |
| Supports basetype | no |
| Supports conversion type | no |
| Supports short properties | no |
| Supports properties | yes, see below |
| Supports subnodes | no |
Long properties
These properties are specified in the node body.
address
The address of the register.
// number
address: 0
Info
- required:
yes - multiple allowed:
no - supports doc comments:
no
access
Limits how the register can be accessed. Must be specified unless a default-access is set by a parent object.
// access specifier
access: RW
Info
- required:
no - multiple allowed:
no - supports doc comments:
no
address-overlap
Allows addresses to overlap with other registers. This is not allowed by default to prevent copy-paste mistakes.
// allow
address-overlap: allow
Info
- required:
no - multiple allowed:
no - supports doc comments:
no
reset
Defines the reset value of the register. When performing a write operation, this value loaded in by default.
The value can be expressed in two ways:
- Byte array: No byte order changes are done. The array will be loaded into the fieldset as is.
- Integer: Will be converted to a byte array with the specified byte order.
// [bytes]
reset: [12, 34],
// number
reset: 1234
Info
- required:
no - multiple allowed:
no - supports doc comments:
no
fields
The fieldset that represents the data of the register. This can be a reference to an existing fieldset or a completely new inline fieldset.
// type reference
fields: MyFieldset,
// sub node
fields: fieldset MyFieldSet
Info
- required:
yes - multiple allowed:
no - supports doc comments:
no