User`s guide
KwikNet Sample Program Architecture
K
A
DAK
E - 3
KwikNet
Sample Program Operation with AMX
When KwikNet is used with AMX, the KwikNet sample programs operate as follows. Once
your board level initialization is complete and the C startup code has been executed, the
sample program begins execution at
main() in the Application OS Interface module
KNSAMOS.C.
The main program makes a series of calls to initialize the various components which
make up the sample program. Your AMX board support function chbrdinit() is called
to set up the hardware environment for AMX use. KwikNet board driver procedure
kn_brdreset() is called to initialize its interrupt support for all KwikNet device drivers.
The
KwikNet message recording interface is initialized with a call to kn_loginit(). If
the console driver has been configured for use as the recording device, procedure
kn_loginit() calls console driver procedure kncon_logprep() to prepare it
accordingly.
Next, the main() procedure calls kn_osprep() in the KwikNet OS Interface Module
KN_OSIF.C (in the KwikNet Library) to initialize the RTOS interface. Since this procedure
initializes the KwikNet data logging service, KwikNet procedure kn_dprintf() can be used
by the sample program even before KwikNet is started.
Finally, the main() procedure launches AMX to start the multitasking sample program.
Once AMX is ready, it calls the KwikNet Restart Procedure kn_osready() in the
KwikNet OS Interface Module KN_OSIF.C (in the KwikNet Library) to initialize the AMX
resources required by KwikNet and to prepare the memory allocation subsystem for use by
KwikNet and your application.
AMX then calls the application Restart Procedure rrproc() in the Application OS
Interface module KNSAMOS.C to start the KwikNet sample program as an AMX application.
The AMX clock driver is initialized with a call to procedure chclockinit(). Task
services in the Application OS Interface module are then used to create and start a low
priority background task (procedure backg_task()) which provides a simulated software
clock in case a real hardware clock is unavailable and an AMX clock driver has not been
linked with the sample program.
Next, Restart Procedure rrproc() starts the sample program's print task, a task used by
some sample programs to log messages on the console device. Finally, procedure
app_prep() in the sample program module is called to prepare all application level
components needed by the sample program.
Every
KwikNet sample program provides function app_prep() as its advance preparation
entry point. This procedure creates and starts one or more application tasks which
collectively make up the sample program. One of these tasks, usually called the client
task, is the task in charge of the sequence of operations performed by the sample
program. For example, the client task often provides a user command line console
interface which allows you to interactively control sample program activities.