User`s guide
KwikNet Sample Program Architecture
K
A
DAK
E - 5
KwikNet
Porting Kit Sample Program - Multitasking Operation
When the KwikNet Porting Kit is used with a multitasking RTOS, 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 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 your KwikNet OS Interface Module
KN_OSIF.C (in the KwikNet Library) to initialize your 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. In many cases,
procedure kn_osprep() will also start your KwikNet clock driver with a call to its
initialization procedure kn_uclockinit().
Finally, the main() procedure starts your RTOS to run the multitasking sample program.
In the example provided with the KwikNet Porting Kit, the RTOS creates a startup task
which is executed by the RTOS as it begins operation. The startup task is located at entry
point sam_osmain() in the Application OS Interface module KNSAMOS.C.
Once the RTOS is ready, it executes the startup task procedure sam_osmain(). Task
services in the Application OS Interface module are used to create and start 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.