Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## avrora.sim.mcu
Class AtmelMicrocontroller

    java.lang.Object
      avrora.sim.mcu.AtmelMicrocontroller

All Implemented Interfaces:
  Microcontroller

Direct Known Subclasses:
  ATMegaFamily

public abstract class AtmelMicrocontroller
extends java.lang.Object
implements Microcontroller

The `AtmelMicrocontroller` class represents the common functionality among microcontrollers for the Atmel series. These all contain a clock domain (collection of internal, external clocks), a simulator, an interpreter, microcontroller properties, and a mapping between string names and IO reg addresses, etc.

Nested Class Summary
`protected class` | `AtmelMicrocontroller.Pin` The `Pin` class implements a model of a pin on the ATMegaFamily for the general purpose IO ports.

Nested classes inherited from class avrora.sim.mcu.Microcontroller
`Microcontroller.InputPin, Microcontroller.OutputPin`

Field Summary
`protected ClockDomain` | `clockDomain`
`protected java.util.HashMap` | `devices`
`long` | `HZ`
`protected BaseInterpreter` | `interpreter`
`protected MainClock` | `mainClock`
`static int` | `MODE_ACTIVE`
`protected Simulator.Printer` | `pinPrinter`
`protected Microcontroller.Pin[]` | `pins`
`protected Platform` | `platform`
`MicrocontrollerProperties` | `properties`
`protected RegisterSet` | `registers`
`protected Simulator` | `simulator`
`protected FiniteStateMachine` | `sleepState`

Constructor Summary
`protected` | `AtmelMicrocontroller(ClockDomain cd, MicrocontrollerProperties p, FiniteStateMachine fsm)`

Method Summary
`protected void` | `addDevice(AtmelInternalDevice d)` The `addDevice()` method adds a new internal device to this microcontroller so that it can be retrieved later with `getDevice()`
`static void` | `addInterrupt(java.util.HashMap iMap, java.lang.String n, int i)`
`static void` | `addPin(java.util.HashMap pinMap, int p, java.lang.String n)`
`static void` | `addPin(java.util.HashMap pinMap, int p, java.lang.String n1, java.lang.String n2)`
`static void` | `addPin(java.util.HashMap pinMap, int p, java.lang.String n1, java.lang.String n2, java.lang.String n3)`
`double` | `cyclesToMillis(long cycles)` The `cyclesToMillis()` method converts the specified number of cycles to a time quantity in milliseconds.
`Clock` | `getClock(java.lang.String name)` The `getClock()` method gets a reference to a specific clock on this device.
`ClockDomain` | `getClockDomain()` The `getClockDomain()` method gets a reference to the `ClockDomain` instance for this node that contains the main clock and any derived clocks for this microcontroller.
`AtmelInternalDevice` | `getDevice(java.lang.String name)` The `getDevice()` method is used to get a reference to an internal device with the given name.
`FiniteStateMachine` | `getFSM()` The `getFSM()` method gets a reference to the finite state machine that represents the sleep modes of the MCU.
`protected ActiveRegister` | `getIOReg(java.lang.String name)` The `getIOReg()` method gets a reference to the active register currently installed for the specified name.
`byte` | `getMode()` The `getMode()` method returns the current sleep mode of the MCU.
`java.lang.String` | `getModeName()` get the name of the current mode
`Microcontroller.Pin` | `getPin(int num)` The `getPin()` method looks up the specified pin by its number and returns a reference to that pin.
`Microcontroller.Pin` | `getPin(java.lang.String n)` The `getPin()` method looks up the named pin and returns a reference to that pin.
`int` | `getPinNumber(java.lang.String n)` The `getPinNumber()` method gets the pin number (according to the pin assignments) for the pin with the specified name.
`Platform` | `getPlatform()` The `getPlatform()` method returns the platform for this microcontroller.
`MicrocontrollerProperties` | `getProperties()` The `getProperties()` method gets a reference to the microcontroller properties for this microcontroller instance.
`RegisterSet` | `getRegisterSet()` The `getRegisterSet()` method gets a reference to the register set of the microcontroller.
`Simulator` | `getSimulator()` The `getSimulator()` method gets a reference to the simulator for this microcontroller instance.
`protected abstract int` | `getSleepMode()`
`protected void` | `installIOReg(java.lang.String name, ActiveRegister reg)` The `installIOReg()` method installs an IO register with the specified name.
`long` | `millisToCycles(double ms)` The `millisToCycles()` method converts the specified number of milliseconds to a cycle count.
`void` | `setPlatform(Platform p)` The `setPlatform()` method sets the platform instance for this microcontroller
`void` | `sleep()` The `sleep()` method is called by the interpreter when the program executes a SLEEP instruction.
`int` | `wakeup()` The `wakeup()` method is called by the interpreter when the microcontroller is woken from a sleep mode by an interrupt or other event.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Methods inherited from interface avrora.sim.mcu.Microcontroller
`getHZ, isSupported`

Field Detail

### HZ

    public final long HZ

### pins

    protected final Microcontroller.Pin[] pins

### mainClock

    protected final MainClock mainClock

### registers

    protected final RegisterSet registers

### platform

    protected Platform platform

### simulator

    protected Simulator simulator

### interpreter

    protected BaseInterpreter interpreter

### pinPrinter

    protected Simulator.Printer pinPrinter

### properties

    public final MicrocontrollerProperties properties

### clockDomain

    protected final ClockDomain clockDomain

### devices

    protected final java.util.HashMap devices

### MODE_ACTIVE

    public static final int MODE_ACTIVE

See Also:
  Constant Field Values

### sleepState

    protected final FiniteStateMachine sleepState

Constructor Detail

### AtmelMicrocontroller

    protected AtmelMicrocontroller(ClockDomain cd,
                                   MicrocontrollerProperties p,
                                   FiniteStateMachine fsm)

Method Detail

### sleep

    public void sleep()

  The `sleep()` method is called by the interpreter when the program executes a SLEEP instruction. This method transitions the microcontroller into a sleep mode, including turning off any devices, shutting down clocks, and transitioning the sleep FSM into a sleep mode.

  Specified by:
    `sleep` in interface `Microcontroller`
  See Also:
    `Microcontroller.sleep()`

### getSleepMode

    protected abstract int getSleepMode()

### wakeup

    public int wakeup()

  The `wakeup()` method is called by the interpreter when the microcontroller is woken from a sleep mode by an interrupt or other event. This method transitions the microcontroller back into active mode, turning back on devices. This method returns the number of clock cycles necessary to wake the MCU from sleep.

  Specified by:
    `wakeup` in interface `Microcontroller`
  Returns:
    cycles it takes to wake up
  See Also:
    `Microcontroller.wakeup()`

### getMode

    public byte getMode()

  The `getMode()` method returns the current sleep mode of the MCU.

  Specified by:
    `getMode` in interface `Microcontroller`
  Returns:
    current mode
  See Also:
    `Microcontroller.getMode()`

### getModeName

    public java.lang.String getModeName()

  get the name of the current mode

  Specified by:
    `getModeName` in interface `Microcontroller`
  Returns:
    name of the current mode

### getFSM

    public FiniteStateMachine getFSM()

  The `getFSM()` method gets a reference to the finite state machine that represents the sleep modes of the MCU. The finite state machine allows probing of the sleep mode transitions.

  Returns:
    a reference to the finite state machine representing the sleep mode of the MCU

### getRegisterSet

    public RegisterSet getRegisterSet()

  The `getRegisterSet()` method gets a reference to the register set of the microcontroller. The register set contains all of the IO registers for this microcontroller.

  Specified by:
    `getRegisterSet` in interface `Microcontroller`
  Returns:
    a reference to the register set of this microcontroller instance

### millisToCycles

    public long millisToCycles(double ms)

  The `millisToCycles()` method converts the specified number of milliseconds to a cycle count. The conversion factor used is the number of cycles per second of this device. This method serves as a utility so that clients need not do repeated work in converting milliseconds to cycles and back.

  Specified by:
    `millisToCycles` in interface `Microcontroller`
  Parameters:
    `ms` - a time quantity in milliseconds as a double
  Returns:
    the same time quantity in clock cycles, rounded up to the nearest integer

### cyclesToMillis

    public double cyclesToMillis(long cycles)

  The `cyclesToMillis()` method converts the specified number of cycles to a time quantity in milliseconds. The conversion factor used is the number of cycles per second of this device. This method serves as a utility so that clients need not do repeated work in converting milliseconds to cycles and back.

  Specified by:
    `cyclesToMillis` in interface `Microcontroller`
  Parameters:
    `cycles` - the number of cycles
  Returns:
    the same time quantity in milliseconds

### getPin

    public Microcontroller.Pin getPin(int num)

  The `getPin()` method looks up the specified pin by its number and returns a reference to that pin. The intended users of this method are external device implementors which connect their devices to the microcontroller through the pins.

  Specified by:
    `getPin` in interface `Microcontroller`
  Parameters:
    `num` - the pin number to look up
  Returns:
    a reference to the `Pin` object corresponding to the named pin if it exists; null otherwise

### installIOReg

    protected void installIOReg(java.lang.String name,
                                ActiveRegister reg)

  The `installIOReg()` method installs an IO register with the specified name. The register layout for this microcontroller is used to get the address of the register (if it exists) and install the `ActiveRegister` object into the correct place.

  Parameters:
    `name` - the name of the IO register as a string
    `reg` - the register to install

### getIOReg

    protected ActiveRegister getIOReg(java.lang.String name)

  The `getIOReg()` method gets a reference to the active register currently installed for the specified name. The register layout for this microcontroller is used to get the correct address.

  Parameters:
    `name` - the name of the IO register as a string
  Returns:
    a reference to the active register object if it exists

### addDevice

    protected void addDevice(AtmelInternalDevice d)

  The `addDevice()` method adds a new internal device to this microcontroller so that it can be retrieved later with `getDevice()`

  Parameters:
    `d` - the device to add to this microcontroller

### getDevice

    public AtmelInternalDevice getDevice(java.lang.String name)

  The `getDevice()` method is used to get a reference to an internal device with the given name. For example, the ADC device will be under the name "adc" and Timer0 will be under the name "timer0". This is useful for external devices that need to connect to the input of internal devices.

  Parameters:
    `name` - the name of the internal device as a string
  Returns:
    a reference to the internal device if it exists
  Throws:
    `java.util.NoSuchElementException` - if no device with that name exists

### getClock

    public Clock getClock(java.lang.String name)

  The `getClock()` method gets a reference to a specific clock on this device. For example, the external clock, or a specific device's clock can be accessed by specifying its name.

  Parameters:
    `name` - the name of the clock to get
  Returns:
    a reference to the `Clock` instance for the specified clock if it exists

### getSimulator

    public Simulator getSimulator()

  The `getSimulator()` method gets a reference to the simulator for this microcontroller instance.

  Specified by:
    `getSimulator` in interface `Microcontroller`
  Returns:
    a reference to the simulator instance for this microcontroller

### getPlatform

    public Platform getPlatform()

  The `getPlatform()` method returns the platform for this microcontroller.

  Specified by:
    `getPlatform` in interface `Microcontroller`
  Returns:
    the platform instance containing this microcontroller

### setPlatform

    public void setPlatform(Platform p)

  The `setPlatform()` method sets the platform instance for this microcontroller

  Specified by:
    `setPlatform` in interface `Microcontroller`
  Parameters:
    `p` - the platform instance associated with this microcontroller

### addPin

    public static void addPin(java.util.HashMap pinMap,
                              int p,
                              java.lang.String n)

### addPin

    public static void addPin(java.util.HashMap pinMap,
                              int p,
                              java.lang.String n1,
                              java.lang.String n2)

### addPin

    public static void addPin(java.util.HashMap pinMap,
                              int p,
                              java.lang.String n1,
                              java.lang.String n2,
                              java.lang.String n3)

### addInterrupt

    public static void addInterrupt(java.util.HashMap iMap,
                                    java.lang.String n,
                                    int i)

### getPin

    public Microcontroller.Pin getPin(java.lang.String n)

  The `getPin()` method looks up the named pin and returns a reference to that pin. Names of pins should be UPPERCASE. The intended users of this method are external device implementors which connect their devices to the microcontroller through the pins.

  Specified by:
    `getPin` in interface `Microcontroller`
  Parameters:
    `n` - the name of the pin; for example "PA0" or "OC1A"
  Returns:
    a reference to the `Pin` object corresponding to the named pin if it exists; null otherwise

### getPinNumber

    public int getPinNumber(java.lang.String n)

  The `getPinNumber()` method gets the pin number (according to the pin assignments) for the pin with the specified name.

  Specified by:
    `getPinNumber` in interface `Microcontroller`
  Parameters:
    `n` - the name of the pin as a string
  Returns:
    the number of the pin if it exists

### getProperties

    public MicrocontrollerProperties getProperties()

  The `getProperties()` method gets a reference to the microcontroller properties for this microcontroller instance.

  Specified by:
    `getProperties` in interface `Microcontroller`
  Returns:
    a reference to the microcontroller properties for this instance

### getClockDomain

    public ClockDomain getClockDomain()

  The `getClockDomain()` method gets a reference to the `ClockDomain` instance for this node that contains the main clock and any derived clocks for this microcontroller.

  Specified by:
    `getClockDomain` in interface `Microcontroller`
  Returns:
    a reference to the clock domain for this microcontroller

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD