📄 app.c
字号:
# 76 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/sched.c"void TOSH_sched_init(void ){ TOSH_sched_free = 0; TOSH_sched_full = 0;}static inline # 108 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/tos.h"result_t rcombine(result_t r1, result_t r2){ return r1 == FAIL ? FAIL : r2;}static inline # 58 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/LedsC.nc"result_t LedsC$Leds$init(void)#line 58{ { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();#line 59 { LedsC$ledsOn = 0; { }#line 61 ; TOSH_SET_RED_LED_PIN(); TOSH_SET_YELLOW_LED_PIN(); TOSH_SET_GREEN_LED_PIN(); }#line 65 __nesc_atomic_end(__nesc_atomic); } return SUCCESS;}# 56 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/Leds.nc"inline static result_t BlinkM$Leds$init(void){#line 56 unsigned char result;#line 56#line 56 result = LedsC$Leds$init();#line 56#line 56 return result;#line 56}#line 56static inline # 52 "BlinkM.nc"result_t BlinkM$StdControl$init(void)#line 52{ BlinkM$Leds$init(); return SUCCESS;}static inline # 118 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/CC2430/HPLClock.nc"result_t HPLClock$Clock$setRate(uint16_t interval, uint8_t scale)#line 118{ scale &= 0x3; { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();#line 121 { T1CTL |= scale << 2; T1CC0L = (uint8_t )interval; T1CC0H = (uint8_t )(interval >> 8); T1IE = 1; }#line 127 __nesc_atomic_end(__nesc_atomic); } return SUCCESS;}# 96 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/CC2430/Clock.nc"inline static result_t TimerM$Clock$setRate(uint16_t arg_0xa27da28, uint8_t arg_0xa27db70){#line 96 unsigned char result;#line 96#line 96 result = HPLClock$Clock$setRate(arg_0xa27da28, arg_0xa27db70);#line 96#line 96 return result;#line 96}#line 96static inline # 34 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/CC2430/TimerM.nc"result_t TimerM$StdControl$init(void)#line 34{ TimerM$mState = 0; TimerM$setIntervalFlag = 0; TimerM$queue_head = TimerM$queue_tail = -1; TimerM$queue_size = 0; TimerM$mScale = 3; TimerM$mInterval = 0xffff;#line 40 ; return TimerM$Clock$setRate(TimerM$mInterval, TimerM$mScale);}# 63 "C:/tinyos/cygwin/opt/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, BlinkM$StdControl$init());#line 63#line 63 return result;#line 63}#line 63# 41 "C:/tinyos/cygwin/opt/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 41static inline # 45 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/CC2430/HPLClock.nc"void HPLClock$Clock$setInterval(uint16_t value)#line 45{ T1CC0L = (uint8_t )value; T1CC0H = (uint8_t )(value >> 8);}# 105 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/CC2430/Clock.nc"inline static void TimerM$Clock$setInterval(uint16_t arg_0xa2768d0){#line 105 HPLClock$Clock$setInterval(arg_0xa2768d0);#line 105}#line 105static inline # 55 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/CC2430/TimerM.nc"result_t TimerM$Timer$start(uint8_t id, char type, uint16_t interval)#line 56{ uint16_t diff;#line 58 if (id >= NUM_TIMERS) {#line 58 return FAIL; }#line 59 if (type > 1) {#line 59 return FAIL; }#line 60 TimerM$mTimerList[id].ticks = interval; TimerM$mTimerList[id].type = type; { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();#line 63 { diff = T1CNTH; diff = diff << 8; diff += T1CNTL; interval += diff; TimerM$mTimerList[id].ticksLeft = interval; TimerM$mState |= 0x1 << id; if (interval < TimerM$mInterval) { TimerM$mInterval = interval; TimerM$Clock$setInterval(TimerM$mInterval); TimerM$setIntervalFlag = 0; T1CTL |= 0x2; T1IE = 1; TimerM$PowerManagement$adjustPower(); } }#line 78 __nesc_atomic_end(__nesc_atomic); } return SUCCESS;}# 59 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/CC2430/Timer.nc"inline static result_t BlinkM$Timer$start(char arg_0xa254a38, uint16_t arg_0xa254b90){#line 59 unsigned char result;#line 59#line 59 result = TimerM$Timer$start(0, arg_0xa254a38, arg_0xa254b90);#line 59#line 59 return result;#line 59}#line 59static inline # 63 "BlinkM.nc"result_t BlinkM$StdControl$start(void)#line 63{ return BlinkM$Timer$start(TIMER_REPEAT, 65534);}static inline # 44 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/CC2430/TimerM.nc"result_t TimerM$StdControl$start(void)#line 44{ return SUCCESS;}# 70 "C:/tinyos/cygwin/opt/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, BlinkM$StdControl$start());#line 70#line 70 return result;#line 70}#line 70static inline # 27 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/CC2430/HPLPowerManagementM.nc"uint8_t HPLPowerManagementM$getPowerLevel(void)#line 27{ if ((T1IE | T3IE) | T4IE) { return HPLPowerManagementM$IDLE; } else {#line 32 if (((#line 31 (unsigned char *)0)[0xDF62] & 0x10) & (((unsigned char *)0)[0xDF62] & 0x08)) { return HPLPowerManagementM$IDLE; } else { if (T2IE) { return HPLPowerManagementM$POWER_SAVE; } else #line 43 { return HPLPowerManagementM$POWER_DOWN; } } }}static inline #line 48void HPLPowerManagementM$doAdjustment(void)#line 48{ uint8_t foo;#line 49 uint8_t mcu;#line 50 foo = HPLPowerManagementM$getPowerLevel(); mcu = SLEEP; mcu &= 0xfc; if (foo == HPLPowerManagementM$IDLE || foo == HPLPowerManagementM$ADC_NR) { return; } else {#line 55 if (foo == HPLPowerManagementM$EXT_STANDBY || foo == HPLPowerManagementM$POWER_SAVE) { mcu |= HPLPowerManagementM$IDLE; mcu &= 0xfc; } }#line 62 mcu |= foo; SLEEP = mcu; PCON |= 1 << 0;}static # 131 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/CC2430/CC2430hardware.h"__inline void __nesc_enable_interrupt(void)#line 131{ EA = 1;}static inline #line 100void TOSH_wait(void){ __asm ("NOP"); __asm ("NOP");}static inline void TOSH_sleep(void){}#line 125__inline void __nesc_atomic_end(__nesc_atomic_t oldSreg){ PSW = oldSreg; EA = 1;}#line 118__inline __nesc_atomic_t __nesc_atomic_start(void ){ __nesc_atomic_t result = PSW;#line 121 EA = 0; return result;}static inline # 139 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/sched.c"bool TOSH_run_next_task(void)#line 139{ __nesc_atomic_t fInterruptFlags; uint8_t old_full; void (*func)(void ); if (TOSH_sched_full == TOSH_sched_free) { return 0; } else { fInterruptFlags = __nesc_atomic_start(); old_full = TOSH_sched_full; TOSH_sched_full++; TOSH_sched_full &= TOSH_TASK_BITMASK; func = TOSH_queue[(int )old_full].tp; TOSH_queue[(int )old_full].tp = 0; __nesc_atomic_end(fInterruptFlags); func(); return 1; }}static inline void TOSH_run_task(void)#line 162{ while (TOSH_run_next_task()) ; TOSH_sleep(); TOSH_wait();}# 82 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/CC2430/TimerM.nc"static void TimerM$adjustInterval(void)#line 82{ uint8_t i; uint16_t val = 0xffff;#line 84 ; if (TimerM$mState) { for (i = 0; i < NUM_TIMERS; i++) { if (TimerM$mState & (0x1 << i) && TimerM$mTimerList[i].ticksLeft < val) { val = TimerM$mTimerList[i].ticksLeft; } } { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();#line 91 { TimerM$mInterval = val; TimerM$Clock$setInterval(TimerM$mInterval); TimerM$setIntervalFlag = 0; }#line 95 __nesc_atomic_end(__nesc_atomic); } } else { { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();#line 98 { TimerM$mInterval = 0xffff;#line 99 ; TimerM$Clock$setInterval(TimerM$mInterval); TimerM$setIntervalFlag = 0; }#line 102 __nesc_atomic_end(__nesc_atomic); } } TimerM$PowerManagement$adjustPower();}# 34 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/CC2430/hardware.h"static __inline void TOSH_CLR_RED_LED_PIN(void)#line 34{#line 34 P1 &= ~(1 << 1);}static inline # 69 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/LedsC.nc"result_t LedsC$Leds$redOn(void)#line 69{ { }#line 70 ; { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();#line 71 { TOSH_CLR_RED_LED_PIN(); LedsC$ledsOn |= LedsC$RED_BIT; }#line 74 __nesc_atomic_end(__nesc_atomic); } return SUCCESS;}static inline result_t LedsC$Leds$redOff(void)#line 78{ { }#line 79 ; { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();#line 80 { TOSH_SET_RED_LED_PIN(); LedsC$ledsOn &= ~LedsC$RED_BIT; }#line 83 __nesc_atomic_end(__nesc_atomic); } return SUCCESS;}static inline result_t LedsC$Leds$redToggle(void)#line 87{ result_t rval;#line 89 { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();#line 89 { if (LedsC$ledsOn & LedsC$RED_BIT) { rval = LedsC$Leds$redOff(); } else {#line 93 rval = LedsC$Leds$redOn(); } }#line 95 __nesc_atomic_end(__nesc_atomic); }#line 95 return rval;}# 81 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/Leds.nc"inline static result_t BlinkM$Leds$redToggle(void){#line 81 unsigned char result;#line 81#line 81 result = LedsC$Leds$redToggle();#line 81#line 81 return result;#line 81}#line 81static inline # 84 "BlinkM.nc"result_t BlinkM$Timer$fired(void){ BlinkM$Leds$redToggle(); return SUCCESS;}static inline # 122 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/CC2430/TimerM.nc"result_t TimerM$Timer$default$fired(uint8_t id)#line 122{ return SUCCESS;}# 73 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/CC2430/Timer.nc"inline static result_t TimerM$Timer$fired(uint8_t arg_0xa25ea88){#line 73 unsigned char result;#line 73#line 73 switch (arg_0xa25ea88) {#line 73 case 0:#line 73 result = BlinkM$Timer$fired();#line 73 break;#line 73 default:#line 73 result = TimerM$Timer$default$fired(arg_0xa25ea88);#line 73 }#line 73#line 73 return result;#line 73}#line 73static inline # 134 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/CC2430/TimerM.nc"uint8_t TimerM$dequeue(void)#line 134{ if (TimerM$queue_size == 0) { return NUM_TIMERS; }#line 137 if (TimerM$queue_head == NUM_TIMERS - 1) { TimerM$queue_head = -1; }#line 139 TimerM$queue_head++; TimerM$queue_size--; return TimerM$queue[(uint8_t )TimerM$queue_head];}static inline void TimerM$signalOneTimer(void)#line 144{ uint8_t itimer = TimerM$dequeue();#line 146 if (itimer < NUM_TIMERS) { TimerM$Timer$fired(itimer); }}static inline #line 126void TimerM$enqueue(uint8_t value)#line 126{ if (TimerM$queue_tail == NUM_TIMERS - 1) { TimerM$queue_tail = -1; }#line 129 TimerM$queue_tail++; TimerM$queue_size++; TimerM$queue[(uint8_t )TimerM$queue_tail] = value;}static inline #line 150void TimerM$HandleFire(void)#line 150{ uint8_t i;#line 152 TimerM$setIntervalFlag = 1; if (TimerM$mState) { for (i = 0; i < NUM_TIMERS; i++) { if (TimerM$mState & (0x1 << i)) { TimerM$mTimerList[i].ticksLeft -= TimerM$mInterval + 1; if (TimerM$mTimerList[i].ticksLeft <= 2) { if (TimerM$mTimerList[i].type == TIMER_REPEAT) { TimerM$mTimerList[i].ticksLeft += TimerM$mTimerList[i].ticks; } else #line 160 { TimerM$mState &= ~(0x1 << i); } TimerM$enqueue(i); TOS_post(TimerM$signalOneTimer); } } } } TimerM$adjustInterval();}static inline result_t TimerM$Clock$fire(void)#line 172{ TOS_post(TimerM$HandleFire); return SUCCESS;}# 180 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/CC2430/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# 98 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/sched.c"bool TOS_post(void (*tp)(void))#line 98{ __nesc_atomic_t fInterruptFlags; uint8_t tmp; fInterruptFlags = __nesc_atomic_start(); tmp = TOSH_sched_free; TOSH_sched_free++; TOSH_sched_free &= TOSH_TASK_BITMASK; if (TOSH_sched_free != TOSH_sched_full) { __nesc_atomic_end(fInterruptFlags); TOSH_queue[tmp].tp = tp; return 1; } else { TOSH_sched_free = tmp; __nesc_atomic_end(fInterruptFlags); return 0; }}# 57 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/CC2430/RealMain.nc"int main(void){ RealMain$hardwareInit(); TOSH_sched_init(); RealMain$StdControl$init(); RealMain$StdControl$start(); __nesc_enable_interrupt(); while (1) { TOSH_run_task(); }}static # 67 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/CC2430/HPLPowerManagementM.nc"uint8_t HPLPowerManagementM$PowerManagement$adjustPower(void)#line 67{ uint8_t mcu;#line 69 if (!HPLPowerManagementM$disabled) { TOS_post(HPLPowerManagementM$doAdjustment); } else #line 71 { mcu = SLEEP; mcu &= 0xfc; mcu |= HPLPowerManagementM$IDLE; SLEEP = mcu; } return 0;}# 138 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/CC2430/HPLClock.nc"void __attribute((interrupt)) T1_VECTOR(void)#line 138{ { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();#line 140 { if (HPLClock$set_flag) { HPLClock$mscale = HPLClock$nextScale; T1CTL |= HPLClock$nextScale << 2; T1CC0L = (uint8_t )HPLClock$minterval; T1CC0H = (uint8_t )(HPLClock$minterval >> 8); HPLClock$set_flag = 0; } T1IF = 0; }#line 149 __nesc_atomic_end(__nesc_atomic); } HPLClock$Clock$fire();}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -