⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 app.c

📁 tinyos中对cc1000芯片的操作实例
💻 C
📖 第 1 页 / 共 4 页
字号:
  unsigned char result;#line 78#line 78  result = PotM$Pot$init(arg_0xa31fc38);#line 78#line 78  return result;#line 78}#line 78static inline # 83 "C:/PROGRA~1/UCB/cygwin/opt/tinyos-1.x/tos/system/sched.c"void TOSH_sched_init(void ){  int i;#line 86  TOSH_sched_free = 0;  TOSH_sched_full = 0;  for (i = 0; i < TOSH_MAX_TASKS; i++)     TOSH_queue[i].tp = (void *)0;}static inline # 120 "C:/PROGRA~1/UCB/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   # 149 "C:/PROGRA~1/UCB/cygwin/opt/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 unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x37 + 0x20) &= ~(1 << 0);      * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x37 + 0x20) &= ~(1 << 1);      * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x30 + 0x20) |= 1 << 3;      * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x33 + 0x20) = scale;      * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x32 + 0x20) = 0;      * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x31 + 0x20) = interval;      * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x37 + 0x20) |= 1 << 1;    }#line 162    __nesc_atomic_end(__nesc_atomic); }  return SUCCESS;}# 96 "C:/PROGRA~1/UCB/cygwin/opt/tinyos-1.x/tos/interfaces/Clock.nc"inline static   result_t TimerM$Clock$setRate(char arg_0xa38b8b8, char arg_0xa38b9f8){#line 96  unsigned char result;#line 96#line 96  result = HPLClock$Clock$setRate(arg_0xa38b8b8, arg_0xa38b9f8);#line 96#line 96  return result;#line 96}#line 96static inline  # 77 "C:/PROGRA~1/UCB/cygwin/opt/tinyos-1.x/tos/system/TimerM.nc"result_t TimerM$StdControl$init(void)#line 77{  TimerM$mState = 0;  TimerM$setIntervalFlag = 0;  TimerM$queue_head = TimerM$queue_tail = -1;  TimerM$queue_size = 0;  TimerM$mScale = 3;  TimerM$mInterval = TimerM$maxTimerInterval;  return TimerM$Clock$setRate(TimerM$mInterval, TimerM$mScale);}# 127 "C:/PROGRA~1/UCB/cygwin/opt/tinyos-1.x/tos/platform/mica2/hardware.h"static __inline void TOSH_SET_CC_PCLK_PIN(void)#line 127{#line 127  * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x12 + 0x20) |= 1 << 6;}#line 126static __inline void TOSH_SET_CC_PDATA_PIN(void)#line 126{#line 126  * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x12 + 0x20) |= 1 << 7;}#line 128static __inline void TOSH_SET_CC_PALE_PIN(void)#line 128{#line 128  * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x12 + 0x20) |= 1 << 4;}#line 127static __inline void TOSH_CLR_CC_PCLK_PIN(void)#line 127{#line 127  * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x12 + 0x20) &= ~(1 << 6);}#line 126static __inline void TOSH_CLR_CC_PDATA_PIN(void)#line 126{#line 126  * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x12 + 0x20) &= ~(1 << 7);}#line 128static __inline void TOSH_CLR_CC_PALE_PIN(void)#line 128{#line 128  * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x12 + 0x20) &= ~(1 << 4);}static inline   # 75 "C:/PROGRA~1/UCB/cygwin/opt/tinyos-1.x/tos/platform/mica2/HPLCC1000M.nc"result_t HPLCC1000M$HPLCC1000$write(uint8_t addr, uint8_t data)#line 75{  char cnt = 0;  addr <<= 1;  TOSH_CLR_CC_PALE_PIN();  for (cnt = 0; cnt < 7; cnt++)     {      if (addr & 0x80) {        TOSH_SET_CC_PDATA_PIN();        }      else {#line 86        TOSH_CLR_CC_PDATA_PIN();        }#line 87      TOSH_CLR_CC_PCLK_PIN();      TOSH_SET_CC_PCLK_PIN();      addr <<= 1;    }  TOSH_SET_CC_PDATA_PIN();  TOSH_CLR_CC_PCLK_PIN();  TOSH_SET_CC_PCLK_PIN();  TOSH_SET_CC_PALE_PIN();  for (cnt = 0; cnt < 8; cnt++)     {      if (data & 0x80) {        TOSH_SET_CC_PDATA_PIN();        }      else {#line 103        TOSH_CLR_CC_PDATA_PIN();        }#line 104      TOSH_CLR_CC_PCLK_PIN();      TOSH_SET_CC_PCLK_PIN();      data <<= 1;    }  TOSH_SET_CC_PALE_PIN();  TOSH_SET_CC_PDATA_PIN();  TOSH_SET_CC_PCLK_PIN();  return SUCCESS;}# 58 "C:/PROGRA~1/UCB/cygwin/opt/tinyos-1.x/tos/platform/mica2/HPLCC1000.nc"inline static   result_t cc1km$HPLCC1000$write(uint8_t arg_0xa2dc010, uint8_t arg_0xa2dc158){#line 58  unsigned char result;#line 58#line 58  result = HPLCC1000M$HPLCC1000$write(arg_0xa2dc010, arg_0xa2dc158);#line 58#line 58  return result;#line 58}#line 58static inline   # 60 "C:/PROGRA~1/UCB/cygwin/opt/tinyos-1.x/tos/platform/mica2/HPLUART0M.nc"result_t HPLUART0M$UART$init(void)#line 60{  * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)0x90 = 0;  * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x09 + 0x20) = 15;  * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x0B + 0x20) = 1 << 1;  * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)0x95 = (1 << 2) | (1 << 1);  * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x0A + 0x20) = (((1 << 7) | (1 << 6)) | (1 << 4)) | (1 << 3);  return SUCCESS;}# 62 "C:/PROGRA~1/UCB/cygwin/opt/tinyos-1.x/tos/interfaces/HPLUART.nc"inline static   result_t cc1km$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 62static inline  # 51 "C:/PROGRA~1/UCB/cygwin/opt/tinyos-1.x/tos/platform/mica2/HPLCC1000M.nc"result_t HPLCC1000M$HPLCC1000$init(void)#line 51{  TOSH_MAKE_CC_CHP_OUT_INPUT();  TOSH_MAKE_CC_PALE_OUTPUT();  TOSH_MAKE_CC_PCLK_OUTPUT();  TOSH_MAKE_CC_PDATA_OUTPUT();  TOSH_SET_CC_PALE_PIN();  TOSH_SET_CC_PDATA_PIN();  TOSH_SET_CC_PCLK_PIN();  return SUCCESS;}# 51 "C:/PROGRA~1/UCB/cygwin/opt/tinyos-1.x/tos/platform/mica2/HPLCC1000.nc"inline static  result_t cc1km$HPLCC1000$init(void){#line 51  unsigned char result;#line 51#line 51  result = HPLCC1000M$HPLCC1000$init();#line 51#line 51  return result;#line 51}#line 51static inline  # 19 "cc1km.nc"result_t cc1km$StdControl$init(void)#line 19{  cc1km$HPLCC1000$init();  cc1km$HPLUART$init();  cc1km$HPLCC1000$write(0x0d, 0x93);}# 63 "C:/PROGRA~1/UCB/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 = cc1km$StdControl$init();#line 63  result = rcombine(result, TimerM$StdControl$init());#line 63#line 63  return result;#line 63}#line 63static inline  # 87 "C:/PROGRA~1/UCB/cygwin/opt/tinyos-1.x/tos/system/TimerM.nc"result_t TimerM$StdControl$start(void)#line 87{  return SUCCESS;}# 41 "C:/PROGRA~1/UCB/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   # 87 "C:/PROGRA~1/UCB/cygwin/opt/tinyos-1.x/tos/platform/mica/HPLClock.nc"void HPLClock$Clock$setInterval(uint8_t value)#line 87{  * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x31 + 0x20) = value;}# 105 "C:/PROGRA~1/UCB/cygwin/opt/tinyos-1.x/tos/interfaces/Clock.nc"inline static   void TimerM$Clock$setInterval(uint8_t arg_0xa3868c8){#line 105  HPLClock$Clock$setInterval(arg_0xa3868c8);#line 105}#line 105static inline   # 134 "C:/PROGRA~1/UCB/cygwin/opt/tinyos-1.x/tos/platform/mica/HPLClock.nc"uint8_t HPLClock$Clock$readCounter(void)#line 134{  return * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x32 + 0x20);}# 153 "C:/PROGRA~1/UCB/cygwin/opt/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 153static inline  # 98 "C:/PROGRA~1/UCB/cygwin/opt/tinyos-1.x/tos/system/TimerM.nc"result_t TimerM$Timer$start(uint8_t id, char type, uint32_t interval)#line 99{  uint8_t diff;#line 101  if (id >= NUM_TIMERS) {#line 101    return FAIL;    }#line 102  if (type > TIMER_ONE_SHOT) {#line 102    return FAIL;    }  if (type == TIMER_REPEAT && interval <= 2) {#line 109    return FAIL;    }  TimerM$mTimerList[id].ticks = interval;  TimerM$mTimerList[id].type = type;  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();#line 114    {      diff = TimerM$Clock$readCounter();      interval += diff;      TimerM$mTimerList[id].ticksLeft = interval;      TimerM$mState |= 0x1L << id;      if (interval < TimerM$mInterval) {          TimerM$mInterval = interval;          TimerM$Clock$setInterval(TimerM$mInterval);          TimerM$setIntervalFlag = 0;          TimerM$PowerManagement$adjustPower();        }    }#line 125    __nesc_atomic_end(__nesc_atomic); }  return SUCCESS;}# 59 "C:/PROGRA~1/UCB/cygwin/opt/tinyos-1.x/tos/interfaces/Timer.nc"inline static  result_t cc1km$Timer$start(char arg_0xa2f11c0, uint32_t arg_0xa2f1318){#line 59  unsigned char result;#line 59#line 59  result = TimerM$Timer$start(0, arg_0xa2f11c0, arg_0xa2f1318);#line 59#line 59  return result;#line 59}#line 59static inline  # 33 "cc1km.nc"result_t cc1km$StdControl$start(void)#line 33{  return cc1km$Timer$start(0, 100);}# 70 "C:/PROGRA~1/UCB/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 = cc1km$StdControl$start();#line 70  result = rcombine(result, TimerM$StdControl$start());#line 70#line 70  return result;#line 70}#line 70static inline # 63 "C:/PROGRA~1/UCB/cygwin/opt/tinyos-1.x/tos/platform/mica2/HPLPowerManagementM.nc"uint8_t HPLPowerManagementM$getPowerLevel(void)#line 63{  uint8_t diff;#line 65  if (* (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x37 + 0x20) & ~((1 << 1) | (1 << 0))) {      return HPLPowerManagementM$IDLE;    }  else {#line 68    if (* (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x0D + 0x20) & (1 << 7)) {        return HPLPowerManagementM$IDLE;      }    else {      if (* (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x06 + 0x20) & (1 << 7)) {          return HPLPowerManagementM$ADC_NR;        }      else {#line 74        if (* (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x37 + 0x20) & ((1 << 1) | (1 << 0))) {            diff = * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x31 + 0x20) - * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x32 + 0x20);            if (diff < 16) {              return HPLPowerManagementM$EXT_STANDBY;              }#line 78            return HPLPowerManagementM$POWER_SAVE;          }        else #line 79          {            return HPLPowerManagementM$POWER_DOWN;          }        }      }    }}static inline  #line 84void HPLPowerManagementM$doAdjustment(void)#line 84{  uint8_t foo;#line 85  uint8_t mcu;#line 86  foo = HPLPowerManagementM$getPowerLevel();  mcu = * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x35 + 0x20);  mcu &= 0xe3;  if (foo == HPLPowerManagementM$EXT_STANDBY || foo == HPLPowerManagementM$POWER_SAVE) {      mcu |= HPLPowerManagementM$IDLE;      while ((* (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x30 + 0x20) & 0x7) != 0) {           __asm volatile ("nop");}      mcu &= 0xe3;    }  mcu |= foo;  * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x35 + 0x20) = mcu;  * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x35 + 0x20) |= 1 << 5;}static # 172 "C:/PROGRA~1/UCB/cygwin/opt/tinyos-1.x/tos/platform/avrmote/avrhardware.h"__inline void __nesc_enable_interrupt(void)#line 172{   __asm volatile ("sei");}static inline #line 135void TOSH_wait(void){

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -