app.c
上传用户:joranyuan
上传日期:2022-06-23
资源大小:3306k
文件大小:273k
- }
- #line 199
- TimerM$queue_head++;
- TimerM$queue_size--;
- return TimerM$queue[(uint8_t )TimerM$queue_head];
- }
- static inline void TimerM$signalOneTimer(void)
- #line 204
- {
- uint8_t itimer = TimerM$dequeue();
- #line 206
- if (itimer < NUM_TIMERS) {
- TimerM$Timer$fired(itimer);
- }
- }
- static inline
- #line 210
- void TimerM$HandleFire(void)
- #line 210
- {
- uint8_t i;
- uint16_t int_out;
- #line 213
- TimerM$setIntervalFlag = 1;
- { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
- #line 216
- {
- int_out = TimerM$interval_outstanding;
- TimerM$interval_outstanding = 0;
- }
- #line 219
- __nesc_atomic_end(__nesc_atomic); }
- if (TimerM$mState) {
- for (i = 0; i < NUM_TIMERS; i++) {
- if (TimerM$mState & (0x1L << i)) {
- TimerM$mTimerList[i].ticksLeft -= int_out;
- if (TimerM$mTimerList[i].ticksLeft <= 2) {
- if (TOS_post(TimerM$signalOneTimer)) {
- if (TimerM$mTimerList[i].type == TIMER_REPEAT) {
- TimerM$mTimerList[i].ticksLeft += TimerM$mTimerList[i].ticks;
- }
- else
- #line 230
- {
- TimerM$mState &= ~(0x1L << i);
- }
- TimerM$enqueue(i);
- }
- else {
- {
- }
- #line 236
- ;
- TimerM$mTimerList[i].ticksLeft = TimerM$mInterval;
- }
- }
- }
- }
- }
- { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
- #line 247
- int_out = TimerM$interval_outstanding;
- #line 247
- __nesc_atomic_end(__nesc_atomic); }
- if (int_out == 0) {
- TimerM$adjustInterval();
- }
- }
- static inline result_t TimerM$Clock$fire(void)
- #line 253
- {
- { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
- #line 254
- {
- if (TimerM$interval_outstanding == 0) {
- TOS_post(TimerM$HandleFire);
- }
- else {
- }
- #line 261
- ;
- TimerM$interval_outstanding += TimerM$Clock$getInterval() + 1;
- }
- #line 264
- __nesc_atomic_end(__nesc_atomic); }
- return SUCCESS;
- }
- # 180 "/home/testuser/tinyos-1.x/tos/interfaces/Clock.nc"
- inline static result_t HPLClock$Clock$fire(void){
- #line 180
- unsigned char result;
- #line 180
- #line 180
- result = TimerM$Clock$fire();
- #line 180
- #line 180
- return result;
- #line 180
- }
- #line 180
- static inline
- # 321 "../../tos/system/DrandM.nc"
- void DrandM$fillGrantSendInfo(uint8_t *array)
- #line 321
- {
- uint8_t i;
- #line 322
- uint8_t j;
- #line 323
- for (i = 0, j = 0; i < MAX_NBR && DrandM$nbrInfo[i].nodeID != 0xFF; i++)
- if (DrandM$nbrInfo[i].bitMap & ONE_HOP && !(DrandM$nbrInfo[i].bitMap & GRANT_SENT)) {
- array[j++] = DrandM$nbrInfo[i].nodeID;
- }
- #line 326
- for (; j < MAX_NBR; j++)
- array[j] = 0xFF;
- }
- # 48 "/home/testuser/tinyos-1.x/tos/interfaces/SendMsg.nc"
- inline static result_t DrandM$SendRequestMsg$send(uint16_t arg_0x857ab18, uint8_t arg_0x857ac60, TOS_MsgPtr arg_0x857adb0){
- #line 48
- unsigned char result;
- #line 48
- #line 48
- result = AMStandard$SendMsg$send(AM_REQUEST, arg_0x857ab18, arg_0x857ac60, arg_0x857adb0);
- #line 48
- #line 48
- return result;
- #line 48
- }
- #line 48
- # 42 "../../tos/platform/mica2/SpiByteFifo.nc"
- inline static result_t HPLSpiM$SpiByteFifo$dataReady(uint8_t arg_0x8713520){
- #line 42
- unsigned char result;
- #line 42
- #line 42
- result = CC1000RadioIntM$SpiByteFifo$dataReady(arg_0x8713520);
- #line 42
- #line 42
- return result;
- #line 42
- }
- #line 42
- # 53 "../../tos/platform/mica2/HPLSpiM.nc"
- void __attribute((signal)) __vector_17(void)
- #line 53
- {
- register uint8_t temp = * (volatile uint8_t *)(0x0F + 0x20);
- #line 55
- * (volatile uint8_t *)(0x0F + 0x20) = HPLSpiM$OutgoingByte;
- HPLSpiM$SpiByteFifo$dataReady(temp);
- }
- static inline
- # 1789 "../../tos/platform/mica2/CC1000RadioIntM.nc"
- void CC1000RadioIntM$RadioSendCoordinator$default$blockTimer(void)
- #line 1789
- {
- }
- # 43 "../../tos/platform/mica2/RadioCoordinator.nc"
- inline static void CC1000RadioIntM$RadioSendCoordinator$blockTimer(void){
- #line 43
- CC1000RadioIntM$RadioSendCoordinator$default$blockTimer();
- #line 43
- }
- #line 43
- static inline
- # 1794 "../../tos/platform/mica2/CC1000RadioIntM.nc"
- void CC1000RadioIntM$RadioReceiveCoordinator$default$blockTimer(void)
- #line 1794
- {
- }
- # 43 "../../tos/platform/mica2/RadioCoordinator.nc"
- inline static void CC1000RadioIntM$RadioReceiveCoordinator$blockTimer(void){
- #line 43
- CC1000RadioIntM$RadioReceiveCoordinator$default$blockTimer();
- #line 43
- }
- #line 43
- static inline
- # 1786 "../../tos/platform/mica2/CC1000RadioIntM.nc"
- void CC1000RadioIntM$RadioSendCoordinator$default$startSymbol(uint8_t bitsPerBlock, uint8_t offset,
- TOS_MsgPtr msgBuff)
- #line 1787
- {
- }
- # 31 "../../tos/platform/mica2/RadioCoordinator.nc"
- inline static void CC1000RadioIntM$RadioSendCoordinator$startSymbol(uint8_t arg_0x86d4858, uint8_t arg_0x86d49a0, TOS_MsgPtr arg_0x86d4af0){
- #line 31
- CC1000RadioIntM$RadioSendCoordinator$default$startSymbol(arg_0x86d4858, arg_0x86d49a0, arg_0x86d4af0);
- #line 31
- }
- #line 31
- static inline
- # 264 "../../tos/platform/mica2/CC1000RadioIntM.nc"
- void CC1000RadioIntM$AddTime(GTime *C, GTime *A, GTime *B)
- #line 264
- {
- if (CC1000RadioIntM$MAX_VAL - B->sticks < A->sticks) {
- C->sticks = A->sticks - (CC1000RadioIntM$MAX_VAL - B->sticks);
- C->mticks = A->mticks + B->mticks + 1;
- }
- else {
- C->sticks = A->sticks + B->sticks;
- C->mticks = A->mticks + B->mticks;
- }
- }
- static inline
- #line 1788
- void CC1000RadioIntM$RadioSendCoordinator$default$byte(TOS_MsgPtr msg, uint8_t byteCount)
- #line 1788
- {
- }
- # 36 "../../tos/platform/mica2/RadioCoordinator.nc"
- inline static void CC1000RadioIntM$RadioSendCoordinator$byte(TOS_MsgPtr arg_0x86d4f68, uint8_t arg_0x86d50b8){
- #line 36
- CC1000RadioIntM$RadioSendCoordinator$default$byte(arg_0x86d4f68, arg_0x86d50b8);
- #line 36
- }
- #line 36
- static inline
- # 210 "/home/testuser/tinyos-1.x/tos/system/AMStandard.nc"
- result_t AMStandard$RadioSend$sendDone(TOS_MsgPtr msg, result_t success)
- #line 210
- {
- return AMStandard$reportSendDone(msg, success);
- }
- # 67 "/home/testuser/tinyos-1.x/tos/interfaces/BareSendMsg.nc"
- inline static result_t CC1000RadioIntM$Send$sendDone(TOS_MsgPtr arg_0x86bed88, result_t arg_0x86beed8){
- #line 67
- unsigned char result;
- #line 67
- #line 67
- result = AMStandard$RadioSend$sendDone(arg_0x86bed88, arg_0x86beed8);
- #line 67
- #line 67
- return result;
- #line 67
- }
- #line 67
- static inline
- # 506 "../../tos/platform/mica2/CC1000RadioIntM.nc"
- void CC1000RadioIntM$PacketSent(void)
- #line 506
- {
- TOS_MsgPtr pBuf;
- #line 508
- { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
- #line 508
- {
- CC1000RadioIntM$txbufptr->time = 0;
- pBuf = CC1000RadioIntM$txbufptr;
- }
- #line 511
- __nesc_atomic_end(__nesc_atomic); }
- if (CC1000RadioIntM$txbufptr->type != 222 && CC1000RadioIntM$txbufptr->type != 223) {
- CC1000RadioIntM$Send$sendDone((TOS_MsgPtr )pBuf, SUCCESS);
- }
- else {
- #line 517
- if (CC1000RadioIntM$txbufptr->type == 223) {
- }
- else {
- if (CC1000RadioIntM$txbufptr->type == 222) {
- }
- }
- }
- { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
- #line 527
- CC1000RadioIntM$bTxBusy = FALSE;
- #line 527
- __nesc_atomic_end(__nesc_atomic); }
- if (CC1000RadioIntM$pktsLastSync > 100) {
- { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
- #line 529
- {
- CC1000RadioIntM$ackOrig = CC1000RadioIntM$bAckEnable;
- CC1000RadioIntM$bAckEnable = FALSE;
- }
- #line 532
- __nesc_atomic_end(__nesc_atomic); }
- CC1000RadioIntM$Send$send(&CC1000RadioIntM$syncMsgHdr);
- CC1000RadioIntM$pktsLastSync = 0;
- }
- else {
- #line 535
- if (CC1000RadioIntM$currentMAC == CC1000RadioIntM$ZMAC && CC1000RadioIntM$ecnforward == TRUE) {
- { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
- #line 536
- {
- CC1000RadioIntM$ackOrig = CC1000RadioIntM$bAckEnable;
- CC1000RadioIntM$bAckEnable = FALSE;
- }
- #line 539
- __nesc_atomic_end(__nesc_atomic); }
- CC1000RadioIntM$Send$send(&CC1000RadioIntM$ecnForwardMsgHdr);
- { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
- #line 541
- CC1000RadioIntM$ecnforward = FALSE;
- #line 541
- __nesc_atomic_end(__nesc_atomic); }
- }
- else {
- if (CC1000RadioIntM$currentMAC == CC1000RadioIntM$ZMAC && CC1000RadioIntM$ecnPending == TRUE) {
- { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
- #line 546
- {
- CC1000RadioIntM$ackOrig = CC1000RadioIntM$bAckEnable;
- CC1000RadioIntM$bAckEnable = FALSE;
- }
- #line 549
- __nesc_atomic_end(__nesc_atomic); }
- CC1000RadioIntM$Send$send(&CC1000RadioIntM$ecnMsgHdr);
- { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
- #line 551
- CC1000RadioIntM$ecnPending = FALSE;
- #line 551
- __nesc_atomic_end(__nesc_atomic); }
- { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
- #line 552
- CC1000RadioIntM$slots_since_ecnsend = 0;
- #line 552
- __nesc_atomic_end(__nesc_atomic); }
- }
- }
- }
- }
- static inline
- #line 329
- bool CC1000RadioIntM$IsHCL(uint32_t gSlot)
- #line 329
- {
- uint32_t tempHCL = 0x1;
- bool flag;
- #line 332
- tempHCL = tempHCL << gSlot;
- { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
- #line 333
- {
- if (tempHCL & CC1000RadioIntM$curHCLlist) {
- flag = TRUE;
- }
- else {
- #line 337
- flag = FALSE;
- }
- }
- #line 339
- __nesc_atomic_end(__nesc_atomic); }
- #line 339
- return flag;
- }
- static inline
- # 63 "/home/testuser/tinyos-1.x/tos/system/NoLeds.nc"
- result_t NoLeds$Leds$redToggle(void)
- #line 63
- {
- return SUCCESS;
- }
- # 81 "/home/testuser/tinyos-1.x/tos/interfaces/Leds.nc"
- inline static result_t CC1000RadioIntM$Leds$redToggle(void){
- #line 81
- unsigned char result;
- #line 81
- #line 81
- result = NoLeds$Leds$redToggle();
- #line 81
- #line 81
- return result;
- #line 81
- }
- #line 81
- static inline
- # 1791 "../../tos/platform/mica2/CC1000RadioIntM.nc"
- void CC1000RadioIntM$RadioReceiveCoordinator$default$startSymbol(uint8_t bitsPerBlock, uint8_t offset,
- TOS_MsgPtr msgBuff)
- #line 1792
- {
- }
- # 31 "../../tos/platform/mica2/RadioCoordinator.nc"
- inline static void CC1000RadioIntM$RadioReceiveCoordinator$startSymbol(uint8_t arg_0x86d4858, uint8_t arg_0x86d49a0, TOS_MsgPtr arg_0x86d4af0){
- #line 31
- CC1000RadioIntM$RadioReceiveCoordinator$default$startSymbol(arg_0x86d4858, arg_0x86d49a0, arg_0x86d4af0);
- #line 31
- }
- #line 31
- static inline
- # 1793 "../../tos/platform/mica2/CC1000RadioIntM.nc"
- void CC1000RadioIntM$RadioReceiveCoordinator$default$byte(TOS_MsgPtr msg, uint8_t byteCount)
- #line 1793
- {
- }
- # 36 "../../tos/platform/mica2/RadioCoordinator.nc"
- inline static void CC1000RadioIntM$RadioReceiveCoordinator$byte(TOS_MsgPtr arg_0x86d4f68, uint8_t arg_0x86d50b8){
- #line 36
- CC1000RadioIntM$RadioReceiveCoordinator$default$byte(arg_0x86d4f68, arg_0x86d50b8);
- #line 36
- }
- #line 36
- static inline
- # 253 "../../tos/platform/mica2/CC1000RadioIntM.nc"
- void CC1000RadioIntM$DivTime2(GTime *B, GTime *A)
- #line 253
- {
- if (A->mticks % 2 == 1) {
- B->mticks = A->mticks >> 1;
- B->sticks = (A->sticks >> 1) + (CC1000RadioIntM$MAX_VAL >> 1);
- }
- else {
- B->mticks = A->mticks >> 1;
- B->sticks = A->sticks >> 1;
- }
- }
- static inline
- #line 306
- uint8_t CC1000RadioIntM$ModSubTime(GTime *C, GTime *A, GTime *B)
- #line 306
- {
- uint8_t retval;
- #line 308
- if (A->mticks > B->mticks) {
- retval = CC1000RadioIntM$POSITIVE;
- }
- else {
- #line 310
- if (A->mticks < B->mticks) {
- retval = CC1000RadioIntM$NEGATIVE;
- }
- else
- #line 312
- {
- if (A->sticks > B->sticks) {
- retval = CC1000RadioIntM$POSITIVE;
- }
- else {
- #line 315
- if (A->sticks < B->sticks) {
- retval = CC1000RadioIntM$NEGATIVE;
- }
- else {
- #line 318
- retval = CC1000RadioIntM$ZERO;
- }
- }
- }
- }
- #line 320
- if (retval == CC1000RadioIntM$POSITIVE) {
- #line 320
- CC1000RadioIntM$SubTime(C, A, B);
- }
- else {
- #line 321
- if (retval == CC1000RadioIntM$NEGATIVE) {
- #line 321
- CC1000RadioIntM$SubTime(C, B, A);
- }
- else
- #line 322
- {
- C->sticks = 0;
- C->mticks = 0;
- }
- }
- #line 326
- return retval;
- }
- # 63 "../../tos/interfaces/SClock.nc"
- inline static void CC1000RadioIntM$SClock$getTime(GTime *arg_0x8584228){
- #line 63
- HPLSClock$SClock$getTime(arg_0x8584228);
- #line 63
- }
- #line 63
- static inline
- # 387 "../../tos/platform/mica2/CC1000RadioIntM.nc"
- void CC1000RadioIntM$getTimeDiff(void)
- #line 387
- {
- { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
- #line 388
- {
- uint16_t i;
- #line 389
- uint16_t trust;
- GTime loctime;
- #line 390
- GTime timeStamp;
- syncMsgType *syncMsgPtr = (syncMsgType *)CC1000RadioIntM$rxbufptr->data;
- #line 392
- timeStamp.mticks = syncMsgPtr->mticks;
- timeStamp.sticks = syncMsgPtr->sticks;
- trust = syncMsgPtr->trust;
- CC1000RadioIntM$currentSender = syncMsgPtr->sender;
- CC1000RadioIntM$SClock$getTime(&loctime);
- CC1000RadioIntM$currentSign = CC1000RadioIntM$ModSubTime(&CC1000RadioIntM$currentDiff, &timeStamp, &loctime);
- if (trust < 1) {
- trust = 1;
- }
- #line 401
- if (trust < 8) {
- for (i = 0; i < trust; i++) {
- CC1000RadioIntM$DivTime2(&CC1000RadioIntM$currentDiff, &CC1000RadioIntM$currentDiff);
- }
- }
- }
- #line 406
- __nesc_atomic_end(__nesc_atomic); }
- }
- static inline
- # 107 "../../tos/platform/mica2/HPLSClock.nc"
- void HPLSClock$SClock$setTime(uint8_t PosOrNeg, GTime *t)
- #line 107
- {
- HPLSClock$sign = PosOrNeg;
- HPLSClock$Update.mticks = t->mticks;
- HPLSClock$Update.sticks = t->sticks;
- HPLSClock$needupdate = 1;
- }
- # 69 "../../tos/interfaces/SClock.nc"
- inline static void CC1000RadioIntM$SClock$setTime(uint8_t arg_0x8584670, GTime *arg_0x85847d0){
- #line 69
- HPLSClock$SClock$setTime(arg_0x8584670, arg_0x85847d0);
- #line 69
- }
- #line 69
- static inline
- # 424 "../../tos/platform/mica2/CC1000RadioIntM.nc"
- void CC1000RadioIntM$adjustTime(void)
- #line 424
- {
- CC1000RadioIntM$needTimeSync = TRUE;
- CC1000RadioIntM$SClock$setTime(CC1000RadioIntM$currentSign, &CC1000RadioIntM$currentDiff);
- }
- static inline
- # 252 "/home/testuser/tinyos-1.x/tos/system/AMStandard.nc"
- TOS_MsgPtr AMStandard$RadioReceive$receive(TOS_MsgPtr packet)
- #line 252
- {
- return received(packet);
- }
- # 75 "/home/testuser/tinyos-1.x/tos/interfaces/ReceiveMsg.nc"
- inline static TOS_MsgPtr CC1000RadioIntM$Receive$receive(TOS_MsgPtr arg_0x856c0f0){
- #line 75
- struct TOS_Msg *result;
- #line 75
- #line 75
- result = AMStandard$RadioReceive$receive(arg_0x856c0f0);
- #line 75
- #line 75
- return result;
- #line 75
- }
- #line 75
- static inline
- # 1601 "../../tos/system/DrandM.nc"
- result_t DrandM$SClock$syncDone(void)
- #line 1601
- {
- #line 1601
- return SUCCESS;
- }
- static inline
- # 1806 "../../tos/platform/mica2/CC1000RadioIntM.nc"
- result_t CC1000RadioIntM$SClock$syncDone(void)
- #line 1806
- {
- if (CC1000RadioIntM$needTimeSync) {
- GTime loctime;
- uint32_t globalTimeStamp;
- #line 1809
- uint32_t slotOffset;
- #line 1810
- CC1000RadioIntM$SClock$getTime(&loctime);
- globalTimeStamp = (uint32_t )(loctime.mticks * 568.889 + loctime.sticks * 0.00868056);
- slotOffset = (uint32_t )(1.024 * (CC1000RadioIntM$slotSize - globalTimeStamp % CC1000RadioIntM$slotSize));
- CC1000RadioIntM$slotNum = (uint32_t )(globalTimeStamp / CC1000RadioIntM$slotSize);
- CC1000RadioIntM$currentSlot = CC1000RadioIntM$slotNum & (CC1000RadioIntM$localFrameLength - 1);
- CC1000RadioIntM$globalSlot = CC1000RadioIntM$slotNum & (CC1000RadioIntM$globalFrameLength - 1);
- if (CC1000RadioIntM$currentMAC == CC1000RadioIntM$ZMAC) {
- CC1000RadioIntM$TDMATimer$start(TIMER_ONE_SHOT, slotOffset);
- }
- #line 1819
- CC1000RadioIntM$needTimeSync = FALSE;
- }
- return SUCCESS;
- }
- # 94 "../../tos/interfaces/SClock.nc"
- inline static result_t HPLSClock$SClock$syncDone(void){
- #line 94
- unsigned char result;
- #line 94
- #line 94
- result = CC1000RadioIntM$SClock$syncDone();
- #line 94
- result = rcombine(result, DrandM$SClock$syncDone());
- #line 94
- #line 94
- return result;
- #line 94
- }
- #line 94
- # 66 "/home/testuser/tinyos-1.x/tos/interfaces/ByteComm.nc"
- inline static result_t UARTM$ByteComm$rxByteReady(uint8_t arg_0x8978308, bool arg_0x8978450, uint16_t arg_0x89785a8){
- #line 66
- unsigned char result;
- #line 66
- #line 66
- result = FramerM$ByteComm$rxByteReady(arg_0x8978308, arg_0x8978450, arg_0x89785a8);
- #line 66
- #line 66
- return result;
- #line 66
- }
- #line 66
- static inline
- # 77 "/home/testuser/tinyos-1.x/tos/system/UARTM.nc"
- result_t UARTM$HPLUART$get(uint8_t data)
- #line 77
- {
- UARTM$ByteComm$rxByteReady(data, FALSE, 0);
- {
- }
- #line 83
- ;
- return SUCCESS;
- }
- # 88 "/home/testuser/tinyos-1.x/tos/interfaces/HPLUART.nc"
- inline static result_t HPLUART0M$UART$get(uint8_t arg_0x89be800){
- #line 88
- unsigned char result;
- #line 88
- #line 88
- result = UARTM$HPLUART$get(arg_0x89be800);
- #line 88
- #line 88
- return result;
- #line 88
- }
- #line 88
- # 90 "../../tos/platform/mica2/HPLUART0M.nc"
- void __attribute((signal)) __vector_18(void)
- #line 90
- {
- if (* (volatile uint8_t *)(0x0B + 0x20) & (1 << 7)) {
- HPLUART0M$UART$get(* (volatile uint8_t *)(0x0C + 0x20));
- }
- }
- static inline
- # 202 "/home/testuser/tinyos-1.x/tos/system/FramerM.nc"
- void FramerM$PacketUnknown(void)
- #line 202
- {
- { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
- #line 203
- {
- FramerM$gFlags |= FramerM$FLAGS_UNKNOWN;
- }
- #line 205
- __nesc_atomic_end(__nesc_atomic); }
- FramerM$StartTx();
- }
- static inline
- # 246 "/home/testuser/tinyos-1.x/tos/system/AMStandard.nc"
- TOS_MsgPtr AMStandard$UARTReceive$receive(TOS_MsgPtr packet)
- #line 246
- {
- packet->group = TOS_AM_GROUP;
- return received(packet);
- }
- # 75 "/home/testuser/tinyos-1.x/tos/interfaces/ReceiveMsg.nc"
- inline static TOS_MsgPtr FramerAckM$ReceiveCombined$receive(TOS_MsgPtr arg_0x856c0f0){
- #line 75
- struct TOS_Msg *result;
- #line 75
- #line 75
- result = AMStandard$UARTReceive$receive(arg_0x856c0f0);
- #line 75
- #line 75
- return result;
- #line 75
- }
- #line 75
- static inline
- # 91 "/home/testuser/tinyos-1.x/tos/system/FramerAckM.nc"
- TOS_MsgPtr FramerAckM$ReceiveMsg$receive(TOS_MsgPtr Msg)
- #line 91
- {
- TOS_MsgPtr pBuf;
- pBuf = FramerAckM$ReceiveCombined$receive(Msg);
- return pBuf;
- }
- # 75 "/home/testuser/tinyos-1.x/tos/interfaces/ReceiveMsg.nc"
- inline static TOS_MsgPtr FramerM$ReceiveMsg$receive(TOS_MsgPtr arg_0x856c0f0){
- #line 75
- struct TOS_Msg *result;
- #line 75
- #line 75
- result = FramerAckM$ReceiveMsg$receive(arg_0x856c0f0);
- #line 75
- #line 75
- return result;
- #line 75
- }
- #line 75
- static inline
- # 328 "/home/testuser/tinyos-1.x/tos/system/FramerM.nc"
- result_t FramerM$TokenReceiveMsg$ReflectToken(uint8_t Token)
- #line 328
- {
- result_t Result = SUCCESS;
- { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
- #line 331
- {
- if (!(FramerM$gFlags & FramerM$FLAGS_TOKENPEND)) {
- FramerM$gFlags |= FramerM$FLAGS_TOKENPEND;
- FramerM$gTxTokenBuf = Token;
- }
- else {
- Result = FAIL;
- }
- }
- #line 339
- __nesc_atomic_end(__nesc_atomic); }
- if (Result == SUCCESS) {
- Result = FramerM$StartTx();
- }
- return Result;
- }
- # 88 "/home/testuser/tinyos-1.x/tos/interfaces/TokenReceiveMsg.nc"
- inline static result_t FramerAckM$TokenReceiveMsg$ReflectToken(uint8_t arg_0x897a0e8){
- #line 88
- unsigned char result;
- #line 88
- #line 88
- result = FramerM$TokenReceiveMsg$ReflectToken(arg_0x897a0e8);
- #line 88
- #line 88
- return result;
- #line 88
- }
- #line 88
- static inline
- # 74 "/home/testuser/tinyos-1.x/tos/system/FramerAckM.nc"
- void FramerAckM$SendAckTask(void)
- #line 74
- {
- FramerAckM$TokenReceiveMsg$ReflectToken(FramerAckM$gTokenBuf);
- }
- static inline TOS_MsgPtr FramerAckM$TokenReceiveMsg$receive(TOS_MsgPtr Msg, uint8_t token)
- #line 79
- {
- TOS_MsgPtr pBuf;
- FramerAckM$gTokenBuf = token;
- TOS_post(FramerAckM$SendAckTask);
- pBuf = FramerAckM$ReceiveCombined$receive(Msg);
- return pBuf;
- }
- # 75 "/home/testuser/tinyos-1.x/tos/interfaces/TokenReceiveMsg.nc"
- inline static TOS_MsgPtr FramerM$TokenReceiveMsg$receive(TOS_MsgPtr arg_0x897f970, uint8_t arg_0x897fab8){
- #line 75
- struct TOS_Msg *result;
- #line 75
- #line 75
- result = FramerAckM$TokenReceiveMsg$receive(arg_0x897f970, arg_0x897fab8);
- #line 75
- #line 75
- return result;
- #line 75
- }
- #line 75
- static inline
- # 210 "/home/testuser/tinyos-1.x/tos/system/FramerM.nc"
- void FramerM$PacketRcvd(void)
- #line 210
- {
- FramerM$MsgRcvEntry_t *pRcv = &FramerM$gMsgRcvTbl[FramerM$gRxTailIndex];
- TOS_MsgPtr pBuf = pRcv->pMsg;
- if (pRcv->Length >= (size_t )& ((TOS_Msg *)0)->data) {
- switch (pRcv->Proto) {
- case FramerM$PROTO_ACK:
- break;
- case FramerM$PROTO_PACKET_ACK:
- pBuf->crc = 1;
- pBuf = FramerM$TokenReceiveMsg$receive(pBuf, pRcv->Token);
- break;
- case FramerM$PROTO_PACKET_NOACK:
- pBuf->crc = 1;
- pBuf = FramerM$ReceiveMsg$receive(pBuf);
- break;
- default:
- FramerM$gTxUnknownBuf = pRcv->Proto;
- TOS_post(FramerM$PacketUnknown);
- break;
- }
- }
- { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
- #line 235
- {
- if (pBuf) {
- pRcv->pMsg = pBuf;
- }
- pRcv->Length = 0;
- pRcv->Token = 0;
- FramerM$gRxTailIndex++;
- FramerM$gRxTailIndex %= FramerM$HDLC_QUEUESIZE;
- }
- #line 243
- __nesc_atomic_end(__nesc_atomic); }
- }
- # 96 "/home/testuser/tinyos-1.x/tos/interfaces/HPLUART.nc"
- inline static result_t HPLUART0M$UART$putDone(void){
- #line 96
- unsigned char result;
- #line 96
- #line 96
- result = UARTM$HPLUART$putDone();
- #line 96
- #line 96
- return result;
- #line 96
- }
- #line 96
- # 100 "../../tos/platform/mica2/HPLUART0M.nc"
- void __attribute((interrupt)) __vector_20(void)
- #line 100
- {
- HPLUART0M$UART$putDone();
- }
- static inline
- # 552 "/home/testuser/tinyos-1.x/tos/system/FramerM.nc"
- result_t FramerM$ByteComm$txDone(void)
- #line 552
- {
- if (FramerM$gTxState == FramerM$TXSTATE_FINISH) {
- FramerM$gTxState = FramerM$TXSTATE_IDLE;
- TOS_post(FramerM$PacketSent);
- }
- return SUCCESS;
- }
- # 83 "/home/testuser/tinyos-1.x/tos/interfaces/ByteComm.nc"
- inline static result_t UARTM$ByteComm$txDone(void){
- #line 83
- unsigned char result;
- #line 83
- #line 83
- result = FramerM$ByteComm$txDone();
- #line 83
- #line 83
- return result;
- #line 83
- }
- #line 83
- #line 55
- inline static result_t FramerM$ByteComm$txByte(uint8_t arg_0x897bdd8){
- #line 55
- unsigned char result;
- #line 55
- #line 55
- result = UARTM$ByteComm$txByte(arg_0x897bdd8);
- #line 55
- #line 55
- return result;
- #line 55
- }
- #line 55
- static inline
- # 66 "/home/testuser/tinyos-1.x/tos/platform/avrmote/crc.h"
- uint16_t crcByte(uint16_t oldCrc, uint8_t byte)
- {
- uint16_t *table = crcTable;
- uint16_t newCrc;
- __asm ("eor %1,%B3n"
- "tlsl %1n"
- "tadc %B2, __zero_reg__n"
- "tadd %A2, %1n"
- "tadc %B2, __zero_reg__n"
- "tlpmn"
- "tmov %B0, %A3n"
- "tmov %A0, r0n"
- "tadiw r30,1n"
- "tlpmn"
- "teor %B0, r0" :
- "=r"(newCrc), "+r"(byte), "+z"(table) : "r"(oldCrc));
- return newCrc;
- }
- static inline
- # 482 "/home/testuser/tinyos-1.x/tos/system/FramerM.nc"
- result_t FramerM$ByteComm$txByteReady(bool LastByteSuccess)
- #line 482
- {
- result_t TxResult = SUCCESS;
- uint8_t nextByte;
- if (LastByteSuccess != TRUE) {
- { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
- #line 487
- FramerM$gTxState = FramerM$TXSTATE_ERROR;
- #line 487
- __nesc_atomic_end(__nesc_atomic); }
- TOS_post(FramerM$PacketSent);
- return SUCCESS;
- }
- switch (FramerM$gTxState) {
- case FramerM$TXSTATE_PROTO:
- FramerM$gTxState = FramerM$TXSTATE_INFO;
- FramerM$gTxRunningCRC = crcByte(FramerM$gTxRunningCRC, (uint8_t )(FramerM$gTxProto & 0x0FF));
- TxResult = FramerM$ByteComm$txByte((uint8_t )(FramerM$gTxProto & 0x0FF));
- break;
- case FramerM$TXSTATE_INFO:
- nextByte = FramerM$gpTxBuf[FramerM$gTxByteCnt];
- FramerM$gTxRunningCRC = crcByte(FramerM$gTxRunningCRC, nextByte);
- FramerM$gTxByteCnt++;
- if (FramerM$gTxByteCnt >= FramerM$gTxLength) {
- FramerM$gTxState = FramerM$TXSTATE_FCS1;
- }
- TxResult = FramerM$TxArbitraryByte(nextByte);
- break;
- case FramerM$TXSTATE_ESC:
- TxResult = FramerM$ByteComm$txByte(FramerM$gTxEscByte ^ 0x20);
- FramerM$gTxState = FramerM$gPrevTxState;
- break;
- case FramerM$TXSTATE_FCS1:
- nextByte = (uint8_t )(FramerM$gTxRunningCRC & 0xff);
- FramerM$gTxState = FramerM$TXSTATE_FCS2;
- TxResult = FramerM$TxArbitraryByte(nextByte);
- break;
- case FramerM$TXSTATE_FCS2:
- nextByte = (uint8_t )((FramerM$gTxRunningCRC >> 8) & 0xff);
- FramerM$gTxState = FramerM$TXSTATE_ENDFLAG;
- TxResult = FramerM$TxArbitraryByte(nextByte);
- break;
- case FramerM$TXSTATE_ENDFLAG:
- FramerM$gTxState = FramerM$TXSTATE_FINISH;
- TxResult = FramerM$ByteComm$txByte(FramerM$HDLC_FLAG_BYTE);
- break;
- case FramerM$TXSTATE_FINISH:
- case FramerM$TXSTATE_ERROR:
- default:
- break;
- }
- if (TxResult != SUCCESS) {
- FramerM$gTxState = FramerM$TXSTATE_ERROR;
- TOS_post(FramerM$PacketSent);
- }
- return SUCCESS;
- }
- # 75 "/home/testuser/tinyos-1.x/tos/interfaces/ByteComm.nc"
- inline static result_t UARTM$ByteComm$txByteReady(bool arg_0x8978ad8){
- #line 75
- unsigned char result;
- #line 75
- #line 75
- result = FramerM$ByteComm$txByteReady(arg_0x8978ad8);
- #line 75
- #line 75
- return result;
- #line 75
- }
- #line 75
- # 102 "/home/testuser/tinyos-1.x/tos/system/sched.c"
- bool TOS_post(void (*tp)(void))
- #line 102
- {
- __nesc_atomic_t fInterruptFlags;
- uint8_t tmp;
- fInterruptFlags = __nesc_atomic_start();
- tmp = TOSH_sched_free;
- if (TOSH_queue[tmp].tp == (void *)0) {
- TOSH_sched_free = (tmp + 1) & TOSH_TASK_BITMASK;
- TOSH_queue[tmp].tp = tp;
- __nesc_atomic_end(fInterruptFlags);
- return TRUE;
- }
- else {
- __nesc_atomic_end(fInterruptFlags);
- return FALSE;
- }
- }
- # 54 "/home/testuser/tinyos-1.x/tos/system/RealMain.nc"
- int main(void)
- #line 54
- {
- RealMain$hardwareInit();
- RealMain$Pot$init(10);
- TOSH_sched_init();
- RealMain$StdControl$init();
- RealMain$StdControl$start();
- __nesc_enable_interrupt();
- while (1) {
- TOSH_run_task();
- }
- }
- static
- # 77 "/home/testuser/tinyos-1.x/tos/system/TimerM.nc"
- result_t TimerM$StdControl$init(void)
- #line 77
- {
- TimerM$mState = 0;
- TimerM$setIntervalFlag = 0;
- TimerM$queue_head = TimerM$queue_tail = -1;
- TimerM$queue_size = 0;
- TimerM$mScale = 3;
- TimerM$mInterval = TimerM$maxTimerInterval;
- return TimerM$Clock$setRate(TimerM$mInterval, TimerM$mScale);
- }
- static
- # 268 "/home/testuser/tinyos-1.x/tos/system/FramerM.nc"
- void FramerM$HDLCInitialize(void)
- #line 268
- {
- int i;
- #line 270
- { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
- #line 270
- {
- for (i = 0; i < FramerM$HDLC_QUEUESIZE; i++) {
- FramerM$gMsgRcvTbl[i].pMsg = &FramerM$gMsgRcvBuf[i];
- FramerM$gMsgRcvTbl[i].Length = 0;
- FramerM$gMsgRcvTbl[i].Token = 0;
- }
- FramerM$gTxState = FramerM$TXSTATE_IDLE;
- FramerM$gTxByteCnt = 0;
- FramerM$gTxLength = 0;
- FramerM$gTxRunningCRC = 0;
- FramerM$gpTxMsg = (void *)0;
- FramerM$gRxState = FramerM$RXSTATE_NOSYNC;
- FramerM$gRxHeadIndex = 0;
- FramerM$gRxTailIndex = 0;
- FramerM$gRxByteCnt = 0;
- FramerM$gRxRunningCRC = 0;
- FramerM$gpRxBuf = (uint8_t *)FramerM$gMsgRcvTbl[FramerM$gRxHeadIndex].pMsg;
- }
- #line 288
- __nesc_atomic_end(__nesc_atomic); }
- }
- static
- # 75 "../../tos/platform/mica2/HPLCC1000M.nc"
- result_t HPLCC1000M$HPLCC1000$write(uint8_t addr, uint8_t data)
- #line 75
- {
- char cnt = 0;
- addr <<= 1;
- TOSH_CLR_CC_PALE_PIN();
- for (cnt = 0; cnt < 7; cnt++)
- {
- if (addr & 0x80) {
- TOSH_SET_CC_PDATA_PIN();
- }
- else {
- #line 86
- TOSH_CLR_CC_PDATA_PIN();
- }
- #line 87
- TOSH_CLR_CC_PCLK_PIN();
- TOSH_SET_CC_PCLK_PIN();
- addr <<= 1;
- }
- TOSH_SET_CC_PDATA_PIN();
- TOSH_CLR_CC_PCLK_PIN();
- TOSH_SET_CC_PCLK_PIN();
- TOSH_SET_CC_PALE_PIN();
- for (cnt = 0; cnt < 8; cnt++)
- {
- if (data & 0x80) {
- TOSH_SET_CC_PDATA_PIN();
- }
- else {
- #line 103
- TOSH_CLR_CC_PDATA_PIN();
- }
- #line 104
- TOSH_CLR_CC_PCLK_PIN();
- TOSH_SET_CC_PCLK_PIN();
- data <<= 1;
- }
- TOSH_SET_CC_PALE_PIN();
- TOSH_SET_CC_PDATA_PIN();
- TOSH_SET_CC_PCLK_PIN();
- return SUCCESS;
- }
- static
- #line 128
- uint8_t HPLCC1000M$HPLCC1000$read(uint8_t addr)
- #line 128
- {
- int cnt;
- uint8_t din;
- uint8_t data = 0;
- addr <<= 1;
- TOSH_CLR_CC_PALE_PIN();
- for (cnt = 0; cnt < 7; cnt++)
- {
- if (addr & 0x80) {
- TOSH_SET_CC_PDATA_PIN();
- }
- else {
- #line 141
- TOSH_CLR_CC_PDATA_PIN();
- }
- #line 142
- TOSH_CLR_CC_PCLK_PIN();
- TOSH_SET_CC_PCLK_PIN();
- addr <<= 1;
- }
- TOSH_CLR_CC_PDATA_PIN();
- TOSH_CLR_CC_PCLK_PIN();
- TOSH_SET_CC_PCLK_PIN();
- TOSH_MAKE_CC_PDATA_INPUT();
- TOSH_SET_CC_PALE_PIN();
- for (cnt = 7; cnt >= 0; cnt--)
- {
- TOSH_CLR_CC_PCLK_PIN();
- din = TOSH_READ_CC_PDATA_PIN();
- if (din) {
- data = (data << 1) | 0x01;
- }
- else {
- #line 161
- data = (data << 1) & 0xfe;
- }
- #line 162
- TOSH_SET_CC_PCLK_PIN();
- }
- TOSH_SET_CC_PALE_PIN();
- TOSH_MAKE_CC_PDATA_OUTPUT();
- TOSH_SET_CC_PDATA_PIN();
- return data;
- }
- static
- # 63 "../../tos/platform/mica2/HPLADCM.nc"
- void HPLADCM$init_portmap(void)
- #line 63
- {
- { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
- #line 65
- {
- if (HPLADCM$init_portmap_done == FALSE) {
- int i;
- #line 68
- for (i = 0; i < TOSH_ADC_PORTMAPSIZE; i++)
- HPLADCM$TOSH_adc_portmap[i] = i;
- HPLADCM$TOSH_adc_portmap[TOS_ADC_BANDGAP_PORT] = TOSH_ACTUAL_BANDGAP_PORT;
- HPLADCM$TOSH_adc_portmap[TOS_ADC_GND_PORT] = TOSH_ACTUAL_GND_PORT;
- HPLADCM$init_portmap_done = TRUE;
- }
- }
- #line 76
- __nesc_atomic_end(__nesc_atomic); }
- }
- static
- # 95 "../../tos/platform/mica2/HPLSClock.nc"
- void HPLSClock$SClock$getTime(GTime *t)
- #line 95
- {
- { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
- #line 96
- {
- t->sticks = * (volatile uint16_t *)0x88;
- if (* (volatile uint8_t *)(uint16_t )& * (volatile uint8_t *)0x7C & (1 << 4)) {
- HPLSClock$MTicks++;
- * (volatile uint8_t *)0x7C |= 1 << 4;
- HPLSClock$SClock$fire(HPLSClock$MTicks);
- }
- t->mticks = HPLSClock$MTicks;
- }
- #line 104
- __nesc_atomic_end(__nesc_atomic); }
- }
- static
- # 435 "../../tos/platform/mica2/CC1000ControlM.nc"
- result_t CC1000ControlM$CC1000Control$RxMode(void)
- #line 435
- {
- CC1000ControlM$HPLChipcon$write(0x09, CC1000ControlM$gCurrentParameters[0x09]);
- CC1000ControlM$HPLChipcon$write(0x0B, 0x00);
- CC1000ControlM$HPLChipcon$write(0x00, (
- 1 << 4) | (1 << 0));
- TOSH_uwait(125);
- return SUCCESS;
- }
- static
- # 98 "/home/testuser/tinyos-1.x/tos/system/TimerM.nc"
- result_t TimerM$Timer$start(uint8_t id, char type,
- uint32_t interval)
- #line 99
- {
- uint8_t diff;
- #line 101
- if (id >= NUM_TIMERS) {
- #line 101
- return FAIL;
- }
- #line 102
- if (type > TIMER_ONE_SHOT) {
- #line 102
- return FAIL;
- }
- if (type == TIMER_REPEAT && interval <= 2) {
- #line 109
- return FAIL;
- }
- TimerM$mTimerList[id].ticks = interval;
- TimerM$mTimerList[id].type = type;
- { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
- #line 114
- {
- diff = TimerM$Clock$readCounter();
- interval += diff;
- TimerM$mTimerList[id].ticksLeft = interval;
- TimerM$mState |= 0x1L << id;
- if (interval < TimerM$mInterval) {
- TimerM$mInterval = interval;
- TimerM$Clock$setInterval(TimerM$mInterval);
- TimerM$setIntervalFlag = 0;
- TimerM$PowerManagement$adjustPower();
- }
- }
- #line 125
- __nesc_atomic_end(__nesc_atomic); }
- return SUCCESS;
- }
- static
- # 102 "../../tos/platform/mica2/HPLPowerManagementM.nc"
- uint8_t HPLPowerManagementM$PowerManagement$adjustPower(void)
- #line 102
- {
- uint8_t mcu;
- #line 104
- if (HPLPowerManagementM$disableCount <= 0) {
- TOS_post(HPLPowerManagementM$doAdjustment);
- }
- else
- #line 106
- {
- mcu = * (volatile uint8_t *)(0x35 + 0x20);
- mcu &= 0xe3;
- mcu |= HPLPowerManagementM$IDLE;
- * (volatile uint8_t *)(0x35 + 0x20) = mcu;
- * (volatile uint8_t *)(0x35 + 0x20) |= 1 << 5;
- }
- return 0;
- }
- static
- # 501 "../../tos/system/DrandM.nc"
- uint16_t DrandM$randNew(void)
- #line 501
- {
- bool endbit;
- uint16_t tmpShiftReg;
- #line 504
- { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
- #line 504
- {
- tmpShiftReg = DrandM$shiftReg;
- endbit = (tmpShiftReg & 0x8000) != 0;
- tmpShiftReg <<= 1;
- if (endbit) {
- tmpShiftReg ^= 0x100b;
- }
- #line 510
- tmpShiftReg++;
- DrandM$shiftReg = tmpShiftReg;
- tmpShiftReg = tmpShiftReg ^ DrandM$mask;
- }
- #line 513
- __nesc_atomic_end(__nesc_atomic); }
- return tmpShiftReg;
- }
- # 215 "/home/testuser/tinyos-1.x/tos/system/AMStandard.nc"
- TOS_MsgPtr received(TOS_MsgPtr packet)
- #line 215
- {
- uint16_t addr = TOS_LOCAL_ADDRESS;
- #line 217
- AMStandard$counter++;
- {
- }
- #line 218
- ;
- if (
- #line 220
- packet->crc == 1 &&
- packet->group == TOS_AM_GROUP && (
- packet->addr == TOS_BCAST_ADDR ||
- packet->addr == addr))
- {
- uint8_t type = packet->type;
- TOS_MsgPtr tmp;
- {
- }
- #line 229
- ;
- AMStandard$dbgPacket(packet);
- {
- }
- #line 231
- ;
- tmp = AMStandard$ReceiveMsg$receive(type, packet);
- if (tmp) {
- packet = tmp;
- }
- }
- #line 238
- return packet;
- }
- static
- # 204 "../../tos/system/DrandM.nc"
- int DrandM$isPresentHelloID(uint8_t node, uint8_t *array, uint8_t max)
- #line 204
- {
- uint8_t i;
- #line 207
- for (i = 0; i < max; i++)
- if (array[i] == node) {
- return i;
- }
- #line 210
- return -1;
- }
- static
- #line 366
- void DrandM$addHelloID(uint8_t node, uint8_t *array)
- #line 366
- {
- uint8_t i;
- #line 368
- if (node == TOS_LOCAL_ADDRESS) {
- #line 368
- return;
- }
- #line 369
- { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
- #line 369
- {
- for (i = 0; i < MAX_NBR && array[i] != 0xFF && array[i] != node; i++) ;
- if (i == MAX_NBR) {
- {
- #line 373
- char bStatus;
- #line 373
- if (DBG_USR2 != 0) {
- #line 373
- bStatus = * (volatile uint8_t *)(uint16_t )& * (volatile uint8_t *)(0x3F + 0x20) & (1 << 7);
- #line 373
- __asm volatile ("cli");DrandM$sprintf(DrandM$debugbuf, "addNode: No space to add noden");
- #line 373
- DrandM$writedebug();
- #line 373
- if (bStatus) {
- #line 373
- __asm volatile ("sei");
- }
- }
- }
- #line 373
- ;
- }
- else {
- #line 375
- if (array[i] != node) {
- array[i] = node;
- }
- }
- }
- #line 379
- __nesc_atomic_end(__nesc_atomic); }
- }
- static
- # 52 "../../tos/interfaces/SODebug.h"
- int DrandM$sprintf(uint8_t *buf, const uint8_t *format, ...)
- {
- uint8_t scratch[64];
- uint8_t format_flag;
- uint16_t u_val = 0;
- #line 57
- uint16_t base;
- uint8_t *ptr;
- DrandM$va_list ap;
- bool b_ChkForNegInt = FALSE;
- __builtin_va_start(ap, format);
- for (; ; ) {
- while ((format_flag = * format++) != '%') {
- if (!format_flag) {
- #line 65
- __builtin_va_end(ap);
- #line 65
- return 0;
- }
- #line 66
- *buf = format_flag;
- #line 66
- buf++;
- #line 66
- *buf = 0;
- }
- b_ChkForNegInt = FALSE;
- switch ((format_flag = * format++)) {
- case 'c':
- format_flag = (__builtin_va_arg(ap, int ));
- default:
- *buf = format_flag;
- #line 74
- buf++;
- #line 74
- *buf = 0;
- continue;
- case 'S':
- case 's':
- ptr = (__builtin_va_arg(ap, char *));
- strcat(buf, ptr);
- continue;
- case 'o':
- base = 8;
- *buf = '0';
- #line 83
- buf++;
- #line 83
- *buf = 0;
- goto CONVERSION_LOOP;
- case 'i':
- b_ChkForNegInt = TRUE;
- case 'u':
- base = 10;
- goto CONVERSION_LOOP;
- case 'x':
- base = 16;
- CONVERSION_LOOP:
- u_val = (__builtin_va_arg(ap, int ));
- if (b_ChkForNegInt) {
- if ((int )u_val < 0) {
- u_val = -u_val;
- *buf = '-';
- #line 103
- buf++;
- #line 103
- *buf = 0;
- }
- }
- ptr = scratch + 64;
- * --ptr = 0;
- do {
- char ch = u_val % base + '0';
- #line 111
- if (ch > '9') {
- ch += 'a' - '9' - 1;
- }
- #line 113
- * --ptr = ch;
- u_val /= base;
- }
- while (
- #line 115
- u_val);
- strcat(buf, ptr);
- buf += strlen(ptr);
- }
- }
- }
- static
- #line 42
- void DrandM$writedebug(void)
- #line 42
- {
- int i = 0;
- #line 44
- DrandM$UARTPutChar('n');
- while (DrandM$debugbuf[i] != 'n')
- DrandM$UARTPutChar(DrandM$debugbuf[i++]);
- }
- static
- #line 35
- void DrandM$UARTPutChar(char c)
- #line 35
- {
- if (c == 'n') {
- DrandM$UARTPutChar('r');
- }
- #line 38
- do {
- }
- while (
- #line 38
- !(* (volatile uint8_t *)(uint16_t )& * (volatile uint8_t *)(0x0B + 0x20) & (1 << 5)));
- * (volatile uint8_t *)(0x0C + 0x20) = c;
- }
- static
- # 380 "../../tos/system/DrandM.nc"
- void DrandM$removeHelloID(uint8_t node, uint8_t *array)
- #line 380
- {
- uint8_t i;
- #line 382
- { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
- #line 382
- {
- for (i = 0; i < MAX_NBR && array[i] != 0xFF && array[i] != node; i++) ;
- if (i != MAX_NBR && array[i] == node) {
- for (; i < MAX_NBR - 1; i++)
- array[i] = array[i + 1];
- array[MAX_NBR - 1] = 0xFF;
- }
- }
- #line 389
- __nesc_atomic_end(__nesc_atomic); }
- }
- static
- #line 579
- void DrandM$sendHelloMsg(void)
- #line 579
- {
- { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
- #line 580
- {
- if (!DrandM$sendBusy) {
- uint8_t i = 0;
- #line 582
- uint8_t j = 0;
- helloMsg *helloMsgData = (helloMsg *)DrandM$DataPkt.data;
- #line 584
- helloMsgData->sendID = TOS_LOCAL_ADDRESS;
- for (i = 0; i < MAX_NBR; i++)
- helloMsgData->OneWayId[i] = 0xFF;
- for (i = 0; i < MAX_NBR && DrandM$OneWayId[i] != 0xFF; i++)
- helloMsgData->OneWayId[i] = DrandM$OneWayId[i];
- if (i == MAX_NBR) {
- {
- #line 592
- char bStatus;
- #line 592
- if (DBG_USR2 != 0) {
- #line 592
- bStatus = * (volatile uint8_t *)(uint16_t )& * (volatile uint8_t *)(0x3F + 0x20) & (1 << 7);
- #line 592
- __asm volatile ("cli");DrandM$sprintf(DrandM$debugbuf, "SendHelloMsg: Too many neighbors, abort !!!!n");
- #line 592
- DrandM$writedebug();
- #line 592
- if (bStatus) {
- #line 592
- __asm volatile ("sei");
- }
- }
- }
- #line 592
- ;
- }
- helloMsgData->OneWayLen = i;
- for (j = 0; j < MAX_NBR && i < MAX_NBR && DrandM$TwoWayId[j] != 0xFF; j++, i++)
- helloMsgData->OneWayId[i] = DrandM$TwoWayId[j];
- if (DrandM$SendHelloMsg$send(TOS_BCAST_ADDR, sizeof(helloMsg ), &DrandM$DataPkt) == SUCCESS) {
- DrandM$sendBusy = TRUE;
- }
- else
- #line 601
- {
- DrandM$reXTimer$start(TIMER_ONE_SHOT, DrandM$randNew() % HELLO_INTERVAL);
- }
- }
- else
- #line 607
- {
- DrandM$reXTimer$start(TIMER_ONE_SHOT, DrandM$randNew() % HELLO_INTERVAL);
- }
- }
- #line 613
- __nesc_atomic_end(__nesc_atomic); }
- }
- static
- # 179 "/home/testuser/tinyos-1.x/tos/system/AMStandard.nc"
- result_t AMStandard$SendMsg$send(uint8_t id, uint16_t addr, uint8_t length, TOS_MsgPtr data)
- #line 179
- {
- if (!AMStandard$state) {
- AMStandard$state = TRUE;
- if (length > DATA_LENGTH) {
- {
- }
- #line 183
- ;
- AMStandard$state = FALSE;
- return FAIL;
- }
- if (!TOS_post(AMStandard$sendTask)) {
- {
- }
- #line 188
- ;
- AMStandard$state = FALSE;
- return FAIL;
- }
- else {
- AMStandard$buffer = data;
- data->length = length;
- data->addr = addr;
- data->type = id;
- AMStandard$buffer->group = TOS_AM_GROUP;
- {
- }
- #line 198
- ;
- AMStandard$dbgPacket(data);
- }
- return SUCCESS;
- }
- return FAIL;
- }
- static
- # 158 "/home/testuser/tinyos-1.x/tos/system/FramerM.nc"
- result_t FramerM$StartTx(void)
- #line 158
- {
- result_t Result = SUCCESS;
- bool fInitiate = FALSE;
- { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
- #line 162
- {
- if (FramerM$gTxState == FramerM$TXSTATE_IDLE) {
- if (FramerM$gFlags & FramerM$FLAGS_TOKENPEND) {
- FramerM$gpTxBuf = (uint8_t *)&FramerM$gTxTokenBuf;
- FramerM$gTxProto = FramerM$PROTO_ACK;
- FramerM$gTxLength = sizeof FramerM$gTxTokenBuf;
- fInitiate = TRUE;
- FramerM$gTxState = FramerM$TXSTATE_PROTO;
- }
- else {
- #line 171
- if (FramerM$gFlags & FramerM$FLAGS_DATAPEND) {
- FramerM$gpTxBuf = (uint8_t *)FramerM$gpTxMsg;
- FramerM$gTxProto = FramerM$PROTO_PACKET_NOACK;
- FramerM$gTxLength = FramerM$gpTxMsg->length + (MSG_DATA_SIZE - DATA_LENGTH - 2);
- fInitiate = TRUE;
- FramerM$gTxState = FramerM$TXSTATE_PROTO;
- }
- else {
- #line 178
- if (FramerM$gFlags & FramerM$FLAGS_UNKNOWN) {
- FramerM$gpTxBuf = (uint8_t *)&FramerM$gTxUnknownBuf;
- FramerM$gTxProto = FramerM$PROTO_UNKNOWN;
- FramerM$gTxLength = sizeof FramerM$gTxUnknownBuf;
- fInitiate = TRUE;
- FramerM$gTxState = FramerM$TXSTATE_PROTO;
- }
- }
- }
- }
- }
- #line 188
- __nesc_atomic_end(__nesc_atomic); }
- #line 188
- if (fInitiate) {
- { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
- #line 189
- {
- FramerM$gTxRunningCRC = 0;
- #line 190
- FramerM$gTxByteCnt = 0;
- }
- #line 191
- __nesc_atomic_end(__nesc_atomic); }
- Result = FramerM$ByteComm$txByte(FramerM$HDLC_FLAG_BYTE);
- if (Result != SUCCESS) {
- { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
- #line 194
- FramerM$gTxState = FramerM$TXSTATE_ERROR;
- #line 194
- __nesc_atomic_end(__nesc_atomic); }
- TOS_post(FramerM$PacketSent);
- }
- }
- return Result;
- }
- static
- # 110 "/home/testuser/tinyos-1.x/tos/system/UARTM.nc"
- result_t UARTM$ByteComm$txByte(uint8_t data)
- #line 110
- {
- bool oldState;
- {
- }
- #line 113
- ;
- { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
- #line 115
- {
- oldState = UARTM$state;
- UARTM$state = TRUE;
- }
- #line 118
- __nesc_atomic_end(__nesc_atomic); }
- if (oldState) {
- return FAIL;
- }
- UARTM$HPLUART$put(data);
- return SUCCESS;
- }
- static
- # 246 "/home/testuser/tinyos-1.x/tos/system/FramerM.nc"
- void FramerM$PacketSent(void)
- #line 246
- {
- result_t TxResult = SUCCESS;
- { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
- #line 249
- {
- if (FramerM$gTxState == FramerM$TXSTATE_ERROR) {
- TxResult = FAIL;
- FramerM$gTxState = FramerM$TXSTATE_IDLE;
- }
- }
- #line 254
- __nesc_atomic_end(__nesc_atomic); }
- if (FramerM$gTxProto == FramerM$PROTO_ACK) {
- { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
- #line 256
- FramerM$gFlags ^= FramerM$FLAGS_TOKENPEND;
- #line 256
- __nesc_atomic_end(__nesc_atomic); }
- }
- else {
- { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
- #line 259
- FramerM$gFlags ^= FramerM$FLAGS_DATAPEND;
- #line 259
- __nesc_atomic_end(__nesc_atomic); }
- FramerM$BareSendMsg$sendDone((TOS_MsgPtr )FramerM$gpTxMsg, TxResult);
- { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
- #line 261
- FramerM$gpTxMsg = (void *)0;
- #line 261
- __nesc_atomic_end(__nesc_atomic); }
- }
- FramerM$StartTx();
- }
- static
- # 143 "/home/testuser/tinyos-1.x/tos/system/AMStandard.nc"
- result_t AMStandard$reportSendDone(TOS_MsgPtr msg, result_t success)
- #line 143
- {
- AMStandard$state = FALSE;
- AMStandard$SendMsg$sendDone(msg->type, msg, success);
- AMStandard$sendDone();
- return SUCCESS;
- }
- static
- # 1102 "../../tos/platform/mica2/CC1000RadioIntM.nc"
- result_t CC1000RadioIntM$Send$send(TOS_MsgPtr pMsg)
- #line 1102
- {
- result_t Result = SUCCESS;
- uint8_t currentRadioState = 0;
- { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
- #line 1106
- {
- if (CC1000RadioIntM$bTxBusy) {
- Result = FAIL;
- }
- else
- {
- CC1000RadioIntM$bTxBusy = TRUE;
- CC1000RadioIntM$txbufptr = pMsg;
- CC1000RadioIntM$txlength = pMsg->length + (MSG_DATA_SIZE - DATA_LENGTH - 2);
- if (CC1000RadioIntM$bCCAEnable) {
- if (CC1000RadioIntM$currentMAC == CC1000RadioIntM$BMAC) {
- CC1000RadioIntM$sMacDelay = CC1000RadioIntM$MacBackoff$initialBackoff(pMsg);
- }
- else {
- #line 1121
- CC1000RadioIntM$sMacDelay = CC1000RadioIntM$getZMACBackoff(0);
- }
- }
- else {
- #line 1123
- CC1000RadioIntM$sMacDelay = 0;
- }
- CC1000RadioIntM$bTxPending = TRUE;
- }
- currentRadioState = CC1000RadioIntM$RadioState;
- }
- #line 1131
- __nesc_atomic_end(__nesc_atomic); }
- if (Result) {
- if (currentRadioState == CC1000RadioIntM$POWER_DOWN_STATE) {
- { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
- #line 1135
- CC1000RadioIntM$RadioState = CC1000RadioIntM$IDLE_STATE;
- #line 1135
- __nesc_atomic_end(__nesc_atomic); }
- CC1000RadioIntM$WakeupTimer$stop();
- CC1000RadioIntM$CC1000StdControl$start();
- CC1000RadioIntM$CC1000Control$BIASOn();
- CC1000RadioIntM$CC1000Control$RxMode();
- CC1000RadioIntM$SpiByteFifo$rxMode();
- CC1000RadioIntM$SpiByteFifo$enableIntr();
- if (CC1000RadioIntM$iSquelchCount > 30) {
- CC1000RadioIntM$SquelchTimer$start(TIMER_REPEAT, 2560);
- }
- else {
- #line 1145
- CC1000RadioIntM$SquelchTimer$start(TIMER_REPEAT, 128);
- }
- #line 1146
- CC1000RadioIntM$WakeupTimer$start(TIMER_ONE_SHOT, 16 * 2);
- }
- }
- return Result;
- }
- static
- # 70 "/home/testuser/tinyos-1.x/tos/system/RandomLFSR.nc"
- uint16_t RandomLFSR$Random$rand(void)
- #line 70
- {
- bool endbit;
- uint16_t tmpShiftReg;
- #line 73
- { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
- #line 73
- {
- tmpShiftReg = RandomLFSR$shiftReg;
- endbit = (tmpShiftReg & 0x8000) != 0;
- tmpShiftReg <<= 1;
- if (endbit) {
- tmpShiftReg ^= 0x100b;
- }
- #line 79
- tmpShiftReg++;
- RandomLFSR$shiftReg = tmpShiftReg;
- tmpShiftReg = tmpShiftReg ^ RandomLFSR$mask;
- }
- #line 82
- __nesc_atomic_end(__nesc_atomic); }
- return tmpShiftReg;
- }
- static
- # 286 "../../tos/platform/mica2/CC1000RadioIntM.nc"
- uint16_t CC1000RadioIntM$getZMACBackoff(uint16_t residualBackoff)
- #line 286
- {
- if (residualBackoff > 0) {
- CC1000RadioIntM$congBackOffs++;
- if (CC1000RadioIntM$currentSlot == CC1000RadioIntM$ownSlot && residualBackoff >= 8) {
- return CC1000RadioIntM$getOwnerBackoff();
- }
- else {
- #line 291
- if (CC1000RadioIntM$currentSlot != CC1000RadioIntM$ownSlot && residualBackoff < 8) {
- if (residualBackoff + 8 < 8 + 32) {
- return residualBackoff + 8;
- }
- else {
- #line 295
- return CC1000RadioIntM$getNonOwnerBackoff();
- }
- }
- else {
- #line 297
- return residualBackoff;
- }
- }
- }
- else
- #line 298
- {
- if (CC1000RadioIntM$currentSlot == CC1000RadioIntM$ownSlot) {
- return CC1000RadioIntM$getOwnerBackoff();
- }
- else {
- #line 302
- return CC1000RadioIntM$getNonOwnerBackoff();
- }
- }
- }
- static
- # 168 "/home/testuser/tinyos-1.x/tos/system/TimerM.nc"
- result_t TimerM$Timer$stop(uint8_t id)
- #line 168
- {
- if (id >= NUM_TIMERS) {
- #line 170
- return FAIL;
- }
- #line 171
- if (TimerM$mState & (0x1L << id)) {
- { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
- #line 172
- TimerM$mState &= ~(0x1L << id);
- #line 172
- __nesc_atomic_end(__nesc_atomic); }
- if (!TimerM$mState) {
- TimerM$setIntervalFlag = 1;
- }
- return SUCCESS;
- }
- return FAIL;
- }
- static
- # 253 "../../tos/system/DrandM.nc"
- void DrandM$addNode(uint8_t nodeID, uint8_t type)
- #line 253
- {
- uint8_t i;
- #line 255
- if (nodeID == TOS_LOCAL_ADDRESS || nodeID == 0xFF) {
- #line 255
- return;
- }
- #line 256
- { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
- #line 256
- {
- for (i = 0; i < MAX_NBR && DrandM$nbrInfo[i].nodeID != 0xFF && DrandM$nbrInfo[i].nodeID != nodeID; i++) ;
- if (i == MAX_NBR) {
- {
- #line 260
- char bStatus;
- #line 260
- if (DBG_USR2 != 0) {
- #line 260
- bStatus = * (volatile uint8_t *)(uint16_t )& * (volatile uint8_t *)(0x3F + 0x20) & (1 << 7);
- #line 260
- __asm volatile ("cli");DrandM$sprintf(DrandM$debugbuf, "addNode: No space to add noden");
- #line 260
- DrandM$writedebug();
- #line 260
- if (bStatus) {
- #line 260
- __asm volatile ("sei");
- }
- }
- }
- #line 260
- ;
- }
- else {
- #line 262
- if (DrandM$nbrInfo[i].nodeID != nodeID) {
- DrandM$nbrInfo[i].nodeID = nodeID;
- DrandM$nbrInfo[i].bitMap = type;
- DrandM$nbrInfo[i].slot = 0xFF;
- DrandM$nbrInfo[i].frame = 0xFF;
- }
- }
- }
- #line 269
- __nesc_atomic_end(__nesc_atomic); }
- }
- static
- #line 271
- void DrandM$removeNode(uint8_t nodeID, uint8_t type)
- #line 271
- {
- uint8_t i;
- #line 273
- { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
- #line 273
- {
- for (i = 0; i < MAX_NBR && DrandM$nbrInfo[i].nodeID != 0xFF && DrandM$nbrInfo[i].nodeID != nodeID; i++) ;
- if (i != MAX_NBR && DrandM$nbrInfo[i].nodeID == nodeID && DrandM$nbrInfo[i].bitMap & type) {
- for (; i < MAX_NBR - 1; i++)
- DrandM$nbrInfo[i] = DrandM$nbrInfo[i + 1];
- DrandM$nbrInfo[MAX_NBR - 1].nodeID = 0xFF;
- }
- }
- #line 280
- __nesc_atomic_end(__nesc_atomic); }
- }
- static
- #line 392
- int DrandM$isPresent(uint8_t nodeID, uint8_t type)
- #line 392
- {
- uint8_t i;
- #line 394
- if (nodeID == 0xFF) {
- #line 394
- return -1;
- }
- #line 395
- for (i = 0; i < MAX_NBR && DrandM$nbrInfo[i].nodeID != 0xFF; i++)
- if (DrandM$nbrInfo[i].nodeID == nodeID && DrandM$nbrInfo[i].bitMap & type) {
- return i;
- }
- #line 398
- return -1;
- }
- static
- #line 670
- void DrandM$sendReleaseMsg(uint8_t slot)
- #line 670
- {
- { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
- #line 671
- {
- if (!DrandM$sendBusy) {
- releaseMsg *releaseMsgData = (releaseMsg *)DrandM$DataPkt.data;
- #line 674
- releaseMsgData->sendID = TOS_LOCAL_ADDRESS;
- releaseMsgData->slot = slot;
- releaseMsgData->myState = DrandM$globalState;
- releaseMsgData->lastRequestID = DrandM$lastReqID;
- releaseMsgData->roundNum = DrandM$roundNum;
- if (DrandM$SendReleaseMsg$send(TOS_BCAST_ADDR, sizeof(releaseMsg ), &DrandM$DataPkt) == SUCCESS) {
- DrandM$sendBusy = TRUE;
- }
- else {
- }
- }
- }
- #line 687
- __nesc_atomic_end(__nesc_atomic); }
- }
- static
- #line 1177
- TOS_MsgPtr DrandM$ReceiveReleaseMsg$receive(TOS_MsgPtr m)
- #line 1177
- {
- int nIndex;
- releaseMsg *recvReleasePtr = (releaseMsg *)m->data;
- if (((
- #line 1184
- nIndex = DrandM$isPresent(recvReleasePtr->sendID, ONE_HOP)) == -1 ||
- DrandM$globalState != GRANT_STATE) || DrandM$lastReqID != recvReleasePtr->sendID) {
- return m;
- }
- #line 1187
- { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
- #line 1187
- {
- DrandM$reXTimer$stop();
- if (DrandM$updateNeighborInfo(recvReleasePtr->sendID, recvReleasePtr->slot)) {
- DrandM$sendTwoHopMsg(recvReleasePtr->slot, recvReleasePtr->sendID);
- }
- if (DrandM$setMySlot) {
- DrandM$globalState = RELEASE_STATE;
- }
- else
- {
- DrandM$globalState = IDLE_STATE2;
- DrandM$drandRoundTimer$start(TIMER_ONE_SHOT, 100);
- }
- DrandM$graX = FALSE;
- DrandM$lastReqID = 0xFF;
- }
- #line 1211
- __nesc_atomic_end(__nesc_atomic); }
- return m;
- }
- static
- #line 310
- bool DrandM$updateNeighborInfo(uint8_t nID, uint8_t slot)
- #line 310
- {
- uint8_t i;
- #line 312
- if (slot == 0xFF || nID == 0xFF) {
- #line 312
- return FALSE;
- }
- #line 313
- for (i = 0; i < MAX_NBR && DrandM$nbrInfo[i].nodeID != 0xFF; i++)
- if (DrandM$nbrInfo[i].nodeID == nID && DrandM$nbrInfo[i].slot == 0xFF) {
- DrandM$nbrInfo[i].slot = slot;
- return TRUE;
- }
- return FALSE;
- }
- static
- #line 67
- GTime DrandM$timeDiff(GTime A, GTime B)
- #line 67
- {
- GTime diff;
- #line 69
- if (A.sticks >= B.sticks) {
- diff.mticks = A.mticks - B.mticks;
- diff.sticks = A.sticks - B.sticks;
- }
- else {
- uint32_t temp = 65536;
- #line 75
- diff.mticks = A.mticks - 1 - B.mticks;
- diff.sticks = (uint16_t )(temp + A.sticks - B.sticks);
- }
- return diff;
- }
- static
- #line 290
- uint8_t DrandM$numGrantsRemaining(void)
- #line 290
- {
- uint8_t i;
- #line 291
- uint8_t count;
- #line 292
- for (i = 0, count = 0; i < MAX_NBR && DrandM$nbrInfo[i].nodeID != 0xFF; i++)
- if (DrandM$nbrInfo[i].bitMap & ONE_HOP && !(DrandM$nbrInfo[i].bitMap & GRANT_SENT)) {
- count++;
- }
- return count;
- }
- static
- #line 693
- void DrandM$setSlot(void)
- #line 693
- {
- uint8_t i;
- uint32_t slotField;
- #line 696
- { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
- #line 696
- {
- for (i = 0, slotField = 0x0; i < MAX_NBR && DrandM$nbrInfo[i].nodeID != 0xFF; i++)
- if (DrandM$nbrInfo[i].slot != 0xFF) {
- slotField = slotField | (0x1 << DrandM$nbrInfo[i].slot);
- }
- #line 700
- for (i = 0; i < 32; i++)
- if (!(slotField & (0x1 << i))) {
- DrandM$myInfo.slot = i;
- DrandM$setMySlot = TRUE;
- break;
- }
- if (!DrandM$setMySlot) {
- {
- #line 709
- char bStatus;
- #line 709
- if (DBG_USR2 != 0) {
- #line 709
- bStatus = * (volatile uint8_t *)(uint16_t )& * (volatile uint8_t *)(0x3F + 0x20) & (1 << 7);
- #line 709
- __asm volatile ("cli");DrandM$sprintf(DrandM$debugbuf, "SetSlot: Could not set slot, something wrong, abort !!!n");
- #line 709
- DrandM$writedebug();
- #line 709
- if (bStatus) {
- #line 709
- __asm volatile ("sei");
- }
- }
- }
- #line 709
- ;
- }
- else {
- DrandM$globalState = RELEASE_STATE;
- DrandM$sendReleaseMsg(DrandM$myInfo.slot);
- DrandM$reXTimer$stop();
- }
- }
- #line 719
- __nesc_atomic_end(__nesc_atomic); }
- }
- static
- #line 146
- void DrandM$timeCheck(void)
- #line 146
- {
- GTime roundTime;
- #line 148
- DrandM$SClock$getTime(&DrandM$locTime);
- DrandM$drandRunTime = DrandM$timeDiff(DrandM$locTime, DrandM$drandStartTime);
- roundTime = DrandM$timeDiff(DrandM$locTime, DrandM$roundStartTime);
- {
- #line 152
- char bStatus;
- #line 152
- if (DBG_USR2 != 0) {
- #line 152
- bStatus = * (volatile uint8_t *)(uint16_t )& * (volatile uint8_t *)(0x3F + 0x20) & (1 << 7);
- #line 152
- __asm volatile ("cli");DrandM$sprintf(DrandM$debugbuf, "MESSAGE sID %u mCt %u rReq %u rGra %u mTime %u sTime %un", TOS_LOCAL_ADDRESS, DrandM$reqCount + DrandM$graCount + DrandM$rejCount + DrandM$relCount + DrandM$twoCount, DrandM$reqXCount, DrandM$graXCount, (uint16_t )DrandM$drandRunTime.mticks, (uint16_t )DrandM$drandRunTime.sticks);
- #line 152
- DrandM$writedebug();
- #line 152
- if (bStatus) {
- #line 152
- __asm volatile ("sei");
- }
- }
- }
- #line 152
- ;
- {
- #line 155
- char bStatus;
- #line 155
- if (DBG_USR2 != 0) {
- #line 155
- bStatus = * (volatile uint8_t *)(uint16_t )& * (volatile uint8_t *)(0x3F + 0x20) & (1 << 7);
- #line 155
- __asm volatile ("cli");DrandM$sprintf(DrandM$debugbuf, "MESSAGE sID %u reqCt %u graCt %u rejCt %u relCt %u twoCt %un", TOS_LOCAL_ADDRESS, DrandM$reqCount, DrandM$graCount, DrandM$rejCount, DrandM$relCount, DrandM$twoCount);
- #line 155
- DrandM$writedebug();
- #line 155
- if (bStatus) {
- #line 155
- __asm volatile ("sei");
- }
- }
- }
- #line 155
- ;
- {
- #line 157
- char bStatus;
- #line 157
- if (DBG_USR2 != 0) {
- #line 157
- bStatus = * (volatile uint8_t *)(uint16_t )& * (volatile uint8_t *)(0x3F + 0x20) & (1 << 7);
- #line 157
- __asm volatile ("cli");DrandM$sprintf(DrandM$debugbuf, "MESSAGE sID %u Round %u slotNum %u mRound %u sRound %un", TOS_LOCAL_ADDRESS, DrandM$roundNum, DrandM$myInfo.slot, roundTime.mticks, roundTime.sticks);
- #line 157
- DrandM$writedebug();
- #line 157
- if (bStatus) {
- #line 157
- __asm volatile ("sei");
- }
- }
- }
- #line 157
- ;
- }
- static
- #line 109
- void DrandM$printNbrInfo(void)
- #line 109
- {
- uint8_t i;
- #line 111
- {
- #line 111
- char bStatus;
- #line 111
- if (DBG_USR2 != 0) {
- #line 111
- bStatus = * (volatile uint8_t *)(uint16_t )& * (volatile uint8_t *)(0x3F + 0x20) & (1 << 7);
- #line 111
- __asm volatile ("cli");DrandM$sprintf(DrandM$debugbuf, "*******************************************************n");
- #line 111
- DrandM$writedebug();
- #line 111
- if (bStatus) {
- #line 111
- __asm volatile ("sei");
- }
- }
- }
- #line 111
- ;
- for (i = 0; i < MAX_NBR && DrandM$nbrInfo[i].nodeID != 0xFF; i++) {
- switch (DrandM$globalState) {
- case IDLE_STATE2:
- if (DrandM$nbrInfo[i].bitMap & ONE_HOP) {
- {
- #line 116
- char bStatus;
- #line 116
- if (DBG_USR2 != 0) {
- #line 116
- bStatus = * (volatile uint8_t *)(uint16_t )& * (volatile uint8_t *)(0x3F + 0x20) & (1 << 7);
- #line 116
- __asm volatile ("cli");DrandM$sprintf(DrandM$debugbuf, "OneHopNodeID(HELLO) : %u %u %un", DrandM$nbrInfo[i].nodeID, DrandM$nbrInfo[i].slot, DrandM$nbrInfo[i].frame);
- #line 116
- DrandM$writedebug();
- #line 116
- if (bStatus) {
- #line 116
- __asm volatile ("sei");
- }
- }
- }
- #line 116
- ;
- }
- else {
- #line 118
- if (DrandM$nbrInfo[i].bitMap & TWO_HOP) {
- {
- #line 119
- char bStatus;
- #line 119
- if (DBG_USR2 != 0) {
- #line 119
- bStatus = * (volatile uint8_t *)(uint16_t )& * (volatile uint8_t *)(0x3F + 0x20) & (1 << 7);
- #line 119
- __asm volatile ("cli");DrandM$sprintf(DrandM$debugbuf, "TwoHopNodeID(HELLO) : %u %u %un", DrandM$nbrInfo[i].nodeID, DrandM$nbrInfo[i].slot, DrandM$nbrInfo[i].frame);
- #line 119
- DrandM$writedebug();
- #line 119
- if (bStatus) {
- #line 119
- __asm volatile ("sei");
- }
- }
- }
- #line 119
- ;
- }
- }
- break;
- case RELEASE_STATE:
- if (DrandM$nbrInfo[i].bitMap & ONE_HOP) {
- {
- #line 125
- char bStatus;
- #line 125
- if (DBG_USR2 != 0) {
- #line 125
- bStatus = * (volatile uint8_t *)(uint16_t )& * (volatile uint8_t *)(0x3F + 0x20) & (1 << 7);
- #line 125
- __asm volatile ("cli");DrandM$sprintf(DrandM$debugbuf, "OneHopNodeID(DRAND) : %u %u %un", DrandM$nbrInfo[i].nodeID, DrandM$nbrInfo[i].slot, DrandM$nbrInfo[i].frame);
- #line 125
- DrandM$writedebug();
- #line 125
- if (bStatus) {
- #line 125
- __asm volatile ("sei");
- }
- }
- }
- #line 125
- ;
- }
- else {
- #line 127
- if (DrandM$nbrInfo[i].bitMap & TWO_HOP) {
- {
- #line 128
- char bStatus;
- #line 128
- if (DBG_USR2 != 0) {
- #line 128
- bStatus = * (volatile uint8_t *)(uint16_t )& * (volatile uint8_t *)(0x3F + 0x20) & (1 << 7);
- #line 128
- __asm volatile ("cli");DrandM$sprintf(DrandM$debugbuf, "TwoHopNodeID(DRAND) : %u %u %un", DrandM$nbrInfo[i].nodeID, DrandM$nbrInfo[i].slot, DrandM$nbrInfo[i].frame);
- #line 128
- DrandM$writedebug();
- #line 128
- if (bStatus) {
- #line 128
- __asm volatile ("sei");
- }
- }
- }
- #line 128
- ;
- }
- }
- break;
- case FRAME_STATE:
- if (DrandM$nbrInfo[i].bitMap & ONE_HOP) {
- {
- #line 134
- char bStatus;
- #line 134
- if (DBG_USR2 != 0) {
- #line 134
- bStatus = * (volatile uint8_t *)(uint16_t )& * (volatile uint8_t *)(0x3F + 0x20) & (1 << 7);
- #line 134
- __asm volatile ("cli");DrandM$sprintf(DrandM$debugbuf, "OneHopNodeID(FRAME) : %u %u %un", DrandM$nbrInfo[i].nodeID, DrandM$nbrInfo[i].slot, DrandM$nbrInfo[i].frame);
- #line 134
- DrandM$writedebug();
- #line 134
- if (bStatus) {
- #line 134
- __asm volatile ("sei");
- }
- }
- }
- #line 134
- ;
- }
- else {
- #line 136
- if (DrandM$nbrInfo[i].bitMap & TWO_HOP) {
- {
- #line 137
- char bStatus;
- #line 137
- if (DBG_USR2 != 0) {
- #line 137
- bStatus = * (volatile uint8_t *)(uint16_t )& * (volatile uint8_t *)(0x3F + 0x20) & (1 << 7);
- #line 137
- __asm volatile ("cli");DrandM$sprintf(DrandM$debugbuf, "TwoHopNodeID(FRAME) : %u %u %un", DrandM$nbrInfo[i].nodeID, DrandM$nbrInfo[i].slot, DrandM$nbrInfo[i].frame);
- #line 137
- DrandM$writedebug();
- #line 137
- if (bStatus) {
- #line 137
- __asm volatile ("sei");
- }
- }
- }
- #line 137
- ;
- }
- }
- break;
- }
- }
- {
- #line 143
- char bStatus;
- #line 143
- if (DBG_USR2 != 0) {
- #line 143
- bStatus = * (volatile uint8_t *)(uint16_t )& * (volatile uint8_t *)(0x3F + 0x20) & (1 << 7);
- #line 143
- __asm volatile ("cli");DrandM$sprintf(DrandM$debugbuf, "*******************************************************n");
- #line 143
- DrandM$writedebug();
- #line 143
- if (bStatus) {
- #line 143
- __asm volatile ("sei");
- }
- }
- }
- #line 143
- ;
- }
- static
- #line 1331
- void DrandM$reXReport(void)
- #line 1331
- {
- if (DrandM$reportFireCount > MAX_REPORT) {
- DrandM$removeNodesForReport();
- }
- else {
- #line 1335
- DrandM$reportFireCount++;
- }
- if (!DrandM$checkForRetransReport()) {
- DrandM$setFrame();
- }
- else
- #line 1339
- {
- DrandM$sendReportMsg(REPORT_REQUEST);
- }
- }
- static
- #line 440
- void DrandM$removeNodesForReport(void)
- #line 440
- {
- int i;
- #line 442
- for (i = MAX_NBR - 1; i >= 0; i--) {
- if (DrandM$nbrInfo[i].nodeID == 0xFF) {
- continue;
- }
- else {
- #line 445
- if (DrandM$nbrInfo[i].slot == 0xFF) {
- {
- #line 447
- char bStatus;
- #line 447
- if (DBG_USR2 != 0) {
- #line 447
- bStatus = * (volatile uint8_t *)(uint16_t )& * (volatile uint8_t *)(0x3F + 0x20) & (1 << 7);
- #line 447
- __asm volatile ("cli");DrandM$sprintf(DrandM$debugbuf, "RemoveNodesForReport: Removed node %un", DrandM$nbrInfo[i].nodeID);
- #line 447
- DrandM$writedebug();
- #line 447
- if (bStatus) {
- #line 447
- __asm volatile ("sei");
- }
- }
- }
- #line 447
- ;
- DrandM$removeNode(DrandM$nbrInfo[i].nodeID, DrandM$nbrInfo[i].bitMap);
- }
- }
- }
- }
- static
- #line 722
- void DrandM$setFrame(void)
- #line 722
- {
- uint8_t maxSlot;
- #line 723
- uint8_t frameLen;
- #line 724
- DrandM$removeNodesForReport();
- DrandM$reXTimer$stop();
- maxSlot = DrandM$getMaxSlot();
- frameLen = 0;
- while (maxSlot != 0) {
- maxSlot = (int )(maxSlot / 2);
- frameLen++;
- }
- DrandM$myInfo.frame = 0x1 << frameLen;
- {
- #line 734
- char bStatus;
- #line 734
- if (DBG_USR2 != 0) {
- #line 734
- bStatus = * (volatile uint8_t *)(uint16_t )& * (volatile uint8_t *)(0x3F + 0x20) & (1 << 7);
- #line 734
- __asm volatile ("cli");DrandM$sprintf(DrandM$debugbuf, "Local Frame Size = %u for maxSlot = %un", DrandM$myInfo.frame, DrandM$getMaxSlot());
- #line 734
- DrandM$writedebug();
- #line 734
- if (bStatus) {
- #line 734
- __asm volatile ("sei");
- }
- }
- }
- #line 734
- ;
- }
- static
- #line 245
- uint8_t DrandM$getMaxSlot(void)
- #line 245
- {
- uint8_t i;
- #line 246
- uint8_t maxSlot = DrandM$myInfo.slot;
- #line 247
- for (i = 0; i < MAX_NBR && DrandM$nbrInfo[i].nodeID != 0xFF; i++)
- if (DrandM$nbrInfo[i].slot > maxSlot) {
- maxSlot = DrandM$nbrInfo[i].slot;
- }
- #line 250
- return maxSlot;
- }
- static
- #line 792
- void DrandM$sendReportMsg(uint8_t type)
- #line 792
- {
- { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
- #line 793
- {
- if (!DrandM$sendBusy) {
- reportMsg *reportMsgData = (reportMsg *)DrandM$DataPkt.data;
- #line 796
- reportMsgData->slot = DrandM$myInfo.slot;
- reportMsgData->sendID = TOS_LOCAL_ADDRESS;
- reportMsgData->type = type;
- DrandM$fillTimeSlotInfoForReport(reportMsgData->timeSlot);
- if (DrandM$SendReportMsg$send(TOS_BCAST_ADDR, sizeof(reportMsg ), &DrandM$DataPkt) != SUCCESS) {
- DrandM$reXTimer$start(TIMER_ONE_SHOT, REPORT_XPERIOD + DrandM$randNew() % REPORT_INTERVAL);
- }
- else
- {
- DrandM$sendBusy = TRUE;
- }
- }
- else
- #line 808
- {
- DrandM$reXTimer$start(TIMER_ONE_SHOT, REPORT_XPERIOD + DrandM$randNew() % REPORT_INTERVAL);
- }
- }
- #line 811
- __nesc_atomic_end(__nesc_atomic); }
- }
- static
- #line 1308
- void DrandM$reXFrame(void)
- #line 1308
- {
- if (DrandM$frameFireCount > MAX_FRAME) {
- DrandM$removeNodesForFrame();
- }
- else {
- #line 1312
- DrandM$frameFireCount++;
- }
- if (!DrandM$checkForRetransFrame()) {
- DrandM$reXTimer$stop();
- if (!DrandM$gotAllFrames) {
- DrandM$Drand$gotFrame();
- DrandM$gotAllFrames = TRUE;
- DrandM$printNbrInfo();
- }
- }
- else {
- DrandM$sendFrameMsg(FRAME_REQUEST);
- }
- }
- static
- #line 817
- void DrandM$sendFrameMsg(uint8_t frameType)
- #line 817
- {
- { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
- #line 818
- {
- if (!DrandM$sendBusy) {
- frameMsg *frameMsgData = (frameMsg *)DrandM$DataPkt.data;
- #line 821
- frameMsgData->sendID = TOS_LOCAL_ADDRESS;
- frameMsgData->frame = DrandM$myInfo.frame;
- frameMsgData->type = frameType;
- DrandM$fillFrameInfo(frameMsgData);
- if (DrandM$SendFrameMsg$send(TOS_BCAST_ADDR, sizeof(frameMsg ), &DrandM$DataPkt) == SUCCESS) {
- DrandM$sendBusy = TRUE;
- }
- else
- #line 827
- {
- DrandM$reXTimer$start(TIMER_ONE_SHOT, FRAME_XPERIOD + DrandM$randNew() % FRAME_INTERVAL);
- }
- }
- else
- #line 833
- {
- DrandM$reXTimer$start(TIMER_ONE_SHOT, FRAME_XPERIOD + DrandM$randNew() % FRAME_INTERVAL);
- }
- }
- #line 839
- __nesc_atomic_end(__nesc_atomic); }
- }
- # 144 "../../tos/platform/mica2/HPLADCM.nc"
- void __attribute((signal)) __vector_21(void)
- #line 144
- {
- uint16_t data = * (volatile uint16_t *)& * (volatile uint8_t *)(0x04 + 0x20);
- #line 146
- data &= 0x3ff;
- * (volatile uint8_t *)(0x06 + 0x20) |= 1 << 4;
- * (volatile uint8_t *)(0x06 + 0x20) &= ~(1 << 7);
- __nesc_enable_interrupt();
- HPLADCM$ADC$dataReady(data);
- }
- static
- #line 122
- result_t HPLADCM$ADC$samplePort(uint8_t port)
- #line 122
- {
- { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
- #line 123
- {
- * (volatile uint8_t *)(0x07 + 0x20) = HPLADCM$TOSH_adc_portmap[port] & 0x1F;
- }
- #line 125
- __nesc_atomic_end(__nesc_atomic); }
- * (volatile uint8_t *)(0x06 + 0x20) |= 1 << 7;
- * (volatile uint8_t *)(0x06 + 0x20) |= 1 << 6;
- return SUCCESS;
- }
- static
- # 342 "../../tos/platform/mica2/CC1000RadioIntM.nc"
- void CC1000RadioIntM$adjustSquelch(void)
- #line 342
- {
- uint16_t tempArray[9];
- char i;
- #line 344
- char j;
- #line 344
- char min;
- uint16_t min_value;
- uint32_t tempsquelch;
- { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
- #line 348
- {
- CC1000RadioIntM$usSquelchTable[CC1000RadioIntM$usSquelchIndex] = CC1000RadioIntM$usTempSquelch;
- CC1000RadioIntM$usSquelchIndex++;
- if (CC1000RadioIntM$usSquelchIndex >= 9) {
- CC1000RadioIntM$usSquelchIndex = 0;
- }
- #line 353
- if (CC1000RadioIntM$iSquelchCount <= 30) {
- CC1000RadioIntM$iSquelchCount++;
- }
- }
- #line 356
- __nesc_atomic_end(__nesc_atomic); }
- for (i = 0; i < 9; i++) {
- tempArray[(int )i] = CC1000RadioIntM$usSquelchTable[(int )i];
- }
- min = 0;
- for (j = 0; j < 3; j++) {
- for (i = 1; i < 9; i++) {
- if (tempArray[(int )i] != 0xFFFF && (
- tempArray[(int )i] > tempArray[(int )min] ||
- tempArray[(int )min] == 0xFFFF)) {
- min = i;
- }
- }
- min_value = tempArray[(int )min];
- tempArray[(int )min] = 0xFFFF;
- }
- tempsquelch = (uint32_t )(CC1000RadioIntM$usSquelchVal << 5) + (uint32_t )(min_value << 1);
- { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
- #line 376
- CC1000RadioIntM$usSquelchVal = (uint16_t )(tempsquelch / 34 & 0x0FFFF);
- #line 376
- __nesc_atomic_end(__nesc_atomic); }
- }
- static
- # 422 "../../tos/platform/mica2/CC1000ControlM.nc"
- result_t CC1000ControlM$CC1000Control$TxMode(void)
- #line 422
- {
- CC1000ControlM$HPLChipcon$write(0x00, (((
- 1 << 7) | (1 << 6)) | (1 << 5)) | (
- 1 << 0));
- CC1000ControlM$HPLChipcon$write(0x09, CC1000ControlM$gCurrentParameters[29]);
- TOSH_uwait(250);
- CC1000ControlM$HPLChipcon$write(0x0B, CC1000ControlM$gCurrentParameters[0xb]);
- TOSH_uwait(20);
- return SUCCESS;
- }
- static
- # 198 "../../tos/platform/mica2/ADCREFM.nc"
- result_t ADCREFM$startGet(uint8_t port)
- #line 198
- {
- uint16_t PortMask;
- #line 199
- uint16_t oldReqVector = 1;
- result_t Result = SUCCESS;
- PortMask = 1 << port;
- if ((PortMask & ADCREFM$ReqVector) != 0) {
- Result = FAIL;
- }
- else {
- oldReqVector = ADCREFM$ReqVector;
- ADCREFM$ReqVector |= PortMask;
- if (oldReqVector == 0) {
- if ((Result = ADCREFM$HPLADC$samplePort(port))) {
- ADCREFM$ReqPort = port;
- }
- }
- }
- return Result;
- }
- static
- # 1586 "../../tos/platform/mica2/CC1000RadioIntM.nc"
- void CC1000RadioIntM$IdleTimerTask(void)
- #line 1586
- {
- if (CC1000RadioIntM$iSquelchCount > 30) {
- CC1000RadioIntM$SquelchTimer$start(TIMER_REPEAT, 2560);
- }
- else {
- #line 1590
- CC1000RadioIntM$SquelchTimer$start(TIMER_REPEAT, 128);
- }
- #line 1591
- CC1000RadioIntM$WakeupTimer$start(TIMER_ONE_SHOT, CC1000RadioIntM$TIME_AFTER_CHECK);
- }
- static
- # 82 "../../tos/platform/mica2/HPLSpiM.nc"
- result_t HPLSpiM$SpiByteFifo$disableIntr(void)
- #line 82
- {
- * (volatile uint8_t *)(0x0D + 0x20) &= ~(1 << 7);
- * (volatile uint8_t *)(0x17 + 0x20) |= 1 << 0;
- * (volatile uint8_t *)(0x18 + 0x20) &= ~(1 << 0);
- HPLSpiM$PowerManagement$adjustPower();
- return SUCCESS;
- }
- # 167 "/home/testuser/tinyos-1.x/tos/platform/mica/HPLClock.nc"
- void __attribute((interrupt)) __vector_15(void)
- #line 167
- {
- { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
- #line 168
- {
- if (HPLClock$set_flag) {
- HPLClock$mscale = HPLClock$nextScale;
- HPLClock$nextScale |= 0x8;
- * (volatile uint8_t *)(0x33 + 0x20) = HPLClock$nextScale;
- * (volatile uint8_t *)(0x31 + 0x20) = HPLClock$minterval;
- HPLClock$set_flag = 0;
- }
- }
- #line 177
- __nesc_atomic_end(__nesc_atomic); }
- HPLClock$Clock$fire();
- }
- static
- # 401 "../../tos/system/DrandM.nc"
- uint8_t DrandM$getContenders(void)
- #line 401
- {
- uint8_t i;
- #line 402
- uint8_t contenders = 0;
- #line 403
- for (i = 0; i < MAX_NBR && DrandM$nbrInfo[i].nodeID != 0xFF; i++)
- if (DrandM$nbrInfo[i].slot == 0xFF) {
- contenders++;
- }
- #line 406
- return contenders + 1;
- }
- static
- #line 616
- void DrandM$sendRequestMsg(void)
- #line 616
- {
- { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
- #line 617
- {
- if (!DrandM$sendBusy) {
- requestMsg *requestMsgData = (requestMsg *)DrandM$DataPkt.data;
- #line 620
- requestMsgData->sendID = TOS_LOCAL_ADDRESS;
- DrandM$SClock$getTime(& requestMsgData->timestamp);
- requestMsgData->myState = DrandM$globalState;
- requestMsgData->roundNum = DrandM$roundNum;
- requestMsgData->lastRequestID = DrandM$lastReqID;
- DrandM$fillGrantSendInfo(requestMsgData->idMap);
- requestMsgData->numRemaining = DrandM$numGrantsRemaining();
- requestMsgData->OTT = DrandM$OTT;
- if (DrandM$SendRequestMsg$send(TOS_BCAST_ADDR, sizeof(requestMsg ), &DrandM$DataPkt) != SUCCESS) {
- DrandM$reXTimer$start(TIMER_ONE_SHOT, DrandM$REQUEST_TIME);
- }
- else
- #line 636
- {
- DrandM$sendBusy = TRUE;
- }
- }
- else
- #line 639
- {
- DrandM$reXTimer$start(TIMER_ONE_SHOT, DrandM$REQUEST_TIME);
- }
- }
- #line 645
- __nesc_atomic_end(__nesc_atomic); }
- }
- static
- # 1166 "../../tos/platform/mica2/CC1000RadioIntM.nc"
- result_t CC1000RadioIntM$SpiByteFifo$dataReady(uint8_t data_in)
- #line 1166
- {
- GTime loctime;
- #line 1168
- CC1000RadioIntM$RadioSendCoordinator$blockTimer();
- CC1000RadioIntM$RadioReceiveCoordinator$blockTimer();
- if (CC1000RadioIntM$bInvertRxData) {
- data_in = ~data_in;
- }
- switch (CC1000RadioIntM$RadioState) {
- case CC1000RadioIntM$TX_STATE:
- {
- CC1000RadioIntM$SpiByteFifo$writeByte(CC1000RadioIntM$NextTxByte);
- CC1000RadioIntM$TxByteCnt++;
- switch (CC1000RadioIntM$RadioTxState) {
- case CC1000RadioIntM$TXSTATE_PREAMBLE:
- CC1000RadioIntM$send_sum++;
- if (!(CC1000RadioIntM$TxByteCnt < CC1000RadioIntM$preamblelen) || (
- CC1000RadioIntM$txbufptr->strength == 0xffff && CC1000RadioIntM$TxByteCnt >= CC1000RadioIntM$PREAMBLE_LENGTH_TO_BASE)) {
- CC1000RadioIntM$NextTxByte = CC1000RadioIntM$SYNC_BYTE;
- CC1000RadioIntM$RadioTxState = CC1000RadioIntM$TXSTATE_SYNC;
- }
- break;
- case CC1000RadioIntM$TXSTATE_SYNC:
- CC1000RadioIntM$send_sum++;
- CC1000RadioIntM$NextTxByte = CC1000RadioIntM$NSYNC_BYTE;
- CC1000RadioIntM$RadioTxState = CC1000RadioIntM$TXSTATE_DATA;
- CC1000RadioIntM$TxByteCnt = -1;
- if (CC1000RadioIntM$txbufptr->type == 223) {
- syncMsgType *syncMsgPtr = (syncMsgType *)CC1000RadioIntM$txbufptr->data;
- #line 1204
- CC1000RadioIntM$SClock$getTime(&loctime);
- syncMsgPtr->mticks = loctime.mticks;
- syncMsgPtr->sticks = loctime.sticks;
- syncMsgPtr->trust = 1;
- syncMsgPtr->sender = TOS_LOCAL_ADDRESS;
- }
- CC1000RadioIntM$RadioSendCoordinator$startSymbol(8, 0, CC1000RadioIntM$txbufptr);
- break;
- case CC1000RadioIntM$TXSTATE_DATA:
- CC1000RadioIntM$send_sum++;
- if ((uint8_t )CC1000RadioIntM$TxByteCnt < CC1000RadioIntM$txlength) {
- if (CC1000RadioIntM$txbufptr->type == 223 && CC1000RadioIntM$TxByteCnt == 5) {
- syncMsgType *syncMsgPtr = (syncMsgType *)CC1000RadioIntM$txbufptr->data;
- #line 1219
- CC1000RadioIntM$SClock$getTime(&loctime);
- CC1000RadioIntM$AddTime(&loctime, &loctime, &CC1000RadioIntM$constOffset);
- syncMsgPtr->mticks = loctime.mticks;
- syncMsgPtr->sticks = loctime.sticks;
- }
- CC1000RadioIntM$NextTxByte = ((uint8_t *)CC1000RadioIntM$txbufptr)[CC1000RadioIntM$TxByteCnt];
- CC1000RadioIntM$usRunningCRC = crcByte(CC1000RadioIntM$usRunningCRC, CC1000RadioIntM$NextTxByte);
- CC1000RadioIntM$RadioSendCoordinator$byte(CC1000RadioIntM$txbufptr, (uint8_t )CC1000RadioIntM$TxByteCnt);
- }
- else {
- CC1000RadioIntM$NextTxByte = (uint8_t )CC1000RadioIntM$usRunningCRC;
- CC1000RadioIntM$RadioTxState = CC1000RadioIntM$TXSTATE_CRC;
- }
- break;
- case CC1000RadioIntM$TXSTATE_CRC:
- CC1000RadioIntM$send_sum++;
- CC1000RadioIntM$NextTxByte = (uint8_t )(CC1000RadioIntM$usRunningCRC >> 8);
- CC1000RadioIntM$RadioTxState = CC1000RadioIntM$TXSTATE_FLUSH;
- CC1000RadioIntM$TxByteCnt = 0;
- break;
- case CC1000RadioIntM$TXSTATE_FLUSH:
- CC1000RadioIntM$send_sum++;
- if (CC1000RadioIntM$TxByteCnt > 3) {
- CC1000RadioIntM$TxByteCnt = 0;
- if (CC1000RadioIntM$bAckEnable) {
- CC1000RadioIntM$RadioTxState = CC1000RadioIntM$TXSTATE_WAIT_FOR_ACK;
- }
- else
- #line 1250
- {
- CC1000RadioIntM$packetsSent++;
- CC1000RadioIntM$SpiByteFifo$rxMode();
- CC1000RadioIntM$CC1000Control$RxMode();
- CC1000RadioIntM$RadioTxState = CC1000RadioIntM$TXSTATE_DONE;
- }
- }
- break;
- case CC1000RadioIntM$TXSTATE_WAIT_FOR_ACK:
- if (CC1000RadioIntM$TxByteCnt == 1) {
- CC1000RadioIntM$send_sum++;
- CC1000RadioIntM$SpiByteFifo$rxMode();
- CC1000RadioIntM$CC1000Control$RxMode();
- break;
- }
- CC1000RadioIntM$receive_sum++;
- if (CC1000RadioIntM$TxByteCnt > 3) {
- CC1000RadioIntM$RadioTxState = CC1000RadioIntM$TXSTATE_READ_ACK;
- CC1000RadioIntM$TxByteCnt = 0;
- CC1000RadioIntM$search_word = 0;
- }
- break;
- case CC1000RadioIntM$TXSTATE_READ_ACK:
- {
- uint8_t i;
- #line 1280
- CC1000RadioIntM$receive_sum++;
- for (i = 0; i < 8; i++) {
- CC1000RadioIntM$search_word <<= 1;
- if (data_in & 0x80) {
- #line 1283
- CC1000RadioIntM$search_word |= 0x1;
- }
- #line 1284
- data_in <<= 1;
- if (CC1000RadioIntM$search_word == 0xba83) {
- CC1000RadioIntM$txbufptr->ack = 1;
- CC1000RadioIntM$RadioTxState = CC1000RadioIntM$TXSTATE_DONE;
- return SUCCESS;
- }
- }
- }
- if (CC1000RadioIntM$TxByteCnt >= CC1000RadioIntM$MAX_ACK_WAIT) {
- CC1000RadioIntM$txbufptr->ack = 0;
- CC1000RadioIntM$RadioTxState = CC1000RadioIntM$TXSTATE_DONE;
- }
- break;
- case CC1000RadioIntM$TXSTATE_DONE:
- default:
- CC1000RadioIntM$bTxPending = FALSE;
- if (CC1000RadioIntM$txbufptr->type == 222 || CC1000RadioIntM$txbufptr->type == 223) {
- CC1000RadioIntM$bAckEnable = CC1000RadioIntM$ackOrig;
- }
- if (TOS_post(CC1000RadioIntM$PacketSent)) {
- CC1000RadioIntM$RadioState = CC1000RadioIntM$IDLE_STATE;
- CC1000RadioIntM$pktsLastSync++;
- CC1000RadioIntM$RSSIInitState = CC1000RadioIntM$RadioState;
- CC1000RadioIntM$RSSIADC$getData();
- }
- break;
- }
- }
- break;
- case CC1000RadioIntM$DISABLED_STATE:
- break;
- case CC1000RadioIntM$IDLE_STATE:
- {
- CC1000RadioIntM$receive_sum++;
- if (data_in == 0xaa || data_in == 0x55) {
- CC1000RadioIntM$PreambleCount++;
- if (CC1000RadioIntM$PreambleCount > 2) {
- CC1000RadioIntM$PreambleCount = CC1000RadioIntM$SOFCount = 0;
- CC1000RadioIntM$RxBitOffset = CC1000RadioIntM$RxByteCnt = 0;
- CC1000RadioIntM$usRunningCRC = 0;
- CC1000RadioIntM$rxlength = MSG_DATA_SIZE - 2;
- CC1000RadioIntM$RadioState = CC1000RadioIntM$SYNC_STATE;
- }
- }
- else
- #line 1350
- {
- if ((CC1000RadioIntM$currentMAC == CC1000RadioIntM$BMAC || CC1000RadioIntM$enableHCL == FALSE) || !CC1000RadioIntM$IsHCL(CC1000RadioIntM$currentSlot)) {
- if (CC1000RadioIntM$bTxPending && --CC1000RadioIntM$sMacDelay <= 0) {
- CC1000RadioIntM$RadioState = CC1000RadioIntM$PRETX_STATE;
- CC1000RadioIntM$RSSIInitState = CC1000RadioIntM$PRETX_STATE;
- CC1000RadioIntM$bRSSIValid = FALSE;
- CC1000RadioIntM$iRSSIcount = 0;
- CC1000RadioIntM$PreambleCount = 0;
- CC1000RadioIntM$RSSIADC$getData();
- }
- }
- else
- #line 1360
- {
- }
- }
- }
- break;
- case CC1000RadioIntM$PRETX_STATE:
- {
- CC1000RadioIntM$receive_sum++;
- if (data_in == 0xaa || data_in == 0x55) {
- CC1000RadioIntM$sMacDelay = CC1000RadioIntM$MacBackoff$congestionBackoff(CC1000RadioIntM$txbufptr);
- CC1000RadioIntM$RadioState = CC1000RadioIntM$IDLE_STATE;
- }
- }
- break;
- case CC1000RadioIntM$SYNC_STATE:
- {
- uint8_t i;
- CC1000RadioIntM$receive_sum++;
- if (data_in == 0xaa || data_in == 0x55) {
- CC1000RadioIntM$RxShiftBuf.MSB = data_in;
- }
- else {
- uint16_t usTmp;
- #line 1405
- switch (CC1000RadioIntM$SOFCount) {
- case 0:
- CC1000RadioIntM$RxShiftBuf.LSB = data_in;
- break;
- case 1:
- case 2:
- case 3:
- case 4:
- case 5:
- usTmp = CC1000RadioIntM$RxShiftBuf.W;
- CC1000RadioIntM$RxShiftBuf.W <<= 8;
- CC1000RadioIntM$RxShiftBuf.LSB = data_in;
- for (i = 0; i < 8; i++) {
- usTmp <<= 1;
- if (data_in & 0x80) {
- usTmp |= 0x1;
- }
- #line 1424
- data_in <<= 1;
- if (usTmp == CC1000RadioIntM$SYNC_WORD) {
- if (CC1000RadioIntM$rxbufptr->length != 0) {
- CC1000RadioIntM$Leds$redToggle();
- CC1000RadioIntM$RadioState = CC1000RadioIntM$IDLE_STATE;
- }
- else {
- CC1000RadioIntM$RadioState = CC1000RadioIntM$RX_STATE;
- CC1000RadioIntM$RSSIInitState = CC1000RadioIntM$RX_STATE;
- CC1000RadioIntM$RSSIADC$getData();
- CC1000RadioIntM$RxBitOffset = 7 - i;
- CC1000RadioIntM$RadioReceiveCoordinator$startSymbol(8, CC1000RadioIntM$RxBitOffset, CC1000RadioIntM$rxbufptr);
- }
- break;
- }
- }
- break;
- default:
- CC1000RadioIntM$RadioState = CC1000RadioIntM$IDLE_STATE;
- break;
- }
- CC1000RadioIntM$SOFCount++;
- }
- }
- break;
- case CC1000RadioIntM$RX_STATE:
- {
- char Byte;
- #line 1462
- CC1000RadioIntM$receive_sum++;
- CC1000RadioIntM$RxShiftBuf.W <<= 8;
- CC1000RadioIntM$RxShiftBuf.LSB = data_in;
- Byte = CC1000RadioIntM$RxShiftBuf.W >> CC1000RadioIntM$RxBitOffset;
- ((char *)CC1000RadioIntM$rxbufptr)[(int )CC1000RadioIntM$RxByteCnt] = Byte;
- CC1000RadioIntM$RxByteCnt++;
- CC1000RadioIntM$RadioReceiveCoordinator$byte(CC1000RadioIntM$rxbufptr, (uint8_t )CC1000RadioIntM$RxByteCnt);
- if (CC1000RadioIntM$RxByteCnt < CC1000RadioIntM$rxlength) {
- CC1000RadioIntM$usRunningCRC = crcByte(CC1000RadioIntM$usRunningCRC, Byte);
- if (CC1000RadioIntM$RxByteCnt == (size_t )& ((struct TOS_Msg *)0)->length +
- sizeof ((struct TOS_Msg *)0)->length) {
- CC1000RadioIntM$rxlength = CC1000RadioIntM$rxbufptr->length;
- if (CC1000RadioIntM$rxlength > 29) {
- CC1000RadioIntM$rxbufptr->length = 0;
- CC1000RadioIntM$RadioState = CC1000RadioIntM$IDLE_STATE;
- return SUCCESS;
- }
- CC1000RadioIntM$rxlength += (size_t )& ((struct TOS_Msg *)0)->data;
- }
- }
- else {
- #line 1489
- if (CC1000RadioIntM$RxByteCnt == CC1000RadioIntM$rxlength) {
- if (CC1000RadioIntM$rxbufptr->type == 223) {
- CC1000RadioIntM$getTimeDiff();
- }
- #line 1492
- CC1000RadioIntM$usRunningCRC = crcByte(CC1000RadioIntM$usRunningCRC, Byte);
- CC1000RadioIntM$RxByteCnt = (size_t )& ((struct TOS_Msg *)0)->crc;
- }
- else {
- #line 1496
- if (CC1000RadioIntM$RxByteCnt >= MSG_DATA_SIZE) {
- if (CC1000RadioIntM$rxbufptr->crc == CC1000RadioIntM$usRunningCRC) {
- if (CC1000RadioIntM$rxbufptr->type == 223) {
- TOS_post(CC1000RadioIntM$adjustTime);
- }
- #line 1503
- CC1000RadioIntM$rxbufptr->crc = 1;
- if (CC1000RadioIntM$bAckEnable && CC1000RadioIntM$rxbufptr->addr == TOS_LOCAL_ADDRESS) {
- CC1000RadioIntM$RadioState = CC1000RadioIntM$SENDING_ACK;
- CC1000RadioIntM$CC1000Control$TxMode();
- CC1000RadioIntM$SpiByteFifo$txMode();
- CC1000RadioIntM$SpiByteFifo$writeByte(0xaa);
- CC1000RadioIntM$RxByteCnt = 0;
- return SUCCESS;
- }
- }
- else {
- CC1000RadioIntM$rxbufptr->crc = 0;
- }
- CC1000RadioIntM$SpiByteFifo$disableIntr();
- CC1000RadioIntM$RadioState = CC1000RadioIntM$IDLE_STATE;
- if (CC1000RadioIntM$currentMAC == CC1000RadioIntM$ZMAC && CC1000RadioIntM$bTxPending) {
- CC1000RadioIntM$sMacDelay = CC1000RadioIntM$getZMACBackoff(CC1000RadioIntM$sMacDelay);
- }
- CC1000RadioIntM$rxbufptr->strength = CC1000RadioIntM$usRSSIVal;
- if (!TOS_post(CC1000RadioIntM$PacketRcvd)) {
- CC1000RadioIntM$rxbufptr->length = 0;
- CC1000RadioIntM$RadioState = CC1000RadioIntM$IDLE_STATE;
- CC1000RadioIntM$SpiByteFifo$enableIntr();
- }
- CC1000RadioIntM$RSSIInitState = CC1000RadioIntM$RadioState;
- CC1000RadioIntM$RSSIADC$getData();
- }
- }
- }
- }
- #line 1541
- break;
- case CC1000RadioIntM$SENDING_ACK:
- {
- CC1000RadioIntM$send_sum++;
- CC1000RadioIntM$RxByteCnt++;
- if (CC1000RadioIntM$RxByteCnt >= CC1000RadioIntM$ACK_LENGTH) {
- CC1000RadioIntM$CC1000Control$RxMode();
- CC1000RadioIntM$SpiByteFifo$rxMode();
- CC1000RadioIntM$SpiByteFifo$disableIntr();
- CC1000RadioIntM$RadioState = CC1000RadioIntM$IDLE_STATE;
- CC1000RadioIntM$rxbufptr->strength = CC1000RadioIntM$usRSSIVal;
- if (!TOS_post(CC1000RadioIntM$PacketRcvd)) {
- CC1000RadioIntM$rxbufptr->length = 0;
- CC1000RadioIntM$RadioState = CC1000RadioIntM$IDLE_STATE;
- CC1000RadioIntM$SpiByteFifo$enableIntr();
- }
- }
- else {
- #line 1558
- if (CC1000RadioIntM$RxByteCnt >= CC1000RadioIntM$ACK_LENGTH - sizeof CC1000RadioIntM$ack_code) {
- CC1000RadioIntM$SpiByteFifo$writeByte(CC1000RadioIntM$ack_code[CC1000RadioIntM$RxByteCnt + sizeof CC1000RadioIntM$ack_code - CC1000RadioIntM$ACK_LENGTH]);
- }
- }
- }
- #line 1562
- break;
- default:
- break;
- }
- if (CC1000RadioIntM$pulse_check_sum > CC1000RadioIntM$CHECK_MA_COUNT) {
- CC1000RadioIntM$power_sum++;
- CC1000RadioIntM$sp_sum++;
- CC1000RadioIntM$pulse_check_sum -= CC1000RadioIntM$CHECK_MA_COUNT;
- }
- if (CC1000RadioIntM$send_sum > CC1000RadioIntM$SEND_MA_COUNT) {
- CC1000RadioIntM$power_sum++;
- CC1000RadioIntM$tx_sum++;
- CC1000RadioIntM$send_sum -= CC1000RadioIntM$SEND_MA_COUNT;
- }
- if (CC1000RadioIntM$receive_sum > CC1000RadioIntM$RECEIVE_MA_COUNT) {
- CC1000RadioIntM$power_sum++;
- CC1000RadioIntM$rx_sum++;
- CC1000RadioIntM$receive_sum -= CC1000RadioIntM$RECEIVE_MA_COUNT;
- }
- return SUCCESS;
- }
- static
- #line 275
- void CC1000RadioIntM$SubTime(GTime *C, GTime *A, GTime *B)
- #line 275
- {
- if (B->sticks > A->sticks) {
- C->sticks = CC1000RadioIntM$MAX_VAL - (B->sticks - A->sticks);
- C->mticks = A->mticks - (B->mticks + 1);
- }
- else {
- C->sticks = A->sticks - B->sticks;
- C->mticks = A->mticks - B->mticks;
- }
- }
- static
- #line 432
- void CC1000RadioIntM$PacketRcvd(void)
- #line 432
- {
- TOS_MsgPtr pBuf;
- ecnForwardMsgType *recvEcnMsgPtr;
- ecnForwardMsgType *ecnForwardMsgPtr;
- #line 436
- { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
- #line 436
- {
- if (CC1000RadioIntM$pktsLastSync > 100) {
- {
- CC1000RadioIntM$ackOrig = CC1000RadioIntM$bAckEnable;
- CC1000RadioIntM$bAckEnable = FALSE;
- }
- CC1000RadioIntM$Send$send(&CC1000RadioIntM$syncMsgHdr);
- CC1000RadioIntM$pktsLastSync = 0;
- }
- CC1000RadioIntM$pktsLastSync++;
- CC1000RadioIntM$rxbufptr->time = 0;
- pBuf = CC1000RadioIntM$rxbufptr;
- recvEcnMsgPtr = (ecnForwardMsgType *)CC1000RadioIntM$rxbufptr->data;
- ecnForwardMsgPtr = (ecnForwardMsgType *)CC1000RadioIntM$ecnForwardMsgHdr.data;
- if (CC1000RadioIntM$currentMAC == CC1000RadioIntM$ZMAC && CC1000RadioIntM$HCLselect && pBuf->type == 222 && pBuf->crc != 0 &&
- recvEcnMsgPtr->senderAddress != TOS_LOCAL_ADDRESS) {
- if (recvEcnMsgPtr->hopCount == 0 && recvEcnMsgPtr->nextHop == TOS_LOCAL_ADDRESS) {
- ecnForwardMsgPtr->hopCount = 1;
- ecnForwardMsgPtr->nextHop = CC1000RadioIntM$nextHop;
- ecnForwardMsgPtr->senderAddress = TOS_LOCAL_ADDRESS;
- if (!CC1000RadioIntM$bTxBusy) {
- CC1000RadioIntM$ackOrig = CC1000RadioIntM$bAckEnable;
- CC1000RadioIntM$bAckEnable = FALSE;
- CC1000RadioIntM$Send$send(&CC1000RadioIntM$ecnForwardMsgHdr);
- }
- else {
- CC1000RadioIntM$ecnforward = TRUE;
- }
- }
- else {
- #line 477
- if (recvEcnMsgPtr->hopCount == 1) {
- CC1000RadioIntM$enableHCL = TRUE;
- if (recvEcnMsgPtr->senderAddress == CC1000RadioIntM$nextHop) {
- CC1000RadioIntM$ecnPending = FALSE;
- CC1000RadioIntM$slots_since_ecnsend = 0;
- CC1000RadioIntM$slots_since_ecnrecv = 0;
- }
- }
- }
- }
- else {
- #line 492
- if (pBuf->type != 223 && pBuf->type != 222) {
- pBuf = CC1000RadioIntM$Receive$receive((TOS_MsgPtr )pBuf);
- }
- }
- if (pBuf) {
- CC1000RadioIntM$rxbufptr = pBuf;
- }
- #line 501
- CC1000RadioIntM$rxbufptr->length = 0;
- }
- #line 502
- __nesc_atomic_end(__nesc_atomic); }
- CC1000RadioIntM$SpiByteFifo$enableIntr();
- }
- # 124 "../../tos/platform/mica2/HPLSClock.nc"
- void __attribute((interrupt)) __vector_26(void)
- #line 124
- {
- if (HPLSClock$needupdate) {
- if (HPLSClock$sign == NEGATIVE) {
- * (volatile uint16_t *)0x88 = MAX_VAL - HPLSClock$Update.sticks;
- HPLSClock$MTicks = HPLSClock$MTicks - HPLSClock$Update.mticks;
- }
- else {
- #line 130
- if (HPLSClock$sign == POSITIVE) {
- * (volatile uint16_t *)0x88 = HPLSClock$Update.sticks;
- HPLSClock$MTicks = HPLSClock$MTicks + HPLSClock$Update.mticks + 1;
- HPLSClock$SClock$fire(HPLSClock$MTicks);
- }
- }
- #line 135
- HPLSClock$needupdate = 0;
- HPLSClock$SClock$syncDone();
- }
- else {
- HPLSClock$MTicks++;
- HPLSClock$SClock$fire(HPLSClock$MTicks);
- }
- }
- static
- # 348 "/home/testuser/tinyos-1.x/tos/system/FramerM.nc"
- result_t FramerM$ByteComm$rxByteReady(uint8_t data, bool error, uint16_t strength)
- #line 348
- {
- switch (FramerM$gRxState) {
- case FramerM$RXSTATE_NOSYNC:
- if (data == FramerM$HDLC_FLAG_BYTE && FramerM$gMsgRcvTbl[FramerM$gRxHeadIndex].Length == 0) {
- FramerM$gMsgRcvTbl[FramerM$gRxHeadIndex].Token = 0;
- FramerM$gRxByteCnt = FramerM$gRxRunningCRC = 0;
- FramerM$gpRxBuf = (uint8_t *)FramerM$gMsgRcvTbl[FramerM$gRxHeadIndex].pMsg;
- FramerM$gRxState = FramerM$RXSTATE_PROTO;
- }
- break;
- case FramerM$RXSTATE_PROTO:
- if (data == FramerM$HDLC_FLAG_BYTE) {
- break;
- }
- FramerM$gMsgRcvTbl[FramerM$gRxHeadIndex].Proto = data;
- FramerM$gRxRunningCRC = crcByte(FramerM$gRxRunningCRC, data);
- switch (data) {
- case FramerM$PROTO_PACKET_ACK:
- FramerM$gRxState = FramerM$RXSTATE_TOKEN;
- break;
- case FramerM$PROTO_PACKET_NOACK:
- FramerM$gRxState = FramerM$RXSTATE_INFO;
- break;
- default:
- FramerM$gRxState = FramerM$RXSTATE_NOSYNC;
- break;
- }
- break;
- case FramerM$RXSTATE_TOKEN:
- if (data == FramerM$HDLC_FLAG_BYTE) {
- FramerM$gRxState = FramerM$RXSTATE_NOSYNC;
- }
- else {
- #line 384
- if (data == FramerM$HDLC_CTLESC_BYTE) {
- FramerM$gMsgRcvTbl[FramerM$gRxHeadIndex].Token = 0x20;
- }
- else {
- FramerM$gMsgRcvTbl[FramerM$gRxHeadIndex].Token ^= data;
- FramerM$gRxRunningCRC = crcByte(FramerM$gRxRunningCRC, FramerM$gMsgRcvTbl[FramerM$gRxHeadIndex].Token);
- FramerM$gRxState = FramerM$RXSTATE_INFO;
- }
- }
- #line 392
- break;
- case FramerM$RXSTATE_INFO:
- if (FramerM$gRxByteCnt > FramerM$HDLC_MTU) {
- FramerM$gRxByteCnt = FramerM$gRxRunningCRC = 0;
- FramerM$gMsgRcvTbl[FramerM$gRxHeadIndex].Length = 0;
- FramerM$gMsgRcvTbl[FramerM$gRxHeadIndex].Token = 0;
- FramerM$gRxState = FramerM$RXSTATE_NOSYNC;
- }
- else {
- #line 402
- if (data == FramerM$HDLC_CTLESC_BYTE) {
- FramerM$gRxState = FramerM$RXSTATE_ESC;
- }
- else {
- #line 405
- if (data == FramerM$HDLC_FLAG_BYTE) {
- if (FramerM$gRxByteCnt >= 2) {
- uint16_t usRcvdCRC = FramerM$gpRxBuf[FramerM$gRxByteCnt - 1] & 0xff;
- #line 408
- usRcvdCRC = (usRcvdCRC << 8) | (FramerM$gpRxBuf[FramerM$gRxByteCnt - 2] & 0xff);
- if (usRcvdCRC == FramerM$gRxRunningCRC) {
- FramerM$gMsgRcvTbl[FramerM$gRxHeadIndex].Length = FramerM$gRxByteCnt - 2;
- TOS_post(FramerM$PacketRcvd);
- FramerM$gRxHeadIndex++;
- #line 412
- FramerM$gRxHeadIndex %= FramerM$HDLC_QUEUESIZE;
- }
- else {
- FramerM$gMsgRcvTbl[FramerM$gRxHeadIndex].Length = 0;
- FramerM$gMsgRcvTbl[FramerM$gRxHeadIndex].Token = 0;
- }
- if (FramerM$gMsgRcvTbl[FramerM$gRxHeadIndex].Length == 0) {
- FramerM$gpRxBuf = (uint8_t *)FramerM$gMsgRcvTbl[FramerM$gRxHeadIndex].pMsg;
- FramerM$gRxState = FramerM$RXSTATE_PROTO;
- }
- else {
- FramerM$gRxState = FramerM$RXSTATE_NOSYNC;
- }
- }
- else {
- FramerM$gMsgRcvTbl[FramerM$gRxHeadIndex].Length = 0;
- FramerM$gMsgRcvTbl[FramerM$gRxHeadIndex].Token = 0;
- FramerM$gRxState = FramerM$RXSTATE_NOSYNC;
- }
- FramerM$gRxByteCnt = FramerM$gRxRunningCRC = 0;
- }
- else {
- FramerM$gpRxBuf[FramerM$gRxByteCnt] = data;
- if (FramerM$gRxByteCnt >= 2) {
- FramerM$gRxRunningCRC = crcByte(FramerM$gRxRunningCRC, FramerM$gpRxBuf[FramerM$gRxByteCnt - 2]);
- }
- FramerM$gRxByteCnt++;
- }
- }
- }
- #line 440
- break;
- case FramerM$RXSTATE_ESC:
- if (data == FramerM$HDLC_FLAG_BYTE) {
- FramerM$gRxByteCnt = FramerM$gRxRunningCRC = 0;
- FramerM$gMsgRcvTbl[FramerM$gRxHeadIndex].Length = 0;
- FramerM$gMsgRcvTbl[FramerM$gRxHeadIndex].Token = 0;
- FramerM$gRxState = FramerM$RXSTATE_NOSYNC;
- }
- else {
- data = data ^ 0x20;
- FramerM$gpRxBuf[FramerM$gRxByteCnt] = data;
- if (FramerM$gRxByteCnt >= 2) {
- FramerM$gRxRunningCRC = crcByte(FramerM$gRxRunningCRC, FramerM$gpRxBuf[FramerM$gRxByteCnt - 2]);
- }
- FramerM$gRxByteCnt++;
- FramerM$gRxState = FramerM$RXSTATE_INFO;
- }
- break;
- default:
- FramerM$gRxState = FramerM$RXSTATE_NOSYNC;
- break;
- }
- return SUCCESS;
- }
- static
- # 87 "/home/testuser/tinyos-1.x/tos/system/UARTM.nc"
- result_t UARTM$HPLUART$putDone(void)
- #line 87
- {
- bool oldState;
- { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
- #line 90
- {
- {
- }
- #line 91
- ;
- oldState = UARTM$state;
- UARTM$state = FALSE;
- }
- #line 94
- __nesc_atomic_end(__nesc_atomic); }
- if (oldState) {
- UARTM$ByteComm$txDone();
- UARTM$ByteComm$txByteReady(TRUE);
- }
- return SUCCESS;
- }
- static
- # 469 "/home/testuser/tinyos-1.x/tos/system/FramerM.nc"
- result_t FramerM$TxArbitraryByte(uint8_t inByte)
- #line 469
- {
- if (inByte == FramerM$HDLC_FLAG_BYTE || inByte == FramerM$HDLC_CTLESC_BYTE) {
- { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
- #line 471
- {
- FramerM$gPrevTxState = FramerM$gTxState;
- FramerM$gTxState = FramerM$TXSTATE_ESC;
- FramerM$gTxEscByte = inByte;
- }
- #line 475
- __nesc_atomic_end(__nesc_atomic); }
- inByte = FramerM$HDLC_CTLESC_BYTE;
- }
- return FramerM$ByteComm$txByte(inByte);
- }