Digital sensor example – Echelon Mini EVK User Manual

Page 65

Advertising
background image

network. Developing an application using the Neuron ISI library is described

in the ISI Programmer’s Guide.

Digital Sensor Example

The following example application adds ISI support to the previous digital sensor

example. The network variable output will automatically connect to all digital

actuators offering connections in the network. The ISI code is highlighted in
bold.

#pragma enable_sd_nv_names
#pragma num_alias_table_entries 2

#include <isi.h>

// Define the device interface
network input SCPTlocation cp cpLocation = {"Unknown"};
#pragma ignore_notused cpLocation
network output SNVT_switch nvoSwitch;

fblock SFPTswitch {

nvoSwitch implements nvoSwitch;

} fbSwitch external_name("Switch");

// Configure the I/O pins
IO_4 input bitshift numbits(8) clockedge(-) ioButtons;
IO_6 output bit ioButtonLd = 1;

// Start the ISI engine
when(reset) {
IsiStartS(isiFlagNone);
}

// Process ISI Messages
when(msg_arrives) {
if (IsiApproveMsg()) {
(void) IsiProcessMsgS();
}
}


// Read the MiniGizmo buttons
boolean GetButton(void) {
// Latch the button inputs
io_out(ioButtonLd, 0);
io_out(ioButtonLd, 1);

// Shift in and return TRUE if any buttons are pressed
return !((unsigned) io_in(ioButtons) == 0xFF);
}

// Repeat every 50 milliseconds
mtimer repeating scanTimer = 50;

// Read the buttons when the timer expires
when(timer_expires(scanTimer)) {
boolean button;
static boolean lastButton;

button = GetButton();
if (button != lastButton) {
lastButton = button;
nvoSwitch.value = button ? 200U : 0;

Mini EVK User’s Guide

59

Advertising