|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object avrora.sim.mcu.AtmelMicrocontroller
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 |
public final long HZ
protected final Microcontroller.Pin[] pins
protected final MainClock mainClock
protected final RegisterSet registers
protected Platform platform
protected Simulator simulator
protected BaseInterpreter interpreter
protected Simulator.Printer pinPrinter
public final MicrocontrollerProperties properties
protected final ClockDomain clockDomain
protected final java.util.HashMap devices
public static final int MODE_ACTIVE
protected final FiniteStateMachine sleepState
Constructor Detail |
protected AtmelMicrocontroller(ClockDomain cd, MicrocontrollerProperties p, FiniteStateMachine fsm)
Method Detail |
public void sleep()
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.
sleep
in interface Microcontroller
Microcontroller.sleep()
protected abstract int getSleepMode()
public int wakeup()
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.
wakeup
in interface Microcontroller
Microcontroller.wakeup()
public byte getMode()
getMode()
method returns the current sleep mode of the MCU.
getMode
in interface Microcontroller
Microcontroller.getMode()
public java.lang.String getModeName()
getModeName
in interface Microcontroller
public FiniteStateMachine getFSM()
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.
public RegisterSet getRegisterSet()
getRegisterSet()
method gets a reference to the register set of the microcontroller.
The register set contains all of the IO registers for this microcontroller.
getRegisterSet
in interface Microcontroller
public long millisToCycles(double ms)
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.
millisToCycles
in interface Microcontroller
ms
- a time quantity in milliseconds as a double
public double cyclesToMillis(long cycles)
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.
cyclesToMillis
in interface Microcontroller
cycles
- the number of cycles
public Microcontroller.Pin getPin(int num)
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.
getPin
in interface Microcontroller
num
- the pin number to look up
Pin
object corresponding to the named pin if it exists; null
otherwiseprotected void installIOReg(java.lang.String name, ActiveRegister reg)
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.
name
- the name of the IO register as a stringreg
- the register to installprotected ActiveRegister getIOReg(java.lang.String name)
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.
name
- the name of the IO register as a string
protected void addDevice(AtmelInternalDevice d)
addDevice()
method adds a new internal device to this microcontroller so that it can
be retrieved later with getDevice()
d
- the device to add to this microcontrollerpublic AtmelInternalDevice getDevice(java.lang.String name)
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.
name
- the name of the internal device as a string
java.util.NoSuchElementException
- if no device with that name existspublic Clock getClock(java.lang.String name)
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.
name
- the name of the clock to get
Clock
instance for the specified clock if it existspublic Simulator getSimulator()
getSimulator()
method gets a reference to the simulator for this microcontroller instance.
getSimulator
in interface Microcontroller
public Platform getPlatform()
getPlatform()
method returns the platform for this microcontroller.
getPlatform
in interface Microcontroller
public void setPlatform(Platform p)
setPlatform()
method sets the platform instance for this microcontroller
setPlatform
in interface Microcontroller
p
- the platform instance associated with this microcontrollerpublic static void addPin(java.util.HashMap pinMap, int p, java.lang.String n)
public static void addPin(java.util.HashMap pinMap, int p, java.lang.String n1, java.lang.String n2)
public static void addPin(java.util.HashMap pinMap, int p, java.lang.String n1, java.lang.String n2, java.lang.String n3)
public static void addInterrupt(java.util.HashMap iMap, java.lang.String n, int i)
public Microcontroller.Pin getPin(java.lang.String n)
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.
getPin
in interface Microcontroller
n
- the name of the pin; for example "PA0" or "OC1A"
Pin
object corresponding to the named pin if it exists; null
otherwisepublic int getPinNumber(java.lang.String n)
getPinNumber()
method gets the pin number (according to the pin assignments) for the
pin with the specified name.
getPinNumber
in interface Microcontroller
n
- the name of the pin as a string
public MicrocontrollerProperties getProperties()
getProperties()
method gets a reference to the microcontroller properties for this
microcontroller instance.
getProperties
in interface Microcontroller
public ClockDomain getClockDomain()
getClockDomain()
method gets a reference to the ClockDomain
instance for
this node that contains the main clock and any derived clocks for this microcontroller.
getClockDomain
in interface Microcontroller
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |