app.c
上传用户:joranyuan
上传日期:2022-06-23
资源大小:3306k
文件大小:273k
- CC1000RadioIntM$ecnForwardMsgHdr.type = 222;
- CC1000RadioIntM$ecnForwardMsgHdr.addr = TOS_BCAST_ADDR;
- CC1000RadioIntM$ecnForwardMsgHdr.length = sizeof(ecnMsgType );
- CC1000RadioIntM$ecnForwardMsgHdr.group = 125;
- CC1000RadioIntM$ecnForwardMsgHdr.crc = 0;
- CC1000RadioIntM$syncMsgHdr.type = 223;
- CC1000RadioIntM$syncMsgHdr.addr = TOS_BCAST_ADDR;
- CC1000RadioIntM$syncMsgHdr.length = sizeof(syncMsgType );
- CC1000RadioIntM$syncMsgHdr.group = 125;
- CC1000RadioIntM$syncMsgHdr.crc = 0;
- ecnMsgPtr->hopCount = 0;
- ecnMsgPtr->nextHop = CC1000RadioIntM$nextHop;
- ecnMsgPtr->senderAddress = TOS_LOCAL_ADDRESS;
- }
- #line 727
- __nesc_atomic_end(__nesc_atomic); }
- for (i = 0; i < 9; i++)
- CC1000RadioIntM$usSquelchTable[(int )i] = 0x120;
- CC1000RadioIntM$SpiByteFifo$initSlave();
- CC1000RadioIntM$CC1000StdControl$init();
- CC1000RadioIntM$CC1000Control$SelectLock(0x9);
- CC1000RadioIntM$bInvertRxData = CC1000RadioIntM$CC1000Control$GetLOStatus();
- CC1000RadioIntM$ADCControl$bindPort(TOS_ADC_CC_RSSI_PORT, TOSH_ACTUAL_CC_RSSI_PORT);
- CC1000RadioIntM$ADCControl$init();
- CC1000RadioIntM$Random$init();
- CC1000RadioIntM$TimerControl$init();
- CC1000RadioIntM$LocalAddr = TOS_LOCAL_ADDRESS;
- return SUCCESS;
- }
- # 63 "/home/testuser/tinyos-1.x/tos/interfaces/StdControl.nc"
- inline static result_t AMStandard$RadioControl$init(void){
- #line 63
- unsigned char result;
- #line 63
- #line 63
- result = CC1000RadioIntM$StdControl$init();
- #line 63
- #line 63
- return result;
- #line 63
- }
- #line 63
- static inline
- # 60 "/home/testuser/tinyos-1.x/tos/system/UARTM.nc"
- result_t UARTM$Control$init(void)
- #line 60
- {
- {
- }
- #line 61
- ;
- { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
- #line 62
- {
- UARTM$state = FALSE;
- }
- #line 64
- __nesc_atomic_end(__nesc_atomic); }
- return SUCCESS;
- }
- # 63 "/home/testuser/tinyos-1.x/tos/interfaces/StdControl.nc"
- inline static result_t FramerM$ByteControl$init(void){
- #line 63
- unsigned char result;
- #line 63
- #line 63
- result = UARTM$Control$init();
- #line 63
- #line 63
- return result;
- #line 63
- }
- #line 63
- static inline
- # 291 "/home/testuser/tinyos-1.x/tos/system/FramerM.nc"
- result_t FramerM$StdControl$init(void)
- #line 291
- {
- FramerM$HDLCInitialize();
- return FramerM$ByteControl$init();
- }
- # 63 "/home/testuser/tinyos-1.x/tos/interfaces/StdControl.nc"
- inline static result_t AMStandard$UARTControl$init(void){
- #line 63
- unsigned char result;
- #line 63
- #line 63
- result = FramerM$StdControl$init();
- #line 63
- #line 63
- return result;
- #line 63
- }
- #line 63
- inline static result_t AMStandard$TimerControl$init(void){
- #line 63
- unsigned char result;
- #line 63
- #line 63
- result = TimerM$StdControl$init();
- #line 63
- #line 63
- return result;
- #line 63
- }
- #line 63
- static inline
- # 87 "/home/testuser/tinyos-1.x/tos/system/AMStandard.nc"
- bool AMStandard$Control$init(void)
- #line 87
- {
- result_t ok1;
- #line 88
- result_t ok2;
- AMStandard$TimerControl$init();
- ok1 = AMStandard$UARTControl$init();
- ok2 = AMStandard$RadioControl$init();
- AMStandard$state = FALSE;
- AMStandard$lastCount = 0;
- AMStandard$counter = 0;
- {
- }
- #line 97
- ;
- return rcombine(ok1, ok2);
- }
- # 63 "/home/testuser/tinyos-1.x/tos/interfaces/StdControl.nc"
- inline static result_t RealMain$StdControl$init(void){
- #line 63
- unsigned char result;
- #line 63
- #line 63
- result = TimerM$StdControl$init();
- #line 63
- result = rcombine(result, TimerM$StdControl$init());
- #line 63
- result = rcombine(result, AMStandard$Control$init());
- #line 63
- result = rcombine(result, TestBedTopologyM$StdControl$init());
- #line 63
- #line 63
- return result;
- #line 63
- }
- #line 63
- static inline
- # 149 "/home/testuser/tinyos-1.x/tos/platform/mica/HPLClock.nc"
- result_t HPLClock$Clock$setRate(char interval, char scale)
- #line 149
- {
- scale &= 0x7;
- scale |= 0x8;
- { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
- #line 152
- {
- * (volatile uint8_t *)(0x37 + 0x20) &= ~(1 << 0);
- * (volatile uint8_t *)(0x37 + 0x20) &= ~(1 << 1);
- * (volatile uint8_t *)(0x30 + 0x20) |= 1 << 3;
- * (volatile uint8_t *)(0x33 + 0x20) = scale;
- * (volatile uint8_t *)(0x32 + 0x20) = 0;
- * (volatile uint8_t *)(0x31 + 0x20) = interval;
- * (volatile uint8_t *)(0x37 + 0x20) |= 1 << 1;
- }
- #line 162
- __nesc_atomic_end(__nesc_atomic); }
- return SUCCESS;
- }
- # 96 "/home/testuser/tinyos-1.x/tos/interfaces/Clock.nc"
- inline static result_t TimerM$Clock$setRate(char arg_0x8913d88, char arg_0x8913ec8){
- #line 96
- unsigned char result;
- #line 96
- #line 96
- result = HPLClock$Clock$setRate(arg_0x8913d88, arg_0x8913ec8);
- #line 96
- #line 96
- return result;
- #line 96
- }
- #line 96
- # 128 "../../tos/platform/mica2/hardware.h"
- static __inline void TOSH_CLR_CC_PALE_PIN(void)
- #line 128
- {
- #line 128
- * (volatile uint8_t *)(0x12 + 0x20) &= ~(1 << 4);
- }
- #line 126
- static __inline void TOSH_CLR_CC_PDATA_PIN(void)
- #line 126
- {
- #line 126
- * (volatile uint8_t *)(0x12 + 0x20) &= ~(1 << 7);
- }
- #line 127
- static __inline void TOSH_CLR_CC_PCLK_PIN(void)
- #line 127
- {
- #line 127
- * (volatile uint8_t *)(0x12 + 0x20) &= ~(1 << 6);
- }
- #line 126
- static __inline void TOSH_MAKE_CC_PDATA_INPUT(void)
- #line 126
- {
- #line 126
- * (volatile uint8_t *)(0x11 + 0x20) &= ~(1 << 7);
- }
- #line 126
- static __inline int TOSH_READ_CC_PDATA_PIN(void)
- #line 126
- {
- #line 126
- return (* (volatile uint8_t *)(0x10 + 0x20) & (1 << 7)) != 0;
- }
- static inline
- # 1602 "../../tos/system/DrandM.nc"
- result_t DrandM$SClock$fire(uint16_t mticks)
- #line 1602
- {
- #line 1602
- return SUCCESS;
- }
- static inline
- # 1823 "../../tos/platform/mica2/CC1000RadioIntM.nc"
- result_t CC1000RadioIntM$SClock$fire(uint16_t mticks)
- #line 1823
- {
- #line 1823
- return SUCCESS;
- }
- # 88 "../../tos/interfaces/SClock.nc"
- inline static result_t HPLSClock$SClock$fire(uint16_t arg_0x8585230){
- #line 88
- unsigned char result;
- #line 88
- #line 88
- result = CC1000RadioIntM$SClock$fire(arg_0x8585230);
- #line 88
- result = rcombine(result, DrandM$SClock$fire(arg_0x8585230));
- #line 88
- #line 88
- return result;
- #line 88
- }
- #line 88
- static inline
- # 494 "../../tos/platform/mica2/CC1000ControlM.nc"
- result_t CC1000ControlM$CC1000Control$SetRFPower(uint8_t power)
- #line 494
- {
- CC1000ControlM$gCurrentParameters[0xb] = power;
- return SUCCESS;
- }
- # 150 "../../tos/platform/mica2/CC1000Control.nc"
- inline static result_t TestBedTopologyM$RFset$SetRFPower(uint8_t arg_0x85440e8){
- #line 150
- unsigned char result;
- #line 150
- #line 150
- result = CC1000ControlM$CC1000Control$SetRFPower(arg_0x85440e8);
- #line 150
- #line 150
- return result;
- #line 150
- }
- #line 150
- # 59 "/home/testuser/tinyos-1.x/tos/interfaces/Timer.nc"
- inline static result_t DrandM$roundTimer$start(char arg_0x85800e0, uint32_t arg_0x8580238){
- #line 59
- unsigned char result;
- #line 59
- #line 59
- result = TimerM$Timer$start(0, arg_0x85800e0, arg_0x8580238);
- #line 59
- #line 59
- return result;
- #line 59
- }
- #line 59
- # 59 "/home/testuser/tinyos-1.x/tos/interfaces/Timer.nc"
- inline static result_t DrandM$reXTimer$start(char arg_0x85800e0, uint32_t arg_0x8580238){
- #line 59
- unsigned char result;
- #line 59
- #line 59
- result = TimerM$Timer$start(1, arg_0x85800e0, arg_0x8580238);
- #line 59
- #line 59
- return result;
- #line 59
- }
- #line 59
- static inline
- # 565 "../../tos/system/DrandM.nc"
- result_t DrandM$StdControl$start(void)
- #line 565
- {
- DrandM$globalState = HELLO_STATE;
- DrandM$reXTimer$start(TIMER_ONE_SHOT, DrandM$randNew() % HELLO_INTERVAL);
- DrandM$roundTimer$start(TIMER_ONE_SHOT, HELLO_PERIOD);
- return SUCCESS;
- }
- # 70 "/home/testuser/tinyos-1.x/tos/interfaces/StdControl.nc"
- inline static result_t TestBedTopologyM$SubControl$start(void){
- #line 70
- unsigned char result;
- #line 70
- #line 70
- result = DrandM$StdControl$start();
- #line 70
- #line 70
- return result;
- #line 70
- }
- #line 70
- static inline
- # 20 "TestBedTopologyM.nc"
- result_t TestBedTopologyM$StdControl$start(void)
- #line 20
- {
- TestBedTopologyM$SubControl$start();
- TestBedTopologyM$RFset$SetRFPower(255);
- return SUCCESS;
- }
- static inline
- # 133 "/home/testuser/tinyos-1.x/tos/system/tos.h"
- result_t rcombine4(result_t r1, result_t r2, result_t r3,
- result_t r4)
- {
- return rcombine(r1, rcombine(r2, rcombine(r3, r4)));
- }
- # 41 "/home/testuser/tinyos-1.x/tos/interfaces/PowerManagement.nc"
- inline static uint8_t AMStandard$PowerManagement$adjustPower(void){
- #line 41
- unsigned char result;
- #line 41
- #line 41
- result = HPLPowerManagementM$PowerManagement$adjustPower();
- #line 41
- #line 41
- return result;
- #line 41
- }
- #line 41
- # 59 "/home/testuser/tinyos-1.x/tos/interfaces/Timer.nc"
- inline static result_t AMStandard$ActivityTimer$start(char arg_0x85800e0, uint32_t arg_0x8580238){
- #line 59
- unsigned char result;
- #line 59
- #line 59
- result = TimerM$Timer$start(3, arg_0x85800e0, arg_0x8580238);
- #line 59
- #line 59
- return result;
- #line 59
- }
- #line 59
- # 59 "/home/testuser/tinyos-1.x/tos/interfaces/Timer.nc"
- inline static result_t CC1000RadioIntM$WakeupTimer$start(char arg_0x85800e0, uint32_t arg_0x8580238){
- #line 59
- unsigned char result;
- #line 59
- #line 59
- result = TimerM$Timer$start(5, arg_0x85800e0, arg_0x8580238);
- #line 59
- #line 59
- return result;
- #line 59
- }
- #line 59
- # 41 "/home/testuser/tinyos-1.x/tos/interfaces/PowerManagement.nc"
- inline static uint8_t HPLSpiM$PowerManagement$adjustPower(void){
- #line 41
- unsigned char result;
- #line 41
- #line 41
- result = HPLPowerManagementM$PowerManagement$adjustPower();
- #line 41
- #line 41
- return result;
- #line 41
- }
- #line 41
- static inline
- # 74 "../../tos/platform/mica2/HPLSpiM.nc"
- result_t HPLSpiM$SpiByteFifo$enableIntr(void)
- #line 74
- {
- * (volatile uint8_t *)(0x0D + 0x20) = 0xC0;
- * (volatile uint8_t *)(0x17 + 0x20) &= ~(1 << 0);
- HPLSpiM$PowerManagement$adjustPower();
- return SUCCESS;
- }
- # 36 "../../tos/platform/mica2/SpiByteFifo.nc"
- inline static result_t CC1000RadioIntM$SpiByteFifo$enableIntr(void){
- #line 36
- unsigned char result;
- #line 36
- #line 36
- result = HPLSpiM$SpiByteFifo$enableIntr();
- #line 36
- #line 36
- return result;
- #line 36
- }
- #line 36
- # 59 "/home/testuser/tinyos-1.x/tos/interfaces/Timer.nc"
- inline static result_t CC1000RadioIntM$SquelchTimer$start(char arg_0x85800e0, uint32_t arg_0x8580238){
- #line 59
- unsigned char result;
- #line 59
- #line 59
- result = TimerM$Timer$start(4, arg_0x85800e0, arg_0x8580238);
- #line 59
- #line 59
- return result;
- #line 59
- }
- #line 59
- # 116 "../../tos/platform/mica2/CC1000Control.nc"
- inline static result_t CC1000RadioIntM$CC1000Control$RxMode(void){
- #line 116
- unsigned char result;
- #line 116
- #line 116
- result = CC1000ControlM$CC1000Control$RxMode();
- #line 116
- #line 116
- return result;
- #line 116
- }
- #line 116
- static inline
- # 109 "../../tos/platform/mica2/HPLSpiM.nc"
- result_t HPLSpiM$SpiByteFifo$rxMode(void)
- #line 109
- {
- TOSH_MAKE_MISO_INPUT();
- TOSH_MAKE_MOSI_INPUT();
- return SUCCESS;
- }
- # 40 "../../tos/platform/mica2/SpiByteFifo.nc"
- inline static result_t CC1000RadioIntM$SpiByteFifo$rxMode(void){
- #line 40
- unsigned char result;
- #line 40
- #line 40
- result = HPLSpiM$SpiByteFifo$rxMode();
- #line 40
- #line 40
- return result;
- #line 40
- }
- #line 40
- static inline
- # 457 "../../tos/platform/mica2/CC1000ControlM.nc"
- result_t CC1000ControlM$CC1000Control$BIASOn(void)
- #line 457
- {
- CC1000ControlM$HPLChipcon$write(0x00, (((
- 1 << 5) | (1 << 4)) | (
- 1 << 3)) | (
- 1 << 0));
- TOSH_uwait(200);
- return SUCCESS;
- }
- # 137 "../../tos/platform/mica2/CC1000Control.nc"
- inline static result_t CC1000RadioIntM$CC1000Control$BIASOn(void){
- #line 137
- unsigned char result;
- #line 137
- #line 137
- result = CC1000ControlM$CC1000Control$BIASOn();
- #line 137
- #line 137
- return result;
- #line 137
- }
- #line 137
- static inline
- # 480 "../../tos/platform/mica2/CC1000ControlM.nc"
- result_t CC1000ControlM$StdControl$start(void)
- #line 480
- {
- CC1000ControlM$HPLChipcon$write(0x00, ((((
- 1 << 5) | (1 << 4)) | (
- 1 << 3)) | (1 << 1)) | (
- 1 << 0));
- return SUCCESS;
- }
- # 70 "/home/testuser/tinyos-1.x/tos/interfaces/StdControl.nc"
- inline static result_t CC1000RadioIntM$CC1000StdControl$start(void){
- #line 70
- unsigned char result;
- #line 70
- #line 70
- result = CC1000ControlM$StdControl$start();
- #line 70
- #line 70
- return result;
- #line 70
- }
- #line 70
- static inline
- # 66 "../../tos/platform/mica2/HPLSClock.nc"
- result_t HPLSClock$SClock$SetRate(uint16_t interval, char scale)
- #line 66
- {
- scale &= 0x7;
- scale |= 0x8;
- { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
- #line 69
- {
- * (volatile uint8_t *)0x7D &= ~(1 << 4);
- * (volatile uint8_t *)0x8A = scale;
- * (volatile uint16_t *)0x88 = 0x0000;
- * (volatile uint16_t *)0x86 = interval;
- * (volatile uint8_t *)0x8B = 0x00;
- * (volatile uint8_t *)0x8B |= 1 << 6;
- * (volatile uint8_t *)(0x02 + 0x20) |= 1 << 3;
- * (volatile uint8_t *)0x8C = 0x00;
- * (volatile uint8_t *)0x7D |= 1 << 4;
- }
- #line 79
- __nesc_atomic_end(__nesc_atomic); }
- HPLSClock$needupdate = 0;
- return SUCCESS;
- }
- # 45 "../../tos/interfaces/SClock.nc"
- inline static result_t CC1000RadioIntM$SClock$SetRate(uint16_t arg_0x857f4a8, char arg_0x857f5e8){
- #line 45
- unsigned char result;
- #line 45
- #line 45
- result = HPLSClock$SClock$SetRate(arg_0x857f4a8, arg_0x857f5e8);
- #line 45
- #line 45
- return result;
- #line 45
- }
- #line 45
- static inline
- # 1056 "../../tos/platform/mica2/CC1000RadioIntM.nc"
- result_t CC1000RadioIntM$StdControl$start(void)
- #line 1056
- {
- uint8_t currentRadioState;
- #line 1058
- { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
- #line 1058
- currentRadioState = CC1000RadioIntM$RadioState;
- #line 1058
- __nesc_atomic_end(__nesc_atomic); }
- CC1000RadioIntM$SClock$SetRate(CC1000RadioIntM$MAX_VAL, CLK_DIV_64);
- if (currentRadioState == CC1000RadioIntM$DISABLED_STATE) {
- { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
- #line 1062
- {
- CC1000RadioIntM$rxbufptr->length = 0;
- CC1000RadioIntM$RadioState = CC1000RadioIntM$IDLE_STATE;
- CC1000RadioIntM$bTxPending = CC1000RadioIntM$bTxBusy = FALSE;
- CC1000RadioIntM$sMacDelay = -1;
- if (0 > 0) {
- CC1000RadioIntM$sleeptime = 0;
- CC1000RadioIntM$preamblelen = 0;
- }
- else
- #line 1070
- {
- CC1000RadioIntM$lplpower = CC1000RadioIntM$lplpowertx = 0;
- CC1000RadioIntM$sleeptime = (({
- #line 1072
- uint16_t __addr16 = (uint16_t )(uint16_t )&CC1K_LPL_SleepTime[CC1000RadioIntM$lplpower * 2];
- #line 1072
- uint8_t __result;
- #line 1072
- __asm ("lpm %0, Z""nt" : "=r"(__result) : "z"(__addr16));__result;
- }
- )
- #line 1072
- << 8) |
- ({
- #line 1073
- uint16_t __addr16 = (uint16_t )(uint16_t )&CC1K_LPL_SleepTime[CC1000RadioIntM$lplpower * 2 + 1];
- #line 1073
- uint8_t __result;
- #line 1073
- __asm ("lpm %0, Z""nt" : "=r"(__result) : "z"(__addr16));__result;
- }
- );
- #line 1074
- CC1000RadioIntM$preamblelen = (({
- #line 1074
- uint16_t __addr16 = (uint16_t )(uint16_t )&CC1K_LPL_PreambleLength[CC1000RadioIntM$lplpowertx * 2];
- #line 1074
- uint8_t __result;
- #line 1074
- __asm ("lpm %0, Z""nt" : "=r"(__result) : "z"(__addr16));__result;
- }
- )
- #line 1074
- << 8) |
- ({
- #line 1075
- uint16_t __addr16 = (uint16_t )(uint16_t )&CC1K_LPL_PreambleLength[CC1000RadioIntM$lplpowertx * 2 + 1];
- #line 1075
- uint8_t __result;
- #line 1075
- __asm ("lpm %0, Z""nt" : "=r"(__result) : "z"(__addr16));__result;
- }
- );
- }
- }
- #line 1079
- __nesc_atomic_end(__nesc_atomic); }
- CC1000RadioIntM$rxbufptr->length = 0;
- { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
- #line 1084
- CC1000RadioIntM$RadioState = CC1000RadioIntM$IDLE_STATE;
- #line 1084
- __nesc_atomic_end(__nesc_atomic); }
- CC1000RadioIntM$CC1000StdControl$start();
- CC1000RadioIntM$CC1000Control$BIASOn();
- CC1000RadioIntM$SpiByteFifo$rxMode();
- CC1000RadioIntM$CC1000Control$RxMode();
- if (CC1000RadioIntM$iSquelchCount > 30) {
- CC1000RadioIntM$SquelchTimer$start(TIMER_REPEAT, 2560);
- }
- else {
- #line 1092
- CC1000RadioIntM$SquelchTimer$start(TIMER_REPEAT, 128);
- }
- #line 1093
- CC1000RadioIntM$SpiByteFifo$enableIntr();
- if (CC1000RadioIntM$lplpower > 0) {
- CC1000RadioIntM$WakeupTimer$start(TIMER_ONE_SHOT, 2560);
- }
- }
- return SUCCESS;
- }
- # 70 "/home/testuser/tinyos-1.x/tos/interfaces/StdControl.nc"
- inline static result_t AMStandard$RadioControl$start(void){
- #line 70
- unsigned char result;
- #line 70
- #line 70
- result = CC1000RadioIntM$StdControl$start();
- #line 70
- #line 70
- return result;
- #line 70
- }
- #line 70
- static inline
- # 60 "../../tos/platform/mica2/HPLUART0M.nc"
- result_t HPLUART0M$UART$init(void)
- #line 60
- {
- * (volatile uint8_t *)0x90 = 0;
- * (volatile uint8_t *)(0x09 + 0x20) = 15;
- * (volatile uint8_t *)(0x0B + 0x20) = 1 << 1;
- * (volatile uint8_t *)0x95 = (1 << 2) | (1 << 1);
- * (volatile uint8_t *)(0x0A + 0x20) = (((1 << 7) | (1 << 6)) | (1 << 4)) | (1 << 3);
- return SUCCESS;
- }
- # 62 "/home/testuser/tinyos-1.x/tos/interfaces/HPLUART.nc"
- inline static result_t UARTM$HPLUART$init(void){
- #line 62
- unsigned char result;
- #line 62
- #line 62
- result = HPLUART0M$UART$init();
- #line 62
- #line 62
- return result;
- #line 62
- }
- #line 62
- static inline
- # 68 "/home/testuser/tinyos-1.x/tos/system/UARTM.nc"
- result_t UARTM$Control$start(void)
- #line 68
- {
- return UARTM$HPLUART$init();
- }
- # 70 "/home/testuser/tinyos-1.x/tos/interfaces/StdControl.nc"
- inline static result_t FramerM$ByteControl$start(void){
- #line 70
- unsigned char result;
- #line 70
- #line 70
- result = UARTM$Control$start();
- #line 70
- #line 70
- return result;
- #line 70
- }
- #line 70
- static inline
- # 296 "/home/testuser/tinyos-1.x/tos/system/FramerM.nc"
- result_t FramerM$StdControl$start(void)
- #line 296
- {
- FramerM$HDLCInitialize();
- return FramerM$ByteControl$start();
- }
- # 70 "/home/testuser/tinyos-1.x/tos/interfaces/StdControl.nc"
- inline static result_t AMStandard$UARTControl$start(void){
- #line 70
- unsigned char result;
- #line 70
- #line 70
- result = FramerM$StdControl$start();
- #line 70
- #line 70
- return result;
- #line 70
- }
- #line 70
- static inline
- # 87 "/home/testuser/tinyos-1.x/tos/system/TimerM.nc"
- result_t TimerM$StdControl$start(void)
- #line 87
- {
- return SUCCESS;
- }
- # 70 "/home/testuser/tinyos-1.x/tos/interfaces/StdControl.nc"
- inline static result_t AMStandard$TimerControl$start(void){
- #line 70
- unsigned char result;
- #line 70
- #line 70
- result = TimerM$StdControl$start();
- #line 70
- #line 70
- return result;
- #line 70
- }
- #line 70
- static inline
- # 103 "/home/testuser/tinyos-1.x/tos/system/AMStandard.nc"
- bool AMStandard$Control$start(void)
- #line 103
- {
- result_t ok0 = AMStandard$TimerControl$start();
- result_t ok1 = AMStandard$UARTControl$start();
- result_t ok2 = AMStandard$RadioControl$start();
- result_t ok3 = AMStandard$ActivityTimer$start(TIMER_REPEAT, 1000);
- AMStandard$state = FALSE;
- AMStandard$PowerManagement$adjustPower();
- return rcombine4(ok0, ok1, ok2, ok3);
- }
- # 70 "/home/testuser/tinyos-1.x/tos/interfaces/StdControl.nc"
- inline static result_t RealMain$StdControl$start(void){
- #line 70
- unsigned char result;
- #line 70
- #line 70
- result = TimerM$StdControl$start();
- #line 70
- result = rcombine(result, TimerM$StdControl$start());
- #line 70
- result = rcombine(result, AMStandard$Control$start());
- #line 70
- result = rcombine(result, TestBedTopologyM$StdControl$start());
- #line 70
- #line 70
- return result;
- #line 70
- }
- #line 70
- static inline
- # 64 "../../tos/platform/mica2/HPLPowerManagementM.nc"
- uint8_t HPLPowerManagementM$getPowerLevel(void)
- #line 64
- {
- uint8_t diff;
- #line 66
- if (* (volatile uint8_t *)(0x37 + 0x20) & ~((1 << 1) | (1 << 0))) {
- return HPLPowerManagementM$IDLE;
- }
- else {
- #line 69
- if (* (volatile uint8_t *)(uint16_t )& * (volatile uint8_t *)(0x0D + 0x20) & (1 << 7)) {
- return HPLPowerManagementM$IDLE;
- }
- else {
- if (* (volatile uint8_t *)(uint16_t )& * (volatile uint8_t *)(0x06 + 0x20) & (1 << 7)) {
- return HPLPowerManagementM$ADC_NR;
- }
- else {
- #line 75
- if (* (volatile uint8_t *)(0x37 + 0x20) & ((1 << 1) | (1 << 0))) {
- diff = * (volatile uint8_t *)(0x31 + 0x20) - * (volatile uint8_t *)(0x32 + 0x20);
- if (diff < 16) {
- return HPLPowerManagementM$EXT_STANDBY;
- }
- #line 79
- return HPLPowerManagementM$POWER_SAVE;
- }
- else
- #line 80
- {
- return HPLPowerManagementM$POWER_DOWN;
- }
- }
- }
- }
- }
- static inline
- #line 85
- void HPLPowerManagementM$doAdjustment(void)
- #line 85
- {
- uint8_t foo;
- #line 86
- uint8_t mcu;
- #line 87
- HPLPowerManagementM$powerLevel = foo = HPLPowerManagementM$getPowerLevel();
- mcu = * (volatile uint8_t *)(0x35 + 0x20);
- mcu &= 0xe3;
- if (foo == HPLPowerManagementM$EXT_STANDBY || foo == HPLPowerManagementM$POWER_SAVE) {
- mcu |= HPLPowerManagementM$IDLE;
- while ((* (volatile uint8_t *)(0x30 + 0x20) & 0x7) != 0) {
- __asm volatile ("nop");}
- mcu &= 0xe3;
- }
- mcu |= foo;
- * (volatile uint8_t *)(0x35 + 0x20) = mcu;
- * (volatile uint8_t *)(0x35 + 0x20) |= 1 << 5;
- }
- static
- # 187 "/home/testuser/tinyos-1.x/tos/platform/avrmote/avrhardware.h"
- __inline void __nesc_enable_interrupt(void)
- #line 187
- {
- __asm volatile ("sei");}
- #line 172
- __inline void __nesc_atomic_end(__nesc_atomic_t oldSreg)
- {
- * (volatile uint8_t *)(0x3F + 0x20) = oldSreg;
- }
- static inline
- #line 150
- void TOSH_wait(void)
- {
- __asm volatile ("nop");
- __asm volatile ("nop");}
- static
- #line 179
- __inline void __nesc_atomic_sleep(void)
- {
- __asm volatile ("sei");
- __asm volatile ("sleep");
- TOSH_wait();
- }
- #line 165
- __inline __nesc_atomic_t __nesc_atomic_start(void )
- {
- __nesc_atomic_t result = * (volatile uint8_t *)(0x3F + 0x20);
- #line 168
- __asm volatile ("cli");
- return result;
- }
- static inline
- # 136 "/home/testuser/tinyos-1.x/tos/system/sched.c"
- bool TOSH_run_next_task(void)
- {
- __nesc_atomic_t fInterruptFlags;
- uint8_t old_full;
- void (*func)(void );
- fInterruptFlags = __nesc_atomic_start();
- old_full = TOSH_sched_full;
- func = TOSH_queue[old_full].tp;
- if (func == (void *)0)
- {
- __nesc_atomic_sleep();
- return 0;
- }
- TOSH_queue[old_full].tp = (void *)0;
- TOSH_sched_full = (old_full + 1) & TOSH_TASK_BITMASK;
- __nesc_atomic_end(fInterruptFlags);
- func();
- return 1;
- }
- static inline void TOSH_run_task(void)
- #line 159
- {
- for (; ; )
- TOSH_run_next_task();
- }
- static inline
- # 132 "/home/testuser/tinyos-1.x/tos/system/AMStandard.nc"
- void AMStandard$dbgPacket(TOS_MsgPtr data)
- #line 132
- {
- uint8_t i;
- for (i = 0; i < sizeof(TOS_Msg ); i++)
- {
- {
- }
- #line 137
- ;
- }
- {
- }
- #line 139
- ;
- }
- static inline
- # 485 "../../tos/system/DrandM.nc"
- void DrandM$updateNeighborInfoForFrame(uint8_t nIndex, frameMsg *pkt)
- #line 485
- {
- uint8_t i;
- int n;
- DrandM$nbrInfo[nIndex].frame = pkt->frame;
- for (i = 0; i < MAX_ONE_HOP && pkt->oneHopNodeID[i] != 0xFF; i++)
- if ((n = DrandM$isPresent(pkt->oneHopNodeID[i], ONE_HOP | TWO_HOP)) != -1) {
- DrandM$nbrInfo[n].frame = pkt->frameArray[i];
- {
- #line 496
- char bStatus;
- #line 496
- if (DBG_USR2 != 0) {
- #line 496
- bStatus = * (volatile uint8_t *)(uint16_t )& * (volatile uint8_t *)(0x3F + 0x20) & (1 << 7);
- #line 496
- __asm volatile ("cli");DrandM$sprintf(DrandM$debugbuf, "updating for node = %u, Frame = %un", DrandM$nbrInfo[n].nodeID, DrandM$nbrInfo[n].frame);
- #line 496
- DrandM$writedebug();
- #line 496
- if (bStatus) {
- #line 496
- __asm volatile ("sei");
- }
- }
- }
- #line 496
- ;
- }
- }
- static inline
- #line 1373
- TOS_MsgPtr DrandM$ReceiveFrameMsg$receive(TOS_MsgPtr m)
- #line 1373
- {
- if (DrandM$globalState != FRAME_STATE && !DrandM$gotAllFrames) {
- #line 1374
- return m;
- }
- #line 1375
- { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
- #line 1375
- {
- frameMsg *recvFramePtr = (frameMsg *)m->data;
- int nIndex = DrandM$isPresent(recvFramePtr->sendID, ONE_HOP);
- DrandM$updateNeighborInfoForFrame(nIndex, recvFramePtr);
- if (DrandM$globalState == REPORT_STATE) {
- DrandM$globalState = FRAME_STATE;
- DrandM$reXFrame();
- }
- if (recvFramePtr->type == FRAME_REQUEST) {
- DrandM$sendFrameMsg(FRAME_REPLY);
- }
- }
- #line 1390
- __nesc_atomic_end(__nesc_atomic); }
- #line 1390
- return m;
- }
- static inline
- #line 468
- void DrandM$updateNeighborInfoForReport(int nIndex, reportMsg *pkt)
- #line 468
- {
- uint8_t i;
- int n;
- if (nIndex != -1) {
- DrandM$nbrInfo[nIndex].slot = pkt->slot;
- }
- #line 476
- for (i = 0; i < MAX_NBR; i++)
- if ((n = DrandM$isPresent(pkt->timeSlot[i], ONE_HOP | TWO_HOP)) != -1) {
- DrandM$nbrInfo[n].slot = i;
- }
- }
- static inline
- #line 1347
- TOS_MsgPtr DrandM$ReceiveReportMsg$receive(TOS_MsgPtr m)
- #line 1347
- {
- if (!DrandM$setMySlot) {
- #line 1348
- return m;
- }
- #line 1349
- { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
- #line 1349
- {
- reportMsg *recvReportPtr = (reportMsg *)m->data;
- int nIndex = DrandM$isPresent(recvReportPtr->sendID, ONE_HOP);
- DrandM$updateNeighborInfoForReport(nIndex, recvReportPtr);
- if (DrandM$globalState == RELEASE_STATE) {
- DrandM$globalState = REPORT_STATE;
- DrandM$reXReport();
- DrandM$roundTimer$start(TIMER_ONE_SHOT, REPORT_PERIOD);
- }
- if (recvReportPtr->type == REPORT_REQUEST) {
- DrandM$sendReportMsg(REPORT_REPLY);
- }
- }
- #line 1366
- __nesc_atomic_end(__nesc_atomic); }
- return m;
- }
- static inline
- #line 302
- uint8_t DrandM$numOneHop(void)
- #line 302
- {
- uint8_t i;
- #line 303
- uint8_t count;
- #line 304
- for (i = 0, count = 0; i < MAX_NBR && DrandM$nbrInfo[i].nodeID != 0xFF; i++)
- if (DrandM$nbrInfo[i].bitMap & ONE_HOP) {
- count++;
- }
- #line 307
- return count;
- }
- static inline
- #line 1236
- TOS_MsgPtr DrandM$ReceiveGrantMsg$receive(TOS_MsgPtr m)
- #line 1236
- {
- uint8_t i;
- GTime rttTime;
- double currOTT;
- bool dup = FALSE;
- grantMsg *recvGrantPtr = (grantMsg *)m->data;
- int nIndex = DrandM$isPresent(recvGrantPtr->sendID, ONE_HOP);
- #line 1243
- if (nIndex == -1) {
- return m;
- }
- #line 1245
- { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
- #line 1245
- {
- for (i = 0; i < MAX_NBR; i++) {
- if (DrandM$isPresent(recvGrantPtr->timeSlot[i], ONE_HOP) == -1) {
- DrandM$addNode(recvGrantPtr->timeSlot[i], TWO_HOP);
- }
- #line 1249
- DrandM$updateNeighborInfo(recvGrantPtr->timeSlot[i], i);
- }
- if (DrandM$setMySlot) {
- DrandM$sendReleaseMsg(DrandM$myInfo.slot);
- }
- else {
- #line 1261
- if (DrandM$globalState == IDLE_STATE2 || DrandM$globalState == GRANT_STATE) {
- DrandM$sendReleaseMsg(0xFF);
- DrandM$sentRelease = TRUE;
- }
- else {
- #line 1269
- if (DrandM$globalState == REQUEST_STATE) {
- if (!(DrandM$nbrInfo[nIndex].bitMap & GRANT_SENT)) {
- DrandM$nbrInfo[nIndex].bitMap |= GRANT_SENT;
- }
- else {
- #line 1273
- dup = TRUE;
- }
- if (DrandM$firstGrant) {
- DrandM$SClock$getTime(&DrandM$locTime);
- rttTime = DrandM$timeDiff(DrandM$locTime, recvGrantPtr->timestamp);
- currOTT = (rttTime.mticks * 568.88 + rttTime.sticks * 0.00868) / 2;
- DrandM$OTT = (uint16_t )(currOTT * .50 + DrandM$OTT * .50);
- DrandM$ROUND_TIME = (DrandM$OTT + DrandM$OTT * DrandM$numOneHop() + DrandM$OTT) * 2;
- DrandM$REQUEST_TIME = 2 * DrandM$OTT * 2;
- DrandM$firstGrant = FALSE;
- }
- if (DrandM$numGrantsRemaining() == 0 && !DrandM$setMySlot) {
- DrandM$setSlot();
- DrandM$timeCheck();
- DrandM$printNbrInfo();
- }
- else {
- if (!dup) {
- DrandM$reXTimer$start(TIMER_ONE_SHOT, DrandM$REQUEST_TIME);
- DrandM$requestFireCount = 0;
- }
- }
- }
- }
- }
- }
- #line 1307
- __nesc_atomic_end(__nesc_atomic); }
- #line 1305
- return m;
- }
- static inline
- #line 1215
- TOS_MsgPtr DrandM$ReceiveTwoHopMsg$receive(TOS_MsgPtr m)
- #line 1215
- {
- int nIndex;
- twoHopMsg *recvTwoHopPtr = (twoHopMsg *)m->data;
- if ((nIndex = DrandM$isPresent(recvTwoHopPtr->sendID, ONE_HOP)) == -1 ||
- recvTwoHopPtr->slotID == TOS_LOCAL_ADDRESS) {
- return m;
- }
- #line 1225
- { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
- #line 1225
- {
- if (DrandM$globalState == GRANT_STATE && recvTwoHopPtr->slotID == DrandM$lastReqID) {
- recvTwoHopPtr->sendID = recvTwoHopPtr->slotID;
- DrandM$ReceiveReleaseMsg$receive(m);
- }
- DrandM$updateNeighborInfo(recvTwoHopPtr->slotID, recvTwoHopPtr->slot);
- }
- #line 1232
- __nesc_atomic_end(__nesc_atomic); }
- return m;
- }
- # 59 "/home/testuser/tinyos-1.x/tos/interfaces/Timer.nc"
- inline static result_t DrandM$drandRoundTimer$start(char arg_0x85800e0, uint32_t arg_0x8580238){
- #line 59
- unsigned char result;
- #line 59
- #line 59
- result = TimerM$Timer$start(2, arg_0x85800e0, arg_0x8580238);
- #line 59
- #line 59
- return result;
- #line 59
- }
- #line 59
- static inline
- # 283 "../../tos/system/DrandM.nc"
- void DrandM$initializeGrantSent(void)
- #line 283
- {
- uint8_t i;
- #line 285
- for (i = 0; i < MAX_NBR && DrandM$nbrInfo[i].nodeID != 0xFF; i++)
- if (DrandM$nbrInfo[i].bitMap & ONE_HOP) {
- DrandM$nbrInfo[i].bitMap = DrandM$nbrInfo[i].bitMap & ~GRANT_SENT;
- }
- }
- # 68 "/home/testuser/tinyos-1.x/tos/interfaces/Timer.nc"
- inline static result_t DrandM$reXTimer$stop(void){
- #line 68
- unsigned char result;
- #line 68
- #line 68
- result = TimerM$Timer$stop(1);
- #line 68
- #line 68
- return result;
- #line 68
- }
- #line 68
- static inline
- # 1149 "../../tos/system/DrandM.nc"
- TOS_MsgPtr DrandM$ReceiveRejectMsg$receive(TOS_MsgPtr m)
- #line 1149
- {
- if (DrandM$globalState != REQUEST_STATE) {
- #line 1150
- return m;
- }
- #line 1151
- { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
- #line 1151
- {
- DrandM$reXTimer$stop();
- DrandM$sendReleaseMsg(0xFF);
- DrandM$sentRelease = TRUE;
- DrandM$initializeGrantSent();
- DrandM$globalState = IDLE_STATE2;
- DrandM$reqX = FALSE;
- DrandM$drandRoundTimer$start(TIMER_ONE_SHOT, 1000);
- }
- #line 1170
- __nesc_atomic_end(__nesc_atomic); }
- return m;
- }
- static inline
- #line 213
- bool DrandM$checkForRetransGrant(requestMsg *reqMsgPtr)
- #line 213
- {
- if (DrandM$isPresentHelloID(TOS_LOCAL_ADDRESS, reqMsgPtr->idMap, MAX_NBR) == -1) {
- return FALSE;
- }
- else {
- return TRUE;
- }
- }
- # 68 "/home/testuser/tinyos-1.x/tos/interfaces/Timer.nc"
- inline static result_t DrandM$drandRoundTimer$stop(void){
- #line 68
- unsigned char result;
- #line 68
- #line 68
- result = TimerM$Timer$stop(2);
- #line 68
- #line 68
- return result;
- #line 68
- }
- #line 68
- # 48 "/home/testuser/tinyos-1.x/tos/interfaces/SendMsg.nc"
- inline static result_t DrandM$SendRejectMsg$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_REJECT, arg_0x857ab18, arg_0x857ac60, arg_0x857adb0);
- #line 48
- #line 48
- return result;
- #line 48
- }
- #line 48
- static inline
- # 648 "../../tos/system/DrandM.nc"
- void DrandM$sendRejectMsg(uint8_t msgADDR)
- #line 648
- {
- { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
- #line 649
- {
- if (!DrandM$sendBusy) {
- rejectMsg *rejectMsgData = (rejectMsg *)DrandM$DataPkt.data;
- #line 652
- rejectMsgData->sendID = TOS_LOCAL_ADDRESS;
- rejectMsgData->myState = DrandM$globalState;
- rejectMsgData->roundNum = DrandM$roundNum;
- rejectMsgData->lastRequestID = DrandM$lastReqID;
- if (DrandM$SendRejectMsg$send((uint16_t )msgADDR, sizeof(rejectMsg ), &DrandM$DataPkt) == SUCCESS) {
- DrandM$sendBusy = TRUE;
- }
- else {
- }
- }
- }
- #line 664
- __nesc_atomic_end(__nesc_atomic); }
- }
- static inline
- #line 1098
- TOS_MsgPtr DrandM$ReceiveRequestMsg$receive(TOS_MsgPtr m)
- #line 1098
- {
- uint8_t i;
- requestMsg *recvRequestPtr = (requestMsg *)m->data;
- uint16_t reqSentID = recvRequestPtr->sendID;
- #line 1102
- if (DrandM$isPresent(reqSentID, ONE_HOP) == -1) {
- #line 1102
- return m;
- }
- #line 1103
- { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
- #line 1103
- {
- DrandM$requestStartTime = recvRequestPtr->timestamp;
- for (i = 0; i < MAX_NBR && recvRequestPtr->idMap[i] != 0xFF; i++)
- if (DrandM$isPresent(recvRequestPtr->idMap[i], ONE_HOP) == -1) {
- DrandM$addNode(recvRequestPtr->idMap[i], TWO_HOP);
- }
- if (reqSentID != DrandM$lastReqID && (DrandM$globalState == GRANT_STATE ||
- DrandM$globalState == REQUEST_STATE)) {
- DrandM$sendRejectMsg(reqSentID);
- }
- else {
- if (DrandM$globalState == IDLE_STATE2 || DrandM$setMySlot) {
- if (!DrandM$setMySlot) {
- DrandM$drandRoundTimer$stop();
- }
- #line 1126
- DrandM$globalState = GRANT_STATE;
- DrandM$grantFireCount = 0;
- DrandM$lastReqID = reqSentID;
- DrandM$GRANT_TIME = (recvRequestPtr->numRemaining * recvRequestPtr->OTT + recvRequestPtr->OTT) * 2;
- DrandM$reXTimer$start(TIMER_ONE_SHOT, DrandM$randNew() % GRANT_INTERVAL);
- }
- else {
- #line 1135
- if (DrandM$globalState == GRANT_STATE && reqSentID == DrandM$lastReqID) {
- DrandM$GRANT_TIME = (recvRequestPtr->numRemaining * recvRequestPtr->OTT + recvRequestPtr->OTT) * 2;
- if (DrandM$checkForRetransGrant(recvRequestPtr)) {
- DrandM$reXTimer$start(TIMER_ONE_SHOT, DrandM$randNew() % GRANT_INTERVAL);
- }
- else
- #line 1140
- {
- DrandM$reXTimer$start(TIMER_ONE_SHOT, DrandM$GRANT_TIME);
- DrandM$grantFireCount = 0;
- }
- }
- }
- }
- }
- #line 1147
- __nesc_atomic_end(__nesc_atomic); }
- #line 1146
- return m;
- }
- static inline
- #line 1017
- TOS_MsgPtr DrandM$ReceiveHelloMsg$receive(TOS_MsgPtr m)
- #line 1017
- {
- if (DrandM$globalState != HELLO_STATE) {
- #line 1018
- return m;
- }
- #line 1019
- { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
- #line 1019
- {
- uint8_t PacketOneWayID[MAX_NBR];
- #line 1020
- uint8_t PacketTwoWayID[MAX_NBR];
- helloMsg *recvHelloPtr = (helloMsg *)m->data;
- uint8_t Sender = recvHelloPtr->sendID;
- uint8_t Me = TOS_LOCAL_ADDRESS;
- uint8_t i;
- #line 1024
- uint8_t j;
- bool SendHelloFlag = FALSE;
- for (i = 0; i < MAX_NBR; i++)
- PacketOneWayID[i] = PacketTwoWayID[i] = 0xFF;
- for (i = 0; i < recvHelloPtr->OneWayLen; i++)
- PacketOneWayID[i] = recvHelloPtr->OneWayId[i];
- for (j = 0; i < MAX_NBR; i++, j++)
- PacketTwoWayID[j] = recvHelloPtr->OneWayId[i];
- if (DrandM$isPresentHelloID(Me, PacketOneWayID, MAX_NBR) != -1) {
- if (DrandM$isPresentHelloID(Sender, DrandM$OneWayId, MAX_NBR) != -1) {
- DrandM$addHelloID(Sender, DrandM$TwoWayId);
- DrandM$removeHelloID(Sender, DrandM$OneWayId);
- }
- else {
- #line 1050
- if (DrandM$isPresentHelloID(Sender, DrandM$TwoWayId, MAX_NBR) != -1) {
- SendHelloFlag = TRUE;
- }
- else {
- DrandM$addHelloID(Sender, DrandM$TwoWayId);
- SendHelloFlag = TRUE;
- }
- }
- }
- else {
- #line 1061
- if (DrandM$isPresentHelloID(Me, PacketTwoWayID, MAX_NBR) != -1) {
- if (DrandM$isPresentHelloID(Sender, DrandM$OneWayId, MAX_NBR) != -1) {
- DrandM$addHelloID(Sender, DrandM$TwoWayId);
- DrandM$removeHelloID(Sender, DrandM$OneWayId);
- SendHelloFlag = TRUE;
- }
- else {
- #line 1070
- if (DrandM$isPresentHelloID(Sender, DrandM$TwoWayId, MAX_NBR) != -1) {
- }
- else {
- #line 1071
- if (DrandM$isPresentHelloID(Sender, DrandM$TwoWayId, MAX_NBR) == -1 &&
- DrandM$isPresentHelloID(Sender, DrandM$OneWayId, MAX_NBR) == -1) {
- }
- }
- }
- }
- else {
- #line 1074
- if (DrandM$isPresentHelloID(Me, PacketOneWayID, MAX_NBR) == -1 &&
- DrandM$isPresentHelloID(Me, PacketTwoWayID, MAX_NBR) == -1) {
- if (DrandM$isPresentHelloID(Sender, DrandM$OneWayId, MAX_NBR) == -1) {
- DrandM$addHelloID(Sender, DrandM$OneWayId);
- }
- else {
- #line 1079
- if (DrandM$isPresentHelloID(Sender, DrandM$OneWayId, MAX_NBR) != -1) {
- SendHelloFlag = TRUE;
- }
- else {
- #line 1082
- if (DrandM$isPresentHelloID(Sender, DrandM$TwoWayId, MAX_NBR) != -1) {
- }
- }
- }
- }
- }
- }
- #line 1085
- if (SendHelloFlag && DrandM$globalState != HELLO_STATE) {
- DrandM$sendHelloMsg();
- }
- for (i = 0; i < MAX_NBR; i++)
- if (DrandM$isPresentHelloID(PacketTwoWayID[i], DrandM$TwoWayId, MAX_NBR) == -1) {
- DrandM$addNode(PacketTwoWayID[i], TWO_HOP);
- }
- DrandM$removeNode(recvHelloPtr->sendID, TWO_HOP);
- }
- #line 1093
- __nesc_atomic_end(__nesc_atomic); }
- return m;
- }
- static inline
- # 242 "/home/testuser/tinyos-1.x/tos/system/AMStandard.nc"
- TOS_MsgPtr AMStandard$ReceiveMsg$default$receive(uint8_t id, TOS_MsgPtr msg)
- #line 242
- {
- return msg;
- }
- # 75 "/home/testuser/tinyos-1.x/tos/interfaces/ReceiveMsg.nc"
- inline static TOS_MsgPtr AMStandard$ReceiveMsg$receive(uint8_t arg_0x86aab68, TOS_MsgPtr arg_0x856c0f0){
- #line 75
- struct TOS_Msg *result;
- #line 75
- #line 75
- switch (arg_0x86aab68) {
- #line 75
- case AM_HELLO:
- #line 75
- result = DrandM$ReceiveHelloMsg$receive(arg_0x856c0f0);
- #line 75
- break;
- #line 75
- case AM_REQUEST:
- #line 75
- result = DrandM$ReceiveRequestMsg$receive(arg_0x856c0f0);
- #line 75
- break;
- #line 75
- case AM_GRANT:
- #line 75
- result = DrandM$ReceiveGrantMsg$receive(arg_0x856c0f0);
- #line 75
- break;
- #line 75
- case AM_RELEASE:
- #line 75
- result = DrandM$ReceiveReleaseMsg$receive(arg_0x856c0f0);
- #line 75
- break;
- #line 75
- case AM_REJECT:
- #line 75
- result = DrandM$ReceiveRejectMsg$receive(arg_0x856c0f0);
- #line 75
- break;
- #line 75
- case AM_TWOHOP:
- #line 75
- result = DrandM$ReceiveTwoHopMsg$receive(arg_0x856c0f0);
- #line 75
- break;
- #line 75
- case AM_REPORT:
- #line 75
- result = DrandM$ReceiveReportMsg$receive(arg_0x856c0f0);
- #line 75
- break;
- #line 75
- case AM_FRAME:
- #line 75
- result = DrandM$ReceiveFrameMsg$receive(arg_0x856c0f0);
- #line 75
- break;
- #line 75
- default:
- #line 75
- result = AMStandard$ReceiveMsg$default$receive(arg_0x86aab68, arg_0x856c0f0);
- #line 75
- }
- #line 75
- #line 75
- return result;
- #line 75
- }
- #line 75
- # 48 "/home/testuser/tinyos-1.x/tos/interfaces/SendMsg.nc"
- inline static result_t DrandM$SendHelloMsg$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_HELLO, arg_0x857ab18, arg_0x857ac60, arg_0x857adb0);
- #line 48
- #line 48
- return result;
- #line 48
- }
- #line 48
- # 58 "/home/testuser/tinyos-1.x/tos/interfaces/BareSendMsg.nc"
- inline static result_t AMStandard$RadioSend$send(TOS_MsgPtr arg_0x86be870){
- #line 58
- unsigned char result;
- #line 58
- #line 58
- result = CC1000RadioIntM$Send$send(arg_0x86be870);
- #line 58
- #line 58
- return result;
- #line 58
- }
- #line 58
- static inline
- # 306 "/home/testuser/tinyos-1.x/tos/system/FramerM.nc"
- result_t FramerM$BareSendMsg$send(TOS_MsgPtr pMsg)
- #line 306
- {
- result_t Result = SUCCESS;
- { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
- #line 309
- {
- if (!(FramerM$gFlags & FramerM$FLAGS_DATAPEND)) {
- FramerM$gFlags |= FramerM$FLAGS_DATAPEND;
- FramerM$gpTxMsg = pMsg;
- }
- else
- {
- Result = FAIL;
- }
- }
- #line 319
- __nesc_atomic_end(__nesc_atomic); }
- if (Result == SUCCESS) {
- Result = FramerM$StartTx();
- }
- return Result;
- }
- # 58 "/home/testuser/tinyos-1.x/tos/interfaces/BareSendMsg.nc"
- inline static result_t AMStandard$UARTSend$send(TOS_MsgPtr arg_0x86be870){
- #line 58
- unsigned char result;
- #line 58
- #line 58
- result = FramerM$BareSendMsg$send(arg_0x86be870);
- #line 58
- #line 58
- return result;
- #line 58
- }
- #line 58
- static inline
- # 165 "/home/testuser/tinyos-1.x/tos/system/AMStandard.nc"
- void AMStandard$sendTask(void)
- #line 165
- {
- result_t ok;
- TOS_MsgPtr buf;
- #line 168
- buf = AMStandard$buffer;
- if (buf->addr == TOS_UART_ADDR) {
- ok = AMStandard$UARTSend$send(buf);
- }
- else {
- #line 172
- ok = AMStandard$RadioSend$send(buf);
- }
- if (ok == FAIL) {
- AMStandard$reportSendDone(AMStandard$buffer, FAIL);
- }
- }
- static inline
- # 105 "../../tos/platform/mica2/HPLUART0M.nc"
- result_t HPLUART0M$UART$put(uint8_t data)
- #line 105
- {
- { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
- #line 106
- {
- * (volatile uint8_t *)(0x0C + 0x20) = data;
- * (volatile uint8_t *)(0x0B + 0x20) |= 1 << 6;
- }
- #line 109
- __nesc_atomic_end(__nesc_atomic); }
- return SUCCESS;
- }
- # 80 "/home/testuser/tinyos-1.x/tos/interfaces/HPLUART.nc"
- inline static result_t UARTM$HPLUART$put(uint8_t arg_0x89be300){
- #line 80
- unsigned char result;
- #line 80
- #line 80
- result = HPLUART0M$UART$put(arg_0x89be300);
- #line 80
- #line 80
- return result;
- #line 80
- }
- #line 80
- static inline
- # 207 "/home/testuser/tinyos-1.x/tos/system/AMStandard.nc"
- result_t AMStandard$UARTSend$sendDone(TOS_MsgPtr msg, result_t success)
- #line 207
- {
- return AMStandard$reportSendDone(msg, success);
- }
- # 67 "/home/testuser/tinyos-1.x/tos/interfaces/BareSendMsg.nc"
- inline static result_t FramerM$BareSendMsg$sendDone(TOS_MsgPtr arg_0x86bed88, result_t arg_0x86beed8){
- #line 67
- unsigned char result;
- #line 67
- #line 67
- result = AMStandard$UARTSend$sendDone(arg_0x86bed88, arg_0x86beed8);
- #line 67
- #line 67
- return result;
- #line 67
- }
- #line 67
- static inline
- # 1002 "../../tos/system/DrandM.nc"
- result_t DrandM$SendFrameMsg$sendDone(TOS_MsgPtr msg, result_t success)
- #line 1002
- {
- { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
- #line 1003
- {
- if (DrandM$sendBusy) {
- DrandM$sendBusy = FALSE;
- }
- if (DrandM$globalState == FRAME_STATE) {
- DrandM$reXTimer$start(TIMER_ONE_SHOT, FRAME_XPERIOD + DrandM$randNew() % FRAME_INTERVAL);
- }
- }
- #line 1014
- __nesc_atomic_end(__nesc_atomic); }
- #line 1014
- return SUCCESS;
- }
- static inline
- #line 984
- result_t DrandM$SendReportMsg$sendDone(TOS_MsgPtr msg, result_t success)
- #line 984
- {
- { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
- #line 985
- {
- if (DrandM$sendBusy) {
- DrandM$sendBusy = FALSE;
- }
- if (DrandM$globalState == REPORT_STATE) {
- DrandM$reXTimer$start(TIMER_ONE_SHOT, REPORT_XPERIOD + DrandM$randNew() % REPORT_INTERVAL);
- }
- }
- #line 999
- __nesc_atomic_end(__nesc_atomic); }
- #line 999
- return SUCCESS;
- }
- static inline
- #line 954
- result_t DrandM$SendGrantMsg$sendDone(TOS_MsgPtr msg, result_t success)
- #line 954
- {
- { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
- #line 955
- {
- if (DrandM$sendBusy) {
- DrandM$sendBusy = FALSE;
- if (success == FAIL) {
- }
- else
- {
- if (DrandM$graX) {
- #line 967
- DrandM$graXCount++;
- }
- else {
- #line 968
- if (!DrandM$graX) {
- #line 968
- DrandM$graX = TRUE;
- }
- }
- #line 969
- DrandM$graCount++;
- DrandM$grantFireCount++;
- }
- }
- if (DrandM$globalState == GRANT_STATE) {
- DrandM$reXTimer$start(TIMER_ONE_SHOT, DrandM$GRANT_TIME);
- }
- }
- #line 981
- __nesc_atomic_end(__nesc_atomic); }
- #line 981
- return SUCCESS;
- }
- static inline
- #line 932
- result_t DrandM$SendTwoHopMsg$sendDone(TOS_MsgPtr msg, result_t success)
- #line 932
- {
- { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
- #line 933
- {
- if (DrandM$sendBusy) {
- DrandM$sendBusy = FALSE;
- if (success == SUCCESS) {
- DrandM$twoCount++;
- }
- else {
- }
- }
- }
- #line 947
- __nesc_atomic_end(__nesc_atomic); }
- return SUCCESS;
- }
- static inline
- #line 910
- result_t DrandM$SendReleaseMsg$sendDone(TOS_MsgPtr msg, result_t success)
- #line 910
- {
- { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
- #line 911
- {
- if (DrandM$sendBusy) {
- DrandM$sendBusy = FALSE;
- if (success == SUCCESS) {
- DrandM$relCount++;
- }
- else
- {
- }
- }
- }
- #line 925
- __nesc_atomic_end(__nesc_atomic); }
- return SUCCESS;
- }
- static inline
- #line 886
- result_t DrandM$SendRejectMsg$sendDone(TOS_MsgPtr msg, result_t success)
- #line 886
- {
- { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
- #line 887
- {
- if (DrandM$sendBusy) {
- DrandM$sendBusy = FALSE;
- if (success == SUCCESS) {
- DrandM$rejCount++;
- }
- else {
- }
- }
- }
- #line 903
- __nesc_atomic_end(__nesc_atomic); }
- return SUCCESS;
- }
- static inline
- #line 856
- result_t DrandM$SendRequestMsg$sendDone(TOS_MsgPtr msg, result_t success)
- #line 856
- {
- { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
- #line 857
- {
- if (DrandM$sendBusy) {
- DrandM$sendBusy = FALSE;
- if (success == FAIL) {
- }
- else
- {
- if (DrandM$reqX) {
- #line 869
- DrandM$reqXCount++;
- }
- else {
- #line 870
- if (!DrandM$reqX) {
- #line 870
- DrandM$reqX = TRUE;
- }
- }
- #line 871
- DrandM$reqCount++;
- DrandM$requestFireCount++;
- }
- if (DrandM$globalState == REQUEST_STATE) {
- DrandM$reXTimer$start(TIMER_ONE_SHOT, DrandM$REQUEST_TIME);
- }
- }
- }
- #line 883
- __nesc_atomic_end(__nesc_atomic); }
- #line 883
- return SUCCESS;
- }
- static inline
- #line 842
- result_t DrandM$SendHelloMsg$sendDone(TOS_MsgPtr msg, result_t success)
- #line 842
- {
- { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
- #line 843
- {
- if (DrandM$sendBusy) {
- DrandM$sendBusy = FALSE;
- if (DrandM$globalState == HELLO_STATE) {
- DrandM$reXTimer$start(TIMER_ONE_SHOT, DrandM$randNew() % HELLO_INTERVAL);
- }
- }
- }
- #line 853
- __nesc_atomic_end(__nesc_atomic); }
- #line 853
- return SUCCESS;
- }
- static inline
- # 157 "/home/testuser/tinyos-1.x/tos/system/AMStandard.nc"
- result_t AMStandard$SendMsg$default$sendDone(uint8_t id, TOS_MsgPtr msg, result_t success)
- #line 157
- {
- return SUCCESS;
- }
- # 49 "/home/testuser/tinyos-1.x/tos/interfaces/SendMsg.nc"
- inline static result_t AMStandard$SendMsg$sendDone(uint8_t arg_0x86aa5b0, TOS_MsgPtr arg_0x857b1d0, result_t arg_0x857b320){
- #line 49
- unsigned char result;
- #line 49
- #line 49
- switch (arg_0x86aa5b0) {
- #line 49
- case AM_HELLO:
- #line 49
- result = DrandM$SendHelloMsg$sendDone(arg_0x857b1d0, arg_0x857b320);
- #line 49
- break;
- #line 49
- case AM_REQUEST:
- #line 49
- result = DrandM$SendRequestMsg$sendDone(arg_0x857b1d0, arg_0x857b320);
- #line 49
- break;
- #line 49
- case AM_GRANT:
- #line 49
- result = DrandM$SendGrantMsg$sendDone(arg_0x857b1d0, arg_0x857b320);
- #line 49
- break;
- #line 49
- case AM_RELEASE:
- #line 49
- result = DrandM$SendReleaseMsg$sendDone(arg_0x857b1d0, arg_0x857b320);
- #line 49
- break;
- #line 49
- case AM_REJECT:
- #line 49
- result = DrandM$SendRejectMsg$sendDone(arg_0x857b1d0, arg_0x857b320);
- #line 49
- break;
- #line 49
- case AM_TWOHOP:
- #line 49
- result = DrandM$SendTwoHopMsg$sendDone(arg_0x857b1d0, arg_0x857b320);
- #line 49
- break;
- #line 49
- case AM_REPORT:
- #line 49
- result = DrandM$SendReportMsg$sendDone(arg_0x857b1d0, arg_0x857b320);
- #line 49
- break;
- #line 49
- case AM_FRAME:
- #line 49
- result = DrandM$SendFrameMsg$sendDone(arg_0x857b1d0, arg_0x857b320);
- #line 49
- break;
- #line 49
- default:
- #line 49
- result = AMStandard$SendMsg$default$sendDone(arg_0x86aa5b0, arg_0x857b1d0, arg_0x857b320);
- #line 49
- }
- #line 49
- #line 49
- return result;
- #line 49
- }
- #line 49
- static inline
- # 160 "/home/testuser/tinyos-1.x/tos/system/AMStandard.nc"
- result_t AMStandard$default$sendDone(void)
- #line 160
- {
- return SUCCESS;
- }
- #line 65
- inline static result_t AMStandard$sendDone(void){
- #line 65
- unsigned char result;
- #line 65
- #line 65
- result = AMStandard$default$sendDone();
- #line 65
- #line 65
- return result;
- #line 65
- }
- #line 65
- # 63 "/home/testuser/tinyos-1.x/tos/interfaces/Random.nc"
- inline static uint16_t CC1000RadioIntM$Random$rand(void){
- #line 63
- unsigned int result;
- #line 63
- #line 63
- result = RandomLFSR$Random$rand();
- #line 63
- #line 63
- return result;
- #line 63
- }
- #line 63
- static inline
- # 1796 "../../tos/platform/mica2/CC1000RadioIntM.nc"
- int16_t CC1000RadioIntM$MacBackoff$default$initialBackoff(TOS_MsgPtr m)
- #line 1796
- {
- return (CC1000RadioIntM$Random$rand() & 0x1F) + 1;
- }
- # 39 "../../tos/platform/mica2/MacBackoff.nc"
- inline static int16_t CC1000RadioIntM$MacBackoff$initialBackoff(TOS_MsgPtr arg_0x86d6c88){
- #line 39
- int result;
- #line 39
- #line 39
- result = CC1000RadioIntM$MacBackoff$default$initialBackoff(arg_0x86d6c88);
- #line 39
- #line 39
- return result;
- #line 39
- }
- #line 39
- static inline
- # 245 "../../tos/platform/mica2/CC1000RadioIntM.nc"
- uint16_t CC1000RadioIntM$getOwnerBackoff(void)
- #line 245
- {
- return (CC1000RadioIntM$Random$rand() & (8 - 1)) + 1;
- }
- static inline uint16_t CC1000RadioIntM$getNonOwnerBackoff(void)
- #line 249
- {
- return (CC1000RadioIntM$Random$rand() & (32 - 1)) + 8 + 1;
- }
- # 68 "/home/testuser/tinyos-1.x/tos/interfaces/Timer.nc"
- inline static result_t CC1000RadioIntM$WakeupTimer$stop(void){
- #line 68
- unsigned char result;
- #line 68
- #line 68
- result = TimerM$Timer$stop(5);
- #line 68
- #line 68
- return result;
- #line 68
- }
- #line 68
- # 48 "/home/testuser/tinyos-1.x/tos/interfaces/SendMsg.nc"
- inline static result_t DrandM$SendReleaseMsg$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_RELEASE, arg_0x857ab18, arg_0x857ac60, arg_0x857adb0);
- #line 48
- #line 48
- return result;
- #line 48
- }
- #line 48
- # 48 "/home/testuser/tinyos-1.x/tos/interfaces/SendMsg.nc"
- inline static result_t DrandM$SendTwoHopMsg$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_TWOHOP, arg_0x857ab18, arg_0x857ac60, arg_0x857adb0);
- #line 48
- #line 48
- return result;
- #line 48
- }
- #line 48
- static inline
- # 738 "../../tos/system/DrandM.nc"
- void DrandM$sendTwoHopMsg(uint8_t slot, uint8_t sendID)
- #line 738
- {
- { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
- #line 739
- {
- if (!DrandM$sendBusy) {
- twoHopMsg *twoHopMsgData = (twoHopMsg *)DrandM$DataPkt.data;
- #line 742
- twoHopMsgData->sendID = TOS_LOCAL_ADDRESS;
- twoHopMsgData->slotID = sendID;
- twoHopMsgData->slot = slot;
- twoHopMsgData->myState = DrandM$globalState;
- twoHopMsgData->roundNum = DrandM$roundNum;
- twoHopMsgData->lastRequestID = DrandM$lastReqID;
- if (DrandM$SendTwoHopMsg$send(TOS_BCAST_ADDR, sizeof(twoHopMsg ), &DrandM$DataPkt) == SUCCESS) {
- DrandM$sendBusy = TRUE;
- }
- else
- #line 752
- {
- }
- }
- }
- #line 755
- __nesc_atomic_end(__nesc_atomic); }
- }
- static inline
- #line 221
- bool DrandM$checkForRetransReport(void)
- #line 221
- {
- uint8_t i;
- #line 223
- for (i = 0; i < MAX_NBR && DrandM$nbrInfo[i].nodeID != 0xFF; i++)
- if (DrandM$nbrInfo[i].slot == 0xFF) {
- return TRUE;
- }
- return FALSE;
- }
- static inline
- #line 355
- void DrandM$fillTimeSlotInfoForReport(uint8_t *array)
- #line 355
- {
- uint8_t i;
- #line 357
- for (i = 0; i < MAX_NBR; i++)
- array[i] = 0xFF;
- for (i = 0; i < MAX_NBR && DrandM$nbrInfo[i].nodeID != 0xFF; i++)
- if (DrandM$nbrInfo[i].slot != 0xFF) {
- array[DrandM$nbrInfo[i].slot] = DrandM$nbrInfo[i].nodeID;
- }
- #line 362
- if (DrandM$setMySlot) {
- array[DrandM$myInfo.slot] = TOS_LOCAL_ADDRESS;
- }
- }
- # 48 "/home/testuser/tinyos-1.x/tos/interfaces/SendMsg.nc"
- inline static result_t DrandM$SendReportMsg$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_REPORT, arg_0x857ab18, arg_0x857ac60, arg_0x857adb0);
- #line 48
- #line 48
- return result;
- #line 48
- }
- #line 48
- static inline
- # 454 "../../tos/system/DrandM.nc"
- void DrandM$removeNodesForFrame(void)
- #line 454
- {
- int i;
- #line 456
- for (i = MAX_NBR - 1; i >= 0; i--) {
- if (DrandM$nbrInfo[i].nodeID == 0xFF) {
- continue;
- }
- else {
- #line 459
- if (DrandM$nbrInfo[i].frame == 0xFF) {
- {
- #line 461
- char bStatus;
- #line 461
- if (DBG_USR2 != 0) {
- #line 461
- bStatus = * (volatile uint8_t *)(uint16_t )& * (volatile uint8_t *)(0x3F + 0x20) & (1 << 7);
- #line 461
- __asm volatile ("cli");DrandM$sprintf(DrandM$debugbuf, "RemoveNodesForFrame: Removed node %un", DrandM$nbrInfo[i].nodeID);
- #line 461
- DrandM$writedebug();
- #line 461
- if (bStatus) {
- #line 461
- __asm volatile ("sei");
- }
- }
- }
- #line 461
- ;
- DrandM$removeNode(DrandM$nbrInfo[i].nodeID, DrandM$nbrInfo[i].bitMap);
- }
- }
- }
- }
- static inline
- #line 233
- bool DrandM$checkForRetransFrame(void)
- #line 233
- {
- uint8_t i;
- #line 235
- for (i = 0; i < MAX_NBR && DrandM$nbrInfo[i].nodeID != 0xFF; i++)
- if (DrandM$nbrInfo[i].frame == 0xFF) {
- return TRUE;
- }
- return FALSE;
- }
- static inline
- # 32 "TestBedTopologyM.nc"
- void TestBedTopologyM$Drand$gotFrame(void)
- #line 32
- {
- }
- # 5 "../../tos/interfaces/Drand.nc"
- inline static void DrandM$Drand$gotFrame(void){
- #line 5
- TestBedTopologyM$Drand$gotFrame();
- #line 5
- }
- #line 5
- static inline
- # 341 "../../tos/system/DrandM.nc"
- void DrandM$fillFrameInfo(frameMsg *pkt)
- #line 341
- {
- uint8_t i;
- #line 342
- uint8_t j;
- #line 343
- for (i = 0; i < MAX_ONE_HOP; i++) {
- pkt->oneHopNodeID[i] = 0xFF;
- pkt->frameArray[i] = 0xFF;
- }
- for (i = 0, j = 0; i < MAX_NBR && DrandM$nbrInfo[i].nodeID != 0xFF; i++)
- if (DrandM$nbrInfo[i].bitMap & ONE_HOP && DrandM$nbrInfo[i].frame != 0xFF) {
- pkt->oneHopNodeID[j] = DrandM$nbrInfo[i].nodeID;
- pkt->frameArray[j] = DrandM$nbrInfo[i].frame;
- j++;
- }
- }
- # 48 "/home/testuser/tinyos-1.x/tos/interfaces/SendMsg.nc"
- inline static result_t DrandM$SendFrameMsg$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_FRAME, arg_0x857ab18, arg_0x857ac60, arg_0x857adb0);
- #line 48
- #line 48
- return result;
- #line 48
- }
- #line 48
- # 37 "../../tos/platform/mica2/SpiByteFifo.nc"
- inline static result_t CC1000RadioIntM$SpiByteFifo$disableIntr(void){
- #line 37
- unsigned char result;
- #line 37
- #line 37
- result = HPLSpiM$SpiByteFifo$disableIntr();
- #line 37
- #line 37
- return result;
- #line 37
- }
- #line 37
- static inline
- # 1606 "../../tos/platform/mica2/CC1000RadioIntM.nc"
- void CC1000RadioIntM$SleepTimerTask(void)
- #line 1606
- {
- CC1000RadioIntM$WakeupTimer$start(TIMER_ONE_SHOT, CC1000RadioIntM$sleeptime);
- }
- static inline
- # 469 "../../tos/platform/mica2/CC1000ControlM.nc"
- result_t CC1000ControlM$StdControl$stop(void)
- #line 469
- {
- CC1000ControlM$HPLChipcon$write(0x00, (((((
- 1 << 5) | (1 << 4)) | (
- 1 << 3)) | (1 << 2)) | (1 << 1)) | (
- 1 << 0));
- CC1000ControlM$HPLChipcon$write(0x0B, 0x00);
- return SUCCESS;
- }
- # 78 "/home/testuser/tinyos-1.x/tos/interfaces/StdControl.nc"
- inline static result_t CC1000RadioIntM$CC1000StdControl$stop(void){
- #line 78
- unsigned char result;
- #line 78
- #line 78
- result = CC1000ControlM$StdControl$stop();
- #line 78
- #line 78
- return result;
- #line 78
- }
- #line 78
- static inline
- # 222 "../../tos/platform/mica2/ADCREFM.nc"
- result_t ADCREFM$ADC$getData(uint8_t port)
- #line 222
- {
- result_t Result;
- #line 224
- if (port > TOSH_ADC_PORTMAPSIZE) {
- return FAIL;
- }
- { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
- #line 228
- {
- Result = ADCREFM$startGet(port);
- }
- #line 230
- __nesc_atomic_end(__nesc_atomic); }
- return Result;
- }
- # 52 "/home/testuser/tinyos-1.x/tos/interfaces/ADC.nc"
- inline static result_t CC1000RadioIntM$RSSIADC$getData(void){
- #line 52
- unsigned char result;
- #line 52
- #line 52
- result = ADCREFM$ADC$getData(TOS_ADC_CC_RSSI_PORT);
- #line 52
- #line 52
- return result;
- #line 52
- }
- #line 52
- static inline
- # 1724 "../../tos/platform/mica2/CC1000RadioIntM.nc"
- uint16_t CC1000RadioIntM$GetSquelch(void)
- #line 1724
- {
- return CC1000RadioIntM$usSquelchVal;
- }
- static inline
- #line 1800
- int16_t CC1000RadioIntM$MacBackoff$default$congestionBackoff(TOS_MsgPtr m)
- #line 1800
- {
- CC1000RadioIntM$congBackOffs++;
- return (CC1000RadioIntM$Random$rand() & 0xF) + 1;
- }
- # 40 "../../tos/platform/mica2/MacBackoff.nc"
- inline static int16_t CC1000RadioIntM$MacBackoff$congestionBackoff(TOS_MsgPtr arg_0x86d70b0){
- #line 40
- int result;
- #line 40
- #line 40
- result = CC1000RadioIntM$MacBackoff$default$congestionBackoff(arg_0x86d70b0);
- #line 40
- #line 40
- return result;
- #line 40
- }
- #line 40
- # 143 "../../tos/platform/mica2/hardware.h"
- static __inline void TOSH_MAKE_MOSI_OUTPUT(void)
- #line 143
- {
- #line 143
- * (volatile uint8_t *)(0x17 + 0x20) |= 1 << 2;
- }
- #line 144
- static __inline void TOSH_MAKE_MISO_OUTPUT(void)
- #line 144
- {
- #line 144
- * (volatile uint8_t *)(0x17 + 0x20) |= 1 << 3;
- }
- static inline
- # 103 "../../tos/platform/mica2/HPLSpiM.nc"
- result_t HPLSpiM$SpiByteFifo$txMode(void)
- #line 103
- {
- TOSH_MAKE_MISO_OUTPUT();
- TOSH_MAKE_MOSI_OUTPUT();
- return SUCCESS;
- }
- # 39 "../../tos/platform/mica2/SpiByteFifo.nc"
- inline static result_t CC1000RadioIntM$SpiByteFifo$txMode(void){
- #line 39
- unsigned char result;
- #line 39
- #line 39
- result = HPLSpiM$SpiByteFifo$txMode();
- #line 39
- #line 39
- return result;
- #line 39
- }
- #line 39
- # 108 "../../tos/platform/mica2/CC1000Control.nc"
- inline static result_t CC1000RadioIntM$CC1000Control$TxMode(void){
- #line 108
- unsigned char result;
- #line 108
- #line 108
- result = CC1000ControlM$CC1000Control$TxMode();
- #line 108
- #line 108
- return result;
- #line 108
- }
- #line 108
- static inline
- # 59 "../../tos/platform/mica2/HPLSpiM.nc"
- result_t HPLSpiM$SpiByteFifo$writeByte(uint8_t data)
- #line 59
- {
- { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
- #line 62
- HPLSpiM$OutgoingByte = data;
- #line 62
- __nesc_atomic_end(__nesc_atomic); }
- return SUCCESS;
- }
- # 33 "../../tos/platform/mica2/SpiByteFifo.nc"
- inline static result_t CC1000RadioIntM$SpiByteFifo$writeByte(uint8_t arg_0x86fbd50){
- #line 33
- unsigned char result;
- #line 33
- #line 33
- result = HPLSpiM$SpiByteFifo$writeByte(arg_0x86fbd50);
- #line 33
- #line 33
- return result;
- #line 33
- }
- #line 33
- static inline
- # 1610 "../../tos/platform/mica2/CC1000RadioIntM.nc"
- result_t CC1000RadioIntM$RSSIADC$dataReady(uint16_t data)
- #line 1610
- {
- { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
- #line 1611
- {
- uint8_t currentRadioState;
- currentRadioState = CC1000RadioIntM$RadioState;
- switch (currentRadioState) {
- case CC1000RadioIntM$IDLE_STATE:
- if (CC1000RadioIntM$RSSIInitState == CC1000RadioIntM$IDLE_STATE) {
- CC1000RadioIntM$usTempSquelch = data;
- TOS_post(CC1000RadioIntM$adjustSquelch);
- }
- CC1000RadioIntM$RSSIInitState = CC1000RadioIntM$NULL_STATE;
- break;
- case CC1000RadioIntM$RX_STATE:
- if (CC1000RadioIntM$RSSIInitState == CC1000RadioIntM$RX_STATE) {
- CC1000RadioIntM$usRSSIVal = data;
- }
- CC1000RadioIntM$RSSIInitState = CC1000RadioIntM$NULL_STATE;
- break;
- case CC1000RadioIntM$PRETX_STATE:
- CC1000RadioIntM$iRSSIcount++;
- if ((
- #line 1636
- data > CC1000RadioIntM$usSquelchVal + 16 ||
- !CC1000RadioIntM$bCCAEnable) && CC1000RadioIntM$RSSIInitState == CC1000RadioIntM$PRETX_STATE) {
- CC1000RadioIntM$SpiByteFifo$writeByte(0xaa);
- CC1000RadioIntM$CC1000Control$TxMode();
- CC1000RadioIntM$SpiByteFifo$txMode();
- CC1000RadioIntM$usRSSIVal = data;
- CC1000RadioIntM$iRSSIcount = 5;
- CC1000RadioIntM$bRSSIValid = TRUE;
- CC1000RadioIntM$TxByteCnt = 0;
- CC1000RadioIntM$usRunningCRC = 0;
- CC1000RadioIntM$RadioState = CC1000RadioIntM$TX_STATE;
- CC1000RadioIntM$RadioTxState = CC1000RadioIntM$TXSTATE_PREAMBLE;
- CC1000RadioIntM$NextTxByte = 0xaa;
- CC1000RadioIntM$RSSIInitState = CC1000RadioIntM$NULL_STATE;
- }
- else {
- CC1000RadioIntM$RSSIInitState = CC1000RadioIntM$NULL_STATE;
- if (CC1000RadioIntM$iRSSIcount == 5) {
- CC1000RadioIntM$sMacDelay = CC1000RadioIntM$MacBackoff$congestionBackoff(CC1000RadioIntM$txbufptr);
- CC1000RadioIntM$RadioState = CC1000RadioIntM$IDLE_STATE;
- }
- else {
- CC1000RadioIntM$RSSIInitState = currentRadioState;
- CC1000RadioIntM$RSSIADC$getData();
- }
- }
- break;
- case CC1000RadioIntM$PULSE_CHECK_STATE:
- {
- uint8_t done = 0;
- uint16_t threshold = CC1000RadioIntM$GetSquelch();
- #line 1672
- threshold = threshold - (CC1000RadioIntM$GetSquelch() >> 2);
- if (data > threshold) {
- CC1000RadioIntM$usTempSquelch = data;
- TOS_post(CC1000RadioIntM$adjustSquelch);
- }
- else {
- #line 1678
- if (CC1000RadioIntM$pulse_check_count > 5) {
- CC1000RadioIntM$CC1000Control$RxMode();
- CC1000RadioIntM$RadioState = CC1000RadioIntM$IDLE_STATE;
- CC1000RadioIntM$SpiByteFifo$rxMode();
- CC1000RadioIntM$SpiByteFifo$enableIntr();
- TOS_post(CC1000RadioIntM$IdleTimerTask);
- done = 1;
- }
- else {
- CC1000RadioIntM$CC1000Control$RxMode();
- if (CC1000RadioIntM$RSSIADC$getData()) {
- TOSH_uwait(80);
- CC1000RadioIntM$pulse_check_count++;
- done = 1;
- }
- CC1000RadioIntM$pulse_check_sum++;
- CC1000RadioIntM$CC1000StdControl$stop();
- }
- }
- if (CC1000RadioIntM$bTxPending) {
- CC1000RadioIntM$CC1000Control$RxMode();
- CC1000RadioIntM$RadioState = CC1000RadioIntM$IDLE_STATE;
- CC1000RadioIntM$SpiByteFifo$rxMode();
- CC1000RadioIntM$SpiByteFifo$enableIntr();
- TOS_post(CC1000RadioIntM$IdleTimerTask);
- done = 1;
- }
- if (done == 0) {
- TOS_post(CC1000RadioIntM$SleepTimerTask);
- CC1000RadioIntM$RadioState = CC1000RadioIntM$POWER_DOWN_STATE;
- CC1000RadioIntM$SpiByteFifo$disableIntr();
- }
- }
- break;
- default: ;
- }
- }
- #line 1719
- __nesc_atomic_end(__nesc_atomic); }
- return SUCCESS;
- }
- static inline
- # 118 "../../tos/platform/mica2/ADCREFM.nc"
- result_t ADCREFM$ADC$default$dataReady(uint8_t port, uint16_t data)
- #line 118
- {
- return FAIL;
- }
- # 70 "/home/testuser/tinyos-1.x/tos/interfaces/ADC.nc"
- inline static result_t ADCREFM$ADC$dataReady(uint8_t arg_0x86d0c08, uint16_t arg_0x86fa7d8){
- #line 70
- unsigned char result;
- #line 70
- #line 70
- switch (arg_0x86d0c08) {
- #line 70
- case TOS_ADC_CC_RSSI_PORT:
- #line 70
- result = CC1000RadioIntM$RSSIADC$dataReady(arg_0x86fa7d8);
- #line 70
- break;
- #line 70
- default:
- #line 70
- result = ADCREFM$ADC$default$dataReady(arg_0x86d0c08, arg_0x86fa7d8);
- #line 70
- }
- #line 70
- #line 70
- return result;
- #line 70
- }
- #line 70
- static inline
- # 122 "../../tos/platform/mica2/ADCREFM.nc"
- result_t ADCREFM$CalADC$default$dataReady(uint8_t port, uint16_t data)
- #line 122
- {
- return FAIL;
- }
- # 70 "/home/testuser/tinyos-1.x/tos/interfaces/ADC.nc"
- inline static result_t ADCREFM$CalADC$dataReady(uint8_t arg_0x86d1290, uint16_t arg_0x86fa7d8){
- #line 70
- unsigned char result;
- #line 70
- #line 70
- result = ADCREFM$CalADC$default$dataReady(arg_0x86d1290, arg_0x86fa7d8);
- #line 70
- #line 70
- return result;
- #line 70
- }
- #line 70
- # 77 "/home/testuser/tinyos-1.x/tos/interfaces/HPLADC.nc"
- inline static result_t ADCREFM$HPLADC$samplePort(uint8_t arg_0x88aba00){
- #line 77
- unsigned char result;
- #line 77
- #line 77
- result = HPLADCM$ADC$samplePort(arg_0x88aba00);
- #line 77
- #line 77
- return result;
- #line 77
- }
- #line 77
- static inline
- # 133 "../../tos/platform/mica2/ADCREFM.nc"
- result_t ADCREFM$HPLADC$dataReady(uint16_t data)
- #line 133
- {
- uint16_t doneValue = data;
- uint8_t donePort;
- uint8_t nextPort = 0xff;
- bool fCalResult = FALSE;
- result_t Result = SUCCESS;
- #line 139
- if (ADCREFM$ReqPort == TOS_ADC_BANDGAP_PORT) {
- ADCREFM$RefVal = data;
- }
- { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
- #line 143
- {
- donePort = ADCREFM$ReqPort;
- if (((1 << donePort) & ADCREFM$ContReqMask) == 0) {
- ADCREFM$ReqVector ^= 1 << donePort;
- }
- if ((1 << donePort) & ADCREFM$CalReqMask) {
- fCalResult = TRUE;
- if (((1 << donePort) & ADCREFM$ContReqMask) == 0) {
- ADCREFM$CalReqMask ^= 1 << donePort;
- }
- }
- if (ADCREFM$ReqVector) {
- do {
- ADCREFM$ReqPort++;
- ADCREFM$ReqPort = ADCREFM$ReqPort == TOSH_ADC_PORTMAPSIZE ? 0 : ADCREFM$ReqPort;
- }
- while (((
- #line 164
- 1 << ADCREFM$ReqPort) & ADCREFM$ReqVector) == 0);
- nextPort = ADCREFM$ReqPort;
- }
- }
- #line 167
- __nesc_atomic_end(__nesc_atomic); }
- if (nextPort != 0xff) {
- ADCREFM$HPLADC$samplePort(nextPort);
- }
- {
- }
- #line 174
- ;
- if (donePort != TOS_ADC_BANDGAP_PORT) {
- if (fCalResult) {
- uint32_t tmp = (uint32_t )data;
- #line 178
- tmp = tmp << 10;
- tmp = tmp / ADCREFM$RefVal;
- doneValue = (uint16_t )tmp;
- Result = ADCREFM$CalADC$dataReady(donePort, doneValue);
- }
- else {
- Result = ADCREFM$ADC$dataReady(donePort, doneValue);
- }
- }
- { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
- #line 188
- {
- if (ADCREFM$ContReqMask & (1 << donePort) && Result == FAIL) {
- ADCREFM$ContReqMask ^= 1 << donePort;
- }
- }
- #line 192
- __nesc_atomic_end(__nesc_atomic); }
- return SUCCESS;
- }
- # 99 "/home/testuser/tinyos-1.x/tos/interfaces/HPLADC.nc"
- inline static result_t HPLADCM$ADC$dataReady(uint16_t arg_0x88c8548){
- #line 99
- unsigned char result;
- #line 99
- #line 99
- result = ADCREFM$HPLADC$dataReady(arg_0x88c8548);
- #line 99
- #line 99
- return result;
- #line 99
- }
- #line 99
- static inline
- # 97 "/home/testuser/tinyos-1.x/tos/platform/mica/HPLClock.nc"
- uint8_t HPLClock$Clock$getInterval(void)
- #line 97
- {
- return * (volatile uint8_t *)(0x31 + 0x20);
- }
- # 121 "/home/testuser/tinyos-1.x/tos/interfaces/Clock.nc"
- inline static uint8_t TimerM$Clock$getInterval(void){
- #line 121
- unsigned char result;
- #line 121
- #line 121
- result = HPLClock$Clock$getInterval();
- #line 121
- #line 121
- return result;
- #line 121
- }
- #line 121
- # 41 "/home/testuser/tinyos-1.x/tos/interfaces/PowerManagement.nc"
- inline static uint8_t TimerM$PowerManagement$adjustPower(void){
- #line 41
- unsigned char result;
- #line 41
- #line 41
- result = HPLPowerManagementM$PowerManagement$adjustPower();
- #line 41
- #line 41
- return result;
- #line 41
- }
- #line 41
- static inline
- # 87 "/home/testuser/tinyos-1.x/tos/platform/mica/HPLClock.nc"
- void HPLClock$Clock$setInterval(uint8_t value)
- #line 87
- {
- * (volatile uint8_t *)(0x31 + 0x20) = value;
- }
- # 105 "/home/testuser/tinyos-1.x/tos/interfaces/Clock.nc"
- inline static void TimerM$Clock$setInterval(uint8_t arg_0x88f08c8){
- #line 105
- HPLClock$Clock$setInterval(arg_0x88f08c8);
- #line 105
- }
- #line 105
- static inline
- # 134 "/home/testuser/tinyos-1.x/tos/platform/mica/HPLClock.nc"
- uint8_t HPLClock$Clock$readCounter(void)
- #line 134
- {
- return * (volatile uint8_t *)(0x32 + 0x20);
- }
- # 153 "/home/testuser/tinyos-1.x/tos/interfaces/Clock.nc"
- inline static uint8_t TimerM$Clock$readCounter(void){
- #line 153
- unsigned char result;
- #line 153
- #line 153
- result = HPLClock$Clock$readCounter();
- #line 153
- #line 153
- return result;
- #line 153
- }
- #line 153
- # 129 "/home/testuser/tinyos-1.x/tos/system/TimerM.nc"
- static void TimerM$adjustInterval(void)
- #line 129
- {
- uint8_t i;
- #line 130
- uint8_t val = TimerM$maxTimerInterval;
- #line 131
- if (TimerM$mState) {
- for (i = 0; i < NUM_TIMERS; i++) {
- if (TimerM$mState & (0x1L << i) && TimerM$mTimerList[i].ticksLeft < val) {
- val = TimerM$mTimerList[i].ticksLeft;
- }
- }
- #line 148
- { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
- #line 148
- {
- i = TimerM$Clock$readCounter() + 3;
- if (val < i) {
- val = i;
- }
- TimerM$mInterval = val;
- TimerM$Clock$setInterval(TimerM$mInterval);
- TimerM$setIntervalFlag = 0;
- }
- #line 156
- __nesc_atomic_end(__nesc_atomic); }
- }
- else {
- { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
- #line 159
- {
- TimerM$mInterval = TimerM$maxTimerInterval;
- TimerM$Clock$setInterval(TimerM$mInterval);
- TimerM$setIntervalFlag = 0;
- }
- #line 163
- __nesc_atomic_end(__nesc_atomic); }
- }
- TimerM$PowerManagement$adjustPower();
- }
- static inline
- #line 186
- void TimerM$enqueue(uint8_t value)
- #line 186
- {
- if (TimerM$queue_tail == NUM_TIMERS - 1) {
- TimerM$queue_tail = -1;
- }
- #line 189
- TimerM$queue_tail++;
- TimerM$queue_size++;
- TimerM$queue[(uint8_t )TimerM$queue_tail] = value;
- }
- static inline
- # 1498 "../../tos/system/DrandM.nc"
- void DrandM$drandRoundOver(void)
- #line 1498
- {
- uint8_t randNum;
- #line 1499
- uint8_t contender;
- #line 1500
- { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
- #line 1500
- {
- DrandM$sentRelease = FALSE;
- DrandM$firstGrant = TRUE;
- DrandM$roundNum++;
- randNum = DrandM$randNew();
- contender = DrandM$getContenders();
- if (randNum % contender == 0) {
- DrandM$globalState = REQUEST_STATE;
- DrandM$SClock$getTime(&DrandM$roundStartTime);
- DrandM$requestFireCount = 0;
- DrandM$sendRequestMsg();
- }
- else
- #line 1526
- {
- DrandM$drandRoundTimer$start(TIMER_ONE_SHOT, DrandM$ROUND_TIME);
- }
- DrandM$lastReqID = 0xff;
- }
- #line 1534
- __nesc_atomic_end(__nesc_atomic); }
- }
- static inline
- #line 1582
- result_t DrandM$drandRoundTimer$fired(void)
- #line 1582
- {
- if (DrandM$globalState == IDLE_STATE2) {
- DrandM$drandRoundOver();
- }
- #line 1585
- return SUCCESS;
- }
- # 48 "/home/testuser/tinyos-1.x/tos/interfaces/SendMsg.nc"
- inline static result_t DrandM$SendGrantMsg$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_GRANT, arg_0x857ab18, arg_0x857ac60, arg_0x857adb0);
- #line 48
- #line 48
- return result;
- #line 48
- }
- #line 48
- static inline
- # 330 "../../tos/system/DrandM.nc"
- void DrandM$fillTimeSlotInfo(uint8_t *array)
- #line 330
- {
- uint8_t i;
- #line 332
- for (i = 0; i < MAX_NBR; i++)
- array[i] = 0xFF;
- for (i = 0; i < MAX_NBR && DrandM$nbrInfo[i].nodeID != 0xFF; i++)
- if (DrandM$nbrInfo[i].slot != 0xFF && DrandM$nbrInfo[i].bitMap & ONE_HOP) {
- array[DrandM$nbrInfo[i].slot] = DrandM$nbrInfo[i].nodeID;
- }
- #line 337
- if (DrandM$setMySlot) {
- array[DrandM$myInfo.slot] = TOS_LOCAL_ADDRESS;
- }
- }
- static inline
- #line 761
- void DrandM$sendGrantMsg(uint8_t msgADDR)
- #line 761
- {
- { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
- #line 762
- {
- if (!DrandM$sendBusy) {
- grantMsg *grantMsgData = (grantMsg *)DrandM$DataPkt.data;
- #line 765
- grantMsgData->sendID = TOS_LOCAL_ADDRESS;
- grantMsgData->myState = DrandM$globalState;
- grantMsgData->lastRequestID = DrandM$lastReqID;
- grantMsgData->roundNum = DrandM$roundNum;
- grantMsgData->timestamp = DrandM$requestStartTime;
- DrandM$fillTimeSlotInfo(grantMsgData->timeSlot);
- if (DrandM$SendGrantMsg$send((uint16_t )msgADDR, sizeof(grantMsg ), &DrandM$DataPkt) != SUCCESS) {
- DrandM$reXTimer$start(TIMER_ONE_SHOT, DrandM$GRANT_TIME);
- }
- else
- {
- DrandM$sendBusy = TRUE;
- }
- }
- else
- #line 783
- {
- DrandM$reXTimer$start(TIMER_ONE_SHOT, DrandM$GRANT_TIME);
- }
- }
- #line 786
- __nesc_atomic_end(__nesc_atomic); }
- }
- static inline
- #line 424
- void DrandM$removeNodeForGrant(uint8_t nodeID)
- #line 424
- {
- int i;
- #line 426
- for (i = MAX_NBR - 1; i >= 0; i--) {
- if (DrandM$nbrInfo[i].nodeID == 0xFF) {
- continue;
- }
- else {
- #line 429
- if (DrandM$nbrInfo[i].nodeID == nodeID) {
- {
- #line 431
- char bStatus;
- #line 431
- if (DBG_USR2 != 0) {
- #line 431
- bStatus = * (volatile uint8_t *)(uint16_t )& * (volatile uint8_t *)(0x3F + 0x20) & (1 << 7);
- #line 431
- __asm volatile ("cli");DrandM$sprintf(DrandM$debugbuf, "RemoveNodeForGrant: Changed %u to Two Hopn", DrandM$nbrInfo[i].nodeID);
- #line 431
- DrandM$writedebug();
- #line 431
- if (bStatus) {
- #line 431
- __asm volatile ("sei");
- }
- }
- }
- #line 431
- ;
- DrandM$nbrInfo[i].bitMap = TWO_HOP;
- return;
- }
- }
- }
- }
- static inline
- #line 1425
- void DrandM$reXGrant(void)
- #line 1425
- {
- { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
- #line 1426
- {
- if (DrandM$grantFireCount > MAX_GRANT) {
- DrandM$removeNodeForGrant(DrandM$lastReqID);
- 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;
- }
- else
- #line 1445
- {
- DrandM$sendGrantMsg(DrandM$lastReqID);
- }
- }
- #line 1451
- __nesc_atomic_end(__nesc_atomic); }
- }
- static inline
- #line 409
- void DrandM$removeNodesForRequest(void)
- #line 409
- {
- int i;
- #line 411
- for (i = MAX_NBR - 1; i >= 0; i--) {
- if (DrandM$nbrInfo[i].nodeID == 0xFF) {
- continue;
- }
- else {
- #line 414
- if (DrandM$nbrInfo[i].bitMap & ONE_HOP && !(DrandM$nbrInfo[i].bitMap & GRANT_SENT)) {
- {
- #line 416
- char bStatus;
- #line 416
- if (DBG_USR2 != 0) {
- #line 416
- bStatus = * (volatile uint8_t *)(uint16_t )& * (volatile uint8_t *)(0x3F + 0x20) & (1 << 7);
- #line 416
- __asm volatile ("cli");DrandM$sprintf(DrandM$debugbuf, "RemoveNodesForRequest: Changed %u to Two Hopn", DrandM$nbrInfo[i].nodeID);
- #line 416
- DrandM$writedebug();
- #line 416
- if (bStatus) {
- #line 416
- __asm volatile ("sei");
- }
- }
- }
- #line 416
- ;
- DrandM$nbrInfo[i].bitMap = TWO_HOP;
- }
- }
- }
- }
- static inline
- #line 1399
- void DrandM$reXRequest(void)
- #line 1399
- {
- { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
- #line 1400
- {
- if (DrandM$requestFireCount > MAX_REQUEST) {
- DrandM$removeNodesForRequest();
- if (DrandM$numGrantsRemaining() == 0 && !DrandM$setMySlot) {
- DrandM$setSlot();
- DrandM$timeCheck();
- DrandM$printNbrInfo();
- }
- }
- else
- {
- DrandM$sendRequestMsg();
- }
- }
- #line 1422
- __nesc_atomic_end(__nesc_atomic); }
- }
- static inline
- #line 1393
- void DrandM$reXHello(void)
- #line 1393
- {
- { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
- #line 1394
- {
- DrandM$sendHelloMsg();
- }
- #line 1396
- __nesc_atomic_end(__nesc_atomic); }
- }
- static inline
- #line 1537
- result_t DrandM$reXTimer$fired(void)
- #line 1537
- {
- { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
- #line 1538
- {
- switch (DrandM$globalState) {
- case HELLO_STATE:
- DrandM$reXHello();
- break;
- case REQUEST_STATE:
- DrandM$reXRequest();
- break;
- case GRANT_STATE:
- DrandM$reXGrant();
- break;
- case REPORT_STATE:
- DrandM$reXReport();
- break;
- case FRAME_STATE:
- DrandM$reXFrame();
- break;
- }
- }
- #line 1556
- __nesc_atomic_end(__nesc_atomic); }
- return SUCCESS;
- }
- static inline
- # 33 "TestBedTopologyM.nc"
- void TestBedTopologyM$Drand$helloOver(void)
- #line 33
- {
- }
- # 6 "../../tos/interfaces/Drand.nc"
- inline static void DrandM$Drand$helloOver(void){
- #line 6
- TestBedTopologyM$Drand$helloOver();
- #line 6
- }
- #line 6
- static inline
- # 1454 "../../tos/system/DrandM.nc"
- void DrandM$helloOver(void)
- #line 1454
- {
- uint8_t i;
- #line 1455
- uint8_t randNum;
- #line 1455
- uint8_t contender;
- #line 1456
- DrandM$Drand$helloOver();
- { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
- #line 1458
- {
- DrandM$globalState = IDLE_STATE2;
- DrandM$reXTimer$stop();
- DrandM$SClock$getTime(&DrandM$drandStartTime);
- for (i = 0; i < MAX_NBR; i++)
- DrandM$addNode(DrandM$TwoWayId[i], ONE_HOP);
- DrandM$printNbrInfo();
- contender = DrandM$getContenders();
- randNum = DrandM$randNew();
- if (randNum % contender == 0) {
- DrandM$globalState = REQUEST_STATE;
- DrandM$requestFireCount = 0;
- DrandM$SClock$getTime(&DrandM$roundStartTime);
- DrandM$sendRequestMsg();
- }
- else {
- #line 1494
- DrandM$drandRoundTimer$start(TIMER_ONE_SHOT, DrandM$ROUND_TIME);
- }
- }
- #line 1496
- __nesc_atomic_end(__nesc_atomic); }
- }
- static inline
- #line 1560
- result_t DrandM$roundTimer$fired(void)
- #line 1560
- {
- { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
- #line 1561
- {
- switch (DrandM$globalState) {
- case HELLO_STATE:
- DrandM$helloOver();
- DrandM$roundTimer$start(TIMER_ONE_SHOT, DRAND_PERIOD);
- break;
- case RELEASE_STATE:
- DrandM$globalState = REPORT_STATE;
- DrandM$reXReport();
- DrandM$roundTimer$start(TIMER_ONE_SHOT, REPORT_PERIOD);
- break;
- case REPORT_STATE:
- DrandM$setFrame();
- DrandM$globalState = FRAME_STATE;
- DrandM$reXFrame();
- break;
- }
- }
- #line 1578
- __nesc_atomic_end(__nesc_atomic); }
- return SUCCESS;
- }
- static inline
- # 151 "/home/testuser/tinyos-1.x/tos/system/AMStandard.nc"
- result_t AMStandard$ActivityTimer$fired(void)
- #line 151
- {
- AMStandard$lastCount = AMStandard$counter;
- AMStandard$counter = 0;
- return SUCCESS;
- }
- # 59 "/home/testuser/tinyos-1.x/tos/interfaces/Timer.nc"
- inline static result_t CC1000RadioIntM$TDMATimer$start(char arg_0x85800e0, uint32_t arg_0x8580238){
- #line 59
- unsigned char result;
- #line 59
- #line 59
- result = TimerM$Timer$start(6, arg_0x85800e0, arg_0x8580238);
- #line 59
- #line 59
- return result;
- #line 59
- }
- #line 59
- static inline
- # 980 "../../tos/platform/mica2/CC1000RadioIntM.nc"
- result_t CC1000RadioIntM$TDMATimer$fired(void)
- #line 980
- {
- CC1000RadioIntM$TDMATimer$start(TIMER_ONE_SHOT, CC1000RadioIntM$slotMultiplier);
- CC1000RadioIntM$slotNum++;
- { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
- #line 983
- CC1000RadioIntM$currentMAC = CC1000RadioIntM$ZMAC;
- #line 983
- __nesc_atomic_end(__nesc_atomic); }
- { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
- #line 984
- {
- CC1000RadioIntM$currentSlot = CC1000RadioIntM$slotNum & (CC1000RadioIntM$localFrameLength - 1);
- CC1000RadioIntM$globalSlot = CC1000RadioIntM$slotNum & (CC1000RadioIntM$globalFrameLength - 1);
- if (CC1000RadioIntM$HCLselect) {
- CC1000RadioIntM$slots_since_ecnsend++;
- CC1000RadioIntM$slots_since_ecnrecv++;
- CC1000RadioIntM$slots_since_ecncheck++;
- if (CC1000RadioIntM$packetsSent > 10 && CC1000RadioIntM$slots_since_ecncheck >= 16) {
- double currentLoss = (double )CC1000RadioIntM$congBackOffs / CC1000RadioIntM$packetsSent;
- #line 996
- CC1000RadioIntM$avgLoss = 0.25 * currentLoss + (1 - 0.25) * CC1000RadioIntM$avgLoss;
- CC1000RadioIntM$slots_since_ecncheck = 0;
- CC1000RadioIntM$congBackOffs = 0;
- CC1000RadioIntM$packetsSent = 0;
- if (CC1000RadioIntM$avgLoss > 3.0 && CC1000RadioIntM$slots_since_ecnsend >= 96) {
- ecnMsgType *ecnMsgPtr = (ecnMsgType *)CC1000RadioIntM$ecnMsgHdr.data;
- CC1000RadioIntM$enableHCL = TRUE;
- CC1000RadioIntM$slots_since_ecnrecv = 0;
- ecnMsgPtr->nextHop = CC1000RadioIntM$nextHop;
- if (!CC1000RadioIntM$pureHCL) {
- CC1000RadioIntM$ecnPending = TRUE;
- }
- }
- }
- #line 1018
- if (CC1000RadioIntM$enableHCL && CC1000RadioIntM$slots_since_ecnrecv >= 192) {
- if (!CC1000RadioIntM$pureHCL) {
- CC1000RadioIntM$enableHCL = FALSE;
- }
- }
- }
- #line 1036
- if (CC1000RadioIntM$bTxPending) {
- CC1000RadioIntM$sMacDelay = CC1000RadioIntM$getZMACBackoff(CC1000RadioIntM$sMacDelay);
- }
- }
- #line 1039
- __nesc_atomic_end(__nesc_atomic); }
- return SUCCESS;
- }
- # 68 "/home/testuser/tinyos-1.x/tos/interfaces/Timer.nc"
- inline static result_t CC1000RadioIntM$SquelchTimer$stop(void){
- #line 68
- unsigned char result;
- #line 68
- #line 68
- result = TimerM$Timer$stop(4);
- #line 68
- #line 68
- return result;
- #line 68
- }
- #line 68
- static inline
- # 927 "../../tos/platform/mica2/CC1000RadioIntM.nc"
- result_t CC1000RadioIntM$WakeupTimer$fired(void)
- #line 927
- {
- uint8_t currentRadioState;
- if (CC1000RadioIntM$lplpower == 0) {
- return SUCCESS;
- }
- { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
- #line 933
- currentRadioState = CC1000RadioIntM$RadioState;
- #line 933
- __nesc_atomic_end(__nesc_atomic); }
- switch (currentRadioState) {
- case CC1000RadioIntM$IDLE_STATE:
- if (!CC1000RadioIntM$bTxPending) {
- { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
- #line 938
- {
- CC1000RadioIntM$RadioState = CC1000RadioIntM$POWER_DOWN_STATE;
- CC1000RadioIntM$SpiByteFifo$disableIntr();
- }
- #line 941
- __nesc_atomic_end(__nesc_atomic); }
- CC1000RadioIntM$WakeupTimer$start(TIMER_ONE_SHOT, CC1000RadioIntM$sleeptime);
- CC1000RadioIntM$SquelchTimer$stop();
- CC1000RadioIntM$CC1000StdControl$stop();
- }
- else
- #line 945
- {
- CC1000RadioIntM$WakeupTimer$start(TIMER_ONE_SHOT, CC1000RadioIntM$sleeptime);
- }
- break;
- case CC1000RadioIntM$POWER_DOWN_STATE:
- { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
- #line 951
- CC1000RadioIntM$RadioState = CC1000RadioIntM$PULSE_CHECK_STATE;
- #line 951
- __nesc_atomic_end(__nesc_atomic); }
- CC1000RadioIntM$pulse_check_count = 0;
- CC1000RadioIntM$CC1000StdControl$start();
- CC1000RadioIntM$CC1000Control$BIASOn();
- CC1000RadioIntM$WakeupTimer$start(TIMER_ONE_SHOT, 1);
- return SUCCESS;
- break;
- case CC1000RadioIntM$PULSE_CHECK_STATE:
- CC1000RadioIntM$CC1000Control$RxMode();
- if (!CC1000RadioIntM$RSSIADC$getData()) {
- CC1000RadioIntM$WakeupTimer$start(TIMER_ONE_SHOT, CC1000RadioIntM$TIME_BETWEEN_CHECKS);
- { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
- #line 963
- CC1000RadioIntM$RadioState = CC1000RadioIntM$POWER_DOWN_STATE;
- #line 963
- __nesc_atomic_end(__nesc_atomic); }
- }
- else {
- TOSH_uwait(80);
- }
- CC1000RadioIntM$CC1000StdControl$stop();
- CC1000RadioIntM$pulse_check_sum++;
- break;
- default:
- CC1000RadioIntM$WakeupTimer$start(TIMER_ONE_SHOT, 5);
- }
- return SUCCESS;
- }
- static inline
- #line 916
- result_t CC1000RadioIntM$SquelchTimer$fired(void)
- #line 916
- {
- char currentRadioState;
- #line 918
- { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
- #line 918
- currentRadioState = CC1000RadioIntM$RadioState;
- #line 918
- __nesc_atomic_end(__nesc_atomic); }
- if (currentRadioState == CC1000RadioIntM$IDLE_STATE) {
- { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
- #line 921
- CC1000RadioIntM$RSSIInitState = currentRadioState;
- #line 921
- __nesc_atomic_end(__nesc_atomic); }
- CC1000RadioIntM$RSSIADC$getData();
- }
- return SUCCESS;
- }
- static inline
- # 284 "../../tos/platform/mica2/ADCREFM.nc"
- result_t ADCREFM$ADCControl$manualCalibrate(void)
- #line 284
- {
- result_t Result;
- { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
- #line 287
- {
- Result = ADCREFM$startGet(TOS_ADC_BANDGAP_PORT);
- }
- #line 289
- __nesc_atomic_end(__nesc_atomic); }
- return Result;
- }
- static inline
- #line 92
- void ADCREFM$CalTask(void)
- #line 92
- {
- ADCREFM$ADCControl$manualCalibrate();
- return;
- }
- static inline
- #line 126
- result_t ADCREFM$Timer$fired(void)
- #line 126
- {
- TOS_post(ADCREFM$CalTask);
- return SUCCESS;
- }
- static inline
- # 182 "/home/testuser/tinyos-1.x/tos/system/TimerM.nc"
- result_t TimerM$Timer$default$fired(uint8_t id)
- #line 182
- {
- return SUCCESS;
- }
- # 73 "/home/testuser/tinyos-1.x/tos/interfaces/Timer.nc"
- inline static result_t TimerM$Timer$fired(uint8_t arg_0x88d4158){
- #line 73
- unsigned char result;
- #line 73
- #line 73
- switch (arg_0x88d4158) {
- #line 73
- case 0:
- #line 73
- result = DrandM$roundTimer$fired();
- #line 73
- break;
- #line 73
- case 1:
- #line 73
- result = DrandM$reXTimer$fired();
- #line 73
- break;
- #line 73
- case 2:
- #line 73
- result = DrandM$drandRoundTimer$fired();
- #line 73
- break;
- #line 73
- case 3:
- #line 73
- result = AMStandard$ActivityTimer$fired();
- #line 73
- break;
- #line 73
- case 4:
- #line 73
- result = CC1000RadioIntM$SquelchTimer$fired();
- #line 73
- break;
- #line 73
- case 5:
- #line 73
- result = CC1000RadioIntM$WakeupTimer$fired();
- #line 73
- break;
- #line 73
- case 6:
- #line 73
- result = CC1000RadioIntM$TDMATimer$fired();
- #line 73
- break;
- #line 73
- case 7:
- #line 73
- result = ADCREFM$Timer$fired();
- #line 73
- break;
- #line 73
- default:
- #line 73
- result = TimerM$Timer$default$fired(arg_0x88d4158);
- #line 73
- }
- #line 73
- #line 73
- return result;
- #line 73
- }
- #line 73
- static inline
- # 194 "/home/testuser/tinyos-1.x/tos/system/TimerM.nc"
- uint8_t TimerM$dequeue(void)
- #line 194
- {
- if (TimerM$queue_size == 0) {
- return NUM_TIMERS;
- }
- #line 197
- if (TimerM$queue_head == NUM_TIMERS - 1) {
- TimerM$queue_head = -1;