TemplateRegister< RegType, Size, BaseAddress_ > Struct Template Reference

A Template to construct register-accessor functions for memory-mapped devices. More...

#include <TemplateRegister.hpp>

List of all members.

Public Types

typedef unsigned int uint32_t

Public Member Functions

 TemplateRegister ()
 The Constructor takes no arguments.
volatile Size * regAddress (RegType reg)
 An unsigned int containing the compile-time base address of this register.
Size regRead (RegType reg)
 Read a single register of a device.
void regWrite (RegType reg, Size value)
 Write a single register of a device.
uint32_t bitRead (RegType reg, uint32_t bits)
 Read one or more (consecutive) bits from a device.
void bitWrite (RegType reg, uint32_t bits, uint32_t value)
 Write one or more (consecutive) bits to a device.

Detailed Description

template<typename RegType, class Size, unsigned int BaseAddress_ = 0>
struct RTT::TemplateRegister< RegType, Size, BaseAddress_ >

A Template to construct register-accessor functions for memory-mapped devices.

Use it as a typedef, as in the example below. This specialisation requires an at compile time known base address of the device's register.

Parameters:
RegType An enum describing the register layout of the device.

        enum UARTRegisters
        {
                STATUS = 0x00, // UART status register
                TXCTL  = 0x01, // Transmit control
                RXCTL  = 0x02 // Receive control
        };
        enum STATUS_bits
        {
                TX_BUFFER_EMPTY = ORO_REG_BIT_DEFN(0,0),
                RX_BUFFER_EMPTY = ORO_REG_BIT_DEFN(1,1),
                TX_UNDERRUN     = ORO_REG_BIT_DEFN(5,5),
                RX_OVERFLOW     = ORO_REG_BIT_DEFN(6,6),
        };
        typedef TemplateRegister<UARTRegisters, uint8_t, 0x0000ffff> UARTDevice;
        UARTDevice uart;
        // ...
        uint16_t v = uart.regRead( STATUS );
        bool     b = uart.bitRead( STATUS, TX_BUFFER_EMPTY );
       
Size The type of a register value. For example, uint8_t if the register contains 8 bits.
BaseAddress The at compile time known base address of the register of the device. If you omit BaseAddress, you need to supply it as the first argument of each method call of this class.

Definition at line 84 of file TemplateRegister.hpp.


Member Function Documentation

uint32_t bitRead ( RegType  reg,
uint32_t  bits 
) [inline]

Read one or more (consecutive) bits from a device.

Parameters:
reg a value of RegType, denoting from which register to read the bits.
bits the bits to read, using the ORO_REG_BIT_DEFN defined enum.

Definition at line 127 of file TemplateRegister.hpp.

References TemplateRegister< RegType, Size, BaseAddress_ >::regAddress().

void bitWrite ( RegType  reg,
uint32_t  bits,
uint32_t  value 
) [inline]

Write one or more (consecutive) bits to a device.

Parameters:
reg a value of RegType, denoting from which register to read the bits.
bits the bits to read, using the ORO_REG_BIT_DEFN defined enum.
value the value to write to bits

Definition at line 143 of file TemplateRegister.hpp.

References TemplateRegister< RegType, Size, BaseAddress_ >::regAddress().

volatile Size* regAddress ( RegType  reg  )  [inline]

The documentation for this struct was generated from the following file:
Generated on Thu Dec 23 15:05:29 2010 for OrocosComponentLibrary by  doxygen 1.6.3