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

📄 iarapp.c

📁 tinyos的硬件闪灯例子代码
💻 C
📖 第 1 页 / 共 2 页
字号:

#include "hal.h"

#define MANGLED_NESC_APP_C
#define dbg(mode, format) ((void)0)
#define dbg_clear(mode, format) ((void)0)
#define dbg_active(mode) 0
//# 60 "/usr/local/avr/include/inttypes.h"
typedef signed char int8_t;




typedef unsigned char uint8_t;
//# 83 "/usr/local/avr/include/inttypes.h" 3
typedef int int16_t;




typedef unsigned int uint16_t;










typedef long int32_t;




typedef unsigned long uint32_t;
//#line 117




//#line 134
typedef int16_t intptr_t;




typedef uint16_t uintptr_t;
//# 213 "/usr/local/lib/gcc-lib/avr/3.3-tinyos/include/stddef.h" 3
typedef unsigned int size_t;
//#line 325
typedef int wchar_t;
//# 60 "/usr/local/avr/include/stdlib.h"
typedef struct __nesc_unnamed4242 {
  int quot;
  int rem;
} div_t;


typedef struct __nesc_unnamed4243 {
  long quot;
  long rem;
} ldiv_t;


typedef int (*__compar_fn_t)(const void *, const void *);
//# 151 "/usr/local/lib/gcc-lib/avr/3.3-tinyos/include/stddef.h" 3
typedef int ptrdiff_t;
//# 85 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/tos.h"
typedef unsigned char bool;



enum __nesc_unnamed4245 {
  FAIL = 0,
  SUCCESS = 1
};
static /*inline*/

uint8_t rcombine(uint8_t r1, uint8_t r2);
typedef uint8_t  result_t;
static /*inline*/






result_t rcombine(result_t r1, result_t r2);
//#line 128
//# 39 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/CC2430/hal.h"
//typedef unsigned char BOOL;


//typedef unsigned char BYTE;
//typedef unsigned short WORD;
//typedef unsigned long DWORD;


//typedef unsigned char UINT8;
//typedef unsigned short UINT16;
//typedef unsigned long UINT32;


//typedef signed char INT8;
//typedef signed short INT16;
//typedef signed long INT32;
//#line 501
//# 89 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/CC2430/ioCC2430.h"
//typedef int sfr;
//#line 126
//PCON = 0x87
//#line 139
//P1 = 0x90
//#line 194
//SLEEP = 0xBE









//CLKCON = 0xC6
//#line 217
//PSW = 0xD0
//#line 229
//T1CC0L = 0xDA
//T1CC0H = 0xDB







//T1CNTL = 0xE2
//T1CNTH = 0xE3
//T1CTL = 0xE4
//#line 259
//P1SEL = 0xF4










//P1DIR = 0xFE







//typedef int sbit;
//#line 325
//EA = 0xAF
//#line 338
//T4IE = 0xBC
//T3IE = 0xBB
//T2IE = 0xBA
//T1IE = 0xB9









//T1IF = 0xC1
static /*inline*/
//# 100 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/CC2430/CC2430hardware.h"
void TOSH_wait(void);
static /*inline*/



void TOSH_sleep(void);










typedef uint8_t __nesc_atomic_t;

/*__inline*/ __nesc_atomic_t  __nesc_atomic_start(void );






/*__inline*/ void  __nesc_atomic_end(__nesc_atomic_t oldSreg);
static




/*__inline*/ void __nesc_enable_interrupt(void);
//# 34 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/CC2430/hardware.h"
static /*__inline*/ void TOSH_SET_RED_LED_PIN(void);
//#line 34
static /*__inline*/ void TOSH_CLR_RED_LED_PIN(void);
//#line 34
static /*__inline*/ void TOSH_MAKE_RED_LED_OUTPUT(void);
//#line 34
static /*__inline*/ void TOSH_MAKE_RED_LED_GIO(void);
static /*__inline*/ void TOSH_SET_GREEN_LED_PIN(void);
//#line 35
static /*__inline*/ void TOSH_MAKE_GREEN_LED_OUTPUT(void);
//#line 35
static /*__inline*/ void TOSH_MAKE_GREEN_LED_GIO(void);
static /*__inline*/ void TOSH_SET_YELLOW_LED_PIN(void);
//#line 36
static /*__inline*/ void TOSH_MAKE_YELLOW_LED_OUTPUT(void);
//#line 36
static /*__inline*/ void TOSH_MAKE_YELLOW_LED_GIO(void);
static /*inline*/
//#line 57
void TOSH_SET_PIN_DIRECTIONS(void );
//#line 74
enum __nesc_unnamed4248 {
  TOSH_ADC_PORTMAPSIZE = 9
};
//# 54 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/types/dbg_modes.h"
typedef long  TOS_dbg_mode;



//# 59 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/sched.c"
typedef struct __nesc_unnamed4250 {
  void (*tp)(void);
} TOSH_sched_entry_T;

enum __nesc_unnamed4251 {
  TOSH_MAX_TASKS = 8,
  TOSH_TASK_BITMASK = TOSH_MAX_TASKS - 1
};

TOSH_sched_entry_T TOSH_queue[TOSH_MAX_TASKS];
volatile uint8_t TOSH_sched_full;
volatile uint8_t TOSH_sched_free;
static /*inline*/

void TOSH_wait(void );
static /*inline*/ void TOSH_sleep(void );
static /*inline*/
void TOSH_sched_init(void );
//#line 98
bool  TOS_post(void (*tp)(void));
static /*inline*/
//#line 139
bool TOSH_run_next_task(void);
static /*inline*/
//#line 162
void TOSH_run_task(void);
//# 39 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/Timer.h"
enum __nesc_unnamed4252 {
  TIMER_REPEAT = 0,
  TIMER_ONE_SHOT = 1,
  NUM_TIMERS = 1
};
//# 34 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/CC2430/Clock.h"
enum __nesc_unnamed4253 {
  TOS_I1024PS = 0, TOS_S1024PS = 3,
  TOS_I512PS = 1, TOS_S512PS = 3,
  TOS_I256PS = 3, TOS_S256PS = 3,
  TOS_I128PS = 7, TOS_S128PS = 3,
  TOS_I64PS = 15, TOS_S64PS = 3,
  TOS_I32PS = 31, TOS_S32PS = 3,
  TOS_I16PS = 63, TOS_S16PS = 3,
  TOS_I8PS = 127, TOS_S8PS = 3,
  TOS_I4PS = 255, TOS_S4PS = 3,
  TOS_I2PS = 15, TOS_S2PS = 7,
  TOS_I1PS = 31, TOS_S1PS = 7,
  TOS_I0PS = 0, TOS_S0PS = 0
};
enum __nesc_unnamed4254 {
  DEFAULT_SCALE = 3, DEFAULT_INTERVAL = 65535
};
static  result_t HPLInit__init(void);
static  result_t BlinkM__StdControl__init(void);
static  result_t BlinkM__StdControl__start(void);
static  result_t BlinkM__Timer__fired(void);
static   result_t TimerM__Clock__fire(void);
static  result_t TimerM__StdControl__init(void);
static  result_t TimerM__StdControl__start(void);
static  result_t TimerM__Timer__default__fired(uint8_t arg_0xa25ea88);
static  result_t TimerM__Timer__start(uint8_t arg_0xa25ea88, char arg_0xa254a38, uint16_t arg_0xa254b90);
static   void HPLClock__Clock__setInterval(uint16_t arg_0xa2768d0);
static   result_t HPLClock__Clock__setRate(uint16_t arg_0xa27da28, uint8_t arg_0xa27db70);
static   uint8_t HPLPowerManagementM__PowerManagement__adjustPower(void);
static   result_t LedsC__Leds__init(void);
static   result_t LedsC__Leds__redOff(void);
static   result_t LedsC__Leds__redToggle(void);
static   result_t LedsC__Leds__redOn(void);
static
//# 47 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/CC2430/RealMain.nc"
result_t RealMain__hardwareInit(void);
static
//# 63 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/StdControl.nc"
result_t RealMain__StdControl__init(void);
static





result_t RealMain__StdControl__start(void);
//# 57 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/CC2430/RealMain.nc"
int   main(void);
static /*inline*/
//# 10 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/CC2430/HPLInit.nc"
result_t HPLInit__init(void);
static
//# 56 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/Leds.nc"
result_t BlinkM__Leds__init(void);
static
//#line 81
result_t BlinkM__Leds__redToggle(void);
static
//# 59 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/CC2430/Timer.nc"
result_t BlinkM__Timer__start(char arg_0xa254a38, uint16_t arg_0xa254b90);
static /*inline*/
//# 52 "BlinkM.nc"
result_t BlinkM__StdControl__init(void);
static /*inline*/









result_t BlinkM__StdControl__start(void);
static /*inline*/
//#line 84
result_t BlinkM__Timer__fired(void);
static
//# 41 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/PowerManagement.nc"
uint8_t TimerM__PowerManagement__adjustPower(void);
static
//# 105 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/CC2430/Clock.nc"
void TimerM__Clock__setInterval(uint16_t arg_0xa2768d0);
static
//#line 96
result_t TimerM__Clock__setRate(uint16_t arg_0xa27da28, uint8_t arg_0xa27db70);
static
//# 73 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/CC2430/Timer.nc"
result_t TimerM__Timer__fired(
//# 6 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/CC2430/TimerM.nc"
uint8_t arg_0xa25ea88);









uint32_t TimerM__mState;
uint8_t TimerM__setIntervalFlag;
uint8_t TimerM__mScale;
uint16_t TimerM__mInterval;
int8_t TimerM__queue_head;
int8_t TimerM__queue_tail;
uint8_t TimerM__queue_size;
uint8_t TimerM__queue[NUM_TIMERS];

struct TimerM__timer_s {
  uint8_t type;
  int32_t ticks;
  int32_t ticksLeft;
} TimerM__mTimerList[NUM_TIMERS];
static /*inline*/



result_t TimerM__StdControl__init(void);
static /*inline*/








result_t TimerM__StdControl__start(void);
static /*inline*/









result_t TimerM__Timer__start(uint8_t id, char type,
uint16_t interval);
//#line 82
static void TimerM__adjustInterval(void);
static /*inline*/
//#line 122
result_t TimerM__Timer__default__fired(uint8_t id);
static /*inline*/


void TimerM__enqueue(uint8_t value);
static /*inline*/






uint8_t TimerM__dequeue(void);
static /*inline*/








void TimerM__signalOneTimer(void);
static /*inline*/




void TimerM__HandleFire(void);
static /*inline*/
//#line 172
result_t TimerM__Clock__fire(void);
static
//# 180 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/CC2430/Clock.nc"
result_t HPLClock__Clock__fire(void);
//# 12 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/CC2430/HPLClock.nc"
uint8_t HPLClock__set_flag;
uint8_t HPLClock__mscale;
//#line 13
uint8_t HPLClock__nextScale;
uint16_t HPLClock__minterval;
static /*inline*/
//#line 45
void HPLClock__Clock__setInterval(uint16_t value);
static /*inline*/
//#line 118
result_t HPLClock__Clock__setRate(uint16_t interval, uint8_t scale);
//#line 138
#pragma vector=T1_VECTOR
  __interrupt void T1_IRQ(void);
//# 14 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/CC2430/HPLPowerManagementM.nc"
bool HPLPowerManagementM__disabled = 1;

enum HPLPowerManagementM____nesc_unnamed4255 {
  HPLPowerManagementM__IDLE = 0,
  HPLPowerManagementM__ADC_NR = 0,

  HPLPowerManagementM__POWER_DOWN = (1 << 0) + (1 << 1),
  HPLPowerManagementM__POWER_SAVE = 1 << 1,
  HPLPowerManagementM__STANDBY = (1 << 0) + (1 << 1),
  HPLPowerManagementM__EXT_STANDBY = 1 << 1
};
static /*inline*/

uint8_t HPLPowerManagementM__getPowerLevel(void);
static /*inline*/
//#line 48
void HPLPowerManagementM__doAdjustment(void);
static
//#line 67
uint8_t HPLPowerManagementM__PowerManagement__adjustPower(void);
//# 50 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/LedsC.nc"
uint8_t LedsC__ledsOn;

enum LedsC____nesc_unnamed4256 {
  LedsC__RED_BIT = 1,
  LedsC__GREEN_BIT = 2,
  LedsC__YELLOW_BIT = 4
};
static /*inline*/
result_t LedsC__Leds__init(void);
static /*inline*/









result_t LedsC__Leds__redOn(void);
static /*inline*/







result_t LedsC__Leds__redOff(void);
static /*inline*/







result_t LedsC__Leds__redToggle(void);
//# 36 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/CC2430/hardware.h"
static /*__inline*/ void TOSH_SET_YELLOW_LED_PIN(void)
//#line 36
{
//#line 36
  P1 |= 1 << 4;
}

//#line 35
static /*__inline*/ void TOSH_SET_GREEN_LED_PIN(void)
//#line 35
{
//#line 35
  P1 |= 1 << 0;
}

//#line 34
static /*__inline*/ void TOSH_SET_RED_LED_PIN(void)
//#line 34
{
//#line 34
  P1 |= 1 << 1;
}

//#line 36
static /*__inline*/ void TOSH_MAKE_YELLOW_LED_OUTPUT(void)
//#line 36
{
//#line 36
  P1DIR |= 1 << 4;
}

//#line 35
static /*__inline*/ void TOSH_MAKE_GREEN_LED_OUTPUT(void)
//#line 35
{
//#line 35
  P1DIR |= 1 << 0;
}

//#line 34
static /*__inline*/ void TOSH_MAKE_RED_LED_OUTPUT(void)
//#line 34
{
//#line 34
  P1DIR |= 1 << 1;
}

//#line 36
static /*__inline*/ void TOSH_MAKE_YELLOW_LED_GIO(void)
//#line 36
{
//#line 36
  P1SEL &= ~(0x01 << 4);
}

//#line 35
static /*__inline*/ void TOSH_MAKE_GREEN_LED_GIO(void)
//#line 35
{
//#line 35
  P1SEL &= ~(0x01 << 0);
}

//#line 34
static /*__inline*/ void TOSH_MAKE_RED_LED_GIO(void)
//#line 34
{
//#line 34
  P1SEL &= ~(0x01 << 1);
}

static /*inline*/
//#line 57
void TOSH_SET_PIN_DIRECTIONS(void )
{



  TOSH_MAKE_RED_LED_GIO();
  TOSH_MAKE_GREEN_LED_GIO();
  TOSH_MAKE_YELLOW_LED_GIO();
  TOSH_MAKE_RED_LED_OUTPUT();
  TOSH_MAKE_GREEN_LED_OUTPUT();
  TOSH_MAKE_YELLOW_LED_OUTPUT();
  TOSH_SET_RED_LED_PIN();
  TOSH_SET_GREEN_LED_PIN();
  TOSH_SET_YELLOW_LED_PIN();
}

static /*inline*/
//# 10 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/CC2430/HPLInit.nc"
result_t HPLInit__init(void)
//#line 10
{
  do {
//#line 11
      if (0x00) {
//#line 11
          CLKCON |= 0x40;
//#line 11
          while (!(SLEEP & 0x20)) ;
//#line 11
          if ((CLKCON & 0x38) >> 3 == 0) {
//#line 11
              CLKCON |= 0x08;
            }
//#line 11
          SLEEP |= 0x04;
        }
      else
//#line 11
        {
//#line 11
          SLEEP &= ~0x04;
//#line 11
          while (!(SLEEP & 0x40)) ;
//#line 11
           __asm ("NOP");CLKCON &= ~0x47;
//#line 11
          SLEEP |= 0x04;
        }
    }
  while (
//#line 11
  0);
  TOSH_SET_PIN_DIRECTIONS();
  return SUCCESS;
}

//# 47 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/CC2430/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 47
static /*inline*/
//# 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); }

⌨️ 快捷键说明

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