Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

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

PropertyValue
Identifier namespaceOperation
Supports repeatyes
Supports basetypeno
Supports conversion typeno
Supports short propertiesno
Supports propertiesyes, see below
Supports subnodesno

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