avrora.sim.mcu
Interface Microcontroller

All Known Implementing Classes:
AtmelMicrocontroller

public interface Microcontroller

The Microcontroller interface corresponds to a hardware device that implements the AVR instruction set. This interface contains methods that get commonly needed information about the particular hardware device and and can load programs onto this virtual device.


Nested Class Summary
static class Microcontroller.InputPin
           
static class Microcontroller.OutputPin
           
static interface Microcontroller.Pin
          The Pin interface encapsulates the notion of a physical pin on the microcontroller chip.
 
Method Summary
 double cyclesToMillis(long cycles)
          The cyclesToMillis() method converts the specified number of cycles to a time quantity in milliseconds.
 ClockDomain getClockDomain()
          The getClockDomain() method returns the clock domain for this microcontroller.
 long getHZ()
          The getHZ() method returns the number of cycles per second at which this hardware device is designed to run.
 byte getMode()
          Deprecated. this method should no longer be used; eventually this state information should be exposed through a FiniteStateMachine object
 java.lang.String getModeName()
          Deprecated. this method should no longer be used; eventually this state information should be exposed through a FiniteStateMachine object
 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 name)
          The getPin() method looks up the named pin and returns a reference to that pin.
 int getPinNumber(java.lang.String name)
          The getPinNumber() method looks up the named pin and returns its number.
 Platform getPlatform()
          The getPlatform() method gets a platform instance that contains this microcontroller.
 MicrocontrollerProperties getProperties()
          The getProperties() method gets an object that describes the microcontroller including the size of the RAM, EEPROM, flash, etc.
 RegisterSet getRegisterSet()
          The getRegisterSet() method returns the register set containing all of the IO registers for this microcontroller.
 Simulator getSimulator()
          The getSimulator() method gets a simulator instance that is capable of emulating this hardware device.
 boolean isSupported(InstrPrototype i)
          The isSupported() method allows a client to query whether a particular instruction is implemented on this hardware device.
 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 that contains this microcontroller.
 void sleep()
          The sleep() method puts the microcontroller into the sleep mode defined by its internal sleep configuration register.
 int wakeup()
          The wakeup() method wakes the microcontroller from a sleep mode.
 

Method Detail

getSimulator

public Simulator getSimulator()
The getSimulator() method gets a simulator instance that is capable of emulating this hardware device.

Returns:
a Simulator instance corresponding to this device

getPlatform

public Platform getPlatform()
The getPlatform() method gets a platform instance that contains this microcontroller.

Returns:
the platform instance containing this microcontroller, if it exists; null otherwise

setPlatform

public void setPlatform(Platform p)
The setPlatform() method sets the platform instance that contains this microcontroller.


getPin

public Microcontroller.Pin getPin(java.lang.String name)
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.

Parameters:
name - 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

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.

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

sleep

public void sleep()
The sleep() method puts the microcontroller into the sleep mode defined by its internal sleep configuration register. It may shutdown devices and disable some clocks. This method should only be called from within the interpreter.


wakeup

public int wakeup()
The wakeup() method wakes the microcontroller from a sleep mode. It may resume devices, turn clocks back on, etc. This method is expected to return the number of cycles that is required for the microcontroller to wake completely from the sleep state it was in.

Returns:
cycles required to wake from the current sleep mode

getMode

public byte getMode()
Deprecated. this method should no longer be used; eventually this state information should be exposed through a FiniteStateMachine object

get the current mode of the mcu

Returns:
current mode

getModeName

public java.lang.String getModeName()
Deprecated. this method should no longer be used; eventually this state information should be exposed through a FiniteStateMachine object

get the name of the current mode

Returns:
name of the current mode

getHZ

public long getHZ()
The getHZ() method returns the number of cycles per second at which this hardware device is designed to run.

Returns:
the number of cycles per second on this device

getClockDomain

public ClockDomain getClockDomain()
The getClockDomain() method returns the clock domain for this microcontroller. The clock domain contains all of the clocks attached to the microcontroller and platform, including the main clock.

Returns:
an instance of the ClockDomain class representing the clock domain for this microcontroller

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.

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.

Parameters:
cycles - the number of cycles
Returns:
the same time quantity in milliseconds

getRegisterSet

public RegisterSet getRegisterSet()
The getRegisterSet() method returns the register set containing all of the IO registers for this microcontroller.

Returns:
a reference to the RegisterSet instance which stores all of the IO registers for this microcontroller.

isSupported

public boolean isSupported(InstrPrototype i)
The isSupported() method allows a client to query whether a particular instruction is implemented on this hardware device. Older implementations of the AVR instruction set preceded the introduction of certain instructions, and therefore did not support the new instructions.

Parameters:
i - the instruction prototype of the instruction
Returns:
true if the specified instruction is supported on this device; false otherwise

getPinNumber

public int getPinNumber(java.lang.String name)
The getPinNumber() method looks up the named pin and returns its number. 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.

Parameters:
name - the name of the pin; for example "PA0" or "OC1A"
Returns:
the number of the pin if it exists; -1 otherwise

getProperties

public MicrocontrollerProperties getProperties()
The getProperties() method gets an object that describes the microcontroller including the size of the RAM, EEPROM, flash, etc.

Returns:
an instance of the MicrocontrollerProperties class that contains all the relevant information about this microcontroller