Fieldset
A fieldset is a collection of fields that make up the data of a register, command input or command output.
Each fieldset defines a type where each of the fields are accessible through operations with the names of the fields.
Note
As a user you should not have to construct your fieldsets manually in normal use. But it’s available to you for special cases.
Example usage:
use device_driver::Fieldset;
let mut reg = MyFieldSet::ZERO;
reg.set_foo(1234);
let foo = reg.foo();
Fieldsets also implement all bitwise operators for easier manipulation. These operations are done on all underlying bits, even ones that are not part of a field.
There’s also an Into and From implementation to byte arrays of the same size of the fieldset.
All possible bitpatterns are legal.
Example usage:
let all_ones = !MyFieldSet::from([0x00, 0x00]);
let lowest_byte_set = MyFieldSet::from([0xFF, 0x00]);
let lowest_byte_inverted = all_ones ^ lowest_byte_set;
Example
/// doc comment line
fieldset Example {
size-bytes: 8,
byte-order: LE,
bit-overlap: allow,
default-access: RW,
field node,
}
Table
| Property | Value |
|---|---|
| Identifier namespace | Type |
| Supports repeat | no |
| Supports basetype | no |
| Supports conversion type | no |
| Supports short properties | no |
| Supports properties | yes, see below |
| Supports subnodes | yes, see below |
Long properties
These properties are specified in the node body.
size-bytes
The size of the fieldset in number of bytes.
// number
size-bytes: 8
Info
- required:
yes - multiple allowed:
no - supports doc comments:
no
byte-order
The byte order of the fieldset data.
// byte order
byte-order: LE
Info
- required:
no - multiple allowed:
no - supports doc comments:
no
bit-overlap
Allows fields to overlap. This is not allowed by default to prevent copy-paste mistakes.
// allow
bit-overlap: allow
Info
- required:
no - multiple allowed:
no - supports doc comments:
no
default-access
When set, all subobjects use this value as their access value (unless overridden) and don’t require an access specifier anymore
// access specifier
default-access: RW
Info
- required:
no - multiple allowed:
no - supports doc comments:
no
Possible subnodes
Subnodes of the following types are allowed in the node body.