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

📄 app.c

📁 tinyos中对cc1000芯片的操作实例
💻 C
📖 第 1 页 / 共 3 页
字号:
  * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x02 + 0x20) &= ~(1 << 7);}#line 160static __inline void TOSH_MAKE_ADC7_INPUT(void)#line 160{#line 160  * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)0x61 &= ~(1 << 7);}#line 136static __inline void TOSH_MAKE_INT3_INPUT(void)#line 136{#line 136  * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x11 + 0x20) &= ~(1 << 3);}#line 113static __inline void TOSH_MAKE_GREEN_LED_OUTPUT(void)#line 113{#line 113  * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x1A + 0x20) |= 1 << 1;}#line 112static __inline void TOSH_MAKE_YELLOW_LED_OUTPUT(void)#line 112{#line 112  * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x1A + 0x20) |= 1 << 0;}#line 108static __inline void TOSH_MAKE_RED_LED_OUTPUT(void)#line 108{#line 108  * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x1A + 0x20) |= 1 << 2;}static inline #line 174void TOSH_SET_PIN_DIRECTIONS(void ){  * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x1A + 0x20) = 0x00;  * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x17 + 0x20) = 0x00;  * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x11 + 0x20) = 0x00;  * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x02 + 0x20) = 0x02;  * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x03 + 0x20) = 0x02;  TOSH_MAKE_RED_LED_OUTPUT();  TOSH_MAKE_YELLOW_LED_OUTPUT();  TOSH_MAKE_GREEN_LED_OUTPUT();  TOSH_MAKE_INT3_INPUT();  TOSH_MAKE_ADC7_INPUT();  TOSH_MAKE_CC_CHP_OUT_INPUT();  TOSH_MAKE_PW7_OUTPUT();  TOSH_MAKE_PW6_OUTPUT();  TOSH_MAKE_PW5_OUTPUT();  TOSH_MAKE_PW4_OUTPUT();  TOSH_MAKE_PW3_OUTPUT();  TOSH_MAKE_PW2_OUTPUT();  TOSH_MAKE_PW1_OUTPUT();  TOSH_MAKE_PW0_OUTPUT();  TOSH_MAKE_CC_PALE_OUTPUT();  TOSH_MAKE_CC_PDATA_OUTPUT();  TOSH_MAKE_CC_PCLK_OUTPUT();  TOSH_MAKE_MISO_INPUT();  TOSH_MAKE_SPI_OC1C_INPUT();  TOSH_MAKE_FLASH_SELECT_OUTPUT();  TOSH_MAKE_FLASH_OUT_OUTPUT();  TOSH_MAKE_FLASH_CLK_OUTPUT();  TOSH_SET_FLASH_SELECT_PIN();  TOSH_SET_FLASH_OUT_PIN();  TOSH_SET_RED_LED_PIN();}static inline  # 57 "E:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/avrmote/HPLInit.nc"result_t HPLInit$init(void)#line 57{  TOSH_SET_PIN_DIRECTIONS();  return SUCCESS;}# 47 "E:/tinyos/cygwin/opt/tinyos-1.x/tos/system/RealMain.nc"inline static  result_t RealMain$hardwareInit(void){#line 47  unsigned char result;#line 47#line 47  result = HPLInit$init();#line 47#line 47  return result;#line 47}#line 47static inline  # 75 "E:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/mica2/HPLPotC.nc"result_t HPLPotC$Pot$finalise(void)#line 75{  return SUCCESS;}# 74 "E:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/HPLPot.nc"inline static  result_t PotM$HPLPot$finalise(void){#line 74  unsigned char result;#line 74#line 74  result = HPLPotC$Pot$finalise();#line 74#line 74  return result;#line 74}#line 74static inline  # 66 "E:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/mica2/HPLPotC.nc"result_t HPLPotC$Pot$increase(void)#line 66{  return SUCCESS;}# 67 "E:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/HPLPot.nc"inline static  result_t PotM$HPLPot$increase(void){#line 67  unsigned char result;#line 67#line 67  result = HPLPotC$Pot$increase();#line 67#line 67  return result;#line 67}#line 67static inline  # 57 "E:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/mica2/HPLPotC.nc"result_t HPLPotC$Pot$decrease(void)#line 57{  return SUCCESS;}# 59 "E:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/HPLPot.nc"inline static  result_t PotM$HPLPot$decrease(void){#line 59  unsigned char result;#line 59#line 59  result = HPLPotC$Pot$decrease();#line 59#line 59  return result;#line 59}#line 59static inline # 93 "E:/tinyos/cygwin/opt/tinyos-1.x/tos/system/PotM.nc"void PotM$setPot(uint8_t value)#line 93{  uint8_t i;#line 95  for (i = 0; i < 151; i++)     PotM$HPLPot$decrease();  for (i = 0; i < value; i++)     PotM$HPLPot$increase();  PotM$HPLPot$finalise();  PotM$potSetting = value;}static inline  result_t PotM$Pot$init(uint8_t initialSetting)#line 106{  PotM$setPot(initialSetting);  return SUCCESS;}# 78 "E:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/Pot.nc"inline static  result_t RealMain$Pot$init(uint8_t arg_0xa3ac970){#line 78  unsigned char result;#line 78#line 78  result = PotM$Pot$init(arg_0xa3ac970);#line 78#line 78  return result;#line 78}#line 78static inline # 76 "E:/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   # 57 "E:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/mica2dot/HPLUART0M.nc"result_t HPLUART0M$UART$init(void)#line 57{  * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)0x90 = 0;  * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x09 + 0x20) = 12;  * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x0C + 0x20);  * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x0B + 0x20) = 0;  * (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 "E:/tinyos/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 "E:/tinyos/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 "E:/tinyos/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   # 149 "E:/tinyos/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 "E:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/Clock.nc"inline static   result_t TimerM$Clock$setRate(char arg_0xa3216f8, char arg_0xa321838){#line 96  unsigned char result;#line 96#line 96  result = HPLClock$Clock$setRate(arg_0xa3216f8, arg_0xa321838);#line 96#line 96  return result;#line 96}#line 96static inline  # 72 "E:/tinyos/cygwin/opt/tinyos-1.x/tos/system/TimerM.nc"result_t TimerM$StdControl$init(void)#line 72{  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);}# 63 "E:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/StdControl.nc"inline static  result_t cc1km$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 63static inline # 108 "E:/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 result_t rcombine3(result_t r1, result_t r2, result_t r3){  return rcombine(r1, rcombine(r2, r3));}static inline  # 19 "cc1km.nc"result_t cc1km$StdControl$init(void)#line 19{  return rcombine3(cc1km$timercontrol$init(), cc1km$HPLCC1000$init(), cc1km$HPLUART$init());}# 63 "E:/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 = cc1km$StdControl$init();#line 63#line 63  return result;#line 63}#line 63static inline  # 93 "E:/tinyos/cygwin/opt/tinyos-1.x/tos/system/TimerM.nc"result_t TimerM$Timer$start(uint8_t id, char type, uint32_t interval)#line 94{  uint8_t diff;#line 96  if (id >= NUM_TIMERS) {#line 96    return FAIL;    }#line 97  if (type > 1) {#line 97    return FAIL;    }#line 98  TimerM$mTimerList[id].ticks = interval;  TimerM$mTimerList[id].type = type;  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();#line 101    {      diff = * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x32 + 0x20);      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;          TimerM$PowerManagement$adjustPower();        }    }#line 112    __nesc_atomic_end(__nesc_atomic); }  return SUCCESS;}# 59 "E:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/Timer.nc"inline static  result_t cc1km$Timer$start(char arg_0xa2d3488, uint32_t arg_0xa2d35e0){#line 59  unsigned char result;#line 59#line 59  result = TimerM$Timer$start(0, arg_0xa2d3488, arg_0xa2d35e0);#line 59#line 59  return result;#line 59}#line 59static inline  # 23 "cc1km.nc"result_t cc1km$StdControl$start(void)#line 23{  return cc1km$Timer$start(0, 1000);}# 70 "E:/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 = cc1km$StdControl$start();#line 70#line 70  return result;#line 70}#line 70static # 165 "E:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/avrmote/avrhardware.h"__inline void __nesc_enable_interrupt(void)#line 165{   __asm volatile ("sei");}static inline #line 135void TOSH_wait(void){   __asm volatile ("nop");   __asm volatile ("nop");}static inline void TOSH_sleep(void){  * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x35 + 0x20) |= 1 << 5;   __asm volatile ("sleep");}#line 160__inline void  __nesc_atomic_end(__nesc_atomic_t oldSreg){  * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x3F + 0x20) = oldSreg;}#line 153__inline __nesc_atomic_t  __nesc_atomic_start(void ){  __nesc_atomic_t result = * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x3F + 0x20);#line 156   __asm volatile ("cli");  return result;}static inline # 139 "E:/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();}#line 98bool  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 TRUE;    }  else {      TOSH_sched_free = tmp;      __nesc_atomic_end(fInterruptFlags);      return FALSE;    }}# 167 "E:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/mica/HPLClock.nc"void __attribute((interrupt))   __vector_15(void)#line 167{  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();#line 168    {      if (HPLClock$set_flag) {          HPLClock$mscale = HPLClock$nextScale;          HPLClock$nextScale |= 0x8;          * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x33 + 0x20) = HPLClock$nextScale;          * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x31 + 0x20) = HPLClock$minterval;          HPLClock$set_flag = 0;        }    }#line 177    __nesc_atomic_end(__nesc_atomic); }  HPLClock$Clock$fire();}static   # 101 "E:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/mica2/HPLPowerManagementM.nc"uint8_t HPLPowerManagementM$PowerManagement$adjustPower(void)#line 101{  uint8_t mcu;#line 103  if (!HPLPowerManagementM$disabled) {    TOS_post(HPLPowerManagementM$doAdjustment);    }  else #line 105    {      mcu = * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x35 + 0x20);      mcu &= 0xe3;      mcu |= HPLPowerManagementM$IDLE;      * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x35 + 0x20) = mcu;      * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x35 + 0x20) |= 1 << 5;    }  return 0;}# 54 "E:/tinyos/cygwin/opt/tinyos-1.x/tos/system/RealMain.nc"int   main(void)#line 54{  RealMain$hardwareInit();  RealMain$Pot$init(10);  TOSH_sched_init();  RealMain$StdControl$init();  RealMain$StdControl$start();  __nesc_enable_interrupt();  while (1) {      TOSH_run_task();    }}

⌨️ 快捷键说明

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