Echelon Mini FX User Manual

Page 107

Advertising
background image

94 Developing

Device

Applications

// uses the PL 3170 Smart Transceiver, and use IsiCompactS.lib for
// devices using an FT 3120 or PL 3120 Smart Transceiver.
//
#include <isi.h>
#pragma library "$STD$\IsiFull.lib"

//
// Reset Processing
//
// The when(reset) task executes when the device resets. To control
// the ISI engine start-up, or to prevent the ISI engine from starting,
// reset processing contains the following logic:
// a) If this is the first reset with a new application image, the reset
// code sets nciNetConfig to CFG_LOCAL. This allows the ISI engine to
// start on a brand new device.
// The initial value of CFG_NUL of the local, persistent, OldNwrkCnfg
// variable is used to detect the first start.
// b) If nciNetConfig is set to CFG_LOCAL but the previous value is
// CFG_EXTERNAL (determined by the tracking variable OldNetConfig),
// the device returns itself to factory defaults.
// c) If nciNetConfig is set to CFG_LOCAL, the ISI engine starts
eeprom SCPTnwrkCnfg oldNetConfig = CFG_NUL;

when(reset) {
SCPTnwrkCnfg networkConfig;

// Prepare the ISI engine. This call is required before starting the
// ISI engine, and should be made under all circumstances.
IsiPreStart();

networkConfig = oldNetConfig;

if (networkConfig == CFG_NUL) {
// For the first application start, set nciNetConfig to CFG_LOCAL,
// allowing the ISI engine to run by default:
nciNetConfig = CFG_LOCAL;
}
oldNetConfig = nciNetConfig;

if (nciNetConfig == CFG_LOCAL) {
if (networkConfig == CFG_EXTERNAL) {
// The application has just returned into the self-installed
// environment. Make sure to re-initialize the ISI engine:
IsiReturnToFactoryDefaults(); // This call resets the device
}
// We are in a self-installed network, so let's start:
IsiStartS(isiFlagNone);
}

InitializeIO();

LcdDisplayString(0,0, "Simple ISI Example");
LcdDisplayString(1,0, "-+-+-+-+-+-+-+-+-+-+");
}

mtimer repeating isiTick = 1000ul / ISI_TICKS_PER_SECOND;

void SignalIsiState(void);

when(timer_expires(isiTick)) {
IsiTickS();
SignalIsiState();
}

when(msg_arrives) {
if (IsiApproveMsg()) {
if (IsiProcessMsgS()) {
// TODO: process unprocessed ISI messages here (if any)
;
}
} else {

Advertising