User`s guide

KwikNet Sample Program Architecture
K
A
DAK
E - 7
KwikNet
Porting Kit Sample Program - Single Threaded Operation
When the KwikNet Porting Kit is used with a single threaded operating system (OS), 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 OS 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 assumes its App-Task role and calls function
app_enter(), the entry point to the main body of the sample program.
The App-Task starts KwikNet with a call to KwikNet procedure kn_enter(). KwikNet
initializes all of its private resources and starts the KwikNet Task which prepares all
network interfaces and their associated device drivers for use.
If the App-Task provides an interactive user interface, the console driver is initialized
with a call to procedure knconinit(). Thereafter, the App-Task orchestrates the
sequence of network operations it is designed to illustrate.
The termination process is handled by the App-Task. If the console driver was in use, it
is closed with a call to
knconexit(). KwikNet is stopped with a call to kn_exit(). After
a brief pause to allow
KwikNet to stop, the OS is forced to shut down with a call to
sam_osshutdown(). Rarely is any termination processing performed by this function.
The App-Task procedure app_enter() returns to the main() function from which it was
called. One final call to procedure kn_osfinish() in your KwikNet OS Interface Module
KN_OSIF.C (in the KwikNet Library) breaks the connection between KwikNet and your OS.
In many cases, procedure
kn_osfinish() will also stop your KwikNet clock driver with a
call to its termination procedure
kn_uclockexit().