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

📄 app.c

📁 tinyos中对cc1000芯片的操作实例
💻 C
📖 第 1 页 / 共 3 页
字号:
static inline   #line 128uint8_t HPLCC1000M$HPLCC1000$read(uint8_t addr);static inline   # 41 "cc1km.nc"result_t cc1km$HPLUART$get(uint8_t data)#line 41{  return SUCCESS;}# 88 "E:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/HPLUART.nc"inline static   result_t HPLUART0M$UART$get(uint8_t arg_0xa2e0010){#line 88  unsigned char result;#line 88#line 88  result = cc1km$HPLUART$get(arg_0xa2e0010);#line 88#line 88  return result;#line 88}#line 88# 85 "E:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/mica2dot/HPLUART0M.nc"void __attribute((signal))   __vector_18(void)#line 85{  if (* (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x0B + 0x20) & (1 << 7)) {    HPLUART0M$UART$get(* (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x0C + 0x20));    }}static inline   # 37 "cc1km.nc"result_t cc1km$HPLUART$putDone(void)#line 37{  return SUCCESS;}# 96 "E:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/HPLUART.nc"inline static   result_t HPLUART0M$UART$putDone(void){#line 96  unsigned char result;#line 96#line 96  result = cc1km$HPLUART$putDone();#line 96#line 96  return result;#line 96}#line 96# 95 "E:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/mica2dot/HPLUART0M.nc"void __attribute((interrupt))   __vector_20(void)#line 95{  HPLUART0M$UART$putDone();}# 41 "E:/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   # 87 "E:/tinyos/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 "E:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/Clock.nc"inline static   void TimerM$Clock$setInterval(uint8_t arg_0xa31c218){#line 105  HPLClock$Clock$setInterval(arg_0xa31c218);#line 105}#line 105# 116 "E:/tinyos/cygwin/opt/tinyos-1.x/tos/system/TimerM.nc"static void TimerM$adjustInterval(void)#line 116{  uint8_t i;#line 117  uint8_t val = TimerM$maxTimerInterval;#line 118  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 124        {          TimerM$mInterval = val;          TimerM$Clock$setInterval(TimerM$mInterval);          TimerM$setIntervalFlag = 0;        }#line 128        __nesc_atomic_end(__nesc_atomic); }    }  else {      { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();#line 131        {          TimerM$mInterval = TimerM$maxTimerInterval;          TimerM$Clock$setInterval(TimerM$mInterval);          TimerM$setIntervalFlag = 0;        }#line 135        __nesc_atomic_end(__nesc_atomic); }    }  TimerM$PowerManagement$adjustPower();}static inline   # 100 "E:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/mica2dot/HPLUART0M.nc"result_t HPLUART0M$UART$put(uint8_t data)#line 100{  * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x0C + 0x20) = data;  * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x0B + 0x20) |= 1 << 6;  return SUCCESS;}# 80 "E:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/HPLUART.nc"inline static   result_t cc1km$HPLUART$put(uint8_t arg_0xa2dba80){#line 80  unsigned char result;#line 80#line 80  result = HPLUART0M$UART$put(arg_0xa2dba80);#line 80#line 80  return result;#line 80}#line 80# 117 "E:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/mica2dot/hardware.h"static __inline void TOSH_SET_CC_PDATA_PIN(void)#line 117{#line 117  * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x12 + 0x20) |= 1 << 7;}#line 117static __inline void TOSH_MAKE_CC_PDATA_OUTPUT(void)#line 117{#line 117  * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x11 + 0x20) |= 1 << 7;}#line 119static __inline void TOSH_SET_CC_PALE_PIN(void)#line 119{#line 119  * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x12 + 0x20) |= 1 << 5;}#line 118static __inline void TOSH_SET_CC_PCLK_PIN(void)#line 118{#line 118  * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x12 + 0x20) |= 1 << 6;}#line 117static __inline int TOSH_READ_CC_PDATA_PIN(void)#line 117{#line 117  return (* (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x10 + 0x20) & (1 << 7)) != 0;}#line 118static __inline void TOSH_CLR_CC_PCLK_PIN(void)#line 118{#line 118  * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x12 + 0x20) &= ~(1 << 6);}#line 117static __inline void TOSH_MAKE_CC_PDATA_INPUT(void)#line 117{#line 117  * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x11 + 0x20) &= ~(1 << 7);}#line 117static __inline void TOSH_CLR_CC_PDATA_PIN(void)#line 117{#line 117  * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x12 + 0x20) &= ~(1 << 7);}#line 119static __inline void TOSH_CLR_CC_PALE_PIN(void)#line 119{#line 119  * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x12 + 0x20) &= ~(1 << 5);}static inline   # 128 "E:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/mica2/HPLCC1000M.nc"uint8_t HPLCC1000M$HPLCC1000$read(uint8_t addr)#line 128{  int cnt;  uint8_t din;  uint8_t data = 0;  addr <<= 1;  TOSH_CLR_CC_PALE_PIN();  for (cnt = 0; cnt < 7; cnt++)     {      if (addr & 0x80) {        TOSH_SET_CC_PDATA_PIN();        }      else {#line 141        TOSH_CLR_CC_PDATA_PIN();        }#line 142      TOSH_CLR_CC_PCLK_PIN();      TOSH_SET_CC_PCLK_PIN();      addr <<= 1;    }  TOSH_CLR_CC_PDATA_PIN();  TOSH_CLR_CC_PCLK_PIN();  TOSH_SET_CC_PCLK_PIN();  TOSH_MAKE_CC_PDATA_INPUT();  TOSH_SET_CC_PALE_PIN();  for (cnt = 7; cnt >= 0; cnt--)     {      TOSH_CLR_CC_PCLK_PIN();      din = TOSH_READ_CC_PDATA_PIN();      if (din) {        data = (data << 1) | 0x01;        }      else {#line 161        data = (data << 1) & 0xfe;        }#line 162      TOSH_SET_CC_PCLK_PIN();    }  TOSH_SET_CC_PALE_PIN();  TOSH_MAKE_CC_PDATA_OUTPUT();  TOSH_SET_CC_PDATA_PIN();  return data;}# 65 "E:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/mica2/HPLCC1000.nc"inline static   uint8_t cc1km$HPLCC1000$read(uint8_t arg_0xa2ceb90){#line 65  unsigned char result;#line 65#line 65  result = HPLCC1000M$HPLCC1000$read(arg_0xa2ceb90);#line 65#line 65  return result;#line 65}#line 65static inline  # 31 "cc1km.nc"result_t cc1km$Timer$fired(void)#line 31{  cc1km$addr++;  cc1km$data = cc1km$HPLCC1000$read(cc1km$addr);  return cc1km$HPLUART$put(cc1km$data);}static inline   # 154 "E:/tinyos/cygwin/opt/tinyos-1.x/tos/system/TimerM.nc"result_t TimerM$Timer$default$fired(uint8_t id)#line 154{  return SUCCESS;}# 73 "E:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/Timer.nc"inline static  result_t TimerM$Timer$fired(uint8_t arg_0xa308030){#line 73  unsigned char result;#line 73#line 73  switch (arg_0xa308030) {#line 73    case 0:#line 73      result = cc1km$Timer$fired();#line 73      break;#line 73    default:#line 73      result = TimerM$Timer$default$fired(arg_0xa308030);#line 73    }#line 73#line 73  return result;#line 73}#line 73static inline # 166 "E:/tinyos/cygwin/opt/tinyos-1.x/tos/system/TimerM.nc"uint8_t TimerM$dequeue(void)#line 166{  if (TimerM$queue_size == 0) {    return NUM_TIMERS;    }#line 169  if (TimerM$queue_head == NUM_TIMERS - 1) {    TimerM$queue_head = -1;    }#line 171  TimerM$queue_head++;  TimerM$queue_size--;  return TimerM$queue[(uint8_t )TimerM$queue_head];}static inline  void TimerM$signalOneTimer(void)#line 176{  uint8_t itimer = TimerM$dequeue();#line 178  if (itimer < NUM_TIMERS) {    TimerM$Timer$fired(itimer);    }}static inline #line 158void TimerM$enqueue(uint8_t value)#line 158{  if (TimerM$queue_tail == NUM_TIMERS - 1) {    TimerM$queue_tail = -1;    }#line 161  TimerM$queue_tail++;  TimerM$queue_size++;  TimerM$queue[(uint8_t )TimerM$queue_tail] = value;}static inline  #line 182void TimerM$HandleFire(void)#line 182{  uint8_t i;#line 184  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 192                    {                      TimerM$mState &= ~(0x1 << i);                    }                  TimerM$enqueue(i);                  TOS_post(TimerM$signalOneTimer);                }            }        }    }  TimerM$adjustInterval();}static inline   result_t TimerM$Clock$fire(void)#line 204{  TOS_post(TimerM$HandleFire);  return SUCCESS;}# 180 "E:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/Clock.nc"inline static   result_t HPLClock$Clock$fire(void){#line 180  unsigned char result;#line 180#line 180  result = TimerM$Clock$fire();#line 180#line 180  return result;#line 180}#line 180static inline # 63 "E:/tinyos/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;}# 108 "E:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/mica2dot/hardware.h"static __inline void TOSH_SET_RED_LED_PIN(void)#line 108{#line 108  * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x1B + 0x20) |= 1 << 2;}#line 129static __inline void TOSH_SET_FLASH_OUT_PIN(void)#line 129{#line 129  * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x1B + 0x20) |= 1 << 7;}#line 127static __inline void TOSH_SET_FLASH_SELECT_PIN(void)#line 127{#line 127  * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x03 + 0x20) |= 1 << 5;}#line 128static __inline void TOSH_MAKE_FLASH_CLK_OUTPUT(void)#line 128{#line 128  * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x1A + 0x20) |= 1 << 3;}#line 129static __inline void TOSH_MAKE_FLASH_OUT_OUTPUT(void)#line 129{#line 129  * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x1A + 0x20) |= 1 << 7;}#line 127static __inline void TOSH_MAKE_FLASH_SELECT_OUTPUT(void)#line 127{#line 127  * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x02 + 0x20) |= 1 << 5;}#line 141static __inline void TOSH_MAKE_SPI_OC1C_INPUT(void)#line 141{#line 141  * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x17 + 0x20) &= ~(1 << 7);}#line 140static __inline void TOSH_MAKE_MISO_INPUT(void)#line 140{#line 140  * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x17 + 0x20) &= ~(1 << 3);}#line 118static __inline void TOSH_MAKE_CC_PCLK_OUTPUT(void)#line 118{#line 118  * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x11 + 0x20) |= 1 << 6;}#line 119static __inline void TOSH_MAKE_CC_PALE_OUTPUT(void)#line 119{#line 119  * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x11 + 0x20) |= 1 << 5;}#line 145static __inline void TOSH_MAKE_PW0_OUTPUT(void)#line 145{#line 145  * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x14 + 0x20) |= 1 << 0;}#line 146static __inline void TOSH_MAKE_PW1_OUTPUT(void)#line 146{#line 146  * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x14 + 0x20) |= 1 << 1;}#line 147static __inline void TOSH_MAKE_PW2_OUTPUT(void)#line 147{#line 147  * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x14 + 0x20) |= 1 << 2;}#line 148static __inline void TOSH_MAKE_PW3_OUTPUT(void)#line 148{#line 148  * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x14 + 0x20) |= 1 << 3;}#line 149static __inline void TOSH_MAKE_PW4_OUTPUT(void)#line 149{#line 149  * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x14 + 0x20) |= 1 << 4;}#line 150static __inline void TOSH_MAKE_PW5_OUTPUT(void)#line 150{#line 150  * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x14 + 0x20) |= 1 << 5;}#line 151static __inline void TOSH_MAKE_PW6_OUTPUT(void)#line 151{#line 151  * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x14 + 0x20) |= 1 << 6;}#line 152static __inline void TOSH_MAKE_PW7_OUTPUT(void)#line 152{#line 152  * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x14 + 0x20) |= 1 << 7;}#line 116static __inline void TOSH_MAKE_CC_CHP_OUT_INPUT(void)#line 116{#line 116

⌨️ 快捷键说明

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