Crate tock_registers

Source
Expand description

Tock Register Interface

Provides efficient mechanisms to express and use type-checked memory mapped registers and bitfields.


use tock_registers::registers::{ReadOnly, ReadWrite};
use tock_registers::register_bitfields;

// Register maps are specified like this:
#[repr(C)]
struct Registers {
    // Control register: read-write
    cr: ReadWrite<u32, Control::Register>,
    // Status register: read-only
    s: ReadOnly<u32, Status::Register>,
}

// Register fields and definitions look like this:
register_bitfields![u32,
    // Simpler bitfields are expressed concisely:
    Control [
        /// Stop the Current Transfer
        STOP 8,
        /// Software Reset
        SWRST 7,
        /// Master Disable
        MDIS 1,
        /// Master Enable
        MEN 0
    ],

    // More complex registers can express subtypes:
    Status [
        TXCOMPLETE  OFFSET(0) NUMBITS(1) [],
        TXINTERRUPT OFFSET(1) NUMBITS(1) [],
        RXCOMPLETE  OFFSET(2) NUMBITS(1) [],
        RXINTERRUPT OFFSET(3) NUMBITS(1) [],
        MODE        OFFSET(4) NUMBITS(3) [
            FullDuplex = 0,
            HalfDuplex = 1,
            Loopback = 2,
            Disabled = 3
        ],
        ERRORCOUNT OFFSET(6) NUMBITS(3) []
    ]
];

§Author

Modules§

debug
Register Debug Support Infrastructure
fields
Register bitfield types and macros
interfaces
Interfaces (traits) to register types
macros
Macros for cleanly defining peripheral registers.
registers
Implementation of included register types.

Macros§

bitmask
Helper macro for computing bitmask of variable number of bits
register_bitfields
Define register types and fields.
register_bitmasks
Helper macro for defining register fields.
register_fields
register_structs
Define a peripheral memory map containing registers.
test_fields
Statically validate the size and offsets of the fields defined within the register struct through the register_structs!() macro.

Structs§

LocalRegisterCopy
A read-write copy of register contents.

Traits§

RegisterLongName
Descriptive name for each register.
UIntLike
Trait representing the base type of registers.