Download AN781A

Transcript
when(msg_fails) {
if(image_state == load_info) image_ptr = last_image_ptr;
load_image = 1;
}
when(msg_succeeds(write_image)) {
io_out(lamp,10000);
// indicate received an ACK if using ACK, or
// finished sending packet for UNACK
switch(image_state) {
case set_offline:
case set_appless:
case set_config:
case recalculate_cs:
case set_online:
image_state++;
load_image = 100; // time given until next operation
break;
case load_info:
if(((long unsigned) image_ptr) >=
(( *(const long unsigned *) &codedata) +
( (long unsigned) &codedata))) { // check for end of table
image_state++; // This is the next step in the procedure
// after loading data (i.e. load_info).
}
else block_number++;
load_image = 100;
// time given until next operation
break;
case final_reset:
//installation complete;
io_out(error_status, 0xc); // LED code for finished programming
// add code here if want to change the communication parameters.
// ...
break;
}
}
when(msg_arrives) {
}
when(resp_arrives( response_image )) {
io_out(lamp,10000);
// indicate received an ACK if using ACK, or
// finished sending packet for UNACK
switch(image_state) {
case clear_status: // clear out Neuron Chip errors
image_state++;
load_image = 1;
break;
case ck_firmware_ver: // must be same as FIRMWARE_VERSION
if(resp_in.data[0] == FIRMWARE_VERSION) { // correct version
image_state++;
load_image = 1;
break;
} // must be same as FIRMWARE_VERSION
else { // wrong firmware version to program
io_out(error_status, 0x0); // LED code for wrong firmwre ver.
wrongVersion = LEDflashTime;
// time to flash LEDs
// application_restart(); // do not restart application
// because want to show error code
load_image = 0; // stop timer so not to do next operation
MOTOROLA LONWORKS TECHNOLOGY
AN1251
AL–127