发表于:2002-12-25 10:33:00
1楼
#include <access.h>
#include <control.h>
network output unsigned int nvoTest;
network input unsigned int nviTest;
msg_tag TAG_Test;
domain_struct domain_copy;
address_struct address_copy;
nv_struct nv_copy;
when(reset)
{
/*domain table setting */
domain_copy=*(access_domain(0));
domain_copy .id[0]=0;
domain_copy .subnet=2;
domain_copy .node=127;
domain_copy .len=0;
update_domain(&domain_copy,0);
/* address table seeting */
address_copy = *(access_address(addr_table_index(TAG_Test)));
address_copy.sn.type = SUBNET_NODE;
address_copy.sn.domain = 0;
address_copy.sn.node = 126;
address_copy.sn.rpt_timer = 0;
address_copy.sn.retry = 1;
address_copy.sn.tx_timer = 5;
address_copy.sn.subnet = 2;
update_address (&address_copy,addr_table_index(TAG_Test));
/* NV table setting */
nv_copy = *(access_nv(nv_table_index(nvoTest)));
nv_copy.nv_selector_hi =1;
nv_copy.nv_selector_lo =0;
nv_copy.nv_addr_index = (addr_table_index(TAG_Test)); // In this point you connect the NV with the TAG
update_nv(&nv_copy, nv_table_index (nvoTest));
nv_copy = *(access_nv(nv_table_index(nviTest)));
nv_copy.nv_selector_hi =2;
nv_copy.nv_selector_lo =0;
nv_copy.nv_addr_index = (addr_table_index(TAG_Test)); // In this point you connect the NV with the TAG
update_nv(&nv_copy, nv_table_index (nviTest));
}
stimer repeating t_timer=1;
when(timer_expires(t_timer))
{ nvoTest++;}
unsigned int counter;
when(nv_update_occurs)
{ counter++;}