app.c
上传用户:joranyuan
上传日期:2022-06-23
资源大小:3306k
文件大小:323k
源码类别:

网络

开发平台:

Others

  1.   3 << 1)) | (1 << 0);
  2.   CC1000ControlM$gCurrentParameters[0x11] = ((5 << 4) | (1 << 2)) | (
  3.   1 << 0);
  4.   CC1000ControlM$cc1000SetModem();
  5.   CC1000ControlM$gCurrentParameters[0x13] = 1 << 0;
  6.   CC1000ControlM$HPLChipcon$write(0x13, CC1000ControlM$gCurrentParameters[0x13]);
  7.   CC1000ControlM$gCurrentParameters[0x1e] = TRUE;
  8.   CC1000ControlM$CC1000Control$TunePreset(0x00);
  9.   return SUCCESS;
  10. }
  11. # 63 "/home/testuser/tinyos-1.x/tos/interfaces/StdControl.nc"
  12. inline static  result_t CC1000RadioIntM$CC1000StdControl$init(void){
  13. #line 63
  14.   unsigned char result;
  15. #line 63
  16. #line 63
  17.   result = CC1000ControlM$StdControl$init();
  18. #line 63
  19. #line 63
  20.   return result;
  21. #line 63
  22. }
  23. #line 63
  24. # 143 "../../tos/platform/mica2/hardware.h"
  25. static __inline void TOSH_MAKE_MOSI_INPUT(void)
  26. #line 143
  27. {
  28. #line 143
  29.   * (volatile uint8_t *)(0x17 + 0x20) &= ~(1 << 2);
  30. }
  31. static __inline void TOSH_MAKE_SPI_SCK_INPUT(void)
  32. #line 146
  33. {
  34. #line 146
  35.   * (volatile uint8_t *)(0x17 + 0x20) &= ~(1 << 1);
  36. }
  37. static inline   
  38. # 90 "../../tos/platform/mica2/HPLSpiM.nc"
  39. result_t HPLSpiM$SpiByteFifo$initSlave(void)
  40. #line 90
  41. {
  42.   { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
  43. #line 91
  44.     {
  45.       TOSH_MAKE_SPI_SCK_INPUT();
  46.       TOSH_MAKE_MISO_INPUT();
  47.       TOSH_MAKE_MOSI_INPUT();
  48.       * (volatile uint8_t *)(0x0D + 0x20) &= ~(1 << 3);
  49.       * (volatile uint8_t *)(0x0D + 0x20) &= ~(1 << 2);
  50.       * (volatile uint8_t *)(0x0D + 0x20) |= 1 << 7;
  51.       * (volatile uint8_t *)(0x0D + 0x20) |= 1 << 6;
  52.     }
  53. #line 99
  54.     __nesc_atomic_end(__nesc_atomic); }
  55.   return SUCCESS;
  56. }
  57. # 38 "../../tos/platform/mica2/SpiByteFifo.nc"
  58. inline static   result_t CC1000RadioIntM$SpiByteFifo$initSlave(void){
  59. #line 38
  60.   unsigned char result;
  61. #line 38
  62. #line 38
  63.   result = HPLSpiM$SpiByteFifo$initSlave();
  64. #line 38
  65. #line 38
  66.   return result;
  67. #line 38
  68. }
  69. #line 38
  70. static inline  
  71. # 648 "../../tos/platform/mica2/CC1000RadioIntM.nc"
  72. result_t CC1000RadioIntM$StdControl$init(void)
  73. #line 648
  74. {
  75.   char i;
  76.   ecnMsgType *ecnMsgPtr = (ecnMsgType *)CC1000RadioIntM$ecnMsgHdr.data;
  77. #line 651
  78.   { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
  79. #line 651
  80.     {
  81.       CC1000RadioIntM$RadioState = CC1000RadioIntM$DISABLED_STATE;
  82.       CC1000RadioIntM$RadioTxState = CC1000RadioIntM$TXSTATE_PREAMBLE;
  83.       CC1000RadioIntM$rxbufptr = &CC1000RadioIntM$RxBuf;
  84.       CC1000RadioIntM$rxbufptr->length = 0;
  85.       CC1000RadioIntM$rxlength = MSG_DATA_SIZE - 2;
  86.       CC1000RadioIntM$RxBitOffset = 0;
  87.       CC1000RadioIntM$iSquelchCount = 0;
  88.       CC1000RadioIntM$PreambleCount = 0;
  89.       CC1000RadioIntM$RSSISampleFreq = 0;
  90.       CC1000RadioIntM$RxShiftBuf.W = 0;
  91.       CC1000RadioIntM$iRSSIcount = 0;
  92.       CC1000RadioIntM$bTxPending = FALSE;
  93.       CC1000RadioIntM$bTxBusy = FALSE;
  94.       CC1000RadioIntM$bRSSIValid = FALSE;
  95.       CC1000RadioIntM$bAckEnable = FALSE;
  96.       CC1000RadioIntM$bCCAEnable = TRUE;
  97.       CC1000RadioIntM$CC1K_PulseLevel = 300;
  98.       CC1000RadioIntM$sMacDelay = -1;
  99.       CC1000RadioIntM$usRSSIVal = -1;
  100.       CC1000RadioIntM$usSquelchIndex = 0;
  101.       CC1000RadioIntM$pulse_check_count = 0;
  102.       CC1000RadioIntM$lplpower = 0;
  103.       CC1000RadioIntM$RSSIInitState = CC1000RadioIntM$NULL_STATE;
  104.       CC1000RadioIntM$usSquelchVal = 0x120;
  105.       CC1000RadioIntM$currentMAC = CC1000RadioIntM$BMAC;
  106.       CC1000RadioIntM$congBackOffs = 0;
  107.       CC1000RadioIntM$packetsSent = 0;
  108.       CC1000RadioIntM$pktsLastSync = 0;
  109.       CC1000RadioIntM$avgLoss = 0.0;
  110.       CC1000RadioIntM$curHCLlist = 0;
  111.       CC1000RadioIntM$globalFrameLength = 32;
  112.       CC1000RadioIntM$localFrameLength = 32;
  113.       CC1000RadioIntM$slotSize = 50;
  114.       CC1000RadioIntM$localFrameSize = CC1000RadioIntM$localFrameLength * CC1000RadioIntM$slotSize;
  115.       CC1000RadioIntM$globalFrameSize = CC1000RadioIntM$globalFrameLength * CC1000RadioIntM$slotSize;
  116.       CC1000RadioIntM$ackOrig = CC1000RadioIntM$bAckEnable;
  117.       CC1000RadioIntM$ecnPending = FALSE;
  118.       CC1000RadioIntM$ecnforward = FALSE;
  119.       CC1000RadioIntM$enableHCL = FALSE;
  120.       CC1000RadioIntM$pureHCL = FALSE;
  121.       CC1000RadioIntM$HCLselect = 1;
  122.       CC1000RadioIntM$needTimeSync = FALSE;
  123.       CC1000RadioIntM$slots_since_ecnsend = 0;
  124.       CC1000RadioIntM$slots_since_ecnrecv = 0;
  125.       CC1000RadioIntM$slots_since_ecncheck = 0;
  126.       CC1000RadioIntM$ecnMsgHdr.type = 222;
  127.       CC1000RadioIntM$ecnMsgHdr.addr = TOS_BCAST_ADDR;
  128.       CC1000RadioIntM$ecnMsgHdr.length = sizeof(ecnMsgType );
  129.       CC1000RadioIntM$ecnMsgHdr.group = 125;
  130.       CC1000RadioIntM$ecnMsgHdr.crc = 0;
  131.       CC1000RadioIntM$ecnForwardMsgHdr.type = 222;
  132.       CC1000RadioIntM$ecnForwardMsgHdr.addr = TOS_BCAST_ADDR;
  133.       CC1000RadioIntM$ecnForwardMsgHdr.length = sizeof(ecnMsgType );
  134.       CC1000RadioIntM$ecnForwardMsgHdr.group = 125;
  135.       CC1000RadioIntM$ecnForwardMsgHdr.crc = 0;
  136.       CC1000RadioIntM$syncMsgHdr.type = 223;
  137.       CC1000RadioIntM$syncMsgHdr.addr = TOS_BCAST_ADDR;
  138.       CC1000RadioIntM$syncMsgHdr.length = sizeof(syncMsgType );
  139.       CC1000RadioIntM$syncMsgHdr.group = 125;
  140.       CC1000RadioIntM$syncMsgHdr.crc = 0;
  141.       ecnMsgPtr->hopCount = 0;
  142.       ecnMsgPtr->nextHop = CC1000RadioIntM$nextHop;
  143.       ecnMsgPtr->senderAddress = TOS_LOCAL_ADDRESS;
  144.     }
  145. #line 727
  146.     __nesc_atomic_end(__nesc_atomic); }
  147.   for (i = 0; i < 9; i++) 
  148.     CC1000RadioIntM$usSquelchTable[(int )i] = 0x120;
  149.   CC1000RadioIntM$SpiByteFifo$initSlave();
  150.   CC1000RadioIntM$CC1000StdControl$init();
  151.   CC1000RadioIntM$CC1000Control$SelectLock(0x9);
  152.   CC1000RadioIntM$bInvertRxData = CC1000RadioIntM$CC1000Control$GetLOStatus();
  153.   CC1000RadioIntM$ADCControl$bindPort(TOS_ADC_CC_RSSI_PORT, TOSH_ACTUAL_CC_RSSI_PORT);
  154.   CC1000RadioIntM$ADCControl$init();
  155.   CC1000RadioIntM$Random$init();
  156.   CC1000RadioIntM$TimerControl$init();
  157.   CC1000RadioIntM$LocalAddr = TOS_LOCAL_ADDRESS;
  158.   return SUCCESS;
  159. }
  160. # 63 "/home/testuser/tinyos-1.x/tos/interfaces/StdControl.nc"
  161. inline static  result_t AMPromiscuous$RadioControl$init(void){
  162. #line 63
  163.   unsigned char result;
  164. #line 63
  165. #line 63
  166.   result = CC1000RadioIntM$StdControl$init();
  167. #line 63
  168. #line 63
  169.   return result;
  170. #line 63
  171. }
  172. #line 63
  173. static inline  
  174. # 60 "/home/testuser/tinyos-1.x/tos/system/UARTM.nc"
  175. result_t UARTM$Control$init(void)
  176. #line 60
  177. {
  178.   {
  179.   }
  180. #line 61
  181.   ;
  182.   { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
  183. #line 62
  184.     {
  185.       UARTM$state = FALSE;
  186.     }
  187. #line 64
  188.     __nesc_atomic_end(__nesc_atomic); }
  189.   return SUCCESS;
  190. }
  191. # 63 "/home/testuser/tinyos-1.x/tos/interfaces/StdControl.nc"
  192. inline static  result_t FramerM$ByteControl$init(void){
  193. #line 63
  194.   unsigned char result;
  195. #line 63
  196. #line 63
  197.   result = UARTM$Control$init();
  198. #line 63
  199. #line 63
  200.   return result;
  201. #line 63
  202. }
  203. #line 63
  204. static inline  
  205. # 291 "/home/testuser/tinyos-1.x/tos/system/FramerM.nc"
  206. result_t FramerM$StdControl$init(void)
  207. #line 291
  208. {
  209.   FramerM$HDLCInitialize();
  210.   return FramerM$ByteControl$init();
  211. }
  212. # 63 "/home/testuser/tinyos-1.x/tos/interfaces/StdControl.nc"
  213. inline static  result_t AMPromiscuous$UARTControl$init(void){
  214. #line 63
  215.   unsigned char result;
  216. #line 63
  217. #line 63
  218.   result = FramerM$StdControl$init();
  219. #line 63
  220. #line 63
  221.   return result;
  222. #line 63
  223. }
  224. #line 63
  225. inline static  result_t AMPromiscuous$TimerControl$init(void){
  226. #line 63
  227.   unsigned char result;
  228. #line 63
  229. #line 63
  230.   result = TimerM$StdControl$init();
  231. #line 63
  232. #line 63
  233.   return result;
  234. #line 63
  235. }
  236. #line 63
  237. static inline  
  238. # 92 "/home/testuser/tinyos-1.x/tos/system/AMPromiscuous.nc"
  239. result_t AMPromiscuous$Control$init(void)
  240. #line 92
  241. {
  242.   result_t ok1;
  243. #line 93
  244.   result_t ok2;
  245. #line 94
  246.   AMPromiscuous$TimerControl$init();
  247.   ok1 = AMPromiscuous$UARTControl$init();
  248.   ok2 = AMPromiscuous$RadioControl$init();
  249.   AMPromiscuous$state = FALSE;
  250.   AMPromiscuous$lastCount = 0;
  251.   AMPromiscuous$counter = 0;
  252.   AMPromiscuous$promiscuous_mode = FALSE;
  253.   AMPromiscuous$crc_check = TRUE;
  254.   {
  255.   }
  256. #line 102
  257.   ;
  258.   return rcombine(ok1, ok2);
  259. }
  260. # 63 "/home/testuser/tinyos-1.x/tos/interfaces/StdControl.nc"
  261. inline static  result_t MultiHopEngineM$CommStdControl$init(void){
  262. #line 63
  263.   unsigned char result;
  264. #line 63
  265. #line 63
  266.   result = AMPromiscuous$Control$init();
  267. #line 63
  268. #line 63
  269.   return result;
  270. #line 63
  271. }
  272. #line 63
  273. # 91 "/home/testuser/tinyos-1.x/tos/lib/MintRoute/MultiHopEngineM.nc"
  274. static void MultiHopEngineM$initialize(void)
  275. #line 91
  276. {
  277.   int n;
  278.   for (n = 0; n < MultiHopEngineM$FWD_QUEUE_SIZE; n++) {
  279.       MultiHopEngineM$FwdBufList[n] = &MultiHopEngineM$FwdBuffers[n];
  280.     }
  281.   MultiHopEngineM$iFwdBufHead = MultiHopEngineM$iFwdBufTail = 0;
  282. }
  283. static inline  result_t MultiHopEngineM$StdControl$init(void)
  284. #line 101
  285. {
  286.   MultiHopEngineM$initialize();
  287.   MultiHopEngineM$CommStdControl$init();
  288.   return MultiHopEngineM$SubControl$init();
  289. }
  290. # 63 "/home/testuser/tinyos-1.x/tos/interfaces/StdControl.nc"
  291. inline static  result_t RealMain$StdControl$init(void){
  292. #line 63
  293.   unsigned char result;
  294. #line 63
  295. #line 63
  296.   result = TimerM$StdControl$init();
  297. #line 63
  298.   result = rcombine(result, MultiHopEngineM$StdControl$init());
  299. #line 63
  300.   result = rcombine(result, TimerM$StdControl$init());
  301. #line 63
  302.   result = rcombine(result, MultiHopTtestM$StdControl$init());
  303. #line 63
  304. #line 63
  305.   return result;
  306. #line 63
  307. }
  308. #line 63
  309. static inline   
  310. # 149 "/home/testuser/tinyos-1.x/tos/platform/mica/HPLClock.nc"
  311. result_t HPLClock$Clock$setRate(char interval, char scale)
  312. #line 149
  313. {
  314.   scale &= 0x7;
  315.   scale |= 0x8;
  316.   { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
  317. #line 152
  318.     {
  319.       * (volatile uint8_t *)(0x37 + 0x20) &= ~(1 << 0);
  320.       * (volatile uint8_t *)(0x37 + 0x20) &= ~(1 << 1);
  321.       * (volatile uint8_t *)(0x30 + 0x20) |= 1 << 3;
  322.       * (volatile uint8_t *)(0x33 + 0x20) = scale;
  323.       * (volatile uint8_t *)(0x32 + 0x20) = 0;
  324.       * (volatile uint8_t *)(0x31 + 0x20) = interval;
  325.       * (volatile uint8_t *)(0x37 + 0x20) |= 1 << 1;
  326.     }
  327. #line 162
  328.     __nesc_atomic_end(__nesc_atomic); }
  329.   return SUCCESS;
  330. }
  331. # 96 "/home/testuser/tinyos-1.x/tos/interfaces/Clock.nc"
  332. inline static   result_t TimerM$Clock$setRate(char arg_0x882c878, char arg_0x882c9b8){
  333. #line 96
  334.   unsigned char result;
  335. #line 96
  336. #line 96
  337.   result = HPLClock$Clock$setRate(arg_0x882c878, arg_0x882c9b8);
  338. #line 96
  339. #line 96
  340.   return result;
  341. #line 96
  342. }
  343. #line 96
  344. # 128 "../../tos/platform/mica2/hardware.h"
  345. static __inline void TOSH_CLR_CC_PALE_PIN(void)
  346. #line 128
  347. {
  348. #line 128
  349.   * (volatile uint8_t *)(0x12 + 0x20) &= ~(1 << 4);
  350. }
  351. #line 126
  352. static __inline void TOSH_CLR_CC_PDATA_PIN(void)
  353. #line 126
  354. {
  355. #line 126
  356.   * (volatile uint8_t *)(0x12 + 0x20) &= ~(1 << 7);
  357. }
  358. #line 127
  359. static __inline void TOSH_CLR_CC_PCLK_PIN(void)
  360. #line 127
  361. {
  362. #line 127
  363.   * (volatile uint8_t *)(0x12 + 0x20) &= ~(1 << 6);
  364. }
  365. #line 126
  366. static __inline void TOSH_MAKE_CC_PDATA_INPUT(void)
  367. #line 126
  368. {
  369. #line 126
  370.   * (volatile uint8_t *)(0x11 + 0x20) &= ~(1 << 7);
  371. }
  372. #line 126
  373. static __inline int TOSH_READ_CC_PDATA_PIN(void)
  374. #line 126
  375. {
  376. #line 126
  377.   return (* (volatile uint8_t *)(0x10 + 0x20) & (1 << 7)) != 0;
  378. }
  379. # 63 "/home/testuser/tinyos-1.x/tos/interfaces/Random.nc"
  380. inline static   uint16_t MultiHopTtestM$Random$rand(void){
  381. #line 63
  382.   unsigned int result;
  383. #line 63
  384. #line 63
  385.   result = RandomLFSR$Random$rand();
  386. #line 63
  387. #line 63
  388.   return result;
  389. #line 63
  390. }
  391. #line 63
  392. # 59 "/home/testuser/tinyos-1.x/tos/interfaces/Timer.nc"
  393. inline static  result_t MultiHopTtestM$RouteTimer$start(char arg_0x8561bb8, uint32_t arg_0x8561d10){
  394. #line 59
  395.   unsigned char result;
  396. #line 59
  397. #line 59
  398.   result = TimerM$Timer$start(0, arg_0x8561bb8, arg_0x8561d10);
  399. #line 59
  400. #line 59
  401.   return result;
  402. #line 59
  403. }
  404. #line 59
  405. static inline  
  406. # 494 "../../tos/platform/mica2/CC1000ControlM.nc"
  407. result_t CC1000ControlM$CC1000Control$SetRFPower(uint8_t power)
  408. #line 494
  409. {
  410.   CC1000ControlM$gCurrentParameters[0xb] = power;
  411.   return SUCCESS;
  412. }
  413. # 150 "../../tos/platform/mica2/CC1000Control.nc"
  414. inline static  result_t MultiHopTtestM$RFset$SetRFPower(uint8_t arg_0x856ce78){
  415. #line 150
  416.   unsigned char result;
  417. #line 150
  418. #line 150
  419.   result = CC1000ControlM$CC1000Control$SetRFPower(arg_0x856ce78);
  420. #line 150
  421. #line 150
  422.   return result;
  423. #line 150
  424. }
  425. #line 150
  426. # 106 "/home/testuser/tinyos-1.x/tos/interfaces/Send.nc"
  427. inline static  void *MultiHopTtestM$Send$getBuffer(TOS_MsgPtr arg_0x8563448, uint16_t *arg_0x85635b0){
  428. #line 106
  429.   void *result;
  430. #line 106
  431. #line 106
  432.   result = MultiHopEngineM$Send$getBuffer(AM_MULTIHOP, arg_0x8563448, arg_0x85635b0);
  433. #line 106
  434. #line 106
  435.   return result;
  436. #line 106
  437. }
  438. #line 106
  439. static inline  
  440. # 68 "MultiHopTtestM.nc"
  441. result_t MultiHopTtestM$StdControl$start(void)
  442. #line 68
  443. {
  444.   uint16_t len;
  445.   multiHopMsg *multiHopMsgData = (multiHopMsg *)MultiHopTtestM$Send$getBuffer(&MultiHopTtestM$DataPkt, &len);
  446. #line 71
  447.   multiHopMsgData->sendID = TOS_LOCAL_ADDRESS;
  448.   MultiHopTtestM$RFset$SetRFPower(255);
  449.   MultiHopTtestM$RouteTimer$start(TIMER_ONE_SHOT, MultiHopTtestM$Random$rand() % ROUTE_TIME);
  450.   return SUCCESS;
  451. }
  452. static inline  
  453. # 87 "/home/testuser/tinyos-1.x/tos/system/TimerM.nc"
  454. result_t TimerM$StdControl$start(void)
  455. #line 87
  456. {
  457.   return SUCCESS;
  458. }
  459. static inline  
  460. # 146 "/home/testuser/tinyos-1.x/tos/system/AMPromiscuous.nc"
  461. result_t AMPromiscuous$CommControl$setPromiscuous(bool value)
  462. #line 146
  463. {
  464.   AMPromiscuous$promiscuous_mode = value;
  465.   return SUCCESS;
  466. }
  467. # 65 "/home/testuser/tinyos-1.x/tos/interfaces/CommControl.nc"
  468. inline static  result_t MultiHopEngineM$CommControl$setPromiscuous(bool arg_0x85a8158){
  469. #line 65
  470.   unsigned char result;
  471. #line 65
  472. #line 65
  473.   result = AMPromiscuous$CommControl$setPromiscuous(arg_0x85a8158);
  474. #line 65
  475. #line 65
  476.   return result;
  477. #line 65
  478. }
  479. #line 65
  480. # 59 "/home/testuser/tinyos-1.x/tos/interfaces/Timer.nc"
  481. inline static  result_t MultiHopWMEWMA$Timer$start(char arg_0x8561bb8, uint32_t arg_0x8561d10){
  482. #line 59
  483.   unsigned char result;
  484. #line 59
  485. #line 59
  486.   result = TimerM$Timer$start(8, arg_0x8561bb8, arg_0x8561d10);
  487. #line 59
  488. #line 59
  489.   return result;
  490. #line 59
  491. }
  492. #line 59
  493. static inline  
  494. # 612 "/home/testuser/tinyos-1.x/tos/lib/MintRoute/MultiHopWMEWMA.nc"
  495. result_t MultiHopWMEWMA$StdControl$start(void)
  496. #line 612
  497. {
  498.   if (TOS_LOCAL_ADDRESS == MultiHopWMEWMA$BASE_STATION_ADDRESS) {
  499.       MultiHopWMEWMA$gpCurrentParent = &MultiHopWMEWMA$BaseStation;
  500.       MultiHopWMEWMA$gbCurrentHopCount = 0;
  501.       MultiHopWMEWMA$gbCurrentCost = 0;
  502.     }
  503.   if (MultiHopWMEWMA$gSelfTimer) {
  504.       TOS_post(MultiHopWMEWMA$TimerTask);
  505.       MultiHopWMEWMA$Timer$start(TIMER_REPEAT, MultiHopWMEWMA$gUpdateInterval);
  506.     }
  507.   return SUCCESS;
  508. }
  509. static inline  
  510. # 106 "/home/testuser/tinyos-1.x/tos/lib/Queue/QueuedSendM.nc"
  511. result_t QueuedSendM$StdControl$start(void)
  512. #line 106
  513. {
  514.   return SUCCESS;
  515. }
  516. # 70 "/home/testuser/tinyos-1.x/tos/interfaces/StdControl.nc"
  517. inline static  result_t MultiHopEngineM$SubControl$start(void){
  518. #line 70
  519.   unsigned char result;
  520. #line 70
  521. #line 70
  522.   result = QueuedSendM$StdControl$start();
  523. #line 70
  524.   result = rcombine(result, MultiHopWMEWMA$StdControl$start());
  525. #line 70
  526. #line 70
  527.   return result;
  528. #line 70
  529. }
  530. #line 70
  531. static inline 
  532. # 133 "/home/testuser/tinyos-1.x/tos/system/tos.h"
  533. result_t rcombine4(result_t r1, result_t r2, result_t r3, 
  534. result_t r4)
  535. {
  536.   return rcombine(r1, rcombine(r2, rcombine(r3, r4)));
  537. }
  538. # 41 "/home/testuser/tinyos-1.x/tos/interfaces/PowerManagement.nc"
  539. inline static   uint8_t AMPromiscuous$PowerManagement$adjustPower(void){
  540. #line 41
  541.   unsigned char result;
  542. #line 41
  543. #line 41
  544.   result = HPLPowerManagementM$PowerManagement$adjustPower();
  545. #line 41
  546. #line 41
  547.   return result;
  548. #line 41
  549. }
  550. #line 41
  551. # 59 "/home/testuser/tinyos-1.x/tos/interfaces/Timer.nc"
  552. inline static  result_t AMPromiscuous$ActivityTimer$start(char arg_0x8561bb8, uint32_t arg_0x8561d10){
  553. #line 59
  554.   unsigned char result;
  555. #line 59
  556. #line 59
  557.   result = TimerM$Timer$start(3, arg_0x8561bb8, arg_0x8561d10);
  558. #line 59
  559. #line 59
  560.   return result;
  561. #line 59
  562. }
  563. #line 59
  564. # 59 "/home/testuser/tinyos-1.x/tos/interfaces/Timer.nc"
  565. inline static  result_t CC1000RadioIntM$WakeupTimer$start(char arg_0x8561bb8, uint32_t arg_0x8561d10){
  566. #line 59
  567.   unsigned char result;
  568. #line 59
  569. #line 59
  570.   result = TimerM$Timer$start(5, arg_0x8561bb8, arg_0x8561d10);
  571. #line 59
  572. #line 59
  573.   return result;
  574. #line 59
  575. }
  576. #line 59
  577. # 41 "/home/testuser/tinyos-1.x/tos/interfaces/PowerManagement.nc"
  578. inline static   uint8_t HPLSpiM$PowerManagement$adjustPower(void){
  579. #line 41
  580.   unsigned char result;
  581. #line 41
  582. #line 41
  583.   result = HPLPowerManagementM$PowerManagement$adjustPower();
  584. #line 41
  585. #line 41
  586.   return result;
  587. #line 41
  588. }
  589. #line 41
  590. static inline   
  591. # 74 "../../tos/platform/mica2/HPLSpiM.nc"
  592. result_t HPLSpiM$SpiByteFifo$enableIntr(void)
  593. #line 74
  594. {
  595.   * (volatile uint8_t *)(0x0D + 0x20) = 0xC0;
  596.   * (volatile uint8_t *)(0x17 + 0x20) &= ~(1 << 0);
  597.   HPLSpiM$PowerManagement$adjustPower();
  598.   return SUCCESS;
  599. }
  600. # 36 "../../tos/platform/mica2/SpiByteFifo.nc"
  601. inline static   result_t CC1000RadioIntM$SpiByteFifo$enableIntr(void){
  602. #line 36
  603.   unsigned char result;
  604. #line 36
  605. #line 36
  606.   result = HPLSpiM$SpiByteFifo$enableIntr();
  607. #line 36
  608. #line 36
  609.   return result;
  610. #line 36
  611. }
  612. #line 36
  613. # 59 "/home/testuser/tinyos-1.x/tos/interfaces/Timer.nc"
  614. inline static  result_t CC1000RadioIntM$SquelchTimer$start(char arg_0x8561bb8, uint32_t arg_0x8561d10){
  615. #line 59
  616.   unsigned char result;
  617. #line 59
  618. #line 59
  619.   result = TimerM$Timer$start(4, arg_0x8561bb8, arg_0x8561d10);
  620. #line 59
  621. #line 59
  622.   return result;
  623. #line 59
  624. }
  625. #line 59
  626. # 116 "../../tos/platform/mica2/CC1000Control.nc"
  627. inline static   result_t CC1000RadioIntM$CC1000Control$RxMode(void){
  628. #line 116
  629.   unsigned char result;
  630. #line 116
  631. #line 116
  632.   result = CC1000ControlM$CC1000Control$RxMode();
  633. #line 116
  634. #line 116
  635.   return result;
  636. #line 116
  637. }
  638. #line 116
  639. static inline   
  640. # 109 "../../tos/platform/mica2/HPLSpiM.nc"
  641. result_t HPLSpiM$SpiByteFifo$rxMode(void)
  642. #line 109
  643. {
  644.   TOSH_MAKE_MISO_INPUT();
  645.   TOSH_MAKE_MOSI_INPUT();
  646.   return SUCCESS;
  647. }
  648. # 40 "../../tos/platform/mica2/SpiByteFifo.nc"
  649. inline static   result_t CC1000RadioIntM$SpiByteFifo$rxMode(void){
  650. #line 40
  651.   unsigned char result;
  652. #line 40
  653. #line 40
  654.   result = HPLSpiM$SpiByteFifo$rxMode();
  655. #line 40
  656. #line 40
  657.   return result;
  658. #line 40
  659. }
  660. #line 40
  661. static inline  
  662. # 457 "../../tos/platform/mica2/CC1000ControlM.nc"
  663. result_t CC1000ControlM$CC1000Control$BIASOn(void)
  664. #line 457
  665. {
  666.   CC1000ControlM$HPLChipcon$write(0x00, (((
  667.   1 << 5) | (1 << 4)) | (
  668.   1 << 3)) | (
  669.   1 << 0));
  670.   TOSH_uwait(200);
  671.   return SUCCESS;
  672. }
  673. # 137 "../../tos/platform/mica2/CC1000Control.nc"
  674. inline static  result_t CC1000RadioIntM$CC1000Control$BIASOn(void){
  675. #line 137
  676.   unsigned char result;
  677. #line 137
  678. #line 137
  679.   result = CC1000ControlM$CC1000Control$BIASOn();
  680. #line 137
  681. #line 137
  682.   return result;
  683. #line 137
  684. }
  685. #line 137
  686. static inline  
  687. # 480 "../../tos/platform/mica2/CC1000ControlM.nc"
  688. result_t CC1000ControlM$StdControl$start(void)
  689. #line 480
  690. {
  691.   CC1000ControlM$HPLChipcon$write(0x00, ((((
  692.   1 << 5) | (1 << 4)) | (
  693.   1 << 3)) | (1 << 1)) | (
  694.   1 << 0));
  695.   return SUCCESS;
  696. }
  697. # 70 "/home/testuser/tinyos-1.x/tos/interfaces/StdControl.nc"
  698. inline static  result_t CC1000RadioIntM$CC1000StdControl$start(void){
  699. #line 70
  700.   unsigned char result;
  701. #line 70
  702. #line 70
  703.   result = CC1000ControlM$StdControl$start();
  704. #line 70
  705. #line 70
  706.   return result;
  707. #line 70
  708. }
  709. #line 70
  710. static inline   
  711. # 66 "../../tos/platform/mica2/HPLSClock.nc"
  712. result_t HPLSClock$SClock$SetRate(uint16_t interval, char scale)
  713. #line 66
  714. {
  715.   scale &= 0x7;
  716.   scale |= 0x8;
  717.   { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
  718. #line 69
  719.     {
  720.       * (volatile uint8_t *)0x7D &= ~(1 << 4);
  721.       * (volatile uint8_t *)0x8A = scale;
  722.       * (volatile uint16_t *)0x88 = 0x0000;
  723.       * (volatile uint16_t *)0x86 = interval;
  724.       * (volatile uint8_t *)0x8B = 0x00;
  725.       * (volatile uint8_t *)0x8B |= 1 << 6;
  726.       * (volatile uint8_t *)(0x02 + 0x20) |= 1 << 3;
  727.       * (volatile uint8_t *)0x8C = 0x00;
  728.       * (volatile uint8_t *)0x7D |= 1 << 4;
  729.     }
  730. #line 79
  731.     __nesc_atomic_end(__nesc_atomic); }
  732.   HPLSClock$needupdate = 0;
  733.   return SUCCESS;
  734. }
  735. # 45 "../../tos/interfaces/SClock.nc"
  736. inline static   result_t CC1000RadioIntM$SClock$SetRate(uint16_t arg_0x862a9b0, char arg_0x862aaf0){
  737. #line 45
  738.   unsigned char result;
  739. #line 45
  740. #line 45
  741.   result = HPLSClock$SClock$SetRate(arg_0x862a9b0, arg_0x862aaf0);
  742. #line 45
  743. #line 45
  744.   return result;
  745. #line 45
  746. }
  747. #line 45
  748. static inline  
  749. # 1056 "../../tos/platform/mica2/CC1000RadioIntM.nc"
  750. result_t CC1000RadioIntM$StdControl$start(void)
  751. #line 1056
  752. {
  753.   uint8_t currentRadioState;
  754. #line 1058
  755.   { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
  756. #line 1058
  757.     currentRadioState = CC1000RadioIntM$RadioState;
  758. #line 1058
  759.     __nesc_atomic_end(__nesc_atomic); }
  760.   CC1000RadioIntM$SClock$SetRate(CC1000RadioIntM$MAX_VAL, CLK_DIV_64);
  761.   if (currentRadioState == CC1000RadioIntM$DISABLED_STATE) {
  762.       { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
  763. #line 1062
  764.         {
  765.           CC1000RadioIntM$rxbufptr->length = 0;
  766.           CC1000RadioIntM$RadioState = CC1000RadioIntM$IDLE_STATE;
  767.           CC1000RadioIntM$bTxPending = CC1000RadioIntM$bTxBusy = FALSE;
  768.           CC1000RadioIntM$sMacDelay = -1;
  769.           if (0 > 0) {
  770.               CC1000RadioIntM$sleeptime = 0;
  771.               CC1000RadioIntM$preamblelen = 0;
  772.             }
  773.           else 
  774. #line 1070
  775.             {
  776.               CC1000RadioIntM$lplpower = CC1000RadioIntM$lplpowertx = 0;
  777.               CC1000RadioIntM$sleeptime = (({
  778. #line 1072
  779.                 uint16_t __addr16 = (uint16_t )(uint16_t )&CC1K_LPL_SleepTime[CC1000RadioIntM$lplpower * 2];
  780. #line 1072
  781.                 uint8_t __result;
  782. #line 1072
  783.                  __asm ("lpm %0, Z""nt" : "=r"(__result) : "z"(__addr16));__result;
  784.               }
  785.               )
  786. #line 1072
  787.                << 8) | 
  788.               ({
  789. #line 1073
  790.                 uint16_t __addr16 = (uint16_t )(uint16_t )&CC1K_LPL_SleepTime[CC1000RadioIntM$lplpower * 2 + 1];
  791. #line 1073
  792.                 uint8_t __result;
  793. #line 1073
  794.                  __asm ("lpm %0, Z""nt" : "=r"(__result) : "z"(__addr16));__result;
  795.               }
  796.               );
  797. #line 1074
  798.               CC1000RadioIntM$preamblelen = (({
  799. #line 1074
  800.                 uint16_t __addr16 = (uint16_t )(uint16_t )&CC1K_LPL_PreambleLength[CC1000RadioIntM$lplpowertx * 2];
  801. #line 1074
  802.                 uint8_t __result;
  803. #line 1074
  804.                  __asm ("lpm %0, Z""nt" : "=r"(__result) : "z"(__addr16));__result;
  805.               }
  806.               )
  807. #line 1074
  808.                << 8) | 
  809.               ({
  810. #line 1075
  811.                 uint16_t __addr16 = (uint16_t )(uint16_t )&CC1K_LPL_PreambleLength[CC1000RadioIntM$lplpowertx * 2 + 1];
  812. #line 1075
  813.                 uint8_t __result;
  814. #line 1075
  815.                  __asm ("lpm %0, Z""nt" : "=r"(__result) : "z"(__addr16));__result;
  816.               }
  817.               );
  818.             }
  819.         }
  820. #line 1079
  821.         __nesc_atomic_end(__nesc_atomic); }
  822.       CC1000RadioIntM$rxbufptr->length = 0;
  823.       { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
  824. #line 1084
  825.         CC1000RadioIntM$RadioState = CC1000RadioIntM$IDLE_STATE;
  826. #line 1084
  827.         __nesc_atomic_end(__nesc_atomic); }
  828.       CC1000RadioIntM$CC1000StdControl$start();
  829.       CC1000RadioIntM$CC1000Control$BIASOn();
  830.       CC1000RadioIntM$SpiByteFifo$rxMode();
  831.       CC1000RadioIntM$CC1000Control$RxMode();
  832.       if (CC1000RadioIntM$iSquelchCount > 30) {
  833.         CC1000RadioIntM$SquelchTimer$start(TIMER_REPEAT, 2560);
  834.         }
  835.       else {
  836. #line 1092
  837.         CC1000RadioIntM$SquelchTimer$start(TIMER_REPEAT, 128);
  838.         }
  839. #line 1093
  840.       CC1000RadioIntM$SpiByteFifo$enableIntr();
  841.       if (CC1000RadioIntM$lplpower > 0) {
  842.           CC1000RadioIntM$WakeupTimer$start(TIMER_ONE_SHOT, 2560);
  843.         }
  844.     }
  845.   return SUCCESS;
  846. }
  847. # 70 "/home/testuser/tinyos-1.x/tos/interfaces/StdControl.nc"
  848. inline static  result_t AMPromiscuous$RadioControl$start(void){
  849. #line 70
  850.   unsigned char result;
  851. #line 70
  852. #line 70
  853.   result = CC1000RadioIntM$StdControl$start();
  854. #line 70
  855. #line 70
  856.   return result;
  857. #line 70
  858. }
  859. #line 70
  860. static inline   
  861. # 60 "../../tos/platform/mica2/HPLUART0M.nc"
  862. result_t HPLUART0M$UART$init(void)
  863. #line 60
  864. {
  865.   * (volatile uint8_t *)0x90 = 0;
  866.   * (volatile uint8_t *)(0x09 + 0x20) = 15;
  867.   * (volatile uint8_t *)(0x0B + 0x20) = 1 << 1;
  868.   * (volatile uint8_t *)0x95 = (1 << 2) | (1 << 1);
  869.   * (volatile uint8_t *)(0x0A + 0x20) = (((1 << 7) | (1 << 6)) | (1 << 4)) | (1 << 3);
  870.   return SUCCESS;
  871. }
  872. # 62 "/home/testuser/tinyos-1.x/tos/interfaces/HPLUART.nc"
  873. inline static   result_t UARTM$HPLUART$init(void){
  874. #line 62
  875.   unsigned char result;
  876. #line 62
  877. #line 62
  878.   result = HPLUART0M$UART$init();
  879. #line 62
  880. #line 62
  881.   return result;
  882. #line 62
  883. }
  884. #line 62
  885. static inline  
  886. # 68 "/home/testuser/tinyos-1.x/tos/system/UARTM.nc"
  887. result_t UARTM$Control$start(void)
  888. #line 68
  889. {
  890.   return UARTM$HPLUART$init();
  891. }
  892. # 70 "/home/testuser/tinyos-1.x/tos/interfaces/StdControl.nc"
  893. inline static  result_t FramerM$ByteControl$start(void){
  894. #line 70
  895.   unsigned char result;
  896. #line 70
  897. #line 70
  898.   result = UARTM$Control$start();
  899. #line 70
  900. #line 70
  901.   return result;
  902. #line 70
  903. }
  904. #line 70
  905. static inline  
  906. # 296 "/home/testuser/tinyos-1.x/tos/system/FramerM.nc"
  907. result_t FramerM$StdControl$start(void)
  908. #line 296
  909. {
  910.   FramerM$HDLCInitialize();
  911.   return FramerM$ByteControl$start();
  912. }
  913. # 70 "/home/testuser/tinyos-1.x/tos/interfaces/StdControl.nc"
  914. inline static  result_t AMPromiscuous$UARTControl$start(void){
  915. #line 70
  916.   unsigned char result;
  917. #line 70
  918. #line 70
  919.   result = FramerM$StdControl$start();
  920. #line 70
  921. #line 70
  922.   return result;
  923. #line 70
  924. }
  925. #line 70
  926. inline static  result_t AMPromiscuous$TimerControl$start(void){
  927. #line 70
  928.   unsigned char result;
  929. #line 70
  930. #line 70
  931.   result = TimerM$StdControl$start();
  932. #line 70
  933. #line 70
  934.   return result;
  935. #line 70
  936. }
  937. #line 70
  938. static inline  
  939. # 109 "/home/testuser/tinyos-1.x/tos/system/AMPromiscuous.nc"
  940. result_t AMPromiscuous$Control$start(void)
  941. #line 109
  942. {
  943.   result_t ok0;
  944. #line 110
  945.   result_t ok1;
  946. #line 110
  947.   result_t ok2;
  948. #line 110
  949.   result_t ok3;
  950.   ok0 = AMPromiscuous$TimerControl$start();
  951.   ok1 = AMPromiscuous$UARTControl$start();
  952.   ok2 = AMPromiscuous$RadioControl$start();
  953.   ok3 = AMPromiscuous$ActivityTimer$start(TIMER_REPEAT, 1000);
  954.   AMPromiscuous$PowerManagement$adjustPower();
  955.   AMPromiscuous$state = FALSE;
  956.   return rcombine4(ok0, ok1, ok2, ok3);
  957. }
  958. # 70 "/home/testuser/tinyos-1.x/tos/interfaces/StdControl.nc"
  959. inline static  result_t MultiHopEngineM$CommStdControl$start(void){
  960. #line 70
  961.   unsigned char result;
  962. #line 70
  963. #line 70
  964.   result = AMPromiscuous$Control$start();
  965. #line 70
  966. #line 70
  967.   return result;
  968. #line 70
  969. }
  970. #line 70
  971. static inline  
  972. # 107 "/home/testuser/tinyos-1.x/tos/lib/MintRoute/MultiHopEngineM.nc"
  973. result_t MultiHopEngineM$StdControl$start(void)
  974. #line 107
  975. {
  976.   MultiHopEngineM$CommStdControl$start();
  977.   MultiHopEngineM$SubControl$start();
  978.   return MultiHopEngineM$CommControl$setPromiscuous(TRUE);
  979. }
  980. # 70 "/home/testuser/tinyos-1.x/tos/interfaces/StdControl.nc"
  981. inline static  result_t RealMain$StdControl$start(void){
  982. #line 70
  983.   unsigned char result;
  984. #line 70
  985. #line 70
  986.   result = TimerM$StdControl$start();
  987. #line 70
  988.   result = rcombine(result, MultiHopEngineM$StdControl$start());
  989. #line 70
  990.   result = rcombine(result, TimerM$StdControl$start());
  991. #line 70
  992.   result = rcombine(result, MultiHopTtestM$StdControl$start());
  993. #line 70
  994. #line 70
  995.   return result;
  996. #line 70
  997. }
  998. #line 70
  999. static inline 
  1000. # 64 "../../tos/platform/mica2/HPLPowerManagementM.nc"
  1001. uint8_t HPLPowerManagementM$getPowerLevel(void)
  1002. #line 64
  1003. {
  1004.   uint8_t diff;
  1005. #line 66
  1006.   if (* (volatile uint8_t *)(0x37 + 0x20) & ~((1 << 1) | (1 << 0))) {
  1007.       return HPLPowerManagementM$IDLE;
  1008.     }
  1009.   else {
  1010. #line 69
  1011.     if (* (volatile uint8_t *)(uint16_t )& * (volatile uint8_t *)(0x0D + 0x20) & (1 << 7)) {
  1012.         return HPLPowerManagementM$IDLE;
  1013.       }
  1014.     else {
  1015.       if (* (volatile uint8_t *)(uint16_t )& * (volatile uint8_t *)(0x06 + 0x20) & (1 << 7)) {
  1016.           return HPLPowerManagementM$ADC_NR;
  1017.         }
  1018.       else {
  1019. #line 75
  1020.         if (* (volatile uint8_t *)(0x37 + 0x20) & ((1 << 1) | (1 << 0))) {
  1021.             diff = * (volatile uint8_t *)(0x31 + 0x20) - * (volatile uint8_t *)(0x32 + 0x20);
  1022.             if (diff < 16) {
  1023.               return HPLPowerManagementM$EXT_STANDBY;
  1024.               }
  1025. #line 79
  1026.             return HPLPowerManagementM$POWER_SAVE;
  1027.           }
  1028.         else 
  1029. #line 80
  1030.           {
  1031.             return HPLPowerManagementM$POWER_DOWN;
  1032.           }
  1033.         }
  1034.       }
  1035.     }
  1036. }
  1037. static inline  
  1038. #line 85
  1039. void HPLPowerManagementM$doAdjustment(void)
  1040. #line 85
  1041. {
  1042.   uint8_t foo;
  1043. #line 86
  1044.   uint8_t mcu;
  1045. #line 87
  1046.   HPLPowerManagementM$powerLevel = foo = HPLPowerManagementM$getPowerLevel();
  1047.   mcu = * (volatile uint8_t *)(0x35 + 0x20);
  1048.   mcu &= 0xe3;
  1049.   if (foo == HPLPowerManagementM$EXT_STANDBY || foo == HPLPowerManagementM$POWER_SAVE) {
  1050.       mcu |= HPLPowerManagementM$IDLE;
  1051.       while ((* (volatile uint8_t *)(0x30 + 0x20) & 0x7) != 0) {
  1052.            __asm volatile ("nop");}
  1053.       mcu &= 0xe3;
  1054.     }
  1055.   mcu |= foo;
  1056.   * (volatile uint8_t *)(0x35 + 0x20) = mcu;
  1057.   * (volatile uint8_t *)(0x35 + 0x20) |= 1 << 5;
  1058. }
  1059. static inline   
  1060. # 63 "/home/testuser/tinyos-1.x/tos/system/NoLeds.nc"
  1061. result_t NoLeds$Leds$redToggle(void)
  1062. #line 63
  1063. {
  1064.   return SUCCESS;
  1065. }
  1066. # 81 "/home/testuser/tinyos-1.x/tos/interfaces/Leds.nc"
  1067. inline static   result_t MultiHopWMEWMA$Leds$redToggle(void){
  1068. #line 81
  1069.   unsigned char result;
  1070. #line 81
  1071. #line 81
  1072.   result = NoLeds$Leds$redToggle();
  1073. #line 81
  1074. #line 81
  1075.   return result;
  1076. #line 81
  1077. }
  1078. #line 81
  1079. static inline 
  1080. # 268 "/home/testuser/tinyos-1.x/tos/lib/MintRoute/MultiHopWMEWMA.nc"
  1081. void MultiHopWMEWMA$updateEst(MultiHopWMEWMA$TableEntry *Nbr)
  1082. #line 268
  1083. {
  1084.   uint16_t usExpTotal;
  1085. #line 269
  1086.   uint16_t usActTotal;
  1087. #line 269
  1088.   uint16_t newAve;
  1089.   if (Nbr->flags & MultiHopWMEWMA$NBRFLAG_NEW) {
  1090.     return;
  1091.     }
  1092.   usExpTotal = MultiHopWMEWMA$ESTIMATE_TO_ROUTE_RATIO;
  1093.   {
  1094.   }
  1095. #line 278
  1096.   ;
  1097.   { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
  1098. #line 281
  1099.     {
  1100.       usActTotal = Nbr->received + Nbr->missed;
  1101.       if (usActTotal < usExpTotal) {
  1102.           usActTotal = usExpTotal;
  1103.         }
  1104.       newAve = (uint16_t )255 * (uint16_t )Nbr->received / (uint16_t )usActTotal;
  1105.       Nbr->missed = 0;
  1106.       Nbr->received = 0;
  1107.       if (Nbr->liveliness == 0) {
  1108.           Nbr->sendEst >>= 1;
  1109.         }
  1110.       else 
  1111. #line 296
  1112.         {
  1113.           Nbr->liveliness--;
  1114.         }
  1115.     }
  1116. #line 299
  1117.     __nesc_atomic_end(__nesc_atomic); }
  1118.   if (Nbr->flags & MultiHopWMEWMA$NBRFLAG_EST_INIT) {
  1119.       uint16_t tmp;
  1120. #line 305
  1121.       tmp = (2 * (uint16_t )Nbr->receiveEst + (uint16_t )newAve * 6) / 8;
  1122.       Nbr->receiveEst = (uint8_t )tmp;
  1123.     }
  1124.   else {
  1125.       Nbr->receiveEst = (uint8_t )newAve;
  1126.       Nbr->flags ^= MultiHopWMEWMA$NBRFLAG_EST_INIT;
  1127.     }
  1128.   if (Nbr->childLiveliness > 0) {
  1129. #line 313
  1130.     Nbr->childLiveliness--;
  1131.     }
  1132. }
  1133. static inline 
  1134. #line 316
  1135. void MultiHopWMEWMA$updateTable(void)
  1136. #line 316
  1137. {
  1138.   MultiHopWMEWMA$TableEntry *pNbr;
  1139.   uint8_t i = 0;
  1140.   MultiHopWMEWMA$gwEstTicks++;
  1141.   MultiHopWMEWMA$gwEstTicks %= MultiHopWMEWMA$ESTIMATE_TO_ROUTE_RATIO;
  1142.   for (i = 0; i < MultiHopWMEWMA$ROUTE_TABLE_SIZE; i++) {
  1143.       pNbr = &MultiHopWMEWMA$NeighborTbl[i];
  1144.       if (pNbr->flags & MultiHopWMEWMA$NBRFLAG_VALID) {
  1145.           if (MultiHopWMEWMA$gwEstTicks == 0) {
  1146.             MultiHopWMEWMA$updateEst(pNbr);
  1147.             }
  1148.         }
  1149.     }
  1150. }
  1151. static inline   
  1152. # 75 "/home/testuser/tinyos-1.x/tos/system/NoLeds.nc"
  1153. result_t NoLeds$Leds$greenToggle(void)
  1154. #line 75
  1155. {
  1156.   return SUCCESS;
  1157. }
  1158. # 106 "/home/testuser/tinyos-1.x/tos/interfaces/Leds.nc"
  1159. inline static   result_t MultiHopWMEWMA$Leds$greenToggle(void){
  1160. #line 106
  1161.   unsigned char result;
  1162. #line 106
  1163. #line 106
  1164.   result = NoLeds$Leds$greenToggle();
  1165. #line 106
  1166. #line 106
  1167.   return result;
  1168. #line 106
  1169. }
  1170. #line 106
  1171. static inline 
  1172. # 369 "/home/testuser/tinyos-1.x/tos/lib/MintRoute/MultiHopWMEWMA.nc"
  1173. void MultiHopWMEWMA$chooseParent(void)
  1174. #line 369
  1175. {
  1176.   MultiHopWMEWMA$TableEntry *pNbr;
  1177.   uint32_t ulNbrLinkCost = (uint32_t )-1;
  1178.   uint32_t ulNbrTotalCost = (uint32_t )-1;
  1179.   uint32_t oldParentCost = (uint32_t )-1;
  1180.   uint32_t oldParentLinkCost = (uint32_t )-1;
  1181.   uint32_t ulMinTotalCost = (uint32_t )-1;
  1182.   MultiHopWMEWMA$TableEntry *pNewParent = (void *)0;
  1183.   MultiHopWMEWMA$TableEntry *pOldParent = (void *)0;
  1184.   uint8_t i;
  1185.   if (TOS_LOCAL_ADDRESS == MultiHopWMEWMA$BASE_STATION_ADDRESS) {
  1186. #line 380
  1187.     return;
  1188.     }
  1189.   for (i = 0; i < MultiHopWMEWMA$ROUTE_TABLE_SIZE; i++) {
  1190.       pNbr = &MultiHopWMEWMA$NeighborTbl[i];
  1191.       if (!(pNbr->flags & MultiHopWMEWMA$NBRFLAG_VALID)) {
  1192. #line 389
  1193.         continue;
  1194.         }
  1195. #line 390
  1196.       if (pNbr->parent == TOS_LOCAL_ADDRESS) {
  1197. #line 390
  1198.         continue;
  1199.         }
  1200. #line 391
  1201.       if (pNbr->parent == MultiHopWMEWMA$ROUTE_INVALID) {
  1202. #line 391
  1203.         continue;
  1204.         }
  1205. #line 392
  1206.       if (pNbr->hop == MultiHopWMEWMA$ROUTE_INVALID) {
  1207. #line 392
  1208.         continue;
  1209.         }
  1210. #line 393
  1211.       if (pNbr->cost == (uint16_t )MultiHopWMEWMA$ROUTE_INVALID) {
  1212. #line 393
  1213.         continue;
  1214.         }
  1215. #line 394
  1216.       if (pNbr->sendEst < 25 || pNbr->receiveEst < 25) {
  1217. #line 394
  1218.         continue;
  1219.         }
  1220. #line 395
  1221.       if (pNbr->childLiveliness > 0) {
  1222. #line 395
  1223.         continue;
  1224.         }
  1225.       ulNbrLinkCost = MultiHopWMEWMA$evaluateCost(0, pNbr->sendEst, pNbr->receiveEst);
  1226.       ulNbrTotalCost = MultiHopWMEWMA$evaluateCost(pNbr->cost, pNbr->sendEst, pNbr->receiveEst);
  1227.       MultiHopWMEWMA$Leds$greenToggle();
  1228.       if (ulNbrLinkCost > MultiHopWMEWMA$MAX_ALLOWABLE_LINK_COST) {
  1229. #line 401
  1230.         continue;
  1231.         }
  1232. #line 402
  1233.       {
  1234.       }
  1235. #line 402
  1236.       ;
  1237.       if (pNbr == MultiHopWMEWMA$gpCurrentParent) {
  1238.           pOldParent = pNbr;
  1239.           oldParentCost = ulNbrTotalCost;
  1240.           oldParentLinkCost = ulNbrLinkCost;
  1241.           continue;
  1242.         }
  1243.       if (ulMinTotalCost > ulNbrTotalCost) {
  1244.           ulMinTotalCost = ulNbrTotalCost;
  1245.           pNewParent = pNbr;
  1246.         }
  1247.     }
  1248.   if (pNewParent == (void *)0) {
  1249.       pNewParent = pOldParent;
  1250.       ulMinTotalCost = oldParentCost;
  1251.     }
  1252.   else {
  1253. #line 422
  1254.     if (pOldParent != (void *)0 && 
  1255.     oldParentCost < MultiHopWMEWMA$SWITCH_THRESHOLD + ulMinTotalCost) {
  1256.         pNewParent = pOldParent;
  1257.         ulMinTotalCost = oldParentCost;
  1258.       }
  1259.     }
  1260.   if (pNewParent) {
  1261.       { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
  1262. #line 430
  1263.         {
  1264.           MultiHopWMEWMA$gpCurrentParent = pNewParent;
  1265.           MultiHopWMEWMA$gbCurrentHopCount = pNewParent->hop + 1;
  1266.           MultiHopWMEWMA$gbCurrentCost = ulMinTotalCost >> 6;
  1267.         }
  1268. #line 434
  1269.         __nesc_atomic_end(__nesc_atomic); }
  1270.     }
  1271.   else 
  1272. #line 435
  1273.     {
  1274.       { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
  1275. #line 436
  1276.         {
  1277.           MultiHopWMEWMA$gpCurrentParent = (void *)0;
  1278.           MultiHopWMEWMA$gbCurrentHopCount = MultiHopWMEWMA$ROUTE_INVALID;
  1279.           MultiHopWMEWMA$gbCurrentCost = MultiHopWMEWMA$ROUTE_INVALID;
  1280.         }
  1281. #line 440
  1282.         __nesc_atomic_end(__nesc_atomic); }
  1283.     }
  1284. }
  1285. # 59 "/home/testuser/tinyos-1.x/tos/interfaces/Timer.nc"
  1286. inline static  result_t MultiHopWMEWMA$ATimer$start(char arg_0x8561bb8, uint32_t arg_0x8561d10){
  1287. #line 59
  1288.   unsigned char result;
  1289. #line 59
  1290. #line 59
  1291.   result = TimerM$Timer$start(9, arg_0x8561bb8, arg_0x8561d10);
  1292. #line 59
  1293. #line 59
  1294.   return result;
  1295. #line 59
  1296. }
  1297. #line 59
  1298. static 
  1299. # 187 "/home/testuser/tinyos-1.x/tos/platform/avrmote/avrhardware.h"
  1300. __inline void __nesc_enable_interrupt(void)
  1301. #line 187
  1302. {
  1303.    __asm volatile ("sei");}
  1304. #line 172
  1305. __inline void  __nesc_atomic_end(__nesc_atomic_t oldSreg)
  1306. {
  1307.   * (volatile uint8_t *)(0x3F + 0x20) = oldSreg;
  1308. }
  1309. static inline 
  1310. #line 150
  1311. void TOSH_wait(void)
  1312. {
  1313.    __asm volatile ("nop");
  1314.    __asm volatile ("nop");}
  1315. static 
  1316. #line 179
  1317. __inline void __nesc_atomic_sleep(void)
  1318. {
  1319.    __asm volatile ("sei");
  1320.    __asm volatile ("sleep");
  1321.   TOSH_wait();
  1322. }
  1323. #line 165
  1324. __inline __nesc_atomic_t  __nesc_atomic_start(void )
  1325. {
  1326.   __nesc_atomic_t result = * (volatile uint8_t *)(0x3F + 0x20);
  1327. #line 168
  1328.    __asm volatile ("cli");
  1329.   return result;
  1330. }
  1331. static inline 
  1332. # 136 "/home/testuser/tinyos-1.x/tos/system/sched.c"
  1333. bool TOSH_run_next_task(void)
  1334. {
  1335.   __nesc_atomic_t fInterruptFlags;
  1336.   uint8_t old_full;
  1337.   void (*func)(void );
  1338.   fInterruptFlags = __nesc_atomic_start();
  1339.   old_full = TOSH_sched_full;
  1340.   func = TOSH_queue[old_full].tp;
  1341.   if (func == (void *)0) 
  1342.     {
  1343.       __nesc_atomic_sleep();
  1344.       return 0;
  1345.     }
  1346.   TOSH_queue[old_full].tp = (void *)0;
  1347.   TOSH_sched_full = (old_full + 1) & TOSH_TASK_BITMASK;
  1348.   __nesc_atomic_end(fInterruptFlags);
  1349.   func();
  1350.   return 1;
  1351. }
  1352. static inline void TOSH_run_task(void)
  1353. #line 159
  1354. {
  1355.   for (; ; ) 
  1356.     TOSH_run_next_task();
  1357. }
  1358. static inline   
  1359. # 87 "/home/testuser/tinyos-1.x/tos/system/NoLeds.nc"
  1360. result_t NoLeds$Leds$yellowToggle(void)
  1361. #line 87
  1362. {
  1363.   return SUCCESS;
  1364. }
  1365. # 131 "/home/testuser/tinyos-1.x/tos/interfaces/Leds.nc"
  1366. inline static   result_t MultiHopWMEWMA$Leds$yellowToggle(void){
  1367. #line 131
  1368.   unsigned char result;
  1369. #line 131
  1370. #line 131
  1371.   result = NoLeds$Leds$yellowToggle();
  1372. #line 131
  1373. #line 131
  1374.   return result;
  1375. #line 131
  1376. }
  1377. #line 131
  1378. static inline  
  1379. # 797 "/home/testuser/tinyos-1.x/tos/lib/MintRoute/MultiHopWMEWMA.nc"
  1380. TOS_MsgPtr MultiHopWMEWMA$ReceiveMsg$receive(TOS_MsgPtr Msg)
  1381. #line 797
  1382. {
  1383.   TOS_MHopMsg *pMHMsg = (TOS_MHopMsg *)&Msg->data[0];
  1384.   MultiHopWMEWMA$RoutePacket *pRP = (MultiHopWMEWMA$RoutePacket *)&pMHMsg->data[0];
  1385.   uint16_t saddr;
  1386.   uint8_t i;
  1387. #line 801
  1388.   uint8_t iNbr;
  1389.   MultiHopWMEWMA$Leds$yellowToggle();
  1390.   saddr = pMHMsg->sourceaddr;
  1391.   MultiHopWMEWMA$updateNbrCounters(saddr, pMHMsg->seqno, &iNbr);
  1392.   MultiHopWMEWMA$NeighborTbl[iNbr].parent = pRP->parent;
  1393.   MultiHopWMEWMA$NeighborTbl[iNbr].hop = pMHMsg->hopcount;
  1394.   MultiHopWMEWMA$NeighborTbl[iNbr].cost = pRP->cost;
  1395.   if (MultiHopWMEWMA$NeighborTbl[iNbr].childLiveliness > 0 && pRP->parent != TOS_LOCAL_ADDRESS) {
  1396.     MultiHopWMEWMA$NeighborTbl[iNbr].childLiveliness = 0;
  1397.     }
  1398.   for (i = 0; i < pRP->estEntries; i++) {
  1399.       if (pRP->estList[i].id == TOS_LOCAL_ADDRESS) {
  1400.           MultiHopWMEWMA$NeighborTbl[iNbr].sendEst = pRP->estList[i].receiveEst;
  1401.           MultiHopWMEWMA$NeighborTbl[iNbr].liveliness = MultiHopWMEWMA$LIVELINESS;
  1402.         }
  1403.     }
  1404.   return Msg;
  1405. }
  1406. static inline   
  1407. # 271 "/home/testuser/tinyos-1.x/tos/system/AMPromiscuous.nc"
  1408. TOS_MsgPtr AMPromiscuous$ReceiveMsg$default$receive(uint8_t id, TOS_MsgPtr msg)
  1409. #line 271
  1410. {
  1411.   return msg;
  1412. }
  1413. # 75 "/home/testuser/tinyos-1.x/tos/interfaces/ReceiveMsg.nc"
  1414. inline static  TOS_MsgPtr AMPromiscuous$ReceiveMsg$receive(uint8_t arg_0x85aae88, TOS_MsgPtr arg_0x85b1db0){
  1415. #line 75
  1416.   struct TOS_Msg *result;
  1417. #line 75
  1418. #line 75
  1419.   switch (arg_0x85aae88) {
  1420. #line 75
  1421.     case 3:
  1422. #line 75
  1423.       result = MultiHopEngineM$ReceiveMsg$receive(3, arg_0x85b1db0);
  1424. #line 75
  1425.       break;
  1426. #line 75
  1427.     case AM_MULTIHOP:
  1428. #line 75
  1429.       result = MultiHopEngineM$ReceiveMsg$receive(AM_MULTIHOP, arg_0x85b1db0);
  1430. #line 75
  1431.       break;
  1432. #line 75
  1433.     case AM_MULTIHOPMSG:
  1434. #line 75
  1435.       result = MultiHopWMEWMA$ReceiveMsg$receive(arg_0x85b1db0);
  1436. #line 75
  1437.       break;
  1438. #line 75
  1439.     default:
  1440. #line 75
  1441.       result = AMPromiscuous$ReceiveMsg$default$receive(arg_0x85aae88, arg_0x85b1db0);
  1442. #line 75
  1443.     }
  1444. #line 75
  1445. #line 75
  1446.   return result;
  1447. #line 75
  1448. }
  1449. #line 75
  1450. static inline 
  1451. # 174 "/home/testuser/tinyos-1.x/tos/lib/MintRoute/MultiHopWMEWMA.nc"
  1452. uint8_t MultiHopWMEWMA$findEntryToBeReplaced(void)
  1453. #line 174
  1454. {
  1455.   uint8_t i = 0;
  1456.   uint8_t minSendEst = -1;
  1457.   uint8_t minSendEstIndex = MultiHopWMEWMA$ROUTE_INVALID;
  1458. #line 178
  1459.   for (i = 0; i < MultiHopWMEWMA$ROUTE_TABLE_SIZE; i++) {
  1460.       if ((MultiHopWMEWMA$NeighborTbl[i].flags & MultiHopWMEWMA$NBRFLAG_VALID) == 0) {
  1461.           return i;
  1462.         }
  1463.       if (minSendEst >= MultiHopWMEWMA$NeighborTbl[i].sendEst) {
  1464.           minSendEst = MultiHopWMEWMA$NeighborTbl[i].sendEst;
  1465.           minSendEstIndex = i;
  1466.         }
  1467.     }
  1468.   return minSendEstIndex;
  1469. }
  1470. static inline 
  1471. #line 226
  1472. uint8_t MultiHopWMEWMA$findPreparedIndex(uint16_t id)
  1473. #line 226
  1474. {
  1475.   uint8_t indes = MultiHopWMEWMA$findEntry(id);
  1476. #line 228
  1477.   if (indes == (uint8_t )MultiHopWMEWMA$ROUTE_INVALID) {
  1478.       indes = MultiHopWMEWMA$findEntryToBeReplaced();
  1479.       MultiHopWMEWMA$newEntry(indes, id);
  1480.     }
  1481.   return indes;
  1482. }
  1483. static inline  
  1484. # 98 "MultiHopTtestM.nc"
  1485. result_t MultiHopTtestM$Intercept$intercept(TOS_MsgPtr m, void *payload, uint16_t payloadLen)
  1486. #line 98
  1487. {
  1488.   multiHopMsg *hData = (multiHopMsg *)payload;
  1489. #line 100
  1490.   if (hData->sendID < 50) {
  1491.       MultiHopTtestM$eachCount[hData->sendID]++;
  1492.       MultiHopTtestM$Rcount++;
  1493.     }
  1494.   return SUCCESS;
  1495. }
  1496. static inline   
  1497. # 250 "/home/testuser/tinyos-1.x/tos/lib/MintRoute/MultiHopEngineM.nc"
  1498. result_t MultiHopEngineM$Intercept$default$intercept(uint8_t id, TOS_MsgPtr pMsg, void *payload, 
  1499. uint16_t payloadLen)
  1500. #line 251
  1501. {
  1502.   return SUCCESS;
  1503. }
  1504. # 86 "/home/testuser/tinyos-1.x/tos/interfaces/Intercept.nc"
  1505. inline static  result_t MultiHopEngineM$Intercept$intercept(uint8_t arg_0x8913f48, TOS_MsgPtr arg_0x854f548, void *arg_0x854f6a0, uint16_t arg_0x854f7f8){
  1506. #line 86
  1507.   unsigned char result;
  1508. #line 86
  1509. #line 86
  1510.   switch (arg_0x8913f48) {
  1511. #line 86
  1512.     case AM_MULTIHOP:
  1513. #line 86
  1514.       result = MultiHopTtestM$Intercept$intercept(arg_0x854f548, arg_0x854f6a0, arg_0x854f7f8);
  1515. #line 86
  1516.       break;
  1517. #line 86
  1518.     default:
  1519. #line 86
  1520.       result = MultiHopEngineM$Intercept$default$intercept(arg_0x8913f48, arg_0x854f548, arg_0x854f6a0, arg_0x854f7f8);
  1521. #line 86
  1522.     }
  1523. #line 86
  1524. #line 86
  1525.   return result;
  1526. #line 86
  1527. }
  1528. #line 86
  1529. # 48 "/home/testuser/tinyos-1.x/tos/interfaces/SendMsg.nc"
  1530. inline static  result_t MultiHopEngineM$SendMsg$send(uint8_t arg_0x89175b0, uint16_t arg_0x85a9e28, uint8_t arg_0x85b0010, TOS_MsgPtr arg_0x85b0160){
  1531. #line 48
  1532.   unsigned char result;
  1533. #line 48
  1534. #line 48
  1535.   result = QueuedSendM$QueueSendMsg$send(arg_0x89175b0, arg_0x85a9e28, arg_0x85b0010, arg_0x85b0160);
  1536. #line 48
  1537. #line 48
  1538.   return result;
  1539. #line 48
  1540. }
  1541. #line 48
  1542. # 71 "/home/testuser/tinyos-1.x/tos/interfaces/RouteSelect.nc"
  1543. inline static  result_t MultiHopEngineM$RouteSelect$selectRoute(TOS_MsgPtr arg_0x89392f8, uint8_t arg_0x8939440){
  1544. #line 71
  1545.   unsigned char result;
  1546. #line 71
  1547. #line 71
  1548.   result = MultiHopWMEWMA$RouteSelect$selectRoute(arg_0x89392f8, arg_0x8939440);
  1549. #line 71
  1550. #line 71
  1551.   return result;
  1552. #line 71
  1553. }
  1554. #line 71
  1555. # 161 "/home/testuser/tinyos-1.x/tos/lib/MintRoute/MultiHopEngineM.nc"
  1556. static TOS_MsgPtr MultiHopEngineM$mForward(TOS_MsgPtr pMsg, uint8_t id)
  1557. #line 161
  1558. {
  1559.   TOS_MsgPtr pNewBuf = pMsg;
  1560.   if ((MultiHopEngineM$iFwdBufHead + 1) % MultiHopEngineM$FWD_QUEUE_SIZE == MultiHopEngineM$iFwdBufTail) {
  1561.     return pNewBuf;
  1562.     }
  1563.   if (MultiHopEngineM$RouteSelect$selectRoute(pMsg, id) != SUCCESS) {
  1564.     return pNewBuf;
  1565.     }
  1566.   if (MultiHopEngineM$SendMsg$send(id, pMsg->addr, pMsg->length, pMsg) == SUCCESS) {
  1567.       pNewBuf = MultiHopEngineM$FwdBufList[MultiHopEngineM$iFwdBufHead];
  1568.       MultiHopEngineM$FwdBufList[MultiHopEngineM$iFwdBufHead] = pMsg;
  1569.       MultiHopEngineM$iFwdBufHead++;
  1570. #line 175
  1571.       MultiHopEngineM$iFwdBufHead %= MultiHopEngineM$FWD_QUEUE_SIZE;
  1572.     }
  1573.   return pNewBuf;
  1574. }
  1575. static inline 
  1576. # 657 "/home/testuser/tinyos-1.x/tos/lib/MintRoute/MultiHopWMEWMA.nc"
  1577. void MultiHopWMEWMA$updateDescendant(uint16_t id)
  1578. #line 657
  1579. {
  1580.   uint8_t indes = MultiHopWMEWMA$findEntry(id);
  1581. #line 659
  1582.   if (indes == (uint8_t )MultiHopWMEWMA$ROUTE_INVALID) {
  1583. #line 659
  1584.       return;
  1585.     }
  1586.   else 
  1587. #line 660
  1588.     {
  1589.       MultiHopWMEWMA$NeighborTbl[indes].childLiveliness = MultiHopWMEWMA$MAX_DESCENDANT_LIVE;
  1590.     }
  1591. }
  1592. # 106 "/home/testuser/tinyos-1.x/tos/interfaces/Leds.nc"
  1593. inline static   result_t QueuedSendM$Leds$greenToggle(void){
  1594. #line 106
  1595.   unsigned char result;
  1596. #line 106
  1597. #line 106
  1598.   result = NoLeds$Leds$greenToggle();
  1599. #line 106
  1600. #line 106
  1601.   return result;
  1602. #line 106
  1603. }
  1604. #line 106
  1605. static inline 
  1606. # 159 "/home/testuser/tinyos-1.x/tos/system/AMPromiscuous.nc"
  1607. void AMPromiscuous$dbgPacket(TOS_MsgPtr data)
  1608. #line 159
  1609. {
  1610.   uint8_t i;
  1611.   for (i = 0; i < sizeof(TOS_Msg ); i++) 
  1612.     {
  1613.       {
  1614.       }
  1615. #line 164
  1616.       ;
  1617.     }
  1618.   {
  1619.   }
  1620. #line 166
  1621.   ;
  1622. }
  1623. # 58 "/home/testuser/tinyos-1.x/tos/interfaces/BareSendMsg.nc"
  1624. inline static  result_t AMPromiscuous$RadioSend$send(TOS_MsgPtr arg_0x85bab68){
  1625. #line 58
  1626.   unsigned char result;
  1627. #line 58
  1628. #line 58
  1629.   result = CC1000RadioIntM$Send$send(arg_0x85bab68);
  1630. #line 58
  1631. #line 58
  1632.   return result;
  1633. #line 58
  1634. }
  1635. #line 58
  1636. static inline  
  1637. # 306 "/home/testuser/tinyos-1.x/tos/system/FramerM.nc"
  1638. result_t FramerM$BareSendMsg$send(TOS_MsgPtr pMsg)
  1639. #line 306
  1640. {
  1641.   result_t Result = SUCCESS;
  1642.   { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
  1643. #line 309
  1644.     {
  1645.       if (!(FramerM$gFlags & FramerM$FLAGS_DATAPEND)) {
  1646.           FramerM$gFlags |= FramerM$FLAGS_DATAPEND;
  1647.           FramerM$gpTxMsg = pMsg;
  1648.         }
  1649.       else 
  1650.         {
  1651.           Result = FAIL;
  1652.         }
  1653.     }
  1654. #line 319
  1655.     __nesc_atomic_end(__nesc_atomic); }
  1656.   if (Result == SUCCESS) {
  1657.       Result = FramerM$StartTx();
  1658.     }
  1659.   return Result;
  1660. }
  1661. # 58 "/home/testuser/tinyos-1.x/tos/interfaces/BareSendMsg.nc"
  1662. inline static  result_t AMPromiscuous$UARTSend$send(TOS_MsgPtr arg_0x85bab68){
  1663. #line 58
  1664.   unsigned char result;
  1665. #line 58
  1666. #line 58
  1667.   result = FramerM$BareSendMsg$send(arg_0x85bab68);
  1668. #line 58
  1669. #line 58
  1670.   return result;
  1671. #line 58
  1672. }
  1673. #line 58
  1674. static inline  
  1675. # 193 "/home/testuser/tinyos-1.x/tos/system/AMPromiscuous.nc"
  1676. void AMPromiscuous$sendTask(void)
  1677. #line 193
  1678. {
  1679.   result_t ok;
  1680.   if (AMPromiscuous$buffer->addr == TOS_UART_ADDR) {
  1681.     ok = AMPromiscuous$UARTSend$send(AMPromiscuous$buffer);
  1682.     }
  1683.   else {
  1684. #line 199
  1685.     ok = AMPromiscuous$RadioSend$send(AMPromiscuous$buffer);
  1686.     }
  1687.   if (ok == FAIL) {
  1688.     AMPromiscuous$reportSendDone(AMPromiscuous$buffer, FAIL);
  1689.     }
  1690. }
  1691. # 106 "/home/testuser/tinyos-1.x/tos/interfaces/Leds.nc"
  1692. inline static   result_t AMPromiscuous$Leds$greenToggle(void){
  1693. #line 106
  1694.   unsigned char result;
  1695. #line 106
  1696. #line 106
  1697.   result = NoLeds$Leds$greenToggle();
  1698. #line 106
  1699. #line 106
  1700.   return result;
  1701. #line 106
  1702. }
  1703. #line 106
  1704. static inline  
  1705. # 206 "/home/testuser/tinyos-1.x/tos/system/AMPromiscuous.nc"
  1706. result_t AMPromiscuous$SendMsg$send(uint8_t id, uint16_t addr, uint8_t length, TOS_MsgPtr data)
  1707. #line 206
  1708. {
  1709.   if (!AMPromiscuous$state) {
  1710.       AMPromiscuous$state = TRUE;
  1711.       AMPromiscuous$Leds$greenToggle();
  1712.       if (length > DATA_LENGTH) {
  1713.           {
  1714.           }
  1715. #line 212
  1716.           ;
  1717.           AMPromiscuous$state = FALSE;
  1718.           return FAIL;
  1719.         }
  1720.       if (!TOS_post(AMPromiscuous$sendTask)) {
  1721.           {
  1722.           }
  1723. #line 217
  1724.           ;
  1725.           AMPromiscuous$state = FALSE;
  1726.           return FAIL;
  1727.         }
  1728.       else {
  1729.           AMPromiscuous$buffer = data;
  1730.           data->length = length;
  1731.           data->addr = addr;
  1732.           data->type = id;
  1733.           AMPromiscuous$buffer->group = TOS_AM_GROUP;
  1734.           AMPromiscuous$dbgPacket(data);
  1735.           {
  1736.           }
  1737. #line 228
  1738.           ;
  1739.         }
  1740.       return SUCCESS;
  1741.     }
  1742.   return FAIL;
  1743. }
  1744. # 48 "/home/testuser/tinyos-1.x/tos/interfaces/SendMsg.nc"
  1745. inline static  result_t QueuedSendM$SerialSendMsg$send(uint8_t arg_0x89a2998, uint16_t arg_0x85a9e28, uint8_t arg_0x85b0010, TOS_MsgPtr arg_0x85b0160){
  1746. #line 48
  1747.   unsigned char result;
  1748. #line 48
  1749. #line 48
  1750.   result = AMPromiscuous$SendMsg$send(arg_0x89a2998, arg_0x85a9e28, arg_0x85b0010, arg_0x85b0160);
  1751. #line 48
  1752. #line 48
  1753.   return result;
  1754. #line 48
  1755. }
  1756. #line 48
  1757. static inline   
  1758. # 105 "../../tos/platform/mica2/HPLUART0M.nc"
  1759. result_t HPLUART0M$UART$put(uint8_t data)
  1760. #line 105
  1761. {
  1762.   { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
  1763. #line 106
  1764.     {
  1765.       * (volatile uint8_t *)(0x0C + 0x20) = data;
  1766.       * (volatile uint8_t *)(0x0B + 0x20) |= 1 << 6;
  1767.     }
  1768. #line 109
  1769.     __nesc_atomic_end(__nesc_atomic); }
  1770.   return SUCCESS;
  1771. }
  1772. # 80 "/home/testuser/tinyos-1.x/tos/interfaces/HPLUART.nc"
  1773. inline static   result_t UARTM$HPLUART$put(uint8_t arg_0x88d4ac8){
  1774. #line 80
  1775.   unsigned char result;
  1776. #line 80
  1777. #line 80
  1778.   result = HPLUART0M$UART$put(arg_0x88d4ac8);
  1779. #line 80
  1780. #line 80
  1781.   return result;
  1782. #line 80
  1783. }
  1784. #line 80
  1785. static inline  
  1786. # 236 "/home/testuser/tinyos-1.x/tos/system/AMPromiscuous.nc"
  1787. result_t AMPromiscuous$UARTSend$sendDone(TOS_MsgPtr msg, result_t success)
  1788. #line 236
  1789. {
  1790.   return AMPromiscuous$reportSendDone(msg, success);
  1791. }
  1792. # 67 "/home/testuser/tinyos-1.x/tos/interfaces/BareSendMsg.nc"
  1793. inline static  result_t FramerM$BareSendMsg$sendDone(TOS_MsgPtr arg_0x85bb080, result_t arg_0x85bb1d0){
  1794. #line 67
  1795.   unsigned char result;
  1796. #line 67
  1797. #line 67
  1798.   result = AMPromiscuous$UARTSend$sendDone(arg_0x85bb080, arg_0x85bb1d0);
  1799. #line 67
  1800. #line 67
  1801.   return result;
  1802. #line 67
  1803. }
  1804. #line 67
  1805. static inline  
  1806. # 845 "/home/testuser/tinyos-1.x/tos/lib/MintRoute/MultiHopWMEWMA.nc"
  1807. result_t MultiHopWMEWMA$SendMsg$sendDone(TOS_MsgPtr pMsg, result_t success)
  1808. #line 845
  1809. {
  1810.   MultiHopWMEWMA$gfSendRouteBusy = FALSE;
  1811.   return SUCCESS;
  1812. }
  1813. # 49 "/home/testuser/tinyos-1.x/tos/interfaces/SendMsg.nc"
  1814. inline static  result_t QueuedSendM$QueueSendMsg$sendDone(uint8_t arg_0x89a2010, TOS_MsgPtr arg_0x85b0580, result_t arg_0x85b06d0){
  1815. #line 49
  1816.   unsigned char result;
  1817. #line 49
  1818. #line 49
  1819.   result = MultiHopEngineM$SendMsg$sendDone(arg_0x89a2010, arg_0x85b0580, arg_0x85b06d0);
  1820. #line 49
  1821.   switch (arg_0x89a2010) {
  1822. #line 49
  1823.     case AM_MULTIHOPMSG:
  1824. #line 49
  1825.       result = rcombine(result, MultiHopWMEWMA$SendMsg$sendDone(arg_0x85b0580, arg_0x85b06d0));
  1826. #line 49
  1827.       break;
  1828. #line 49
  1829.   }
  1830. #line 49
  1831. #line 49
  1832.   return result;
  1833. #line 49
  1834. }
  1835. #line 49
  1836. # 81 "/home/testuser/tinyos-1.x/tos/interfaces/Leds.nc"
  1837. inline static   result_t QueuedSendM$Leds$redToggle(void){
  1838. #line 81
  1839.   unsigned char result;
  1840. #line 81
  1841. #line 81
  1842.   result = NoLeds$Leds$redToggle();
  1843. #line 81
  1844. #line 81
  1845.   return result;
  1846. #line 81
  1847. }
  1848. #line 81
  1849. static inline  
  1850. # 188 "/home/testuser/tinyos-1.x/tos/lib/Queue/QueuedSendM.nc"
  1851. result_t QueuedSendM$SerialSendMsg$sendDone(uint8_t id, TOS_MsgPtr msg, result_t success)
  1852. #line 188
  1853. {
  1854.   if (msg != QueuedSendM$msgqueue[QueuedSendM$dequeue_next].pMsg) {
  1855.       return FAIL;
  1856.     }
  1857.   if ((!QueuedSendM$retransmit || msg->ack != 0) || QueuedSendM$msgqueue[QueuedSendM$dequeue_next].address == TOS_UART_ADDR) {
  1858.       QueuedSendM$QueueSendMsg$sendDone(id, msg, success);
  1859.       QueuedSendM$msgqueue[QueuedSendM$dequeue_next].pMsg = (void *)0;
  1860.       {
  1861.       }
  1862. #line 198
  1863.       ;
  1864.       QueuedSendM$dequeue_next++;
  1865. #line 199
  1866.       QueuedSendM$dequeue_next %= QueuedSendM$MESSAGE_QUEUE_SIZE;
  1867.     }
  1868.   else 
  1869.     {
  1870.       QueuedSendM$Leds$redToggle();
  1871.       if (++ QueuedSendM$msgqueue[QueuedSendM$dequeue_next].xmit_count > QueuedSendM$MAX_RETRANSMIT_COUNT) {
  1872.           QueuedSendM$QueueSendMsg$sendDone(id, msg, FAIL);
  1873.           QueuedSendM$msgqueue[QueuedSendM$dequeue_next].pMsg = (void *)0;
  1874.           QueuedSendM$dequeue_next++;
  1875. #line 216
  1876.           QueuedSendM$dequeue_next %= QueuedSendM$MESSAGE_QUEUE_SIZE;
  1877.         }
  1878.     }
  1879.   TOS_post(QueuedSendM$QueueServiceTask);
  1880.   return SUCCESS;
  1881. }
  1882. # 49 "/home/testuser/tinyos-1.x/tos/interfaces/SendMsg.nc"
  1883. inline static  result_t AMPromiscuous$SendMsg$sendDone(uint8_t arg_0x85aa8d0, TOS_MsgPtr arg_0x85b0580, result_t arg_0x85b06d0){
  1884. #line 49
  1885.   unsigned char result;
  1886. #line 49
  1887. #line 49
  1888.   result = QueuedSendM$SerialSendMsg$sendDone(arg_0x85aa8d0, arg_0x85b0580, arg_0x85b06d0);
  1889. #line 49
  1890. #line 49
  1891.   return result;
  1892. #line 49
  1893. }
  1894. #line 49
  1895. static inline  
  1896. # 850 "/home/testuser/tinyos-1.x/tos/lib/MintRoute/MultiHopWMEWMA.nc"
  1897. result_t MultiHopWMEWMA$DebugSendMsg$sendDone(TOS_MsgPtr pMsg, result_t success)
  1898. #line 850
  1899. {
  1900.   return SUCCESS;
  1901. }
  1902. static inline  
  1903. # 87 "MultiHopTtestM.nc"
  1904. result_t MultiHopTtestM$Send$sendDone(TOS_MsgPtr msg, result_t success)
  1905. #line 87
  1906. {
  1907.   if (success == SUCCESS) {
  1908.       MultiHopTtestM$Scount++;
  1909.     }
  1910.   MultiHopTtestM$txBusy = FALSE;
  1911.   return SUCCESS;
  1912. }
  1913. static inline   
  1914. # 246 "/home/testuser/tinyos-1.x/tos/lib/MintRoute/MultiHopEngineM.nc"
  1915. result_t MultiHopEngineM$Send$default$sendDone(uint8_t id, TOS_MsgPtr pMsg, result_t success)
  1916. #line 246
  1917. {
  1918.   return SUCCESS;
  1919. }
  1920. # 119 "/home/testuser/tinyos-1.x/tos/interfaces/Send.nc"
  1921. inline static  result_t MultiHopEngineM$Send$sendDone(uint8_t arg_0x89138e0, TOS_MsgPtr arg_0x8563dd8, result_t arg_0x8563f28){
  1922. #line 119
  1923.   unsigned char result;
  1924. #line 119
  1925. #line 119
  1926.   switch (arg_0x89138e0) {
  1927. #line 119
  1928.     case 3:
  1929. #line 119
  1930.       result = MultiHopWMEWMA$DebugSendMsg$sendDone(arg_0x8563dd8, arg_0x8563f28);
  1931. #line 119
  1932.       break;
  1933. #line 119
  1934.     case AM_MULTIHOP:
  1935. #line 119
  1936.       result = MultiHopTtestM$Send$sendDone(arg_0x8563dd8, arg_0x8563f28);
  1937. #line 119
  1938.       break;
  1939. #line 119
  1940.     default:
  1941. #line 119
  1942.       result = MultiHopEngineM$Send$default$sendDone(arg_0x89138e0, arg_0x8563dd8, arg_0x8563f28);
  1943. #line 119
  1944.     }
  1945. #line 119
  1946. #line 119
  1947.   return result;
  1948. #line 119
  1949. }
  1950. #line 119
  1951. static inline   
  1952. # 188 "/home/testuser/tinyos-1.x/tos/system/AMPromiscuous.nc"
  1953. result_t AMPromiscuous$default$sendDone(void)
  1954. #line 188
  1955. {
  1956.   return SUCCESS;
  1957. }
  1958. #line 67
  1959. inline static  result_t AMPromiscuous$sendDone(void){
  1960. #line 67
  1961.   unsigned char result;
  1962. #line 67
  1963. #line 67
  1964.   result = AMPromiscuous$default$sendDone();
  1965. #line 67
  1966. #line 67
  1967.   return result;
  1968. #line 67
  1969. }
  1970. #line 67
  1971. # 63 "/home/testuser/tinyos-1.x/tos/interfaces/Random.nc"
  1972. inline static   uint16_t CC1000RadioIntM$Random$rand(void){
  1973. #line 63
  1974.   unsigned int result;
  1975. #line 63
  1976. #line 63
  1977.   result = RandomLFSR$Random$rand();
  1978. #line 63
  1979. #line 63
  1980.   return result;
  1981. #line 63
  1982. }
  1983. #line 63
  1984. static inline    
  1985. # 1796 "../../tos/platform/mica2/CC1000RadioIntM.nc"
  1986. int16_t CC1000RadioIntM$MacBackoff$default$initialBackoff(TOS_MsgPtr m)
  1987. #line 1796
  1988. {
  1989.   return (CC1000RadioIntM$Random$rand() & 0x1F) + 1;
  1990. }
  1991. # 39 "../../tos/platform/mica2/MacBackoff.nc"
  1992. inline static   int16_t CC1000RadioIntM$MacBackoff$initialBackoff(TOS_MsgPtr arg_0x85f7e60){
  1993. #line 39
  1994.   int result;
  1995. #line 39
  1996. #line 39
  1997.   result = CC1000RadioIntM$MacBackoff$default$initialBackoff(arg_0x85f7e60);
  1998. #line 39
  1999. #line 39
  2000.   return result;
  2001. #line 39
  2002. }
  2003. #line 39
  2004. static inline 
  2005. # 245 "../../tos/platform/mica2/CC1000RadioIntM.nc"
  2006. uint16_t CC1000RadioIntM$getOwnerBackoff(void)
  2007. #line 245
  2008. {
  2009.   return (CC1000RadioIntM$Random$rand() & (8 - 1)) + 1;
  2010. }
  2011. static inline uint16_t CC1000RadioIntM$getNonOwnerBackoff(void)
  2012. #line 249
  2013. {
  2014.   return (CC1000RadioIntM$Random$rand() & (32 - 1)) + 8 + 1;
  2015. }
  2016. # 68 "/home/testuser/tinyos-1.x/tos/interfaces/Timer.nc"
  2017. inline static  result_t CC1000RadioIntM$WakeupTimer$stop(void){
  2018. #line 68
  2019.   unsigned char result;
  2020. #line 68
  2021. #line 68
  2022.   result = TimerM$Timer$stop(5);
  2023. #line 68
  2024. #line 68
  2025.   return result;
  2026. #line 68
  2027. }
  2028. #line 68
  2029. static inline  
  2030. # 832 "/home/testuser/tinyos-1.x/tos/lib/MintRoute/MultiHopWMEWMA.nc"
  2031. result_t MultiHopWMEWMA$Snoop$intercept(uint8_t id, TOS_MsgPtr Msg, void *Payload, uint16_t Len)
  2032. #line 832
  2033. {
  2034.   TOS_MHopMsg *pMHMsg = (TOS_MHopMsg *)&Msg->data[0];
  2035.   uint8_t iNbr;
  2036.   MultiHopWMEWMA$updateNbrCounters(pMHMsg->sourceaddr, pMHMsg->seqno, &iNbr);
  2037.   return SUCCESS;
  2038. }
  2039. # 86 "/home/testuser/tinyos-1.x/tos/interfaces/Intercept.nc"
  2040. inline static  result_t MultiHopEngineM$Snoop$intercept(uint8_t arg_0x8916490, TOS_MsgPtr arg_0x854f548, void *arg_0x854f6a0, uint16_t arg_0x854f7f8){
  2041. #line 86
  2042.   unsigned char result;
  2043. #line 86
  2044. #line 86
  2045.   result = MultiHopWMEWMA$Snoop$intercept(arg_0x8916490, arg_0x854f548, arg_0x854f6a0, arg_0x854f7f8);
  2046. #line 86
  2047. #line 86
  2048.   return result;
  2049. #line 86
  2050. }
  2051. #line 86
  2052. # 37 "../../tos/platform/mica2/SpiByteFifo.nc"
  2053. inline static   result_t CC1000RadioIntM$SpiByteFifo$disableIntr(void){
  2054. #line 37
  2055.   unsigned char result;
  2056. #line 37
  2057. #line 37
  2058.   result = HPLSpiM$SpiByteFifo$disableIntr();
  2059. #line 37
  2060. #line 37
  2061.   return result;
  2062. #line 37
  2063. }
  2064. #line 37
  2065. static inline  
  2066. # 1606 "../../tos/platform/mica2/CC1000RadioIntM.nc"
  2067. void CC1000RadioIntM$SleepTimerTask(void)
  2068. #line 1606
  2069. {
  2070.   CC1000RadioIntM$WakeupTimer$start(TIMER_ONE_SHOT, CC1000RadioIntM$sleeptime);
  2071. }
  2072. static inline  
  2073. # 469 "../../tos/platform/mica2/CC1000ControlM.nc"
  2074. result_t CC1000ControlM$StdControl$stop(void)
  2075. #line 469
  2076. {
  2077.   CC1000ControlM$HPLChipcon$write(0x00, (((((
  2078.   1 << 5) | (1 << 4)) | (
  2079.   1 << 3)) | (1 << 2)) | (1 << 1)) | (
  2080.   1 << 0));
  2081.   CC1000ControlM$HPLChipcon$write(0x0B, 0x00);
  2082.   return SUCCESS;
  2083. }
  2084. # 78 "/home/testuser/tinyos-1.x/tos/interfaces/StdControl.nc"
  2085. inline static  result_t CC1000RadioIntM$CC1000StdControl$stop(void){
  2086. #line 78
  2087.   unsigned char result;
  2088. #line 78
  2089. #line 78
  2090.   result = CC1000ControlM$StdControl$stop();
  2091. #line 78
  2092. #line 78
  2093.   return result;
  2094. #line 78
  2095. }
  2096. #line 78
  2097. static inline   
  2098. # 222 "../../tos/platform/mica2/ADCREFM.nc"
  2099. result_t ADCREFM$ADC$getData(uint8_t port)
  2100. #line 222
  2101. {
  2102.   result_t Result;
  2103. #line 224
  2104.   if (port > TOSH_ADC_PORTMAPSIZE) {
  2105.       return FAIL;
  2106.     }
  2107.   { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
  2108. #line 228
  2109.     {
  2110.       Result = ADCREFM$startGet(port);
  2111.     }
  2112. #line 230
  2113.     __nesc_atomic_end(__nesc_atomic); }
  2114.   return Result;
  2115. }
  2116. # 52 "/home/testuser/tinyos-1.x/tos/interfaces/ADC.nc"
  2117. inline static   result_t CC1000RadioIntM$RSSIADC$getData(void){
  2118. #line 52
  2119.   unsigned char result;
  2120. #line 52
  2121. #line 52
  2122.   result = ADCREFM$ADC$getData(TOS_ADC_CC_RSSI_PORT);
  2123. #line 52
  2124. #line 52
  2125.   return result;
  2126. #line 52
  2127. }
  2128. #line 52
  2129. static inline   
  2130. # 1724 "../../tos/platform/mica2/CC1000RadioIntM.nc"
  2131. uint16_t CC1000RadioIntM$GetSquelch(void)
  2132. #line 1724
  2133. {
  2134.   return CC1000RadioIntM$usSquelchVal;
  2135. }
  2136. static inline    
  2137. #line 1800
  2138. int16_t CC1000RadioIntM$MacBackoff$default$congestionBackoff(TOS_MsgPtr m)
  2139. #line 1800
  2140. {
  2141.   CC1000RadioIntM$congBackOffs++;
  2142.   return (CC1000RadioIntM$Random$rand() & 0xF) + 1;
  2143. }
  2144. # 40 "../../tos/platform/mica2/MacBackoff.nc"
  2145. inline static   int16_t CC1000RadioIntM$MacBackoff$congestionBackoff(TOS_MsgPtr arg_0x85fe310){
  2146. #line 40
  2147.   int result;
  2148. #line 40
  2149. #line 40
  2150.   result = CC1000RadioIntM$MacBackoff$default$congestionBackoff(arg_0x85fe310);
  2151. #line 40
  2152. #line 40
  2153.   return result;
  2154. #line 40
  2155. }
  2156. #line 40
  2157. # 143 "../../tos/platform/mica2/hardware.h"
  2158. static __inline void TOSH_MAKE_MOSI_OUTPUT(void)
  2159. #line 143
  2160. {
  2161. #line 143
  2162.   * (volatile uint8_t *)(0x17 + 0x20) |= 1 << 2;
  2163. }
  2164. #line 144
  2165. static __inline void TOSH_MAKE_MISO_OUTPUT(void)
  2166. #line 144
  2167. {
  2168. #line 144
  2169.   * (volatile uint8_t *)(0x17 + 0x20) |= 1 << 3;
  2170. }
  2171. static inline   
  2172. # 103 "../../tos/platform/mica2/HPLSpiM.nc"
  2173. result_t HPLSpiM$SpiByteFifo$txMode(void)
  2174. #line 103
  2175. {
  2176.   TOSH_MAKE_MISO_OUTPUT();
  2177.   TOSH_MAKE_MOSI_OUTPUT();
  2178.   return SUCCESS;
  2179. }
  2180. # 39 "../../tos/platform/mica2/SpiByteFifo.nc"
  2181. inline static   result_t CC1000RadioIntM$SpiByteFifo$txMode(void){
  2182. #line 39
  2183.   unsigned char result;
  2184. #line 39
  2185. #line 39
  2186.   result = HPLSpiM$SpiByteFifo$txMode();
  2187. #line 39
  2188. #line 39
  2189.   return result;
  2190. #line 39
  2191. }
  2192. #line 39
  2193. # 108 "../../tos/platform/mica2/CC1000Control.nc"
  2194. inline static   result_t CC1000RadioIntM$CC1000Control$TxMode(void){
  2195. #line 108
  2196.   unsigned char result;
  2197. #line 108
  2198. #line 108
  2199.   result = CC1000ControlM$CC1000Control$TxMode();
  2200. #line 108
  2201. #line 108
  2202.   return result;
  2203. #line 108
  2204. }
  2205. #line 108
  2206. static inline   
  2207. # 59 "../../tos/platform/mica2/HPLSpiM.nc"
  2208. result_t HPLSpiM$SpiByteFifo$writeByte(uint8_t data)
  2209. #line 59
  2210. {
  2211.   { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
  2212. #line 62
  2213.     HPLSpiM$OutgoingByte = data;
  2214. #line 62
  2215.     __nesc_atomic_end(__nesc_atomic); }
  2216.   return SUCCESS;
  2217. }
  2218. # 33 "../../tos/platform/mica2/SpiByteFifo.nc"
  2219. inline static   result_t CC1000RadioIntM$SpiByteFifo$writeByte(uint8_t arg_0x8634010){
  2220. #line 33
  2221.   unsigned char result;
  2222. #line 33
  2223. #line 33
  2224.   result = HPLSpiM$SpiByteFifo$writeByte(arg_0x8634010);
  2225. #line 33
  2226. #line 33
  2227.   return result;
  2228. #line 33
  2229. }
  2230. #line 33
  2231. static inline   
  2232. # 1610 "../../tos/platform/mica2/CC1000RadioIntM.nc"
  2233. result_t CC1000RadioIntM$RSSIADC$dataReady(uint16_t data)
  2234. #line 1610
  2235. {
  2236.   { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
  2237. #line 1611
  2238.     {
  2239.       uint8_t currentRadioState;
  2240.       currentRadioState = CC1000RadioIntM$RadioState;
  2241.       switch (currentRadioState) {
  2242.           case CC1000RadioIntM$IDLE_STATE: 
  2243.             if (CC1000RadioIntM$RSSIInitState == CC1000RadioIntM$IDLE_STATE) {
  2244.                 CC1000RadioIntM$usTempSquelch = data;
  2245.                 TOS_post(CC1000RadioIntM$adjustSquelch);
  2246.               }
  2247.           CC1000RadioIntM$RSSIInitState = CC1000RadioIntM$NULL_STATE;
  2248.           break;
  2249.           case CC1000RadioIntM$RX_STATE: 
  2250.             if (CC1000RadioIntM$RSSIInitState == CC1000RadioIntM$RX_STATE) {
  2251.                 CC1000RadioIntM$usRSSIVal = data;
  2252.               }
  2253.           CC1000RadioIntM$RSSIInitState = CC1000RadioIntM$NULL_STATE;
  2254.           break;
  2255.           case CC1000RadioIntM$PRETX_STATE: 
  2256.             CC1000RadioIntM$iRSSIcount++;
  2257.           if ((
  2258. #line 1636
  2259.           data > CC1000RadioIntM$usSquelchVal + 16 || 
  2260.           !CC1000RadioIntM$bCCAEnable) && CC1000RadioIntM$RSSIInitState == CC1000RadioIntM$PRETX_STATE) {
  2261.               CC1000RadioIntM$SpiByteFifo$writeByte(0xaa);
  2262.               CC1000RadioIntM$CC1000Control$TxMode();
  2263.               CC1000RadioIntM$SpiByteFifo$txMode();
  2264.               CC1000RadioIntM$usRSSIVal = data;
  2265.               CC1000RadioIntM$iRSSIcount = 5;
  2266.               CC1000RadioIntM$bRSSIValid = TRUE;
  2267.               CC1000RadioIntM$TxByteCnt = 0;
  2268.               CC1000RadioIntM$usRunningCRC = 0;
  2269.               CC1000RadioIntM$RadioState = CC1000RadioIntM$TX_STATE;
  2270.               CC1000RadioIntM$RadioTxState = CC1000RadioIntM$TXSTATE_PREAMBLE;
  2271.               CC1000RadioIntM$NextTxByte = 0xaa;
  2272.               CC1000RadioIntM$RSSIInitState = CC1000RadioIntM$NULL_STATE;
  2273.             }
  2274.           else {
  2275.               CC1000RadioIntM$RSSIInitState = CC1000RadioIntM$NULL_STATE;
  2276.               if (CC1000RadioIntM$iRSSIcount == 5) {
  2277.                   CC1000RadioIntM$sMacDelay = CC1000RadioIntM$MacBackoff$congestionBackoff(CC1000RadioIntM$txbufptr);
  2278.                   CC1000RadioIntM$RadioState = CC1000RadioIntM$IDLE_STATE;
  2279.                 }
  2280.               else {
  2281.                   CC1000RadioIntM$RSSIInitState = currentRadioState;
  2282.                   CC1000RadioIntM$RSSIADC$getData();
  2283.                 }
  2284.             }
  2285.           break;
  2286.           case CC1000RadioIntM$PULSE_CHECK_STATE: 
  2287.             {
  2288.               uint8_t done = 0;
  2289.               uint16_t threshold = CC1000RadioIntM$GetSquelch();
  2290. #line 1672
  2291.               threshold = threshold - (CC1000RadioIntM$GetSquelch() >> 2);
  2292.               if (data > threshold) {
  2293.                   CC1000RadioIntM$usTempSquelch = data;
  2294.                   TOS_post(CC1000RadioIntM$adjustSquelch);
  2295.                 }
  2296.               else {
  2297. #line 1678
  2298.                 if (CC1000RadioIntM$pulse_check_count > 5) {
  2299.                     CC1000RadioIntM$CC1000Control$RxMode();
  2300.                     CC1000RadioIntM$RadioState = CC1000RadioIntM$IDLE_STATE;
  2301.                     CC1000RadioIntM$SpiByteFifo$rxMode();
  2302.                     CC1000RadioIntM$SpiByteFifo$enableIntr();
  2303.                     TOS_post(CC1000RadioIntM$IdleTimerTask);
  2304.                     done = 1;
  2305.                   }
  2306.                 else {
  2307.                     CC1000RadioIntM$CC1000Control$RxMode();
  2308.                     if (CC1000RadioIntM$RSSIADC$getData()) {
  2309.                         TOSH_uwait(80);
  2310.                         CC1000RadioIntM$pulse_check_count++;
  2311.                         done = 1;
  2312.                       }
  2313.                     CC1000RadioIntM$pulse_check_sum++;
  2314.                     CC1000RadioIntM$CC1000StdControl$stop();
  2315.                   }
  2316.                 }
  2317.               if (CC1000RadioIntM$bTxPending) {
  2318.                   CC1000RadioIntM$CC1000Control$RxMode();
  2319.                   CC1000RadioIntM$RadioState = CC1000RadioIntM$IDLE_STATE;
  2320.                   CC1000RadioIntM$SpiByteFifo$rxMode();
  2321.                   CC1000RadioIntM$SpiByteFifo$enableIntr();
  2322.                   TOS_post(CC1000RadioIntM$IdleTimerTask);
  2323.                   done = 1;
  2324.                 }
  2325.               if (done == 0) {
  2326.                   TOS_post(CC1000RadioIntM$SleepTimerTask);
  2327.                   CC1000RadioIntM$RadioState = CC1000RadioIntM$POWER_DOWN_STATE;
  2328.                   CC1000RadioIntM$SpiByteFifo$disableIntr();
  2329.                 }
  2330.             }
  2331.           break;
  2332.           default: ;
  2333.         }
  2334.     }
  2335. #line 1719
  2336.     __nesc_atomic_end(__nesc_atomic); }
  2337.   return SUCCESS;
  2338. }
  2339. static inline    
  2340. # 118 "../../tos/platform/mica2/ADCREFM.nc"
  2341. result_t ADCREFM$ADC$default$dataReady(uint8_t port, uint16_t data)
  2342. #line 118
  2343. {
  2344.   return FAIL;
  2345. }
  2346. # 70 "/home/testuser/tinyos-1.x/tos/interfaces/ADC.nc"
  2347. inline static   result_t ADCREFM$ADC$dataReady(uint8_t arg_0x87e1880, uint16_t arg_0x8636a60){
  2348. #line 70
  2349.   unsigned char result;
  2350. #line 70
  2351. #line 70
  2352.   switch (arg_0x87e1880) {
  2353. #line 70
  2354.     case TOS_ADC_CC_RSSI_PORT:
  2355. #line 70
  2356.       result = CC1000RadioIntM$RSSIADC$dataReady(arg_0x8636a60);
  2357. #line 70
  2358.       break;
  2359. #line 70
  2360.     default:
  2361. #line 70
  2362.       result = ADCREFM$ADC$default$dataReady(arg_0x87e1880, arg_0x8636a60);
  2363. #line 70
  2364.     }
  2365. #line 70
  2366. #line 70
  2367.   return result;
  2368. #line 70
  2369. }
  2370. #line 70
  2371. static inline    
  2372. # 122 "../../tos/platform/mica2/ADCREFM.nc"
  2373. result_t ADCREFM$CalADC$default$dataReady(uint8_t port, uint16_t data)
  2374. #line 122
  2375. {
  2376.   return FAIL;
  2377. }
  2378. # 70 "/home/testuser/tinyos-1.x/tos/interfaces/ADC.nc"
  2379. inline static   result_t ADCREFM$CalADC$dataReady(uint8_t arg_0x87e1f08, uint16_t arg_0x8636a60){
  2380. #line 70
  2381.   unsigned char result;
  2382. #line 70
  2383. #line 70
  2384.     result = ADCREFM$CalADC$default$dataReady(arg_0x87e1f08, arg_0x8636a60);
  2385. #line 70
  2386. #line 70
  2387.   return result;
  2388. #line 70
  2389. }
  2390. #line 70
  2391. # 77 "/home/testuser/tinyos-1.x/tos/interfaces/HPLADC.nc"
  2392. inline static   result_t ADCREFM$HPLADC$samplePort(uint8_t arg_0x87f8690){
  2393. #line 77
  2394.   unsigned char result;
  2395. #line 77
  2396. #line 77
  2397.   result = HPLADCM$ADC$samplePort(arg_0x87f8690);
  2398. #line 77
  2399. #line 77
  2400.   return result;
  2401. #line 77
  2402. }
  2403. #line 77
  2404. static inline   
  2405. # 133 "../../tos/platform/mica2/ADCREFM.nc"
  2406. result_t ADCREFM$HPLADC$dataReady(uint16_t data)
  2407. #line 133
  2408. {
  2409.   uint16_t doneValue = data;
  2410.   uint8_t donePort;
  2411.   uint8_t nextPort = 0xff;
  2412.   bool fCalResult = FALSE;
  2413.   result_t Result = SUCCESS;
  2414. #line 139
  2415.   if (ADCREFM$ReqPort == TOS_ADC_BANDGAP_PORT) {
  2416.       ADCREFM$RefVal = data;
  2417.     }
  2418.   { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
  2419. #line 143
  2420.     {
  2421.       donePort = ADCREFM$ReqPort;
  2422.       if (((1 << donePort) & ADCREFM$ContReqMask) == 0) {
  2423.           ADCREFM$ReqVector ^= 1 << donePort;
  2424.         }
  2425.       if ((1 << donePort) & ADCREFM$CalReqMask) {
  2426.           fCalResult = TRUE;
  2427.           if (((1 << donePort) & ADCREFM$ContReqMask) == 0) {
  2428.               ADCREFM$CalReqMask ^= 1 << donePort;
  2429.             }
  2430.         }
  2431.       if (ADCREFM$ReqVector) {
  2432.           do {
  2433.               ADCREFM$ReqPort++;
  2434.               ADCREFM$ReqPort = ADCREFM$ReqPort == TOSH_ADC_PORTMAPSIZE ? 0 : ADCREFM$ReqPort;
  2435.             }
  2436.           while (((
  2437. #line 164
  2438.           1 << ADCREFM$ReqPort) & ADCREFM$ReqVector) == 0);
  2439.           nextPort = ADCREFM$ReqPort;
  2440.         }
  2441.     }
  2442. #line 167
  2443.     __nesc_atomic_end(__nesc_atomic); }
  2444.   if (nextPort != 0xff) {
  2445.       ADCREFM$HPLADC$samplePort(nextPort);
  2446.     }
  2447.   {
  2448.   }
  2449. #line 174
  2450.   ;
  2451.   if (donePort != TOS_ADC_BANDGAP_PORT) {
  2452.       if (fCalResult) {
  2453.           uint32_t tmp = (uint32_t )data;
  2454. #line 178
  2455.           tmp = tmp << 10;
  2456.           tmp = tmp / ADCREFM$RefVal;
  2457.           doneValue = (uint16_t )tmp;
  2458.           Result = ADCREFM$CalADC$dataReady(donePort, doneValue);
  2459.         }
  2460.       else {
  2461.           Result = ADCREFM$ADC$dataReady(donePort, doneValue);
  2462.         }
  2463.     }
  2464.   { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
  2465. #line 188
  2466.     {
  2467.       if (ADCREFM$ContReqMask & (1 << donePort) && Result == FAIL) {
  2468.           ADCREFM$ContReqMask ^= 1 << donePort;
  2469.         }
  2470.     }
  2471. #line 192
  2472.     __nesc_atomic_end(__nesc_atomic); }
  2473.   return SUCCESS;
  2474. }
  2475. # 99 "/home/testuser/tinyos-1.x/tos/interfaces/HPLADC.nc"
  2476. inline static   result_t HPLADCM$ADC$dataReady(uint16_t arg_0x87f91b8){
  2477. #line 99
  2478.   unsigned char result;
  2479. #line 99
  2480. #line 99
  2481.   result = ADCREFM$HPLADC$dataReady(arg_0x87f91b8);
  2482. #line 99
  2483. #line 99
  2484.   return result;
  2485. #line 99
  2486. }
  2487. #line 99
  2488. static inline   
  2489. # 97 "/home/testuser/tinyos-1.x/tos/platform/mica/HPLClock.nc"
  2490. uint8_t HPLClock$Clock$getInterval(void)
  2491. #line 97
  2492. {
  2493.   return * (volatile uint8_t *)(0x31 + 0x20);
  2494. }
  2495. # 121 "/home/testuser/tinyos-1.x/tos/interfaces/Clock.nc"
  2496. inline static   uint8_t TimerM$Clock$getInterval(void){
  2497. #line 121
  2498.   unsigned char result;
  2499. #line 121
  2500. #line 121
  2501.   result = HPLClock$Clock$getInterval();
  2502. #line 121
  2503. #line 121
  2504.   return result;
  2505. #line 121
  2506. }
  2507. #line 121
  2508. # 41 "/home/testuser/tinyos-1.x/tos/interfaces/PowerManagement.nc"
  2509. inline static   uint8_t TimerM$PowerManagement$adjustPower(void){
  2510. #line 41
  2511.   unsigned char result;
  2512. #line 41
  2513. #line 41
  2514.   result = HPLPowerManagementM$PowerManagement$adjustPower();
  2515. #line 41
  2516. #line 41
  2517.   return result;
  2518. #line 41
  2519. }
  2520. #line 41
  2521. static inline   
  2522. # 87 "/home/testuser/tinyos-1.x/tos/platform/mica/HPLClock.nc"
  2523. void HPLClock$Clock$setInterval(uint8_t value)
  2524. #line 87
  2525. {
  2526.   * (volatile uint8_t *)(0x31 + 0x20) = value;
  2527. }
  2528. # 105 "/home/testuser/tinyos-1.x/tos/interfaces/Clock.nc"
  2529. inline static   void TimerM$Clock$setInterval(uint8_t arg_0x882d378){
  2530. #line 105
  2531.   HPLClock$Clock$setInterval(arg_0x882d378);
  2532. #line 105
  2533. }
  2534. #line 105
  2535. static inline   
  2536. # 134 "/home/testuser/tinyos-1.x/tos/platform/mica/HPLClock.nc"
  2537. uint8_t HPLClock$Clock$readCounter(void)
  2538. #line 134
  2539. {
  2540.   return * (volatile uint8_t *)(0x32 + 0x20);
  2541. }
  2542. # 153 "/home/testuser/tinyos-1.x/tos/interfaces/Clock.nc"
  2543. inline static   uint8_t TimerM$Clock$readCounter(void){
  2544. #line 153
  2545.   unsigned char result;
  2546. #line 153
  2547. #line 153
  2548.   result = HPLClock$Clock$readCounter();
  2549. #line 153
  2550. #line 153
  2551.   return result;
  2552. #line 153
  2553. }
  2554. #line 153
  2555. # 129 "/home/testuser/tinyos-1.x/tos/system/TimerM.nc"
  2556. static void TimerM$adjustInterval(void)
  2557. #line 129
  2558. {
  2559.   uint8_t i;
  2560. #line 130
  2561.   uint8_t val = TimerM$maxTimerInterval;
  2562. #line 131
  2563.   if (TimerM$mState) {
  2564.       for (i = 0; i < NUM_TIMERS; i++) {
  2565.           if (TimerM$mState & (0x1L << i) && TimerM$mTimerList[i].ticksLeft < val) {
  2566.               val = TimerM$mTimerList[i].ticksLeft;
  2567.             }
  2568.         }
  2569. #line 148
  2570.       { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
  2571. #line 148
  2572.         {
  2573.           i = TimerM$Clock$readCounter() + 3;
  2574.           if (val < i) {
  2575.               val = i;
  2576.             }
  2577.           TimerM$mInterval = val;
  2578.           TimerM$Clock$setInterval(TimerM$mInterval);
  2579.           TimerM$setIntervalFlag = 0;
  2580.         }
  2581. #line 156
  2582.         __nesc_atomic_end(__nesc_atomic); }
  2583.     }
  2584.   else {
  2585.       { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
  2586. #line 159
  2587.         {
  2588.           TimerM$mInterval = TimerM$maxTimerInterval;
  2589.           TimerM$Clock$setInterval(TimerM$mInterval);
  2590.           TimerM$setIntervalFlag = 0;
  2591.         }
  2592. #line 163
  2593.         __nesc_atomic_end(__nesc_atomic); }
  2594.     }
  2595.   TimerM$PowerManagement$adjustPower();
  2596. }
  2597. static inline 
  2598. #line 186
  2599. void TimerM$enqueue(uint8_t value)
  2600. #line 186
  2601. {
  2602.   if (TimerM$queue_tail == NUM_TIMERS - 1) {
  2603.     TimerM$queue_tail = -1;
  2604.     }
  2605. #line 189
  2606.   TimerM$queue_tail++;
  2607.   TimerM$queue_size++;
  2608.   TimerM$queue[(uint8_t )TimerM$queue_tail] = value;
  2609. }
  2610. static inline  
  2611. # 722 "/home/testuser/tinyos-1.x/tos/lib/MintRoute/MultiHopWMEWMA.nc"
  2612. result_t MultiHopWMEWMA$RouteSelect$initializeFields(TOS_MsgPtr Msg, uint8_t id)
  2613. #line 722
  2614. {
  2615.   TOS_MHopMsg *pMHMsg = (TOS_MHopMsg *)&Msg->data[0];
  2616.   pMHMsg->sourceaddr = pMHMsg->originaddr = TOS_LOCAL_ADDRESS;
  2617.   pMHMsg->hopcount = MultiHopWMEWMA$ROUTE_INVALID;
  2618.   return SUCCESS;
  2619. }
  2620. # 86 "/home/testuser/tinyos-1.x/tos/interfaces/RouteSelect.nc"
  2621. inline static  result_t MultiHopEngineM$RouteSelect$initializeFields(TOS_MsgPtr arg_0x89399b8, uint8_t arg_0x8939b00){
  2622. #line 86
  2623.   unsigned char result;
  2624. #line 86
  2625. #line 86
  2626.   result = MultiHopWMEWMA$RouteSelect$initializeFields(arg_0x89399b8, arg_0x8939b00);
  2627. #line 86
  2628. #line 86
  2629.   return result;
  2630. #line 86
  2631. }
  2632. #line 86
  2633. static inline  
  2634. # 124 "/home/testuser/tinyos-1.x/tos/lib/MintRoute/MultiHopEngineM.nc"
  2635. result_t MultiHopEngineM$Send$send(uint8_t id, TOS_MsgPtr pMsg, uint16_t PayloadLen)
  2636. #line 124
  2637. {
  2638.   uint16_t usMHLength = (size_t )& ((TOS_MHopMsg *)0)->data + PayloadLen;
  2639.   if (usMHLength > 70) {
  2640.       return FAIL;
  2641.     }
  2642.   MultiHopEngineM$RouteSelect$initializeFields(pMsg, id);
  2643.   if (MultiHopEngineM$RouteSelect$selectRoute(pMsg, id) != SUCCESS) {
  2644.       return FAIL;
  2645.     }
  2646.   if (MultiHopEngineM$SendMsg$send(id, pMsg->addr, usMHLength, pMsg) != SUCCESS) {
  2647.       return FAIL;
  2648.     }
  2649.   return SUCCESS;
  2650. }
  2651. # 83 "/home/testuser/tinyos-1.x/tos/interfaces/Send.nc"
  2652. inline static  result_t MultiHopTtestM$Send$send(TOS_MsgPtr arg_0x8562cc0, uint16_t arg_0x8562e10){
  2653. #line 83
  2654.   unsigned char result;
  2655. #line 83
  2656. #line 83
  2657.   result = MultiHopEngineM$Send$send(AM_MULTIHOP, arg_0x8562cc0, arg_0x8562e10);
  2658. #line 83
  2659. #line 83
  2660.   return result;
  2661. #line 83
  2662. }
  2663. #line 83
  2664. static inline  
  2665. # 107 "MultiHopTtestM.nc"
  2666. result_t MultiHopTtestM$SendTimer$fired(void)
  2667. #line 107
  2668. {
  2669.   if (!MultiHopTtestM$txBusy && MultiHopTtestM$gotFrames) {
  2670.       if (MultiHopTtestM$Send$send(&MultiHopTtestM$DataPkt, sizeof(multiHopMsg )) == SUCCESS) {
  2671.           MultiHopTtestM$txBusy = TRUE;
  2672.         }
  2673.       else 
  2674. #line 114
  2675.         {
  2676.         }
  2677.     }
  2678.   return SUCCESS;
  2679. }
  2680. # 59 "/home/testuser/tinyos-1.x/tos/interfaces/Timer.nc"
  2681. inline static  result_t MultiHopTtestM$StatTimer$start(char arg_0x8561bb8, uint32_t arg_0x8561d10){
  2682. #line 59
  2683.   unsigned char result;
  2684. #line 59
  2685. #line 59
  2686.   result = TimerM$Timer$start(1, arg_0x8561bb8, arg_0x8561d10);
  2687. #line 59
  2688. #line 59
  2689.   return result;
  2690. #line 59
  2691. }
  2692. #line 59
  2693. # 59 "/home/testuser/tinyos-1.x/tos/interfaces/Timer.nc"
  2694. inline static  result_t MultiHopTtestM$SendTimer$start(char arg_0x8561bb8, uint32_t arg_0x8561d10){
  2695. #line 59
  2696.   unsigned char result;
  2697. #line 59
  2698. #line 59
  2699.   result = TimerM$Timer$start(2, arg_0x8561bb8, arg_0x8561d10);
  2700. #line 59
  2701. #line 59
  2702.   return result;
  2703. #line 59
  2704. }
  2705. #line 59
  2706. static inline   
  2707. # 1744 "../../tos/platform/mica2/CC1000RadioIntM.nc"
  2708. uint16_t CC1000RadioIntM$GetPower_sp(void)
  2709. #line 1744
  2710. {
  2711.   return CC1000RadioIntM$sp_sum;
  2712. }
  2713. # 29 "MultiHopTtestM.nc"
  2714. inline static   uint16_t MultiHopTtestM$GetPower_sp(void){
  2715. #line 29
  2716.   unsigned int result;
  2717. #line 29
  2718. #line 29
  2719.   result = CC1000RadioIntM$GetPower_sp();
  2720. #line 29
  2721. #line 29
  2722.   return result;
  2723. #line 29
  2724. }
  2725. #line 29
  2726. static inline   
  2727. # 1741 "../../tos/platform/mica2/CC1000RadioIntM.nc"
  2728. uint16_t CC1000RadioIntM$GetPower_rx(void)
  2729. #line 1741
  2730. {
  2731.   return CC1000RadioIntM$rx_sum;
  2732. }
  2733. # 30 "MultiHopTtestM.nc"
  2734. inline static   uint16_t MultiHopTtestM$GetPower_rx(void){
  2735. #line 30
  2736.   unsigned int result;
  2737. #line 30
  2738. #line 30
  2739.   result = CC1000RadioIntM$GetPower_rx();
  2740. #line 30
  2741. #line 30
  2742.   return result;
  2743. #line 30
  2744. }
  2745. #line 30
  2746. static inline   
  2747. # 1738 "../../tos/platform/mica2/CC1000RadioIntM.nc"
  2748. uint16_t CC1000RadioIntM$GetPower_tx(void)
  2749. #line 1738
  2750. {
  2751.   return CC1000RadioIntM$tx_sum;
  2752. }
  2753. # 27 "MultiHopTtestM.nc"
  2754. inline static   uint16_t MultiHopTtestM$GetPower_tx(void){
  2755. #line 27
  2756.   unsigned int result;
  2757. #line 27
  2758. #line 27
  2759.   result = CC1000RadioIntM$GetPower_tx();
  2760. #line 27
  2761. #line 27
  2762.   return result;
  2763. #line 27
  2764. }
  2765. #line 27
  2766. static inline   
  2767. # 1731 "../../tos/platform/mica2/CC1000RadioIntM.nc"
  2768. uint16_t CC1000RadioIntM$GetDataSent(void)
  2769. #line 1731
  2770. {
  2771.   return CC1000RadioIntM$dataSent;
  2772. }
  2773. # 28 "MultiHopTtestM.nc"
  2774. inline static   uint16_t MultiHopTtestM$GetDataSent(void){
  2775. #line 28
  2776.   unsigned int result;
  2777. #line 28
  2778. #line 28
  2779.   result = CC1000RadioIntM$GetDataSent();
  2780. #line 28
  2781. #line 28
  2782.   return result;
  2783. #line 28
  2784. }
  2785. #line 28
  2786. static inline  
  2787. #line 123
  2788. result_t MultiHopTtestM$StatTimer$fired(void)
  2789. #line 123
  2790. {
  2791.   if (!MultiHopTtestM$drandFirstTime && MultiHopTtestM$gotFrames) {
  2792.       uint8_t i;
  2793. #line 126
  2794.       MultiHopTtestM$time++;
  2795.       for (i = 0; i < 50; i++) {
  2796.           if (MultiHopTtestM$eachCount[i] != 0) 
  2797.             {
  2798. #line 129
  2799.               char bStatus;
  2800. #line 129
  2801.               if (DBG_USR2 != 0) {
  2802. #line 129
  2803.                   bStatus = * (volatile uint8_t *)(uint16_t )& * (volatile uint8_t *)(0x3F + 0x20) & (1 << 7);
  2804. #line 129
  2805.                    __asm volatile ("cli");MultiHopTtestM$sprintf(MultiHopTtestM$debugbuf, "      %u : %un", (uint8_t )i, (uint16_t )MultiHopTtestM$eachCount[i]);
  2806. #line 129
  2807.                   MultiHopTtestM$writedebug();
  2808. #line 129
  2809.                   if (bStatus) {
  2810. #line 129
  2811.                      __asm volatile ("sei");
  2812.                     }
  2813.                 }
  2814.             }
  2815. #line 129
  2816.           ;
  2817.         }
  2818.       {
  2819. #line 131
  2820.         char bStatus;
  2821. #line 131
  2822.         if (DBG_USR2 != 0) {
  2823. #line 131
  2824.             bStatus = * (volatile uint8_t *)(uint16_t )& * (volatile uint8_t *)(0x3F + 0x20) & (1 << 7);
  2825. #line 131
  2826.              __asm volatile ("cli");MultiHopTtestM$sprintf(MultiHopTtestM$debugbuf, "Rcount %u Scount %u EnergyTX %u EnergyRX %u EnergySP %un", MultiHopTtestM$Rcount, MultiHopTtestM$GetDataSent(), MultiHopTtestM$GetPower_tx(), MultiHopTtestM$GetPower_rx(), MultiHopTtestM$GetPower_sp());
  2827. #line 131
  2828.             MultiHopTtestM$writedebug();
  2829. #line 131
  2830.             if (bStatus) {
  2831. #line 131
  2832.                __asm volatile ("sei");
  2833.               }
  2834.           }
  2835.       }
  2836. #line 131
  2837.       ;
  2838.       MultiHopTtestM$Rcount = 0;
  2839.       MultiHopTtestM$Scount = 0;
  2840.       MultiHopTtestM$ResetPower();
  2841.       MultiHopTtestM$ResetDataSent();
  2842.       for (i = 0; i < 50; i++) 
  2843.         MultiHopTtestM$eachCount[i] = 0;
  2844.     }
  2845.   else {
  2846. #line 139
  2847.     if (MultiHopTtestM$drandFirstTime && MultiHopTtestM$gotFrames) {
  2848.         if (TOS_LOCAL_ADDRESS != 0) {
  2849.             MultiHopTtestM$SendTimer$start(TIMER_REPEAT, 1000);
  2850.           }
  2851.         MultiHopTtestM$StatTimer$start(TIMER_REPEAT, STAT_TIME);
  2852.         MultiHopTtestM$drandFirstTime = FALSE;
  2853.       }
  2854.     }
  2855. #line 146
  2856.   return SUCCESS;
  2857. }
  2858. static inline  
  2859. # 735 "/home/testuser/tinyos-1.x/tos/lib/MintRoute/MultiHopWMEWMA.nc"
  2860. uint16_t MultiHopWMEWMA$RouteControl$getParent(void)
  2861. #line 735
  2862. {
  2863.   uint16_t addr;
  2864.   addr = MultiHopWMEWMA$gpCurrentParent != (void *)0 ? MultiHopWMEWMA$gpCurrentParent->id : 0xffff;
  2865.   return addr;
  2866. }
  2867. # 49 "/home/testuser/tinyos-1.x/tos/interfaces/RouteControl.nc"
  2868. inline static  uint16_t MultiHopEngineM$RouteSelectCntl$getParent(void){
  2869. #line 49
  2870.   unsigned int result;
  2871. #line 49
  2872. #line 49
  2873.   result = MultiHopWMEWMA$RouteControl$getParent();
  2874. #line 49
  2875. #line 49
  2876.   return result;
  2877. #line 49
  2878. }
  2879. #line 49
  2880. static inline  
  2881. # 215 "/home/testuser/tinyos-1.x/tos/lib/MintRoute/MultiHopEngineM.nc"
  2882. uint16_t MultiHopEngineM$RouteControl$getParent(void)
  2883. #line 215
  2884. {
  2885.   return MultiHopEngineM$RouteSelectCntl$getParent();
  2886. }
  2887. # 49 "/home/testuser/tinyos-1.x/tos/interfaces/RouteControl.nc"
  2888. inline static  uint16_t MultiHopTtestM$RouteControl$getParent(void){
  2889. #line 49
  2890.   unsigned int result;
  2891. #line 49
  2892. #line 49
  2893.   result = MultiHopEngineM$RouteControl$getParent();
  2894. #line 49
  2895. #line 49
  2896.   return result;
  2897. #line 49
  2898. }
  2899. #line 49
  2900. # 4 "../../tos/interfaces/SetDrand.nc"
  2901. inline static  result_t MultiHopTtestM$SetDrand$Set(nodeInfo *arg_0x85796b8, uint8_t arg_0x8579800, nodeInfo *arg_0x8579968, uint16_t arg_0x8579ab8){
  2902. #line 4
  2903.   unsigned char result;
  2904. #line 4
  2905. #line 4
  2906.   result = CC1000RadioIntM$SetDrand$Set(arg_0x85796b8, arg_0x8579800, arg_0x8579968, arg_0x8579ab8);
  2907. #line 4
  2908. #line 4
  2909.   return result;
  2910. #line 4
  2911. }
  2912. #line 4
  2913. static inline  
  2914. # 149 "MultiHopTtestM.nc"
  2915. result_t MultiHopTtestM$RouteTimer$fired(void)
  2916. #line 149
  2917. {
  2918.   MultiHopTtestM$drandFirstTime = FALSE;
  2919.   if (TOS_LOCAL_ADDRESS == 0) {
  2920.       MultiHopTtestM$SetDrand$Set((void *)0, 0, (void *)0, 50);
  2921.     }
  2922.   else 
  2923. #line 158
  2924.     {
  2925.       MultiHopTtestM$SendTimer$start(TIMER_REPEAT, 1000);
  2926.       MultiHopTtestM$SetDrand$Set((void *)0, MultiHopTtestM$RouteControl$getParent(), (void *)0, 50);
  2927.     }
  2928.   MultiHopTtestM$StatTimer$start(TIMER_REPEAT, STAT_TIME);
  2929.   return SUCCESS;
  2930. }
  2931. static inline  
  2932. # 179 "/home/testuser/tinyos-1.x/tos/system/AMPromiscuous.nc"
  2933. result_t AMPromiscuous$ActivityTimer$fired(void)
  2934. #line 179
  2935. {
  2936.   AMPromiscuous$lastCount = AMPromiscuous$counter;
  2937.   AMPromiscuous$counter = 0;
  2938.   return SUCCESS;
  2939. }
  2940. # 59 "/home/testuser/tinyos-1.x/tos/interfaces/Timer.nc"
  2941. inline static  result_t CC1000RadioIntM$TDMATimer$start(char arg_0x8561bb8, uint32_t arg_0x8561d10){
  2942. #line 59
  2943.   unsigned char result;
  2944. #line 59
  2945. #line 59
  2946.   result = TimerM$Timer$start(6, arg_0x8561bb8, arg_0x8561d10);
  2947. #line 59
  2948. #line 59
  2949.   return result;
  2950. #line 59
  2951. }
  2952. #line 59
  2953. static inline  
  2954. # 980 "../../tos/platform/mica2/CC1000RadioIntM.nc"
  2955. result_t CC1000RadioIntM$TDMATimer$fired(void)
  2956. #line 980
  2957. {
  2958.   CC1000RadioIntM$TDMATimer$start(TIMER_ONE_SHOT, CC1000RadioIntM$slotMultiplier);
  2959.   CC1000RadioIntM$slotNum++;
  2960.   { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
  2961. #line 983
  2962.     CC1000RadioIntM$currentMAC = CC1000RadioIntM$ZMAC;
  2963. #line 983
  2964.     __nesc_atomic_end(__nesc_atomic); }
  2965.   { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
  2966. #line 984
  2967.     {
  2968.       CC1000RadioIntM$currentSlot = CC1000RadioIntM$slotNum & (CC1000RadioIntM$localFrameLength - 1);
  2969.       CC1000RadioIntM$globalSlot = CC1000RadioIntM$slotNum & (CC1000RadioIntM$globalFrameLength - 1);
  2970.       if (CC1000RadioIntM$HCLselect) {
  2971.           CC1000RadioIntM$slots_since_ecnsend++;
  2972.           CC1000RadioIntM$slots_since_ecnrecv++;
  2973.           CC1000RadioIntM$slots_since_ecncheck++;
  2974.           if (CC1000RadioIntM$packetsSent > 10 && CC1000RadioIntM$slots_since_ecncheck >= 16) {
  2975.               double currentLoss = (double )CC1000RadioIntM$congBackOffs / CC1000RadioIntM$packetsSent;
  2976. #line 996
  2977.               CC1000RadioIntM$avgLoss = 0.25 * currentLoss + (1 - 0.25) * CC1000RadioIntM$avgLoss;
  2978.               CC1000RadioIntM$slots_since_ecncheck = 0;
  2979.               CC1000RadioIntM$congBackOffs = 0;
  2980.               CC1000RadioIntM$packetsSent = 0;
  2981.               if (CC1000RadioIntM$avgLoss > 3.0 && CC1000RadioIntM$slots_since_ecnsend >= 96) {
  2982.                   ecnMsgType *ecnMsgPtr = (ecnMsgType *)CC1000RadioIntM$ecnMsgHdr.data;
  2983.                   CC1000RadioIntM$enableHCL = TRUE;
  2984.                   CC1000RadioIntM$slots_since_ecnrecv = 0;
  2985.                   ecnMsgPtr->nextHop = CC1000RadioIntM$nextHop;
  2986.                   if (!CC1000RadioIntM$pureHCL) {
  2987.                     CC1000RadioIntM$ecnPending = TRUE;
  2988.                     }
  2989.                 }
  2990.             }
  2991. #line 1018
  2992.           if (CC1000RadioIntM$enableHCL && CC1000RadioIntM$slots_since_ecnrecv >= 192) {
  2993.               if (!CC1000RadioIntM$pureHCL) {
  2994.                 CC1000RadioIntM$enableHCL = FALSE;
  2995.                 }
  2996.             }
  2997.         }
  2998. #line 1036
  2999.       if (CC1000RadioIntM$bTxPending) {
  3000.           CC1000RadioIntM$sMacDelay = CC1000RadioIntM$getZMACBackoff(CC1000RadioIntM$sMacDelay);
  3001.         }
  3002.     }
  3003. #line 1039
  3004.     __nesc_atomic_end(__nesc_atomic); }
  3005.   return SUCCESS;
  3006. }
  3007. # 68 "/home/testuser/tinyos-1.x/tos/interfaces/Timer.nc"
  3008. inline static  result_t CC1000RadioIntM$SquelchTimer$stop(void){
  3009. #line 68
  3010.   unsigned char result;
  3011. #line 68
  3012. #line 68
  3013.   result = TimerM$Timer$stop(4);
  3014. #line 68
  3015. #line 68
  3016.   return result;
  3017. #line 68
  3018. }
  3019. #line 68
  3020. static inline  
  3021. # 927 "../../tos/platform/mica2/CC1000RadioIntM.nc"
  3022. result_t CC1000RadioIntM$WakeupTimer$fired(void)
  3023. #line 927
  3024. {
  3025.   uint8_t currentRadioState;
  3026.   if (CC1000RadioIntM$lplpower == 0) {
  3027.     return SUCCESS;
  3028.     }
  3029.   { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
  3030. #line 933
  3031.     currentRadioState = CC1000RadioIntM$RadioState;
  3032. #line 933
  3033.     __nesc_atomic_end(__nesc_atomic); }
  3034.   switch (currentRadioState) {
  3035.       case CC1000RadioIntM$IDLE_STATE: 
  3036.         if (!CC1000RadioIntM$bTxPending) {
  3037.             { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
  3038. #line 938
  3039.               {
  3040.                 CC1000RadioIntM$RadioState = CC1000RadioIntM$POWER_DOWN_STATE;
  3041.                 CC1000RadioIntM$SpiByteFifo$disableIntr();
  3042.               }
  3043. #line 941
  3044.               __nesc_atomic_end(__nesc_atomic); }
  3045.             CC1000RadioIntM$WakeupTimer$start(TIMER_ONE_SHOT, CC1000RadioIntM$sleeptime);
  3046.             CC1000RadioIntM$SquelchTimer$stop();
  3047.             CC1000RadioIntM$CC1000StdControl$stop();
  3048.           }
  3049.         else 
  3050. #line 945
  3051.           {
  3052.             CC1000RadioIntM$WakeupTimer$start(TIMER_ONE_SHOT, CC1000RadioIntM$sleeptime);
  3053.           }
  3054.       break;
  3055.       case CC1000RadioIntM$POWER_DOWN_STATE: 
  3056.         { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
  3057. #line 951
  3058.           CC1000RadioIntM$RadioState = CC1000RadioIntM$PULSE_CHECK_STATE;
  3059. #line 951
  3060.           __nesc_atomic_end(__nesc_atomic); }
  3061.       CC1000RadioIntM$pulse_check_count = 0;
  3062.       CC1000RadioIntM$CC1000StdControl$start();
  3063.       CC1000RadioIntM$CC1000Control$BIASOn();
  3064.       CC1000RadioIntM$WakeupTimer$start(TIMER_ONE_SHOT, 1);
  3065.       return SUCCESS;
  3066.       break;
  3067.       case CC1000RadioIntM$PULSE_CHECK_STATE: 
  3068.         CC1000RadioIntM$CC1000Control$RxMode();
  3069.       if (!CC1000RadioIntM$RSSIADC$getData()) {
  3070.           CC1000RadioIntM$WakeupTimer$start(TIMER_ONE_SHOT, CC1000RadioIntM$TIME_BETWEEN_CHECKS);
  3071.           { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
  3072. #line 963
  3073.             CC1000RadioIntM$RadioState = CC1000RadioIntM$POWER_DOWN_STATE;
  3074. #line 963
  3075.             __nesc_atomic_end(__nesc_atomic); }
  3076.         }
  3077.       else {
  3078.           TOSH_uwait(80);
  3079.         }
  3080.       CC1000RadioIntM$CC1000StdControl$stop();
  3081.       CC1000RadioIntM$pulse_check_sum++;
  3082.       break;
  3083.       default: 
  3084.         CC1000RadioIntM$WakeupTimer$start(TIMER_ONE_SHOT, 5);
  3085.     }
  3086.   return SUCCESS;
  3087. }
  3088. static inline  
  3089. #line 916
  3090. result_t CC1000RadioIntM$SquelchTimer$fired(void)
  3091. #line 916
  3092. {
  3093.   char currentRadioState;
  3094. #line 918
  3095.   { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
  3096. #line 918
  3097.     currentRadioState = CC1000RadioIntM$RadioState;
  3098. #line 918
  3099.     __nesc_atomic_end(__nesc_atomic); }
  3100.   if (currentRadioState == CC1000RadioIntM$IDLE_STATE) {
  3101.       { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
  3102. #line 921
  3103.         CC1000RadioIntM$RSSIInitState = currentRadioState;
  3104. #line 921
  3105.         __nesc_atomic_end(__nesc_atomic); }
  3106.       CC1000RadioIntM$RSSIADC$getData();
  3107.     }
  3108.   return SUCCESS;
  3109. }
  3110. static inline   
  3111. # 284 "../../tos/platform/mica2/ADCREFM.nc"
  3112. result_t ADCREFM$ADCControl$manualCalibrate(void)
  3113. #line 284
  3114. {
  3115.   result_t Result;
  3116.   { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
  3117. #line 287
  3118.     {
  3119.       Result = ADCREFM$startGet(TOS_ADC_BANDGAP_PORT);
  3120.     }
  3121. #line 289
  3122.     __nesc_atomic_end(__nesc_atomic); }
  3123.   return Result;
  3124. }
  3125. static inline  
  3126. #line 92
  3127. void ADCREFM$CalTask(void)
  3128. #line 92
  3129. {
  3130.   ADCREFM$ADCControl$manualCalibrate();
  3131.   return;
  3132. }
  3133. static inline  
  3134. #line 126
  3135. result_t ADCREFM$Timer$fired(void)
  3136. #line 126
  3137. {
  3138.   TOS_post(ADCREFM$CalTask);
  3139.   return SUCCESS;
  3140. }
  3141. # 48 "/home/testuser/tinyos-1.x/tos/interfaces/SendMsg.nc"
  3142. inline static  result_t MultiHopWMEWMA$SendMsg$send(uint16_t arg_0x85a9e28, uint8_t arg_0x85b0010, TOS_MsgPtr arg_0x85b0160){
  3143. #line 48
  3144.   unsigned char result;
  3145. #line 48
  3146. #line 48
  3147.   result = QueuedSendM$QueueSendMsg$send(AM_MULTIHOPMSG, arg_0x85a9e28, arg_0x85b0010, arg_0x85b0160);
  3148. #line 48
  3149. #line 48
  3150.   return result;
  3151. #line 48
  3152. }
  3153. #line 48
  3154. static inline  
  3155. # 447 "/home/testuser/tinyos-1.x/tos/lib/MintRoute/MultiHopWMEWMA.nc"
  3156. void MultiHopWMEWMA$SendRouteTask(void)
  3157. #line 447
  3158. {
  3159.   TOS_MHopMsg *pMHMsg = (TOS_MHopMsg *)&MultiHopWMEWMA$routeMsg.data[0];
  3160.   MultiHopWMEWMA$RoutePacket *pRP = (MultiHopWMEWMA$RoutePacket *)&pMHMsg->data[0];
  3161.   uint8_t length = (size_t )& ((TOS_MHopMsg *)0)->data + (size_t )& ((MultiHopWMEWMA$RoutePacket *)0)->estList;
  3162.   uint8_t maxEstEntries;
  3163.   uint8_t i;
  3164. #line 452
  3165.   uint8_t j;
  3166.   uint8_t last_index_added = 0;
  3167.   if (MultiHopWMEWMA$gfSendRouteBusy) {
  3168.       return;
  3169.     }
  3170.   {
  3171.   }
  3172. #line 459
  3173.   ;
  3174.   {
  3175.   }
  3176. #line 460
  3177.   ;
  3178.   maxEstEntries = 70 - length;
  3179.   maxEstEntries = maxEstEntries / sizeof(MultiHopWMEWMA$RPEstEntry );
  3180.   pRP->parent = MultiHopWMEWMA$gpCurrentParent ? MultiHopWMEWMA$gpCurrentParent->id : MultiHopWMEWMA$ROUTE_INVALID;
  3181.   pRP->cost = MultiHopWMEWMA$gbCurrentCost;
  3182.   for (i = 0, j = 0; i < MultiHopWMEWMA$ROUTE_TABLE_SIZE && j < maxEstEntries; i++) {
  3183.       uint8_t table_index = i + MultiHopWMEWMA$last_entry_sent + 1;
  3184. #line 471
  3185.       if (table_index >= MultiHopWMEWMA$ROUTE_TABLE_SIZE) {
  3186. #line 471
  3187.         table_index -= MultiHopWMEWMA$ROUTE_TABLE_SIZE;
  3188.         }
  3189. #line 472
  3190.       if (MultiHopWMEWMA$NeighborTbl[table_index].flags & MultiHopWMEWMA$NBRFLAG_VALID && MultiHopWMEWMA$NeighborTbl[table_index].receiveEst > 100) {
  3191.           pRP->estList[j].id = MultiHopWMEWMA$NeighborTbl[table_index].id;
  3192.           pRP->estList[j].receiveEst = MultiHopWMEWMA$NeighborTbl[table_index].receiveEst;
  3193.           j++;
  3194.           length += sizeof(MultiHopWMEWMA$RPEstEntry );
  3195.           last_index_added = table_index;
  3196.           {
  3197.           }
  3198. #line 478
  3199.           ;
  3200.         }
  3201.     }
  3202.   MultiHopWMEWMA$last_entry_sent = last_index_added;
  3203.   {
  3204.   }
  3205. #line 482
  3206.   ;
  3207.   pRP->estEntries = j;
  3208.   pMHMsg->sourceaddr = pMHMsg->originaddr = TOS_LOCAL_ADDRESS;
  3209.   pMHMsg->hopcount = MultiHopWMEWMA$gbCurrentHopCount;
  3210.   pMHMsg->seqno = MultiHopWMEWMA$gCurrentSeqNo++;
  3211.   if (MultiHopWMEWMA$SendMsg$send(TOS_BCAST_ADDR, length, &MultiHopWMEWMA$routeMsg) == SUCCESS) {
  3212.       MultiHopWMEWMA$gfSendRouteBusy = TRUE;
  3213.     }
  3214. }
  3215. static inline  
  3216. #line 589
  3217. result_t MultiHopWMEWMA$ATimer$fired(void)
  3218. #line 589
  3219. {
  3220.   TOS_post(MultiHopWMEWMA$SendRouteTask);
  3221.   return SUCCESS;
  3222. }
  3223. static inline  
  3224. #line 792
  3225. result_t MultiHopWMEWMA$Timer$fired(void)
  3226. #line 792
  3227. {
  3228.   TOS_post(MultiHopWMEWMA$TimerTask);
  3229.   return SUCCESS;
  3230. }
  3231. static inline   
  3232. # 182 "/home/testuser/tinyos-1.x/tos/system/TimerM.nc"
  3233. result_t TimerM$Timer$default$fired(uint8_t id)
  3234. #line 182
  3235. {
  3236.   return SUCCESS;
  3237. }
  3238. # 73 "/home/testuser/tinyos-1.x/tos/interfaces/Timer.nc"
  3239. inline static  result_t TimerM$Timer$fired(uint8_t arg_0x85e4d90){
  3240. #line 73
  3241.   unsigned char result;
  3242. #line 73
  3243. #line 73
  3244.   switch (arg_0x85e4d90) {
  3245. #line 73
  3246.     case 0:
  3247. #line 73
  3248.       result = MultiHopTtestM$RouteTimer$fired();
  3249. #line 73
  3250.       break;
  3251. #line 73
  3252.     case 1:
  3253. #line 73
  3254.       result = MultiHopTtestM$StatTimer$fired();
  3255. #line 73
  3256.       break;
  3257. #line 73
  3258.     case 2:
  3259. #line 73
  3260.       result = MultiHopTtestM$SendTimer$fired();
  3261. #line 73
  3262.       break;
  3263. #line 73
  3264.     case 3:
  3265. #line 73
  3266.       result = AMPromiscuous$ActivityTimer$fired();
  3267. #line 73
  3268.       break;
  3269. #line 73
  3270.     case 4:
  3271. #line 73
  3272.       result = CC1000RadioIntM$SquelchTimer$fired();
  3273. #line 73
  3274.       break;
  3275. #line 73
  3276.     case 5:
  3277. #line 73
  3278.       result = CC1000RadioIntM$WakeupTimer$fired();
  3279. #line 73
  3280.       break;
  3281. #line 73
  3282.     case 6:
  3283. #line 73
  3284.       result = CC1000RadioIntM$TDMATimer$fired();
  3285. #line 73
  3286.       break;
  3287. #line 73
  3288.     case 7:
  3289. #line 73
  3290.       result = ADCREFM$Timer$fired();
  3291. #line 73
  3292.       break;
  3293. #line 73
  3294.     case 8:
  3295. #line 73
  3296.       result = MultiHopWMEWMA$Timer$fired();
  3297. #line 73
  3298.       break;
  3299. #line 73
  3300.     case 9:
  3301. #line 73
  3302.       result = MultiHopWMEWMA$ATimer$fired();
  3303. #line 73
  3304.       break;
  3305. #line 73
  3306.     default:
  3307. #line 73
  3308.       result = TimerM$Timer$default$fired(arg_0x85e4d90);
  3309. #line 73
  3310.     }
  3311. #line 73
  3312. #line 73
  3313.   return result;
  3314. #line 73
  3315. }
  3316. #line 73
  3317. static inline 
  3318. # 194 "/home/testuser/tinyos-1.x/tos/system/TimerM.nc"
  3319. uint8_t TimerM$dequeue(void)
  3320. #line 194
  3321. {
  3322.   if (TimerM$queue_size == 0) {
  3323.     return NUM_TIMERS;
  3324.     }
  3325. #line 197
  3326.   if (TimerM$queue_head == NUM_TIMERS - 1) {
  3327.     TimerM$queue_head = -1;
  3328.     }
  3329. #line 199
  3330.   TimerM$queue_head++;
  3331.   TimerM$queue_size--;
  3332.   return TimerM$queue[(uint8_t )TimerM$queue_head];
  3333. }
  3334. static inline  void TimerM$signalOneTimer(void)
  3335. #line 204
  3336. {
  3337.   uint8_t itimer = TimerM$dequeue();
  3338. #line 206
  3339.   if (itimer < NUM_TIMERS) {
  3340.     TimerM$Timer$fired(itimer);
  3341.     }
  3342. }
  3343. static inline  
  3344. #line 210
  3345. void TimerM$HandleFire(void)
  3346. #line 210
  3347. {
  3348.   uint8_t i;
  3349.   uint16_t int_out;
  3350. #line 213
  3351.   TimerM$setIntervalFlag = 1;
  3352.   { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
  3353. #line 216
  3354.     {
  3355.       int_out = TimerM$interval_outstanding;
  3356.       TimerM$interval_outstanding = 0;
  3357.     }
  3358. #line 219
  3359.     __nesc_atomic_end(__nesc_atomic); }
  3360.   if (TimerM$mState) {
  3361.       for (i = 0; i < NUM_TIMERS; i++) {
  3362.           if (TimerM$mState & (0x1L << i)) {
  3363.               TimerM$mTimerList[i].ticksLeft -= int_out;
  3364.               if (TimerM$mTimerList[i].ticksLeft <= 2) {
  3365.                   if (TOS_post(TimerM$signalOneTimer)) {
  3366.                       if (TimerM$mTimerList[i].type == TIMER_REPEAT) {
  3367.                           TimerM$mTimerList[i].ticksLeft += TimerM$mTimerList[i].ticks;
  3368.                         }
  3369.                       else 
  3370. #line 230
  3371.                         {
  3372.                           TimerM$mState &= ~(0x1L << i);
  3373.                         }
  3374.                       TimerM$enqueue(i);
  3375.                     }
  3376.                   else {
  3377.                       {
  3378.                       }
  3379. #line 236
  3380.                       ;
  3381.                       TimerM$mTimerList[i].ticksLeft = TimerM$mInterval;
  3382.                     }
  3383.                 }
  3384.             }
  3385.         }
  3386.     }
  3387.   { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
  3388. #line 247
  3389.     int_out = TimerM$interval_outstanding;
  3390. #line 247
  3391.     __nesc_atomic_end(__nesc_atomic); }
  3392.   if (int_out == 0) {
  3393.     TimerM$adjustInterval();
  3394.     }
  3395. }
  3396. static inline   result_t TimerM$Clock$fire(void)
  3397. #line 253
  3398. {
  3399.   { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
  3400. #line 254
  3401.     {
  3402.       if (TimerM$interval_outstanding == 0) {
  3403.         TOS_post(TimerM$HandleFire);
  3404.         }
  3405.       else {
  3406.         }
  3407. #line 261
  3408.       ;
  3409.       TimerM$interval_outstanding += TimerM$Clock$getInterval() + 1;
  3410.     }
  3411. #line 264
  3412.     __nesc_atomic_end(__nesc_atomic); }
  3413.   return SUCCESS;
  3414. }
  3415. # 180 "/home/testuser/tinyos-1.x/tos/interfaces/Clock.nc"
  3416. inline static   result_t HPLClock$Clock$fire(void){
  3417. #line 180
  3418.   unsigned char result;
  3419. #line 180
  3420. #line 180
  3421.   result = TimerM$Clock$fire();
  3422. #line 180
  3423. #line 180
  3424.   return result;
  3425. #line 180
  3426. }
  3427. #line 180
  3428. static inline   
  3429. # 1823 "../../tos/platform/mica2/CC1000RadioIntM.nc"
  3430. result_t CC1000RadioIntM$SClock$fire(uint16_t mticks)
  3431. #line 1823
  3432. {
  3433. #line 1823
  3434.   return SUCCESS;
  3435. }
  3436. # 88 "../../tos/interfaces/SClock.nc"
  3437. inline static   result_t HPLSClock$SClock$fire(uint16_t arg_0x8624768){
  3438. #line 88
  3439.   unsigned char result;
  3440. #line 88
  3441. #line 88
  3442.   result = CC1000RadioIntM$SClock$fire(arg_0x8624768);
  3443. #line 88
  3444. #line 88
  3445.   return result;
  3446. #line 88
  3447. }
  3448. #line 88
  3449. # 42 "../../tos/platform/mica2/SpiByteFifo.nc"
  3450. inline static   result_t HPLSpiM$SpiByteFifo$dataReady(uint8_t arg_0x86357c8){
  3451. #line 42
  3452.   unsigned char result;
  3453. #line 42
  3454. #line 42
  3455.   result = CC1000RadioIntM$SpiByteFifo$dataReady(arg_0x86357c8);
  3456. #line 42
  3457. #line 42
  3458.   return result;
  3459. #line 42
  3460. }
  3461. #line 42
  3462. # 53 "../../tos/platform/mica2/HPLSpiM.nc"
  3463. void __attribute((signal))   __vector_17(void)
  3464. #line 53
  3465. {
  3466.   register uint8_t temp = * (volatile uint8_t *)(0x0F + 0x20);
  3467. #line 55