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§

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

Macros§

Structs§

Traits§