May
2004, Issue 166
Embedded
Java Controllers
JAVA
PACKAGES
Because
an aJile processor is a microcontroller, you need access
to the low-level parts of the controller. Just as it
is necessary to use low-level registers on standard
microcontrollers, it is necessary to do the same with
the aJile processors. Hence, aJile wrote a number of
packages to deal with the controller at the device level.
The
com.ajile.components package contains various hardware
components, including timers, triggers, and debounced
buttons. com.ajile.events includes events specific to
the aJile processors. The com.ajile.io package adds
BufferedInputStream, BufferedOutputStream, and BufferedReader
to the CLDC java.io package.
com.ajile.jem
is the lowest level package. By using the rawJEM class,
you can deal with memory locations and registers. The
package also contains the PeriodicThread and PianoRoll
classes, which are used later in this article.
Because
the CLDC doesn’t include the Float, Double, and Math
classes, they are added in com.ajile.lang, along with
some Error classes. com.ajile. drivers.irq is the interrupt
handler framework. The com.ajile.drivers.flash package
contains the methods needed to read and write directly
to the flash memory of the JStamp/JStik.
I
find the com.ajile.drivers.gpio package to be the most
useful. It is used to deal with low-level I/O ports
and pins via high-level objects.
The
com.ajile.drivers.gptc package is used to access the
general-purpose timer/counters and the waveform module.
The waveform module is a low-level part of the aJile
chip, which can be used to generate arbitrary digital
waveforms.
com.ajile.drivers.i2c
has a driver to communicate via I2C. com.ajile.drivers.
rtc.DS1305 provides support for the internal real-time
clock chip, while com.ajile.drivers.RX5C62 provides
support for the calendar chip.
com.ajile.drivers.spi
has a driver to communicate via SPI. The com.ajile.file
system package supports the accessing of the file systems
available to the aJile chips. (Currently, these are
only flash memory file systems.)
com.ajile.bootloader is an interface that allows a program
to be loaded into a separate JVM. com.ajile.util contains
a class, PropUtils, which allows access to system properties.
com.ajile.microedition.io contains the MemoryEfficientConnector
class. This is an implementation of the java.microedition.io
connector interface. com.ajile.net.util is a package
containing network utility classes. com.ajile.net.dns
provides basic access to domain name service. And, finally,
note that com.ajile.net.sntp is a package for dealing
with the simple network time protocol.
In
order to have the advantages of preemptive threading,
aJile, which wrote the Java libraries and tools for
these controllers, has provided the PeriodicThread class
to allow fully preemptive threading for time-critical
items. The PeriodicThread can be a bit tricky to use
until you get the hang of it. It uses the PianoRoll
feature of the controller in order to run the PeriodicThread
at intervals.