#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
typedef long long int64_t;




typedef unsigned long long uint64_t;
#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_unnamed4244 {
  FALSE = 0, 
  TRUE = 1
};

uint16_t TOS_LOCAL_ADDRESS = 1;

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);
static inline 






result_t rcombine3(result_t r1, result_t r2, result_t r3);
#line 128
enum __nesc_unnamed4246 {
  NULL = 0x0
};
# 81 "/usr/local/avr/include/avr/pgmspace.h"
typedef void __attribute((__progmem__)) prog_void;
typedef char __attribute((__progmem__)) prog_char;
typedef unsigned char __attribute((__progmem__)) prog_uchar;
typedef int __attribute((__progmem__)) prog_int;
typedef long __attribute((__progmem__)) prog_long;
typedef long long __attribute((__progmem__)) prog_long_long;
# 124 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/avrmote/avrhardware.h"
enum __nesc_unnamed4247 {
  TOSH_period16 = 0x00, 
  TOSH_period32 = 0x01, 
  TOSH_period64 = 0x02, 
  TOSH_period128 = 0x03, 
  TOSH_period256 = 0x04, 
  TOSH_period512 = 0x05, 
  TOSH_period1024 = 0x06, 
  TOSH_period2048 = 0x07
};
static inline 
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);
# 57 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/mica/hardware.h"
static __inline void TOSH_SET_RED_LED_PIN(void);
#line 57
static __inline void TOSH_CLR_RED_LED_PIN(void);
#line 57
static __inline void TOSH_MAKE_RED_LED_OUTPUT(void);
static __inline void TOSH_SET_YELLOW_LED_PIN(void);
#line 58
static __inline void TOSH_CLR_YELLOW_LED_PIN(void);
#line 58
static __inline void TOSH_MAKE_YELLOW_LED_OUTPUT(void);
static __inline void TOSH_SET_GREEN_LED_PIN(void);
#line 59
static __inline void TOSH_CLR_GREEN_LED_PIN(void);
#line 59
static __inline void TOSH_MAKE_GREEN_LED_OUTPUT(void);

static __inline void TOSH_SET_UD_PIN(void);
#line 61
static __inline void TOSH_CLR_UD_PIN(void);
static __inline void TOSH_SET_INC_PIN(void);
#line 62
static __inline void TOSH_CLR_INC_PIN(void);
static __inline void TOSH_SET_POT_SELECT_PIN(void);
#line 63
static __inline void TOSH_CLR_POT_SELECT_PIN(void);
#line 63
static __inline void TOSH_MAKE_POT_SELECT_OUTPUT(void);
static __inline void TOSH_SET_POT_POWER_PIN(void);
#line 64
static __inline void TOSH_MAKE_POT_POWER_OUTPUT(void);
static __inline void TOSH_SET_BOOST_ENABLE_PIN(void);
#line 65
static __inline void TOSH_MAKE_BOOST_ENABLE_OUTPUT(void);

static __inline void TOSH_MAKE_FLASH_SELECT_INPUT(void);








static __inline int TOSH_READ_RFM_RXD_PIN(void);
static __inline void TOSH_CLR_RFM_TXD_PIN(void);
#line 77
static __inline void TOSH_MAKE_RFM_TXD_OUTPUT(void);
#line 77
static __inline void TOSH_MAKE_RFM_TXD_INPUT(void);
static __inline void TOSH_SET_RFM_CTL0_PIN(void);
#line 78
static __inline void TOSH_CLR_RFM_CTL0_PIN(void);
#line 78
static __inline void TOSH_MAKE_RFM_CTL0_OUTPUT(void);
static __inline void TOSH_SET_RFM_CTL1_PIN(void);
#line 79
static __inline void TOSH_CLR_RFM_CTL1_PIN(void);
#line 79
static __inline void TOSH_MAKE_RFM_CTL1_OUTPUT(void);

static __inline void TOSH_MAKE_PW0_OUTPUT(void);
static __inline void TOSH_MAKE_PW1_OUTPUT(void);
static __inline void TOSH_MAKE_PW2_OUTPUT(void);
static __inline void TOSH_MAKE_PW3_OUTPUT(void);
static __inline void TOSH_MAKE_PW4_OUTPUT(void);
static __inline void TOSH_MAKE_PW5_OUTPUT(void);
static __inline void TOSH_MAKE_PW6_OUTPUT(void);
static __inline void TOSH_MAKE_PW7_OUTPUT(void);









static __inline void TOSH_SET_UART_RXD0_PIN(void);


static __inline void TOSH_SET_ONE_WIRE_PIN(void);
#line 101
static __inline void TOSH_CLR_ONE_WIRE_PIN(void);
#line 101
static __inline void TOSH_MAKE_ONE_WIRE_OUTPUT(void);
#line 101
static __inline void TOSH_MAKE_ONE_WIRE_INPUT(void);
static inline 
void TOSH_SET_PIN_DIRECTIONS(void );
#line 146
enum __nesc_unnamed4248 {
  TOSH_ADC_PORTMAPSIZE = 12
};


enum __nesc_unnamed4249 {

  TOSH_ACTUAL_VOLTAGE_PORT = 7
};
enum __nesc_unnamed4250 {

  TOS_ADC_VOLTAGE_PORT = 7
};
# 54 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/types/dbg_modes.h"
typedef long long TOS_dbg_mode;



enum __nesc_unnamed4251 {
  DBG_ALL = ~0ULL, 


  DBG_BOOT = 1ULL << 0, 
  DBG_CLOCK = 1ULL << 1, 
  DBG_TASK = 1ULL << 2, 
  DBG_SCHED = 1ULL << 3, 
  DBG_SENSOR = 1ULL << 4, 
  DBG_LED = 1ULL << 5, 
  DBG_CRYPTO = 1ULL << 6, 


  DBG_ROUTE = 1ULL << 7, 
  DBG_AM = 1ULL << 8, 
  DBG_CRC = 1ULL << 9, 
  DBG_PACKET = 1ULL << 10, 
  DBG_ENCODE = 1ULL << 11, 
  DBG_RADIO = 1ULL << 12, 


  DBG_LOG = 1ULL << 13, 
  DBG_ADC = 1ULL << 14, 
  DBG_I2C = 1ULL << 15, 
  DBG_UART = 1ULL << 16, 
  DBG_PROG = 1ULL << 17, 
  DBG_SOUNDER = 1ULL << 18, 
  DBG_TIME = 1ULL << 19, 




  DBG_SIM = 1ULL << 21, 
  DBG_QUEUE = 1ULL << 22, 
  DBG_SIMRADIO = 1ULL << 23, 
  DBG_HARD = 1ULL << 24, 
  DBG_MEM = 1ULL << 25, 



  DBG_USR1 = 1ULL << 27, 
  DBG_USR2 = 1ULL << 28, 
  DBG_USR3 = 1ULL << 29, 
  DBG_TEMP = 1ULL << 30, 

  DBG_ERROR = 1ULL << 31, 
  DBG_NONE = 0, 

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

enum __nesc_unnamed4253 {
  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);
# 49 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/types/AM.h"
enum __nesc_unnamed4254 {
  TOS_BCAST_ADDR = 0xffff, 
  TOS_UART_ADDR = 0x007e
};





enum __nesc_unnamed4255 {
  TOS_DEFAULT_AM_GROUP = 0x7d
};

uint8_t TOS_AM_GROUP = TOS_DEFAULT_AM_GROUP;
#line 84
typedef struct TOS_Msg {


  uint16_t addr;
  uint8_t type;
  uint8_t group;
  uint8_t length;
  int8_t data[29];
  uint16_t crc;







  uint16_t strength;
  uint8_t ack;
  uint16_t time;
  uint8_t sendSecurityMode;
  uint8_t receiveSecurityMode;
} TOS_Msg;

typedef struct TOS_Msg_TinySecCompat {


  uint16_t addr;
  uint8_t type;

  uint8_t length;
  uint8_t group;
  int8_t data[29];
  uint16_t crc;







  uint16_t strength;
  uint8_t ack;
  uint16_t time;
  uint8_t sendSecurityMode;
  uint8_t receiveSecurityMode;
} TOS_Msg_TinySecCompat;

typedef struct TinySec_Msg {

  uint16_t addr;
  uint8_t type;
  uint8_t length;

  uint8_t iv[4];

  uint8_t enc[29];

  uint8_t mac[4];


  uint8_t calc_mac[4];
  uint8_t ack_byte;
  bool cryptoDone;
  bool receiveDone;

  bool validMAC;
} __attribute((packed))  TinySec_Msg;



enum __nesc_unnamed4256 {
  MSG_DATA_SIZE = (size_t )& ((struct TOS_Msg *)0)->crc + sizeof(uint16_t ), 
  TINYSEC_MSG_DATA_SIZE = (size_t )& ((struct TinySec_Msg *)0)->mac + 4, 
  DATA_LENGTH = 29, 
  LENGTH_BYTE_NUMBER = (size_t )& ((struct TOS_Msg *)0)->length + 1, 
  TINYSEC_NODE_ID_SIZE = sizeof(uint16_t )
};

enum __nesc_unnamed4257 {
  TINYSEC_AUTH_ONLY = 1, 
  TINYSEC_ENCRYPT_AND_AUTH = 2, 
  TINYSEC_DISABLED = 3, 
  TINYSEC_ENABLED_BIT = 128, 
  TINYSEC_ENCRYPT_ENABLED_BIT = 64
} __attribute((packed)) ;


typedef TOS_Msg *TOS_MsgPtr;
# 33 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/TosTime.h"
typedef struct __nesc_unnamed4258 {
  uint32_t high32;
  uint32_t low32;
} tos_time_t;
# 31 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/avrmote/crc.h"
uint16_t __attribute((__progmem__)) crcTable[256] = { 
0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50a5, 0x60c6, 0x70e7, 
0x8108, 0x9129, 0xa14a, 0xb16b, 0xc18c, 0xd1ad, 0xe1ce, 0xf1ef, 
0x1231, 0x0210, 0x3273, 0x2252, 0x52b5, 0x4294, 0x72f7, 0x62d6, 
0x9339, 0x8318, 0xb37b, 0xa35a, 0xd3bd, 0xc39c, 0xf3ff, 0xe3de, 
0x2462, 0x3443, 0x0420, 0x1401, 0x64e6, 0x74c7, 0x44a4, 0x5485, 
0xa56a, 0xb54b, 0x8528, 0x9509, 0xe5ee, 0xf5cf, 0xc5ac, 0xd58d, 
0x3653, 0x2672, 0x1611, 0x0630, 0x76d7, 0x66f6, 0x5695, 0x46b4, 
0xb75b, 0xa77a, 0x9719, 0x8738, 0xf7df, 0xe7fe, 0xd79d, 0xc7bc, 
0x48c4, 0x58e5, 0x6886, 0x78a7, 0x0840, 0x1861, 0x2802, 0x3823, 
0xc9cc, 0xd9ed, 0xe98e, 0xf9af, 0x8948, 0x9969, 0xa90a, 0xb92b, 
0x5af5, 0x4ad4, 0x7ab7, 0x6a96, 0x1a71, 0x0a50, 0x3a33, 0x2a12, 
0xdbfd, 0xcbdc, 0xfbbf, 0xeb9e, 0x9b79, 0x8b58, 0xbb3b, 0xab1a, 
0x6ca6, 0x7c87, 0x4ce4, 0x5cc5, 0x2c22, 0x3c03, 0x0c60, 0x1c41, 
0xedae, 0xfd8f, 0xcdec, 0xddcd, 0xad2a, 0xbd0b, 0x8d68, 0x9d49, 
0x7e97, 0x6eb6, 0x5ed5, 0x4ef4, 0x3e13, 0x2e32, 0x1e51, 0x0e70, 
0xff9f, 0xefbe, 0xdfdd, 0xcffc, 0xbf1b, 0xaf3a, 0x9f59, 0x8f78, 
0x9188, 0x81a9, 0xb1ca, 0xa1eb, 0xd10c, 0xc12d, 0xf14e, 0xe16f, 
0x1080, 0x00a1, 0x30c2, 0x20e3, 0x5004, 0x4025, 0x7046, 0x6067, 
0x83b9, 0x9398, 0xa3fb, 0xb3da, 0xc33d, 0xd31c, 0xe37f, 0xf35e, 
0x02b1, 0x1290, 0x22f3, 0x32d2, 0x4235, 0x5214, 0x6277, 0x7256, 
0xb5ea, 0xa5cb, 0x95a8, 0x8589, 0xf56e, 0xe54f, 0xd52c, 0xc50d, 
0x34e2, 0x24c3, 0x14a0, 0x0481, 0x7466, 0x6447, 0x5424, 0x4405, 
0xa7db, 0xb7fa, 0x8799, 0x97b8, 0xe75f, 0xf77e, 0xc71d, 0xd73c, 
0x26d3, 0x36f2, 0x0691, 0x16b0, 0x6657, 0x7676, 0x4615, 0x5634, 
0xd94c, 0xc96d, 0xf90e, 0xe92f, 0x99c8, 0x89e9, 0xb98a, 0xa9ab, 
0x5844, 0x4865, 0x7806, 0x6827, 0x18c0, 0x08e1, 0x3882, 0x28a3, 
0xcb7d, 0xdb5c, 0xeb3f, 0xfb1e, 0x8bf9, 0x9bd8, 0xabbb, 0xbb9a, 
0x4a75, 0x5a54, 0x6a37, 0x7a16, 0x0af1, 0x1ad0, 0x2ab3, 0x3a92, 
0xfd2e, 0xed0f, 0xdd6c, 0xcd4d, 0xbdaa, 0xad8b, 0x9de8, 0x8dc9, 
0x7c26, 0x6c07, 0x5c64, 0x4c45, 0x3ca2, 0x2c83, 0x1ce0, 0x0cc1, 
0xef1f, 0xff3e, 0xcf5d, 0xdf7c, 0xaf9b, 0xbfba, 0x8fd9, 0x9ff8, 
0x6e17, 0x7e36, 0x4e55, 0x5e74, 0x2e93, 0x3eb2, 0x0ed1, 0x1ef0 };
static inline 

uint16_t crcByte(uint16_t oldCrc, uint8_t byte);
static  result_t PotM$Pot$init(uint8_t arg_0xa272d88);
static  result_t HPLPotC$Pot$finalise(void);
static  result_t HPLPotC$Pot$decrease(void);
static  result_t HPLPotC$Pot$increase(void);
static  result_t HPLInit$init(void);
static  result_t TOSBaseM$UARTSend$sendDone(TOS_MsgPtr arg_0xa2c28f0, result_t arg_0xa2c2a40);
static  TOS_MsgPtr TOSBaseM$UARTTokenReceive$receive(TOS_MsgPtr arg_0xa2af480, uint8_t arg_0xa2af5c8);
static  TOS_MsgPtr TOSBaseM$RadioReceive$receive(TOS_MsgPtr arg_0xa2c3e00);
static  result_t TOSBaseM$RadioSend$sendDone(TOS_MsgPtr arg_0xa2c28f0, result_t arg_0xa2c2a40);
static  result_t TOSBaseM$StdControl$init(void);
static  result_t TOSBaseM$StdControl$start(void);
static  TOS_MsgPtr TOSBaseM$UARTReceive$receive(TOS_MsgPtr arg_0xa2c3e00);
static   result_t SlavePinM$SlavePin$low(void);
static   result_t SlavePinM$SlavePin$high(bool arg_0xa29fbe0);
static   result_t HPLSlavePinC$SlavePin$low(void);
static   result_t HPLSlavePinC$SlavePin$high(void);
static  result_t MicaHighSpeedRadioM$Send$send(TOS_MsgPtr arg_0xa2c23d8);
static   result_t MicaHighSpeedRadioM$Code$decodeDone(char arg_0xa341038, char arg_0xa341178);
static   result_t MicaHighSpeedRadioM$Code$encodeDone(char arg_0xa341598);
static   void MicaHighSpeedRadioM$RadioReceiveCoordinator$default$byte(TOS_MsgPtr arg_0xa320d88, uint8_t arg_0xa320ed8);
static   void MicaHighSpeedRadioM$RadioReceiveCoordinator$default$startSymbol(void);
static   result_t MicaHighSpeedRadioM$SpiByteFifo$dataReady(uint8_t arg_0xa34d458);
static  result_t MicaHighSpeedRadioM$Control$init(void);
static  result_t MicaHighSpeedRadioM$Control$start(void);
static   void MicaHighSpeedRadioM$RadioSendCoordinator$default$byte(TOS_MsgPtr arg_0xa320d88, uint8_t arg_0xa320ed8);
static   void MicaHighSpeedRadioM$RadioSendCoordinator$default$startSymbol(void);
static   result_t MicaHighSpeedRadioM$ChannelMon$idleDetect(void);
static   result_t MicaHighSpeedRadioM$ChannelMon$startSymDetect(void);
static   result_t SecDedEncoding$Code$encode_flush(void);
static   result_t SecDedEncoding$Code$decode(char arg_0xa340c20);
static   result_t SecDedEncoding$Code$encode(char arg_0xa340810);
static   uint16_t RandomLFSR$Random$rand(void);
static   result_t RandomLFSR$Random$init(void);
static   result_t ChannelMonC$ChannelMon$macDelay(void);
static   result_t ChannelMonC$ChannelMon$startSymbolSearch(void);
static   result_t ChannelMonC$ChannelMon$init(void);
static   uint16_t RadioTimingC$RadioTiming$currentTime(void);
static   uint16_t RadioTimingC$RadioTiming$getTiming(void);
static  result_t SpiByteFifoC$SlavePin$notifyHigh(void);
static   result_t SpiByteFifoC$SpiByteFifo$send(uint8_t arg_0xa34c0e8);
static   result_t SpiByteFifoC$SpiByteFifo$phaseShift(void);
static   result_t SpiByteFifoC$SpiByteFifo$startReadBytes(uint16_t arg_0xa34c7d8);
static   result_t SpiByteFifoC$SpiByteFifo$idle(void);
static   result_t SpiByteFifoC$SpiByteFifo$txMode(void);
static   result_t SpiByteFifoC$SpiByteFifo$rxMode(void);
static   uint8_t HPLPowerManagementM$PowerManagement$adjustPower(void);
static   result_t FramerM$ByteComm$txDone(void);
static   result_t FramerM$ByteComm$txByteReady(bool arg_0xa4208b8);
static   result_t FramerM$ByteComm$rxByteReady(uint8_t arg_0xa4200e8, bool arg_0xa420230, uint16_t arg_0xa420388);
static  result_t FramerM$BareSendMsg$send(TOS_MsgPtr arg_0xa2c23d8);
static  result_t FramerM$StdControl$init(void);
static  result_t FramerM$StdControl$start(void);
static  result_t FramerM$TokenReceiveMsg$ReflectToken(uint8_t arg_0xa2afbe0);
static   result_t UARTM$HPLUART$get(uint8_t arg_0xa459a58);
static   result_t UARTM$HPLUART$putDone(void);
static   result_t UARTM$ByteComm$txByte(uint8_t arg_0xa40dc48);
static  result_t UARTM$Control$init(void);
static  result_t UARTM$Control$start(void);
static   result_t HPLUARTM$UART$init(void);
static   result_t HPLUARTM$UART$put(uint8_t arg_0xa459558);
static   result_t LedsC$Leds$yellowOff(void);
static   result_t LedsC$Leds$yellowOn(void);
static   result_t LedsC$Leds$init(void);
static   result_t LedsC$Leds$greenOff(void);
static   result_t LedsC$Leds$redOff(void);
static   result_t LedsC$Leds$greenToggle(void);
static   result_t LedsC$Leds$yellowToggle(void);
static   result_t LedsC$Leds$redToggle(void);
static   result_t LedsC$Leds$redOn(void);
static   result_t LedsC$Leds$greenOn(void);
static  
# 47 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/RealMain.nc"
result_t RealMain$hardwareInit(void);
static  
# 78 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/Pot.nc"
result_t RealMain$Pot$init(uint8_t arg_0xa272d88);
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);
# 54 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/RealMain.nc"
int   main(void);
static  
# 74 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/HPLPot.nc"
result_t PotM$HPLPot$finalise(void);
static  
#line 59
result_t PotM$HPLPot$decrease(void);
static  






result_t PotM$HPLPot$increase(void);
# 91 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/PotM.nc"
uint8_t PotM$potSetting;
static inline 
void PotM$setPot(uint8_t value);
static inline  
#line 106
result_t PotM$Pot$init(uint8_t initialSetting);
static inline  
# 56 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/avrmote/HPLPotC.nc"
result_t HPLPotC$Pot$decrease(void);
static inline  







result_t HPLPotC$Pot$increase(void);
static inline  







result_t HPLPotC$Pot$finalise(void);
static inline  
# 57 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/avrmote/HPLInit.nc"
result_t HPLInit$init(void);
static  
# 58 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/BareSendMsg.nc"
result_t TOSBaseM$UARTSend$send(TOS_MsgPtr arg_0xa2c23d8);
static  
# 63 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/StdControl.nc"
result_t TOSBaseM$RadioControl$init(void);
static  





result_t TOSBaseM$RadioControl$start(void);
static  
# 88 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/TokenReceiveMsg.nc"
result_t TOSBaseM$UARTTokenReceive$ReflectToken(uint8_t arg_0xa2afbe0);
static  
# 63 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/StdControl.nc"
result_t TOSBaseM$UARTControl$init(void);
static  





result_t TOSBaseM$UARTControl$start(void);
static   
# 56 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/Leds.nc"
result_t TOSBaseM$Leds$init(void);
static   
#line 106
result_t TOSBaseM$Leds$greenToggle(void);
static   
#line 131
result_t TOSBaseM$Leds$yellowToggle(void);
static   
#line 81
result_t TOSBaseM$Leds$redToggle(void);
static  
# 58 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/BareSendMsg.nc"
result_t TOSBaseM$RadioSend$send(TOS_MsgPtr arg_0xa2c23d8);
# 65 "TOSBaseM.nc"
enum TOSBaseM$__nesc_unnamed4259 {
  TOSBaseM$QUEUE_SIZE = 5
};

enum TOSBaseM$__nesc_unnamed4260 {
  TOSBaseM$TXFLAG_BUSY = 0x1, 
  TOSBaseM$TXFLAG_TOKEN = 0x2
};


TOS_Msg TOSBaseM$gRxBufPool[TOSBaseM$QUEUE_SIZE];
TOS_MsgPtr TOSBaseM$gRxBufPoolTbl[TOSBaseM$QUEUE_SIZE];
uint8_t TOSBaseM$gRxHeadIndex;
#line 77
uint8_t TOSBaseM$gRxTailIndex;

TOS_Msg TOSBaseM$gTxBuf;
TOS_MsgPtr TOSBaseM$gpTxMsg;
uint8_t TOSBaseM$gTxPendingToken;
uint8_t TOSBaseM$gfTxFlags;
static inline  
void TOSBaseM$RadioRcvdTask(void);
static  
#line 102
void TOSBaseM$UARTRcvdTask(void);
static inline  
#line 117
void TOSBaseM$SendAckTask(void);
static inline  







result_t TOSBaseM$StdControl$init(void);
static inline  
#line 150
result_t TOSBaseM$StdControl$start(void);
static inline  
#line 168
TOS_MsgPtr TOSBaseM$RadioReceive$receive(TOS_MsgPtr Msg);
static inline  
#line 204
TOS_MsgPtr TOSBaseM$UARTReceive$receive(TOS_MsgPtr Msg);
static inline  
#line 231
TOS_MsgPtr TOSBaseM$UARTTokenReceive$receive(TOS_MsgPtr Msg, uint8_t Token);
static inline  
#line 259
result_t TOSBaseM$UARTSend$sendDone(TOS_MsgPtr Msg, result_t success);
static inline  



result_t TOSBaseM$RadioSend$sendDone(TOS_MsgPtr Msg, result_t success);
static  
# 66 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/mica/SlavePin.nc"
result_t SlavePinM$SlavePin$notifyHigh(void);
static   
# 47 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/mica/HPLSlavePin.nc"
result_t SlavePinM$HPLSlavePin$low(void);
static   result_t SlavePinM$HPLSlavePin$high(void);
# 90 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/mica/SlavePinM.nc"
int8_t SlavePinM$n;
bool SlavePinM$signalHigh;
static 
#line 110
__inline   result_t SlavePinM$SlavePin$low(void);
static inline  







void SlavePinM$signalHighTask(void);
static 





__inline   result_t SlavePinM$SlavePin$high(bool needEvent);
static inline   
# 52 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/mica/HPLSlavePinC.nc"
result_t HPLSlavePinC$SlavePin$high(void);
static inline   




result_t HPLSlavePinC$SlavePin$low(void);
static   
# 34 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/mica/RadioTiming.nc"
uint16_t MicaHighSpeedRadioM$RadioTiming$currentTime(void);
static   
#line 33
uint16_t MicaHighSpeedRadioM$RadioTiming$getTiming(void);
static  
# 67 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/BareSendMsg.nc"
result_t MicaHighSpeedRadioM$Send$sendDone(TOS_MsgPtr arg_0xa2c28f0, result_t arg_0xa2c2a40);
static   
# 57 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/Random.nc"
result_t MicaHighSpeedRadioM$Random$init(void);
static   
# 33 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/mica/RadioEncoding.nc"
result_t MicaHighSpeedRadioM$Code$encode_flush(void);
static   
result_t MicaHighSpeedRadioM$Code$decode(char arg_0xa340c20);
static   
#line 34
result_t MicaHighSpeedRadioM$Code$encode(char arg_0xa340810);
static   
# 41 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/PowerManagement.nc"
uint8_t MicaHighSpeedRadioM$PowerManagement$adjustPower(void);
static  
# 75 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/ReceiveMsg.nc"
TOS_MsgPtr MicaHighSpeedRadioM$Receive$receive(TOS_MsgPtr arg_0xa2c3e00);
static   
# 48 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/RadioCoordinator.nc"
void MicaHighSpeedRadioM$RadioReceiveCoordinator$byte(TOS_MsgPtr arg_0xa320d88, uint8_t arg_0xa320ed8);
static   
#line 45
void MicaHighSpeedRadioM$RadioReceiveCoordinator$startSymbol(void);
static   
# 33 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/mica/SpiByteFifo.nc"
result_t MicaHighSpeedRadioM$SpiByteFifo$send(uint8_t arg_0xa34c0e8);
static   



result_t MicaHighSpeedRadioM$SpiByteFifo$phaseShift(void);
static   
#line 35
result_t MicaHighSpeedRadioM$SpiByteFifo$startReadBytes(uint16_t arg_0xa34c7d8);
static   
#line 34
result_t MicaHighSpeedRadioM$SpiByteFifo$idle(void);
static   
result_t MicaHighSpeedRadioM$SpiByteFifo$txMode(void);
static   result_t MicaHighSpeedRadioM$SpiByteFifo$rxMode(void);
static   
# 48 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/RadioCoordinator.nc"
void MicaHighSpeedRadioM$RadioSendCoordinator$byte(TOS_MsgPtr arg_0xa320d88, uint8_t arg_0xa320ed8);
static   
#line 45
void MicaHighSpeedRadioM$RadioSendCoordinator$startSymbol(void);
static   
# 36 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/mica/ChannelMon.nc"
result_t MicaHighSpeedRadioM$ChannelMon$macDelay(void);
static   
#line 34
result_t MicaHighSpeedRadioM$ChannelMon$startSymbolSearch(void);
static   
#line 33
result_t MicaHighSpeedRadioM$ChannelMon$init(void);
# 55 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/mica/MicaHighSpeedRadioM.nc"
enum MicaHighSpeedRadioM$__nesc_unnamed4261 {
  MicaHighSpeedRadioM$IDLE_STATE, 
  MicaHighSpeedRadioM$SEND_WAITING, 
  MicaHighSpeedRadioM$RX_STATE, 
  MicaHighSpeedRadioM$TRANSMITTING, 
  MicaHighSpeedRadioM$WAITING_FOR_ACK, 
  MicaHighSpeedRadioM$SENDING_STRENGTH_PULSE, 
  MicaHighSpeedRadioM$TRANSMITTING_START, 
  MicaHighSpeedRadioM$RX_DONE_STATE, 
  MicaHighSpeedRadioM$ACK_SEND_STATE, 
  MicaHighSpeedRadioM$STOPPED_STATE
};

enum MicaHighSpeedRadioM$__nesc_unnamed4262 {
  MicaHighSpeedRadioM$ACK_CNT = 4, 
  MicaHighSpeedRadioM$ENCODE_PACKET_LENGTH_DEFAULT = MSG_DATA_SIZE * 3
};






char  TOSH_MHSR_start[12] = 
{ 0xf0, 0xf0, 0xf0, 0xff, 0x00, 0xff, 0x0f, 0x00, 0xff, 0x0f, 0x0f, 0x0f };

char MicaHighSpeedRadioM$state;
char MicaHighSpeedRadioM$send_state;
char MicaHighSpeedRadioM$tx_count;
uint16_t MicaHighSpeedRadioM$calc_crc;
uint8_t MicaHighSpeedRadioM$ack_count;
char MicaHighSpeedRadioM$rec_count;
TOS_Msg MicaHighSpeedRadioM$buffer;
TOS_Msg *MicaHighSpeedRadioM$rec_ptr;
TOS_Msg *MicaHighSpeedRadioM$send_ptr;
unsigned char MicaHighSpeedRadioM$rx_count;
char MicaHighSpeedRadioM$msg_length;
char MicaHighSpeedRadioM$buf_head;
char MicaHighSpeedRadioM$buf_end;
char MicaHighSpeedRadioM$encoded_buffer[4];
char MicaHighSpeedRadioM$enc_count;
static inline  



void MicaHighSpeedRadioM$packetReceived(void);
static inline  
#line 113
void MicaHighSpeedRadioM$packetSent(void);
static inline  
#line 125
result_t MicaHighSpeedRadioM$Send$send(TOS_MsgPtr msg);
static inline  
#line 144
result_t MicaHighSpeedRadioM$Control$init(void);
static inline  









result_t MicaHighSpeedRadioM$Control$start(void);
static inline   
#line 197
result_t MicaHighSpeedRadioM$ChannelMon$startSymDetect(void);
static inline   
#line 218
result_t MicaHighSpeedRadioM$ChannelMon$idleDetect(void);
static inline   
#line 259
result_t MicaHighSpeedRadioM$Code$decodeDone(char data, char error);
static   
#line 299
result_t MicaHighSpeedRadioM$Code$encodeDone(char data1);
static   








result_t MicaHighSpeedRadioM$SpiByteFifo$dataReady(uint8_t data);
static inline    
#line 400
void MicaHighSpeedRadioM$RadioSendCoordinator$default$startSymbol(void);
static inline    void MicaHighSpeedRadioM$RadioSendCoordinator$default$byte(TOS_MsgPtr msg, uint8_t byteCount);
static inline    void MicaHighSpeedRadioM$RadioReceiveCoordinator$default$startSymbol(void);
static inline    void MicaHighSpeedRadioM$RadioReceiveCoordinator$default$byte(TOS_MsgPtr msg, uint8_t byteCount);
static   
# 36 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/mica/RadioEncoding.nc"
result_t SecDedEncoding$Code$decodeDone(char arg_0xa341038, char arg_0xa341178);
static   result_t SecDedEncoding$Code$encodeDone(char arg_0xa341598);
# 39 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/mica/SecDedEncoding.nc"
enum SecDedEncoding$__nesc_unnamed4263 {
  SecDedEncoding$IDLE_STATE = 0, 
  SecDedEncoding$DECODING_BYTE_3 = 1, 
  SecDedEncoding$DECODING_BYTE_2 = 2, 
  SecDedEncoding$DECODING_BYTE_1 = 3, 
  SecDedEncoding$ENCODING_BYTE = 4
};

char SecDedEncoding$data1;
char SecDedEncoding$data2;
char SecDedEncoding$data3;
char SecDedEncoding$state;
static inline 
void SecDedEncoding$radio_decode_thread(void);
static inline void SecDedEncoding$radio_encode_thread(void);
static inline   
result_t SecDedEncoding$Code$decode(char d1);
static inline   
#line 76
result_t SecDedEncoding$Code$encode_flush(void);
static   


result_t SecDedEncoding$Code$encode(char d);
static inline 
#line 99
void SecDedEncoding$radio_encode_thread(void);
static inline 
#line 167
void SecDedEncoding$radio_decode_thread(void);
# 54 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/RandomLFSR.nc"
uint16_t RandomLFSR$shiftReg;
uint16_t RandomLFSR$initSeed;
uint16_t RandomLFSR$mask;
static inline   

result_t RandomLFSR$Random$init(void);
static   









uint16_t RandomLFSR$Random$rand(void);
static   
# 63 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/Random.nc"
uint16_t ChannelMonC$Random$rand(void);
static   
# 39 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/mica/ChannelMon.nc"
result_t ChannelMonC$ChannelMon$idleDetect(void);
static   
#line 38
result_t ChannelMonC$ChannelMon$startSymDetect(void);
# 42 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/mica/ChannelMonC.nc"
enum ChannelMonC$__nesc_unnamed4264 {
  ChannelMonC$IDLE_STATE, 
  ChannelMonC$START_SYMBOL_SEARCH, 
  ChannelMonC$PACKET_START, 
  ChannelMonC$DISABLED_STATE
};

enum ChannelMonC$__nesc_unnamed4265 {
  ChannelMonC$SAMPLE_RATE = 100 / 2 * 4
};

unsigned short ChannelMonC$CM_search[2];
char ChannelMonC$CM_state;
unsigned char ChannelMonC$CM_lastBit;
unsigned char ChannelMonC$CM_startSymBits;
short ChannelMonC$CM_waiting;
static inline   
result_t ChannelMonC$ChannelMon$init(void);
static   





result_t ChannelMonC$ChannelMon$startSymbolSearch(void);
#line 94
void __attribute((signal))   __vector_9(void);
static inline   
#line 151
result_t ChannelMonC$ChannelMon$macDelay(void);
static inline   
# 40 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/mica/RadioTimingC.nc"
uint16_t RadioTimingC$RadioTiming$getTiming(void);
static inline   
#line 55
uint16_t RadioTimingC$RadioTiming$currentTime(void);
static   
# 51 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/mica/SlavePin.nc"
result_t SpiByteFifoC$SlavePin$low(void);
static   








result_t SpiByteFifoC$SlavePin$high(bool arg_0xa29fbe0);
static   
# 40 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/mica/SpiByteFifo.nc"
result_t SpiByteFifoC$SpiByteFifo$dataReady(uint8_t arg_0xa34d458);
# 41 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/mica/SpiByteFifoC.nc"
uint8_t SpiByteFifoC$nextByte;
uint8_t SpiByteFifoC$state;

enum SpiByteFifoC$__nesc_unnamed4266 {
  SpiByteFifoC$IDLE, 
  SpiByteFifoC$FULL, 
  SpiByteFifoC$OPEN, 
  SpiByteFifoC$READING
};

enum SpiByteFifoC$__nesc_unnamed4267 {
  SpiByteFifoC$BIT_RATE = 20 * 4 / 2 * 5 / 4
};


void __attribute((signal))   __vector_17(void);
static   
#line 71
result_t SpiByteFifoC$SpiByteFifo$send(uint8_t data);
static   
#line 102
result_t SpiByteFifoC$SpiByteFifo$idle(void);
static inline   
#line 119
result_t SpiByteFifoC$SpiByteFifo$startReadBytes(uint16_t timing);
static inline   
#line 164
result_t SpiByteFifoC$SpiByteFifo$txMode(void);
static inline   






result_t SpiByteFifoC$SpiByteFifo$rxMode(void);
static inline   
#line 188
result_t SpiByteFifoC$SpiByteFifo$phaseShift(void);
static inline  








result_t SpiByteFifoC$SlavePin$notifyHigh(void);
# 51 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/mica/HPLPowerManagementM.nc"
bool HPLPowerManagementM$disabled = TRUE;

enum HPLPowerManagementM$__nesc_unnamed4268 {
  HPLPowerManagementM$IDLE = 0, 
  HPLPowerManagementM$ADC_NR = 1 << 3, 
  HPLPowerManagementM$POWER_SAVE = (1 << 3) + (1 << 4), 
  HPLPowerManagementM$POWER_DOWN = 1 << 3
};
static inline 


uint8_t HPLPowerManagementM$getPowerLevel(void);
static inline  
#line 85
void HPLPowerManagementM$doAdjustment(void);
static inline   
#line 103
uint8_t HPLPowerManagementM$PowerManagement$adjustPower(void);
static  
# 75 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/ReceiveMsg.nc"
TOS_MsgPtr FramerM$ReceiveMsg$receive(TOS_MsgPtr arg_0xa2c3e00);
static   
# 55 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/ByteComm.nc"
result_t FramerM$ByteComm$txByte(uint8_t arg_0xa40dc48);
static  
# 63 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/StdControl.nc"
result_t FramerM$ByteControl$init(void);
static  





result_t FramerM$ByteControl$start(void);
static  
# 67 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/BareSendMsg.nc"
result_t FramerM$BareSendMsg$sendDone(TOS_MsgPtr arg_0xa2c28f0, result_t arg_0xa2c2a40);
static  
# 75 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/TokenReceiveMsg.nc"
TOS_MsgPtr FramerM$TokenReceiveMsg$receive(TOS_MsgPtr arg_0xa2af480, uint8_t arg_0xa2af5c8);
# 82 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/FramerM.nc"
enum FramerM$__nesc_unnamed4269 {
  FramerM$HDLC_QUEUESIZE = 2, 
  FramerM$HDLC_MTU = sizeof(TOS_Msg ), 
  FramerM$HDLC_FLAG_BYTE = 0x7e, 
  FramerM$HDLC_CTLESC_BYTE = 0x7d, 
  FramerM$PROTO_ACK = 64, 
  FramerM$PROTO_PACKET_ACK = 65, 
  FramerM$PROTO_PACKET_NOACK = 66, 
  FramerM$PROTO_UNKNOWN = 255
};

enum FramerM$__nesc_unnamed4270 {
  FramerM$RXSTATE_NOSYNC, 
  FramerM$RXSTATE_PROTO, 
  FramerM$RXSTATE_TOKEN, 
  FramerM$RXSTATE_INFO, 
  FramerM$RXSTATE_ESC
};

enum FramerM$__nesc_unnamed4271 {
  FramerM$TXSTATE_IDLE, 
  FramerM$TXSTATE_PROTO, 
  FramerM$TXSTATE_INFO, 
  FramerM$TXSTATE_ESC, 
  FramerM$TXSTATE_FCS1, 
  FramerM$TXSTATE_FCS2, 
  FramerM$TXSTATE_ENDFLAG, 
  FramerM$TXSTATE_FINISH, 
  FramerM$TXSTATE_ERROR
};

enum FramerM$__nesc_unnamed4272 {
  FramerM$FLAGS_TOKENPEND = 0x2, 
  FramerM$FLAGS_DATAPEND = 0x4, 
  FramerM$FLAGS_UNKNOWN = 0x8
};

TOS_Msg FramerM$gMsgRcvBuf[FramerM$HDLC_QUEUESIZE];

typedef struct FramerM$_MsgRcvEntry {
  uint8_t Proto;
  uint8_t Token;
  uint16_t Length;
  TOS_MsgPtr pMsg;
} FramerM$MsgRcvEntry_t;

FramerM$MsgRcvEntry_t FramerM$gMsgRcvTbl[FramerM$HDLC_QUEUESIZE];

uint8_t *FramerM$gpRxBuf;
uint8_t *FramerM$gpTxBuf;

uint8_t FramerM$gFlags;
 

uint8_t FramerM$gTxState;
 uint8_t FramerM$gPrevTxState;
 uint8_t FramerM$gTxProto;
 uint16_t FramerM$gTxByteCnt;
 uint16_t FramerM$gTxLength;
 uint16_t FramerM$gTxRunningCRC;


uint8_t FramerM$gRxState;
uint8_t FramerM$gRxHeadIndex;
uint8_t FramerM$gRxTailIndex;
uint16_t FramerM$gRxByteCnt;

uint16_t FramerM$gRxRunningCRC;

TOS_MsgPtr FramerM$gpTxMsg;
uint8_t FramerM$gTxTokenBuf;
uint8_t FramerM$gTxUnknownBuf;
 uint8_t FramerM$gTxEscByte;
static  
void FramerM$PacketSent(void);
static 
result_t FramerM$StartTx(void);
static inline  
#line 202
void FramerM$PacketUnknown(void);
static inline  






void FramerM$PacketRcvd(void);
static  
#line 246
void FramerM$PacketSent(void);
static 
#line 268
void FramerM$HDLCInitialize(void);
static inline  
#line 291
result_t FramerM$StdControl$init(void);
static inline  



result_t FramerM$StdControl$start(void);
static inline  








result_t FramerM$BareSendMsg$send(TOS_MsgPtr pMsg);
static inline  
#line 328
result_t FramerM$TokenReceiveMsg$ReflectToken(uint8_t Token);
static   
#line 348
result_t FramerM$ByteComm$rxByteReady(uint8_t data, bool error, uint16_t strength);
static 
#line 469
result_t FramerM$TxArbitraryByte(uint8_t Byte);
static inline   
#line 482
result_t FramerM$ByteComm$txByteReady(bool LastByteSuccess);
static inline   
#line 552
result_t FramerM$ByteComm$txDone(void);
static   
# 62 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/HPLUART.nc"
result_t UARTM$HPLUART$init(void);
static   
#line 80
result_t UARTM$HPLUART$put(uint8_t arg_0xa459558);
static   
# 83 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/ByteComm.nc"
result_t UARTM$ByteComm$txDone(void);
static   
#line 75
result_t UARTM$ByteComm$txByteReady(bool arg_0xa4208b8);
static   
#line 66
result_t UARTM$ByteComm$rxByteReady(uint8_t arg_0xa4200e8, bool arg_0xa420230, uint16_t arg_0xa420388);
# 58 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/UARTM.nc"
bool UARTM$state;
static inline  
result_t UARTM$Control$init(void);
static inline  






result_t UARTM$Control$start(void);
static inline   







result_t UARTM$HPLUART$get(uint8_t data);
static   








result_t UARTM$HPLUART$putDone(void);
static   
#line 110
result_t UARTM$ByteComm$txByte(uint8_t data);
static   
# 88 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/HPLUART.nc"
result_t HPLUARTM$UART$get(uint8_t arg_0xa459a58);
static   






result_t HPLUARTM$UART$putDone(void);
static inline   
# 56 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/avrmote/HPLUARTM.nc"
result_t HPLUARTM$UART$init(void);
#line 71
void __attribute((signal))   __vector_18(void);





void __attribute((interrupt))   __vector_20(void);
static inline   


result_t HPLUARTM$UART$put(uint8_t data);
# 50 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/LedsC.nc"
uint8_t LedsC$ledsOn;

enum LedsC$__nesc_unnamed4273 {
  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);
static inline   









result_t LedsC$Leds$greenOn(void);
static inline   







result_t LedsC$Leds$greenOff(void);
static inline   







result_t LedsC$Leds$greenToggle(void);
static inline   









result_t LedsC$Leds$yellowOn(void);
static inline   







result_t LedsC$Leds$yellowOff(void);
static inline   







result_t LedsC$Leds$yellowToggle(void);
# 101 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/mica/hardware.h"
static __inline void TOSH_SET_ONE_WIRE_PIN(void)
#line 101
{
#line 101
  * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x03 + 0x20) |= 1 << 5;
}

#line 101
static __inline void TOSH_MAKE_ONE_WIRE_INPUT(void)
#line 101
{
#line 101
  * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x02 + 0x20) &= ~(1 << 5);
}

#line 65
static __inline void TOSH_SET_BOOST_ENABLE_PIN(void)
#line 65
{
#line 65
  * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x03 + 0x20) |= 1 << 4;
}

#line 65
static __inline void TOSH_MAKE_BOOST_ENABLE_OUTPUT(void)
#line 65
{
#line 65
  * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x02 + 0x20) |= 1 << 4;
}

#line 59
static __inline void TOSH_SET_GREEN_LED_PIN(void)
#line 59
{
#line 59
  * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x1B + 0x20) |= 1 << 1;
}

#line 58
static __inline void TOSH_SET_YELLOW_LED_PIN(void)
#line 58
{
#line 58
  * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x1B + 0x20) |= 1 << 0;
}

#line 57
static __inline void TOSH_SET_RED_LED_PIN(void)
#line 57
{
#line 57
  * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x1B + 0x20) |= 1 << 2;
}








static __inline void TOSH_MAKE_FLASH_SELECT_INPUT(void)
#line 67
{
#line 67
  * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x17 + 0x20) &= ~(1 << 0);
}

#line 64
static __inline void TOSH_SET_POT_POWER_PIN(void)
#line 64
{
#line 64
  * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x03 + 0x20) |= 1 << 7;
}











static __inline void TOSH_MAKE_RFM_TXD_OUTPUT(void)
#line 77
{
#line 77
  * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x17 + 0x20) |= 1 << 3;
}

#line 79
static __inline void TOSH_MAKE_RFM_CTL1_OUTPUT(void)
#line 79
{
#line 79
  * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x11 + 0x20) |= 1 << 6;
}

#line 78
static __inline void TOSH_MAKE_RFM_CTL0_OUTPUT(void)
#line 78
{
#line 78
  * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x11 + 0x20) |= 1 << 7;
}

static __inline void TOSH_MAKE_PW0_OUTPUT(void)
#line 81
{
#line 81
  ;
}

#line 82
static __inline void TOSH_MAKE_PW1_OUTPUT(void)
#line 82
{
#line 82
  ;
}

#line 83
static __inline void TOSH_MAKE_PW2_OUTPUT(void)
#line 83
{
#line 83
  ;
}

#line 84
static __inline void TOSH_MAKE_PW3_OUTPUT(void)
#line 84
{
#line 84
  ;
}

#line 85
static __inline void TOSH_MAKE_PW4_OUTPUT(void)
#line 85
{
#line 85
  ;
}

#line 86
static __inline void TOSH_MAKE_PW5_OUTPUT(void)
#line 86
{
#line 86
  ;
}

#line 87
static __inline void TOSH_MAKE_PW6_OUTPUT(void)
#line 87
{
#line 87
  ;
}

#line 88
static __inline void TOSH_MAKE_PW7_OUTPUT(void)
#line 88
{
#line 88
  ;
}

#line 64
static __inline void TOSH_MAKE_POT_POWER_OUTPUT(void)
#line 64
{
#line 64
  * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x02 + 0x20) |= 1 << 7;
}

#line 63
static __inline void TOSH_MAKE_POT_SELECT_OUTPUT(void)
#line 63
{
#line 63
  * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x11 + 0x20) |= 1 << 5;
}

#line 59
static __inline void TOSH_MAKE_GREEN_LED_OUTPUT(void)
#line 59
{
#line 59
  * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x1A + 0x20) |= 1 << 1;
}

#line 58
static __inline void TOSH_MAKE_YELLOW_LED_OUTPUT(void)
#line 58
{
#line 58
  * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x1A + 0x20) |= 1 << 0;
}

#line 57
static __inline void TOSH_MAKE_RED_LED_OUTPUT(void)
#line 57
{
#line 57
  * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x1A + 0x20) |= 1 << 2;
}

static inline 
#line 103
void 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_POT_SELECT_OUTPUT();
  TOSH_MAKE_POT_POWER_OUTPUT();

  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_RFM_CTL0_OUTPUT();
  TOSH_MAKE_RFM_CTL1_OUTPUT();
  TOSH_MAKE_RFM_TXD_OUTPUT();
  TOSH_SET_POT_POWER_PIN();



  TOSH_MAKE_FLASH_SELECT_INPUT();

  TOSH_SET_RED_LED_PIN();
  TOSH_SET_YELLOW_LED_PIN();
  TOSH_SET_GREEN_LED_PIN();


  TOSH_MAKE_BOOST_ENABLE_OUTPUT();
  TOSH_SET_BOOST_ENABLE_PIN();

  TOSH_MAKE_ONE_WIRE_INPUT();
  TOSH_SET_ONE_WIRE_PIN();
}

static inline  
# 57 "C:/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 "C:/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 47
# 62 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/mica/hardware.h"
static __inline void TOSH_SET_INC_PIN(void)
#line 62
{
#line 62
  * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x1B + 0x20) |= 1 << 2;
}

#line 61
static __inline void TOSH_SET_UD_PIN(void)
#line 61
{
#line 61
  * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x1B + 0x20) |= 1 << 1;
}

static inline  
# 74 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/avrmote/HPLPotC.nc"
result_t HPLPotC$Pot$finalise(void)
#line 74
{
  TOSH_SET_UD_PIN();
  TOSH_SET_INC_PIN();
  return SUCCESS;
}

# 74 "C:/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 74
# 63 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/mica/hardware.h"
static __inline void TOSH_SET_POT_SELECT_PIN(void)
#line 63
{
#line 63
  * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x12 + 0x20) |= 1 << 5;
}

#line 62
static __inline void TOSH_CLR_INC_PIN(void)
#line 62
{
#line 62
  * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x1B + 0x20) &= ~(1 << 2);
}

#line 63
static __inline void TOSH_CLR_POT_SELECT_PIN(void)
#line 63
{
#line 63
  * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x12 + 0x20) &= ~(1 << 5);
}

#line 61
static __inline void TOSH_CLR_UD_PIN(void)
#line 61
{
#line 61
  * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x1B + 0x20) &= ~(1 << 1);
}

static inline  
# 65 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/avrmote/HPLPotC.nc"
result_t HPLPotC$Pot$increase(void)
#line 65
{
  TOSH_CLR_UD_PIN();
  TOSH_CLR_POT_SELECT_PIN();
  TOSH_SET_INC_PIN();
  TOSH_CLR_INC_PIN();
  TOSH_SET_POT_SELECT_PIN();
  return SUCCESS;
}

# 67 "C:/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 67
static inline  
# 56 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/avrmote/HPLPotC.nc"
result_t HPLPotC$Pot$decrease(void)
#line 56
{
  TOSH_SET_UD_PIN();
  TOSH_CLR_POT_SELECT_PIN();
  TOSH_SET_INC_PIN();
  TOSH_CLR_INC_PIN();
  TOSH_SET_POT_SELECT_PIN();
  return SUCCESS;
}

# 59 "C:/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 59
static inline 
# 93 "C:/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 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/Pot.nc"
inline static  result_t RealMain$Pot$init(uint8_t arg_0xa272d88){
#line 78
  unsigned char result;
#line 78

#line 78
  result = PotM$Pot$init(arg_0xa272d88);
#line 78

#line 78
  return result;
#line 78
}
#line 78
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 result_t rcombine3(result_t r1, result_t r2, result_t r3)
{
  return rcombine(r1, rcombine(r2, r3));
}

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 TOSBaseM$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 56
static inline   
# 59 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/RandomLFSR.nc"
result_t RandomLFSR$Random$init(void)
#line 59
{
  {
  }
#line 60
  ;
  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 61
    {
      RandomLFSR$shiftReg = 119 * 119 * (TOS_LOCAL_ADDRESS + 1);
      RandomLFSR$initSeed = RandomLFSR$shiftReg;
      RandomLFSR$mask = 137 * 29 * (TOS_LOCAL_ADDRESS + 1);
    }
#line 65
    __nesc_atomic_end(__nesc_atomic); }
  return SUCCESS;
}

# 57 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/Random.nc"
inline static   result_t MicaHighSpeedRadioM$Random$init(void){
#line 57
  unsigned char result;
#line 57

#line 57
  result = RandomLFSR$Random$init();
#line 57

#line 57
  return result;
#line 57
}
#line 57
static inline   
# 59 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/mica/ChannelMonC.nc"
result_t ChannelMonC$ChannelMon$init(void)
#line 59
{
  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 60
    {
      ChannelMonC$CM_waiting = -1;
    }
#line 62
    __nesc_atomic_end(__nesc_atomic); }
  return ChannelMonC$ChannelMon$startSymbolSearch();
}

# 33 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/mica/ChannelMon.nc"
inline static   result_t MicaHighSpeedRadioM$ChannelMon$init(void){
#line 33
  unsigned char result;
#line 33

#line 33
  result = ChannelMonC$ChannelMon$init();
#line 33

#line 33
  return result;
#line 33
}
#line 33
static inline  
# 144 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/mica/MicaHighSpeedRadioM.nc"
result_t MicaHighSpeedRadioM$Control$init(void)
#line 144
{
  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 145
    {
      MicaHighSpeedRadioM$rec_ptr = &MicaHighSpeedRadioM$buffer;
      MicaHighSpeedRadioM$send_state = MicaHighSpeedRadioM$IDLE_STATE;
      MicaHighSpeedRadioM$state = MicaHighSpeedRadioM$IDLE_STATE;
    }
#line 149
    __nesc_atomic_end(__nesc_atomic); }
  return rcombine(MicaHighSpeedRadioM$ChannelMon$init(), MicaHighSpeedRadioM$Random$init());
}

# 63 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/StdControl.nc"
inline static  result_t TOSBaseM$RadioControl$init(void){
#line 63
  unsigned char result;
#line 63

#line 63
  result = MicaHighSpeedRadioM$Control$init();
#line 63

#line 63
  return result;
#line 63
}
#line 63
static inline  
# 60 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/UARTM.nc"
result_t UARTM$Control$init(void)
#line 60
{
  {
  }
#line 61
  ;
  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 62
    {
      UARTM$state = FALSE;
    }
#line 64
    __nesc_atomic_end(__nesc_atomic); }
  return SUCCESS;
}

# 63 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/StdControl.nc"
inline static  result_t FramerM$ByteControl$init(void){
#line 63
  unsigned char result;
#line 63

#line 63
  result = UARTM$Control$init();
#line 63

#line 63
  return result;
#line 63
}
#line 63
static inline  
# 291 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/FramerM.nc"
result_t FramerM$StdControl$init(void)
#line 291
{
  FramerM$HDLCInitialize();
  return FramerM$ByteControl$init();
}

# 63 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/StdControl.nc"
inline static  result_t TOSBaseM$UARTControl$init(void){
#line 63
  unsigned char result;
#line 63

#line 63
  result = FramerM$StdControl$init();
#line 63

#line 63
  return result;
#line 63
}
#line 63
static inline  
# 126 "TOSBaseM.nc"
result_t TOSBaseM$StdControl$init(void)
#line 126
{
  result_t ok1;
#line 127
  result_t ok2;
#line 127
  result_t ok3;
  uint8_t i;

  for (i = 0; i < TOSBaseM$QUEUE_SIZE; i++) {
      TOSBaseM$gRxBufPool[i].length = 0;
      TOSBaseM$gRxBufPoolTbl[i] = &TOSBaseM$gRxBufPool[i];
    }
  TOSBaseM$gRxHeadIndex = 0;
  TOSBaseM$gRxTailIndex = 0;

  TOSBaseM$gTxBuf.length = 0;
  TOSBaseM$gpTxMsg = &TOSBaseM$gTxBuf;
  TOSBaseM$gfTxFlags = 0;

  ok1 = TOSBaseM$UARTControl$init();
  ok2 = TOSBaseM$RadioControl$init();
  ok3 = TOSBaseM$Leds$init();

  {
  }
#line 145
  ;

  return rcombine3(ok1, ok2, ok3);
}

# 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 = TOSBaseM$StdControl$init();
#line 63

#line 63
  return result;
#line 63
}
#line 63
# 34 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/mica/ChannelMon.nc"
inline static   result_t MicaHighSpeedRadioM$ChannelMon$startSymbolSearch(void){
#line 34
  unsigned char result;
#line 34

#line 34
  result = ChannelMonC$ChannelMon$startSymbolSearch();
#line 34

#line 34
  return result;
#line 34
}
#line 34
static inline 
# 62 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/mica/HPLPowerManagementM.nc"
uint8_t HPLPowerManagementM$getPowerLevel(void)
#line 62
{
  uint8_t diff;

#line 64
  if (* (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x37 + 0x20) & ~((1 << 1) | (1 << 0))) {

      return HPLPowerManagementM$IDLE;
    }
  else {
#line 67
    if (* (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x0D + 0x20) & (1 << 7)) {
        return HPLPowerManagementM$IDLE;
      }
    else {
#line 69
      if (* (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x0A + 0x20) & ((1 << 6) | (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 75
          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$IDLE;
                }
#line 79
              return HPLPowerManagementM$POWER_SAVE;
            }
          else 
#line 80
            {
              return HPLPowerManagementM$POWER_DOWN;
            }
          }
        }
      }
    }
}

static inline  
#line 85
void HPLPowerManagementM$doAdjustment(void)
#line 85
{
  uint8_t foo;
#line 86
  uint8_t mcu;

#line 87
  foo = HPLPowerManagementM$getPowerLevel();
  mcu = * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x35 + 0x20);
  mcu &= 0xe3;
  if (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 inline   
uint8_t HPLPowerManagementM$PowerManagement$adjustPower(void)
#line 103
{
  uint8_t mcu;

#line 105
  if (!HPLPowerManagementM$disabled) {
    TOS_post(HPLPowerManagementM$doAdjustment);
    }
  else 
#line 107
    {
      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;
}

# 41 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/PowerManagement.nc"
inline static   uint8_t MicaHighSpeedRadioM$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 41
static inline  
# 155 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/mica/MicaHighSpeedRadioM.nc"
result_t MicaHighSpeedRadioM$Control$start(void)
#line 155
{
  uint8_t oldState;
  result_t rval = SUCCESS;

#line 158
  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 158
    {
      oldState = MicaHighSpeedRadioM$state;
      if (MicaHighSpeedRadioM$state == MicaHighSpeedRadioM$STOPPED_STATE) {
          MicaHighSpeedRadioM$state = MicaHighSpeedRadioM$IDLE_STATE;
          MicaHighSpeedRadioM$send_state = MicaHighSpeedRadioM$IDLE_STATE;
          MicaHighSpeedRadioM$PowerManagement$adjustPower();
          rval = MicaHighSpeedRadioM$ChannelMon$startSymbolSearch();
        }
    }
#line 166
    __nesc_atomic_end(__nesc_atomic); }

  return rval;
}

# 70 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/StdControl.nc"
inline static  result_t TOSBaseM$RadioControl$start(void){
#line 70
  unsigned char result;
#line 70

#line 70
  result = MicaHighSpeedRadioM$Control$start();
#line 70

#line 70
  return result;
#line 70
}
#line 70
# 98 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/mica/hardware.h"
static __inline void TOSH_SET_UART_RXD0_PIN(void)
#line 98
{
#line 98
  * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x03 + 0x20) |= 1 << 0;
}

static inline   
# 56 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/avrmote/HPLUARTM.nc"
result_t HPLUARTM$UART$init(void)
#line 56
{
  * (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 *)(0x0A + 0x20) = 0xd8;
  TOSH_SET_UART_RXD0_PIN();

  return SUCCESS;
}

# 62 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/HPLUART.nc"
inline static   result_t UARTM$HPLUART$init(void){
#line 62
  unsigned char result;
#line 62

#line 62
  result = HPLUARTM$UART$init();
#line 62

#line 62
  return result;
#line 62
}
#line 62
static inline  
# 68 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/UARTM.nc"
result_t UARTM$Control$start(void)
#line 68
{
  return UARTM$HPLUART$init();
}

# 70 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/StdControl.nc"
inline static  result_t FramerM$ByteControl$start(void){
#line 70
  unsigned char result;
#line 70

#line 70
  result = UARTM$Control$start();
#line 70

#line 70
  return result;
#line 70
}
#line 70
static inline  
# 296 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/FramerM.nc"
result_t FramerM$StdControl$start(void)
#line 296
{
  FramerM$HDLCInitialize();
  return FramerM$ByteControl$start();
}

# 70 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/StdControl.nc"
inline static  result_t TOSBaseM$UARTControl$start(void){
#line 70
  unsigned char result;
#line 70

#line 70
  result = FramerM$StdControl$start();
#line 70

#line 70
  return result;
#line 70
}
#line 70
static inline  
# 150 "TOSBaseM.nc"
result_t TOSBaseM$StdControl$start(void)
#line 150
{
  result_t ok1;
#line 151
  result_t ok2;

  ok1 = TOSBaseM$UARTControl$start();
  ok2 = TOSBaseM$RadioControl$start();

  return rcombine(ok1, ok2);
}

# 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 = TOSBaseM$StdControl$start();
#line 70

#line 70
  return result;
#line 70
}
#line 70
static 
# 165 "C:/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 135
void 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 "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();
}

static inline    
# 400 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/mica/MicaHighSpeedRadioM.nc"
void MicaHighSpeedRadioM$RadioSendCoordinator$default$startSymbol(void)
#line 400
{
}

# 45 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/RadioCoordinator.nc"
inline static   void MicaHighSpeedRadioM$RadioSendCoordinator$startSymbol(void){
#line 45
  MicaHighSpeedRadioM$RadioSendCoordinator$default$startSymbol();
#line 45
}
#line 45
static inline 
# 66 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/avrmote/crc.h"
uint16_t crcByte(uint16_t oldCrc, uint8_t byte)
{

  uint16_t *table = crcTable;
  uint16_t newCrc;

   __asm ("eor %1,%B3\n"
  "\tlsl %1\n"
  "\tadc %B2, __zero_reg__\n"
  "\tadd %A2, %1\n"
  "\tadc %B2, __zero_reg__\n"
  "\tlpm\n"
  "\tmov %B0, %A3\n"
  "\tmov %A0, r0\n"
  "\tadiw r30,1\n"
  "\tlpm\n"
  "\teor %B0, r0" : 
  "=r"(newCrc), "+r"(byte), "+z"(table) : "r"(oldCrc));
  return newCrc;
}

static inline   
# 55 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/mica/RadioTimingC.nc"
uint16_t RadioTimingC$RadioTiming$currentTime(void)
#line 55
{
  return ({
#line 56
    uint16_t __t;
#line 56
    bool bStatus;

#line 56
    bStatus = * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x3F + 0x20) & (1 << 7);
#line 56
     __asm volatile ("cli");__t = * (volatile unsigned int *)(unsigned int )& * (volatile unsigned char *)(0x2C + 0x20);
#line 56
    if (bStatus) {
#line 56
       __asm volatile ("sei");
      }
#line 56
    __t;
  }
  );
}

# 34 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/mica/RadioTiming.nc"
inline static   uint16_t MicaHighSpeedRadioM$RadioTiming$currentTime(void){
#line 34
  unsigned int result;
#line 34

#line 34
  result = RadioTimingC$RadioTiming$currentTime();
#line 34

#line 34
  return result;
#line 34
}
#line 34
# 33 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/mica/SpiByteFifo.nc"
inline static   result_t MicaHighSpeedRadioM$SpiByteFifo$send(uint8_t arg_0xa34c0e8){
#line 33
  unsigned char result;
#line 33

#line 33
  result = SpiByteFifoC$SpiByteFifo$send(arg_0xa34c0e8);
#line 33

#line 33
  return result;
#line 33
}
#line 33
# 34 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/mica/RadioEncoding.nc"
inline static   result_t MicaHighSpeedRadioM$Code$encode(char arg_0xa340810){
#line 34
  unsigned char result;
#line 34

#line 34
  result = SecDedEncoding$Code$encode(arg_0xa340810);
#line 34

#line 34
  return result;
#line 34
}
#line 34
static inline   
# 218 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/mica/MicaHighSpeedRadioM.nc"
result_t MicaHighSpeedRadioM$ChannelMon$idleDetect(void)
#line 218
{
  uint8_t firstSSByte;
  uint8_t firstMsgByte;
  uint16_t timeVal;
  uint16_t tmpCrc;
  uint8_t oldSendState;

  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 225
    {
      oldSendState = MicaHighSpeedRadioM$send_state;
      if (MicaHighSpeedRadioM$send_state == MicaHighSpeedRadioM$SEND_WAITING) {
          MicaHighSpeedRadioM$send_state = MicaHighSpeedRadioM$IDLE_STATE;
          MicaHighSpeedRadioM$state = MicaHighSpeedRadioM$TRANSMITTING_START;
        }
    }
#line 231
    __nesc_atomic_end(__nesc_atomic); }

  if (oldSendState == MicaHighSpeedRadioM$SEND_WAITING) {
      { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 234
        {
          firstMsgByte = ((char *)MicaHighSpeedRadioM$send_ptr)[0];
          firstSSByte = TOSH_MHSR_start[0];

          MicaHighSpeedRadioM$buf_end = MicaHighSpeedRadioM$buf_head = 0;
          MicaHighSpeedRadioM$enc_count = 0;
          MicaHighSpeedRadioM$Code$encode(firstMsgByte);
          MicaHighSpeedRadioM$rx_count = 0;
          MicaHighSpeedRadioM$msg_length = (unsigned char )MicaHighSpeedRadioM$send_ptr->length + MSG_DATA_SIZE - DATA_LENGTH - 2;
        }
#line 243
        __nesc_atomic_end(__nesc_atomic); }



      MicaHighSpeedRadioM$SpiByteFifo$send(firstSSByte);
      timeVal = MicaHighSpeedRadioM$RadioTiming$currentTime();
      tmpCrc = crcByte(0x00, firstMsgByte);
      { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 250
        {
          MicaHighSpeedRadioM$send_ptr->time = timeVal;
          MicaHighSpeedRadioM$calc_crc = tmpCrc;
        }
#line 253
        __nesc_atomic_end(__nesc_atomic); }
    }
  MicaHighSpeedRadioM$RadioSendCoordinator$startSymbol();
  return 1;
}

# 39 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/mica/ChannelMon.nc"
inline static   result_t ChannelMonC$ChannelMon$idleDetect(void){
#line 39
  unsigned char result;
#line 39

#line 39
  result = MicaHighSpeedRadioM$ChannelMon$idleDetect();
#line 39

#line 39
  return result;
#line 39
}
#line 39
# 37 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/mica/RadioEncoding.nc"
inline static   result_t SecDedEncoding$Code$encodeDone(char arg_0xa341598){
#line 37
  unsigned char result;
#line 37

#line 37
  result = MicaHighSpeedRadioM$Code$encodeDone(arg_0xa341598);
#line 37

#line 37
  return result;
#line 37
}
#line 37
static inline 
# 99 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/mica/SecDedEncoding.nc"
void SecDedEncoding$radio_encode_thread(void)
#line 99
{
  char ret_high = 0;
  char ret_low = 0;
  char parity = 0;
  char val;

#line 104
  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 104
    {
      val = SecDedEncoding$data1;
    }
#line 106
    __nesc_atomic_end(__nesc_atomic); }




  if ((val & 0x1) != 0) {
      parity ^= 0x5b;
      ret_low |= 0x1;
    }
  else 
#line 114
    {
#line 114
      ret_low |= 0x2;
    }
  if ((val & 0x2) != 0) {
      parity ^= 0x58;
      ret_low |= 0x4;
    }
  else 
#line 119
    {
#line 119
      ret_low |= 0x8;
    }
  if ((val & 0x4) != 0) {
      parity ^= 0x52;
      ret_low |= 0x10;
    }
  else 
#line 124
    {
#line 124
      ret_low |= 0x20;
    }
  if ((val & 0x8) != 0) {
      parity ^= 0x51;
      ret_low |= 0x40;
    }
  else 
#line 129
    {
#line 129
      ret_low |= 0x80;
    }
  if ((val & 0x10) != 0) {
      parity ^= 0x4a;
      ret_high |= 0x1;
    }
  else 
#line 134
    {
#line 134
      ret_high |= 0x2;
    }
  if ((val & 0x20) != 0) {
      parity ^= 0x49;
      ret_high |= 0x4;
    }
  else 
#line 139
    {
#line 139
      ret_high |= 0x8;
    }
  if ((val & 0x40) != 0) {
      parity ^= 0x13;
      ret_high |= 0x10;
    }
  else 
#line 144
    {
#line 144
      ret_high |= 0x20;
    }
  if ((val & 0x80) != 0) {
      parity ^= 0x0b;
      ret_high |= 0x40;
    }
  else 
#line 149
    {
#line 149
      ret_high |= 0x80;
    }


  if (!(parity & 0x40)) {
#line 153
    parity |= 0x80;
    }
#line 154
  if (!(parity & 0x50)) {
#line 154
    parity |= 0x20;
    }
#line 155
  if (!(parity & 0xa)) {
#line 155
    parity |= 0x4;
    }
  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 157
    {
      SecDedEncoding$state = SecDedEncoding$IDLE_STATE;
    }
#line 159
    __nesc_atomic_end(__nesc_atomic); }
  SecDedEncoding$Code$encodeDone(parity);
  SecDedEncoding$Code$encodeDone(ret_high);
  SecDedEncoding$Code$encodeDone(ret_low);
}

static inline    
# 401 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/mica/MicaHighSpeedRadioM.nc"
void MicaHighSpeedRadioM$RadioSendCoordinator$default$byte(TOS_MsgPtr msg, uint8_t byteCount)
#line 401
{
}

# 48 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/RadioCoordinator.nc"
inline static   void MicaHighSpeedRadioM$RadioSendCoordinator$byte(TOS_MsgPtr arg_0xa320d88, uint8_t arg_0xa320ed8){
#line 48
  MicaHighSpeedRadioM$RadioSendCoordinator$default$byte(arg_0xa320d88, arg_0xa320ed8);
#line 48
}
#line 48
static inline   
# 76 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/mica/SecDedEncoding.nc"
result_t SecDedEncoding$Code$encode_flush(void)
#line 76
{
  return 1;
}

# 33 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/mica/RadioEncoding.nc"
inline static   result_t MicaHighSpeedRadioM$Code$encode_flush(void){
#line 33
  unsigned char result;
#line 33

#line 33
  result = SecDedEncoding$Code$encode_flush();
#line 33

#line 33
  return result;
#line 33
}
#line 33
static inline   
# 188 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/mica/SpiByteFifoC.nc"
result_t SpiByteFifoC$SpiByteFifo$phaseShift(void)
#line 188
{
  unsigned char f;

#line 190
  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 190
    {
      f = * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x24 + 0x20);
      if (f > 20) {
#line 192
        f -= 20;
        }
#line 193
      * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x24 + 0x20) = f;
    }
#line 194
    __nesc_atomic_end(__nesc_atomic); }
  return SUCCESS;
}

# 38 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/mica/SpiByteFifo.nc"
inline static   result_t MicaHighSpeedRadioM$SpiByteFifo$phaseShift(void){
#line 38
  unsigned char result;
#line 38

#line 38
  result = SpiByteFifoC$SpiByteFifo$phaseShift();
#line 38

#line 38
  return result;
#line 38
}
#line 38
# 79 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/mica/hardware.h"
static __inline void TOSH_SET_RFM_CTL1_PIN(void)
#line 79
{
#line 79
  * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x12 + 0x20) |= 1 << 6;
}

#line 78
static __inline void TOSH_SET_RFM_CTL0_PIN(void)
#line 78
{
#line 78
  * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x12 + 0x20) |= 1 << 7;
}

#line 77
static __inline void TOSH_MAKE_RFM_TXD_INPUT(void)
#line 77
{
#line 77
  * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x17 + 0x20) &= ~(1 << 3);
}

#line 77
static __inline void TOSH_CLR_RFM_TXD_PIN(void)
#line 77
{
#line 77
  * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x18 + 0x20) &= ~(1 << 3);
}

static inline   
# 172 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/mica/SpiByteFifoC.nc"
result_t SpiByteFifoC$SpiByteFifo$rxMode(void)
#line 172
{
  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 173
    {
      TOSH_CLR_RFM_TXD_PIN();
      TOSH_MAKE_RFM_TXD_INPUT();
      TOSH_SET_RFM_CTL0_PIN();
      TOSH_SET_RFM_CTL1_PIN();
    }
#line 178
    __nesc_atomic_end(__nesc_atomic); }






  return SUCCESS;
}

# 37 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/mica/SpiByteFifo.nc"
inline static   result_t MicaHighSpeedRadioM$SpiByteFifo$rxMode(void){
#line 37
  unsigned char result;
#line 37

#line 37
  result = SpiByteFifoC$SpiByteFifo$rxMode();
#line 37

#line 37
  return result;
#line 37
}
#line 37
#line 34
inline static   result_t MicaHighSpeedRadioM$SpiByteFifo$idle(void){
#line 34
  unsigned char result;
#line 34

#line 34
  result = SpiByteFifoC$SpiByteFifo$idle();
#line 34

#line 34
  return result;
#line 34
}
#line 34
static inline  
# 198 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/mica/SpiByteFifoC.nc"
result_t SpiByteFifoC$SlavePin$notifyHigh(void)
#line 198
{
  return SUCCESS;
}

# 66 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/mica/SlavePin.nc"
inline static  result_t SlavePinM$SlavePin$notifyHigh(void){
#line 66
  unsigned char result;
#line 66

#line 66
  result = SpiByteFifoC$SlavePin$notifyHigh();
#line 66

#line 66
  return result;
#line 66
}
#line 66
static inline  
# 119 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/mica/SlavePinM.nc"
void SlavePinM$signalHighTask(void)
#line 119
{
  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
    SlavePinM$signalHigh = FALSE;
#line 121
    __nesc_atomic_end(__nesc_atomic); }

  SlavePinM$SlavePin$notifyHigh();
}

# 101 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/mica/hardware.h"
static __inline void TOSH_MAKE_ONE_WIRE_OUTPUT(void)
#line 101
{
#line 101
  * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x02 + 0x20) |= 1 << 5;
}

static inline   
# 52 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/mica/HPLSlavePinC.nc"
result_t HPLSlavePinC$SlavePin$high(void)
#line 52
{
  TOSH_MAKE_ONE_WIRE_OUTPUT();
  TOSH_SET_ONE_WIRE_PIN();
  return SUCCESS;
}

# 48 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/mica/HPLSlavePin.nc"
inline static   result_t SlavePinM$HPLSlavePin$high(void){
#line 48
  unsigned char result;
#line 48

#line 48
  result = HPLSlavePinC$SlavePin$high();
#line 48

#line 48
  return result;
#line 48
}
#line 48
static 
# 126 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/mica/SlavePinM.nc"
__inline   result_t SlavePinM$SlavePin$high(bool needEvent)
#line 126
{
  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
    {
      SlavePinM$n++;
      if (SlavePinM$n > 0) 
        {
          SlavePinM$HPLSlavePin$high();
          if (needEvent || SlavePinM$signalHigh) {
            TOS_post(SlavePinM$signalHighTask);
            }
        }
      else {
#line 137
        SlavePinM$signalHigh |= needEvent;
        }
    }
#line 139
    __nesc_atomic_end(__nesc_atomic); }
#line 139
  return SUCCESS;
}

# 61 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/mica/SlavePin.nc"
inline static   result_t SpiByteFifoC$SlavePin$high(bool arg_0xa29fbe0){
#line 61
  unsigned char result;
#line 61

#line 61
  result = SlavePinM$SlavePin$high(arg_0xa29fbe0);
#line 61

#line 61
  return result;
#line 61
}
#line 61
# 79 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/mica/hardware.h"
static __inline void TOSH_CLR_RFM_CTL1_PIN(void)
#line 79
{
#line 79
  * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x12 + 0x20) &= ~(1 << 6);
}

#line 58
static __inline void TOSH_CLR_YELLOW_LED_PIN(void)
#line 58
{
#line 58
  * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x1B + 0x20) &= ~(1 << 0);
}

static inline   
# 127 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/LedsC.nc"
result_t LedsC$Leds$yellowOn(void)
#line 127
{
  {
  }
#line 128
  ;
  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 129
    {
      TOSH_CLR_YELLOW_LED_PIN();
      LedsC$ledsOn |= LedsC$YELLOW_BIT;
    }
#line 132
    __nesc_atomic_end(__nesc_atomic); }
  return SUCCESS;
}

static inline   result_t LedsC$Leds$yellowOff(void)
#line 136
{
  {
  }
#line 137
  ;
  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 138
    {
      TOSH_SET_YELLOW_LED_PIN();
      LedsC$ledsOn &= ~LedsC$YELLOW_BIT;
    }
#line 141
    __nesc_atomic_end(__nesc_atomic); }
  return SUCCESS;
}

static inline   result_t LedsC$Leds$yellowToggle(void)
#line 145
{
  result_t rval;

#line 147
  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 147
    {
      if (LedsC$ledsOn & LedsC$YELLOW_BIT) {
        rval = LedsC$Leds$yellowOff();
        }
      else {
#line 151
        rval = LedsC$Leds$yellowOn();
        }
    }
#line 153
    __nesc_atomic_end(__nesc_atomic); }
#line 153
  return rval;
}

# 131 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/Leds.nc"
inline static   result_t TOSBaseM$Leds$yellowToggle(void){
#line 131
  unsigned char result;
#line 131

#line 131
  result = LedsC$Leds$yellowToggle();
#line 131

#line 131
  return result;
#line 131
}
#line 131
static inline  
# 328 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/FramerM.nc"
result_t FramerM$TokenReceiveMsg$ReflectToken(uint8_t Token)
#line 328
{
  result_t Result = SUCCESS;

  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 331
    {
      if (!(FramerM$gFlags & FramerM$FLAGS_TOKENPEND)) {
          FramerM$gFlags |= FramerM$FLAGS_TOKENPEND;
          FramerM$gTxTokenBuf = Token;
        }
      else {
          Result = FAIL;
        }
    }
#line 339
    __nesc_atomic_end(__nesc_atomic); }

  if (Result == SUCCESS) {
      Result = FramerM$StartTx();
    }

  return Result;
}

# 88 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/TokenReceiveMsg.nc"
inline static  result_t TOSBaseM$UARTTokenReceive$ReflectToken(uint8_t arg_0xa2afbe0){
#line 88
  unsigned char result;
#line 88

#line 88
  result = FramerM$TokenReceiveMsg$ReflectToken(arg_0xa2afbe0);
#line 88

#line 88
  return result;
#line 88
}
#line 88
static inline  
# 117 "TOSBaseM.nc"
void TOSBaseM$SendAckTask(void)
#line 117
{
  TOSBaseM$UARTTokenReceive$ReflectToken(TOSBaseM$gTxPendingToken);
  TOSBaseM$Leds$yellowToggle();
  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 120
    {
      TOSBaseM$gpTxMsg->length = 0;
      TOSBaseM$gfTxFlags = 0;
    }
#line 123
    __nesc_atomic_end(__nesc_atomic); }
}

static inline  
#line 264
result_t TOSBaseM$RadioSend$sendDone(TOS_MsgPtr Msg, result_t success)
#line 264
{


  if (TOSBaseM$gfTxFlags & TOSBaseM$TXFLAG_TOKEN) {
      if (success == SUCCESS) {

          TOS_post(TOSBaseM$SendAckTask);
        }
    }
  else {
      { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 274
        {
          TOSBaseM$gpTxMsg->length = 0;
          TOSBaseM$gfTxFlags = 0;
        }
#line 277
        __nesc_atomic_end(__nesc_atomic); }
    }
  return SUCCESS;
}

# 67 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/BareSendMsg.nc"
inline static  result_t MicaHighSpeedRadioM$Send$sendDone(TOS_MsgPtr arg_0xa2c28f0, result_t arg_0xa2c2a40){
#line 67
  unsigned char result;
#line 67

#line 67
  result = TOSBaseM$RadioSend$sendDone(arg_0xa2c28f0, arg_0xa2c2a40);
#line 67

#line 67
  return result;
#line 67
}
#line 67
static inline  
# 113 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/mica/MicaHighSpeedRadioM.nc"
void MicaHighSpeedRadioM$packetSent(void)
#line 113
{
  TOS_MsgPtr ptr;

#line 115
  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 115
    {
      MicaHighSpeedRadioM$send_state = MicaHighSpeedRadioM$IDLE_STATE;
      MicaHighSpeedRadioM$state = MicaHighSpeedRadioM$IDLE_STATE;
      ptr = (TOS_MsgPtr )MicaHighSpeedRadioM$send_ptr;
    }
#line 119
    __nesc_atomic_end(__nesc_atomic); }
  MicaHighSpeedRadioM$ChannelMon$startSymbolSearch();
  MicaHighSpeedRadioM$Send$sendDone(ptr, SUCCESS);
}

static inline   
# 81 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/avrmote/HPLUARTM.nc"
result_t HPLUARTM$UART$put(uint8_t data)
#line 81
{
  * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x0B + 0x20) |= 1 << 6;
  * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x0C + 0x20) = data;
  return SUCCESS;
}

# 80 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/HPLUART.nc"
inline static   result_t UARTM$HPLUART$put(uint8_t arg_0xa459558){
#line 80
  unsigned char result;
#line 80

#line 80
  result = HPLUARTM$UART$put(arg_0xa459558);
#line 80

#line 80
  return result;
#line 80
}
#line 80
static inline  
# 259 "TOSBaseM.nc"
result_t TOSBaseM$UARTSend$sendDone(TOS_MsgPtr Msg, result_t success)
#line 259
{
  Msg->length = 0;
  return SUCCESS;
}

# 67 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/BareSendMsg.nc"
inline static  result_t FramerM$BareSendMsg$sendDone(TOS_MsgPtr arg_0xa2c28f0, result_t arg_0xa2c2a40){
#line 67
  unsigned char result;
#line 67

#line 67
  result = TOSBaseM$UARTSend$sendDone(arg_0xa2c28f0, arg_0xa2c2a40);
#line 67

#line 67
  return result;
#line 67
}
#line 67
static inline    
# 403 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/mica/MicaHighSpeedRadioM.nc"
void MicaHighSpeedRadioM$RadioReceiveCoordinator$default$byte(TOS_MsgPtr msg, uint8_t byteCount)
#line 403
{
}

# 48 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/RadioCoordinator.nc"
inline static   void MicaHighSpeedRadioM$RadioReceiveCoordinator$byte(TOS_MsgPtr arg_0xa320d88, uint8_t arg_0xa320ed8){
#line 48
  MicaHighSpeedRadioM$RadioReceiveCoordinator$default$byte(arg_0xa320d88, arg_0xa320ed8);
#line 48
}
#line 48
static inline   
# 259 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/mica/MicaHighSpeedRadioM.nc"
result_t MicaHighSpeedRadioM$Code$decodeDone(char data, char error)
#line 259
{
  result_t rval = SUCCESS;

#line 261
  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 261
    {
      if (MicaHighSpeedRadioM$state == MicaHighSpeedRadioM$IDLE_STATE) {
          rval = FAIL;
        }
      else {
#line 265
        if (MicaHighSpeedRadioM$state == MicaHighSpeedRadioM$RX_STATE) {
            ((char *)MicaHighSpeedRadioM$rec_ptr)[(int )MicaHighSpeedRadioM$rec_count] = data;
            MicaHighSpeedRadioM$rec_count++;
            if (MicaHighSpeedRadioM$rec_count >= MSG_DATA_SIZE) {

                if (MicaHighSpeedRadioM$calc_crc == MicaHighSpeedRadioM$rec_ptr->crc) {
                    MicaHighSpeedRadioM$rec_ptr->crc = 1;
                    if (MicaHighSpeedRadioM$rec_ptr->addr == TOS_LOCAL_ADDRESS || 
                    MicaHighSpeedRadioM$rec_ptr->addr == TOS_BCAST_ADDR) {
                        MicaHighSpeedRadioM$SpiByteFifo$send(0x55);
                      }
                  }
                else 
#line 276
                  {
                    MicaHighSpeedRadioM$rec_ptr->crc = 0;
                  }
                MicaHighSpeedRadioM$state = MicaHighSpeedRadioM$ACK_SEND_STATE;
                rval = 0;
                MicaHighSpeedRadioM$RadioReceiveCoordinator$byte(MicaHighSpeedRadioM$rec_ptr, (uint8_t )MicaHighSpeedRadioM$rec_count);
              }
            else {
#line 283
              if (MicaHighSpeedRadioM$rec_count <= MSG_DATA_SIZE - 2) {
                  MicaHighSpeedRadioM$calc_crc = crcByte(MicaHighSpeedRadioM$calc_crc, data);
                  if (MicaHighSpeedRadioM$rec_count == LENGTH_BYTE_NUMBER) {
                      if ((unsigned char )data < DATA_LENGTH) {
                          MicaHighSpeedRadioM$msg_length = (unsigned char )data + MSG_DATA_SIZE - DATA_LENGTH - 2;
                        }
                    }
                  if (MicaHighSpeedRadioM$rec_count == MicaHighSpeedRadioM$msg_length) {
                      MicaHighSpeedRadioM$rec_count = MSG_DATA_SIZE - 2;
                    }
                }
              }
          }
        }
    }
#line 297
    __nesc_atomic_end(__nesc_atomic); }
#line 296
  return rval;
}

# 36 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/mica/RadioEncoding.nc"
inline static   result_t SecDedEncoding$Code$decodeDone(char arg_0xa341038, char arg_0xa341178){
#line 36
  unsigned char result;
#line 36

#line 36
  result = MicaHighSpeedRadioM$Code$decodeDone(arg_0xa341038, arg_0xa341178);
#line 36

#line 36
  return result;
#line 36
}
#line 36
static inline 
# 167 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/mica/SecDedEncoding.nc"
void SecDedEncoding$radio_decode_thread(void)
#line 167
{


  char ret_high = 0;
  char ret_low = 0;
  char parity;
  char error = 0;
  short encoded_value = 0;

#line 175
  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 175
    {
      parity = SecDedEncoding$data1;
      ret_high = SecDedEncoding$data2;
      ret_low = SecDedEncoding$data3;
    }
#line 179
    __nesc_atomic_end(__nesc_atomic); }

  if ((ret_low & 0x1) != 0) {
#line 181
    encoded_value |= 0x1;
    }
#line 182
  if ((ret_low & 0x4) != 0) {
#line 182
    encoded_value |= 0x2;
    }
#line 183
  if ((ret_low & 0x10) != 0) {
#line 183
    encoded_value |= 0x4;
    }
#line 184
  if ((ret_low & 0x40) != 0) {
#line 184
    encoded_value |= 0x8;
    }
#line 185
  if ((ret_high & 0x01) != 0) {
#line 185
    encoded_value |= 0x10;
    }
#line 186
  if ((ret_high & 0x04) != 0) {
#line 186
    encoded_value |= 0x20;
    }
#line 187
  if ((ret_high & 0x10) != 0) {
#line 187
    encoded_value |= 0x40;
    }
#line 188
  if ((ret_high & 0x40) != 0) {
#line 188
    encoded_value |= 0x80;
    }
  parity = ((parity & 0x3) | ((parity & 0x18) >> 1)) | ((parity & 0x40) >> 2);
  encoded_value = (encoded_value << 5) | parity;


  parity = 0;
  if ((encoded_value & 0x1) != 0) {
#line 195
    parity ^= 0x1;
    }
#line 196
  if ((encoded_value & 0x2) != 0) {
#line 196
    parity ^= 0x2;
    }
#line 197
  if ((encoded_value & 0x4) != 0) {
#line 197
    parity ^= 0x4;
    }
#line 198
  if ((encoded_value & 0x8) != 0) {
#line 198
    parity ^= 0x8;
    }
#line 199
  if ((encoded_value & 0x10) != 0) {
#line 199
    parity ^= 0x10;
    }
#line 200
  if ((encoded_value & 0x20) != 0) {
#line 200
    parity ^= 0x1f;
    }
#line 201
  if ((encoded_value & 0x40) != 0) {
#line 201
    parity ^= 0x1c;
    }
#line 202
  if ((encoded_value & 0x80) != 0) {
#line 202
    parity ^= 0x1a;
    }
#line 203
  if ((encoded_value & 0x100) != 0) {
#line 203
    parity ^= 0x19;
    }
#line 204
  if ((encoded_value & 0x200) != 0) {
#line 204
    parity ^= 0x16;
    }
#line 205
  if ((encoded_value & 0x400) != 0) {
#line 205
    parity ^= 0x15;
    }
#line 206
  if ((encoded_value & 0x800) != 0) {
#line 206
    parity ^= 0xb;
    }
#line 207
  if ((encoded_value & 0x1000) != 0) {
#line 207
    parity ^= 0x7;
    }

  error = -1;
  if (parity == 0) {
    }
  else {
#line 212
    if (parity == 0x1) {
#line 212
        encoded_value ^= 0x1;
      }
    else {
#line 213
      if (parity == 0x2) {
#line 213
          encoded_value ^= 0x2;
        }
      else {
#line 214
        if (parity == 0x4) {
#line 214
            encoded_value ^= 0x4;
          }
        else {
#line 215
          if (parity == 0x8) {
#line 215
              encoded_value ^= 0x8;
            }
          else {
#line 216
            if (parity == 0x10) {
#line 216
                encoded_value ^= 0x10;
              }
            else 
#line 217
              {
                error = 0;
                if (parity == 0x1f) {
#line 219
                    encoded_value ^= 0x20;
                  }
                else {
#line 220
                  if (parity == 0x1c) {
#line 220
                      encoded_value ^= 0x40;
                    }
                  else {
#line 221
                    if (parity == 0x1a) {
#line 221
                        encoded_value ^= 0x80;
                      }
                    else {
#line 222
                      if (parity == 0x19) {
#line 222
                          encoded_value ^= 0x100;
                        }
                      else {
#line 223
                        if (parity == 0x16) {
#line 223
                            encoded_value ^= 0x200;
                          }
                        else {
#line 224
                          if (parity == 0x15) {
#line 224
                              encoded_value ^= 0x400;
                            }
                          else {
#line 225
                            if (parity == 0xb) {
#line 225
                                encoded_value ^= 0x800;
                              }
                            else {
#line 226
                              if (parity == 0x7) {
#line 226
                                  encoded_value ^= 0x1000;
                                }
                              else 
#line 227
                                {
                                  error = 1;
                                }
                              }
                            }
                          }
                        }
                      }
                    }
                  }
              }
            }
          }
        }
      }
    }
#line 233
  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 233
    {
      SecDedEncoding$state = SecDedEncoding$IDLE_STATE;
    }
#line 235
    __nesc_atomic_end(__nesc_atomic); }
  SecDedEncoding$Code$decodeDone((encoded_value >> 5) & 0xff, error);
}

static inline   
#line 55
result_t SecDedEncoding$Code$decode(char d1)
#line 55
{
  result_t rval = 1;

#line 57
  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 57
    {
      if (SecDedEncoding$state == SecDedEncoding$IDLE_STATE) {
          SecDedEncoding$state = SecDedEncoding$DECODING_BYTE_1;
          SecDedEncoding$data1 = d1;
        }
      else {
#line 61
        if (SecDedEncoding$state == SecDedEncoding$DECODING_BYTE_1) {
            SecDedEncoding$state = SecDedEncoding$DECODING_BYTE_2;
            SecDedEncoding$data2 = d1;
          }
        else {
#line 64
          if (SecDedEncoding$state == SecDedEncoding$DECODING_BYTE_2) {
              SecDedEncoding$state = SecDedEncoding$DECODING_BYTE_3;
              SecDedEncoding$data3 = d1;
              SecDedEncoding$radio_decode_thread();
            }
          else 
#line 68
            {
              rval = 0;
            }
          }
        }
    }
#line 73
    __nesc_atomic_end(__nesc_atomic); }
#line 72
  return rval;
}

# 35 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/mica/RadioEncoding.nc"
inline static   result_t MicaHighSpeedRadioM$Code$decode(char arg_0xa340c20){
#line 35
  unsigned char result;
#line 35

#line 35
  result = SecDedEncoding$Code$decode(arg_0xa340c20);
#line 35

#line 35
  return result;
#line 35
}
#line 35
# 59 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/mica/hardware.h"
static __inline void TOSH_CLR_GREEN_LED_PIN(void)
#line 59
{
#line 59
  * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x1B + 0x20) &= ~(1 << 1);
}

static inline   
# 98 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/LedsC.nc"
result_t LedsC$Leds$greenOn(void)
#line 98
{
  {
  }
#line 99
  ;
  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 100
    {
      TOSH_CLR_GREEN_LED_PIN();
      LedsC$ledsOn |= LedsC$GREEN_BIT;
    }
#line 103
    __nesc_atomic_end(__nesc_atomic); }
  return SUCCESS;
}

static inline   result_t LedsC$Leds$greenOff(void)
#line 107
{
  {
  }
#line 108
  ;
  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 109
    {
      TOSH_SET_GREEN_LED_PIN();
      LedsC$ledsOn &= ~LedsC$GREEN_BIT;
    }
#line 112
    __nesc_atomic_end(__nesc_atomic); }
  return SUCCESS;
}

static inline   result_t LedsC$Leds$greenToggle(void)
#line 116
{
  result_t rval;

#line 118
  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 118
    {
      if (LedsC$ledsOn & LedsC$GREEN_BIT) {
        rval = LedsC$Leds$greenOff();
        }
      else {
#line 122
        rval = LedsC$Leds$greenOn();
        }
    }
#line 124
    __nesc_atomic_end(__nesc_atomic); }
#line 124
  return rval;
}

# 106 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/Leds.nc"
inline static   result_t TOSBaseM$Leds$greenToggle(void){
#line 106
  unsigned char result;
#line 106

#line 106
  result = LedsC$Leds$greenToggle();
#line 106

#line 106
  return result;
#line 106
}
#line 106
static inline  
# 306 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/FramerM.nc"
result_t FramerM$BareSendMsg$send(TOS_MsgPtr pMsg)
#line 306
{
  result_t Result = SUCCESS;

  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 309
    {
      if (!(FramerM$gFlags & FramerM$FLAGS_DATAPEND)) {
          FramerM$gFlags |= FramerM$FLAGS_DATAPEND;
          FramerM$gpTxMsg = pMsg;
        }
      else 

        {
          Result = FAIL;
        }
    }
#line 319
    __nesc_atomic_end(__nesc_atomic); }

  if (Result == SUCCESS) {
      Result = FramerM$StartTx();
    }

  return Result;
}

# 58 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/BareSendMsg.nc"
inline static  result_t TOSBaseM$UARTSend$send(TOS_MsgPtr arg_0xa2c23d8){
#line 58
  unsigned char result;
#line 58

#line 58
  result = FramerM$BareSendMsg$send(arg_0xa2c23d8);
#line 58

#line 58
  return result;
#line 58
}
#line 58
static inline  
# 84 "TOSBaseM.nc"
void TOSBaseM$RadioRcvdTask(void)
#line 84
{
  TOS_MsgPtr pMsg;
  result_t Result;

  {
  }
#line 88
  ;
  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 89
    {
      pMsg = TOSBaseM$gRxBufPoolTbl[TOSBaseM$gRxTailIndex];
      TOSBaseM$gRxTailIndex++;
#line 91
      TOSBaseM$gRxTailIndex %= TOSBaseM$QUEUE_SIZE;
    }
#line 92
    __nesc_atomic_end(__nesc_atomic); }
  Result = TOSBaseM$UARTSend$send(pMsg);
  if (Result != SUCCESS) {
      pMsg->length = 0;
    }
  else {
      TOSBaseM$Leds$greenToggle();
    }
}

static inline  
#line 168
TOS_MsgPtr TOSBaseM$RadioReceive$receive(TOS_MsgPtr Msg)
#line 168
{
  TOS_MsgPtr pBuf;

  {
  }
#line 171
  ;

  if (Msg->crc) {


      if (Msg->group != TOS_AM_GROUP) {
        return Msg;
        }
      { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 179
        {
          pBuf = TOSBaseM$gRxBufPoolTbl[TOSBaseM$gRxHeadIndex];
          if (pBuf->length == 0) {
              TOSBaseM$gRxBufPoolTbl[TOSBaseM$gRxHeadIndex] = Msg;
              TOSBaseM$gRxHeadIndex++;
#line 183
              TOSBaseM$gRxHeadIndex %= TOSBaseM$QUEUE_SIZE;
            }
          else {
              pBuf = (void *)0;
            }
        }
#line 188
        __nesc_atomic_end(__nesc_atomic); }

      if (pBuf) {
          TOS_post(TOSBaseM$RadioRcvdTask);
        }
      else {
          pBuf = Msg;
        }
    }
  else {
      pBuf = Msg;
    }

  return pBuf;
}

# 75 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/ReceiveMsg.nc"
inline static  TOS_MsgPtr MicaHighSpeedRadioM$Receive$receive(TOS_MsgPtr arg_0xa2c3e00){
#line 75
  struct TOS_Msg *result;
#line 75

#line 75
  result = TOSBaseM$RadioReceive$receive(arg_0xa2c3e00);
#line 75

#line 75
  return result;
#line 75
}
#line 75
static inline  
# 100 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/mica/MicaHighSpeedRadioM.nc"
void MicaHighSpeedRadioM$packetReceived(void)
#line 100
{
  TOS_MsgPtr tmp = (TOS_MsgPtr )MicaHighSpeedRadioM$rec_ptr;

  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 103
    MicaHighSpeedRadioM$state = MicaHighSpeedRadioM$IDLE_STATE;
#line 103
    __nesc_atomic_end(__nesc_atomic); }
  tmp = MicaHighSpeedRadioM$Receive$receive(tmp);
  if (tmp != 0) {
      { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 106
        {
          MicaHighSpeedRadioM$rec_ptr = tmp;
        }
#line 108
        __nesc_atomic_end(__nesc_atomic); }
    }
  MicaHighSpeedRadioM$ChannelMon$startSymbolSearch();
}

# 78 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/mica/hardware.h"
static __inline void TOSH_CLR_RFM_CTL0_PIN(void)
#line 78
{
#line 78
  * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x12 + 0x20) &= ~(1 << 7);
}

static inline   
# 164 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/mica/SpiByteFifoC.nc"
result_t SpiByteFifoC$SpiByteFifo$txMode(void)
#line 164
{
  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 165
    {
      TOSH_CLR_RFM_CTL0_PIN();
      TOSH_SET_RFM_CTL1_PIN();
    }
#line 168
    __nesc_atomic_end(__nesc_atomic); }
  return SUCCESS;
}

# 36 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/mica/SpiByteFifo.nc"
inline static   result_t MicaHighSpeedRadioM$SpiByteFifo$txMode(void){
#line 36
  unsigned char result;
#line 36

#line 36
  result = SpiByteFifoC$SpiByteFifo$txMode();
#line 36

#line 36
  return result;
#line 36
}
#line 36
static inline    
# 402 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/mica/MicaHighSpeedRadioM.nc"
void MicaHighSpeedRadioM$RadioReceiveCoordinator$default$startSymbol(void)
#line 402
{
}

# 45 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/RadioCoordinator.nc"
inline static   void MicaHighSpeedRadioM$RadioReceiveCoordinator$startSymbol(void){
#line 45
  MicaHighSpeedRadioM$RadioReceiveCoordinator$default$startSymbol();
#line 45
}
#line 45
# 101 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/mica/hardware.h"
static __inline void TOSH_CLR_ONE_WIRE_PIN(void)
#line 101
{
#line 101
  * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x03 + 0x20) &= ~(1 << 5);
}

static inline   
# 58 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/mica/HPLSlavePinC.nc"
result_t HPLSlavePinC$SlavePin$low(void)
#line 58
{
  TOSH_MAKE_ONE_WIRE_OUTPUT();
  TOSH_CLR_ONE_WIRE_PIN();
  return SUCCESS;
}

# 47 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/mica/HPLSlavePin.nc"
inline static   result_t SlavePinM$HPLSlavePin$low(void){
#line 47
  unsigned char result;
#line 47

#line 47
  result = HPLSlavePinC$SlavePin$low();
#line 47

#line 47
  return result;
#line 47
}
#line 47
static 
# 110 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/mica/SlavePinM.nc"
__inline   result_t SlavePinM$SlavePin$low(void)
#line 110
{
  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
    {
      SlavePinM$n--;
      SlavePinM$HPLSlavePin$low();
    }
#line 115
    __nesc_atomic_end(__nesc_atomic); }
  return SUCCESS;
}

# 51 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/mica/SlavePin.nc"
inline static   result_t SpiByteFifoC$SlavePin$low(void){
#line 51
  unsigned char result;
#line 51

#line 51
  result = SlavePinM$SlavePin$low();
#line 51

#line 51
  return result;
#line 51
}
#line 51
static inline   
# 119 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/mica/SpiByteFifoC.nc"
result_t SpiByteFifoC$SpiByteFifo$startReadBytes(uint16_t timing)
#line 119
{
  uint8_t oldState;




  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 125
    {
      oldState = SpiByteFifoC$state;
      if (SpiByteFifoC$state == SpiByteFifoC$IDLE) {
          SpiByteFifoC$state = SpiByteFifoC$READING;
        }
    }
#line 130
    __nesc_atomic_end(__nesc_atomic); }
  if (oldState == SpiByteFifoC$IDLE) {


      SpiByteFifoC$SlavePin$low();
      * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x0D + 0x20) = 0x00;
      * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x18 + 0x20) &= ~(1 << 7);
      * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x17 + 0x20) |= 1 << 7;
      * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x25 + 0x20) = 0x0;
      * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x24 + 0x20) = 0x1;
      * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x23 + 0x20) = SpiByteFifoC$BIT_RATE;

      timing += 400 - 19;
      if (timing > 0xfff0) {
#line 143
        timing = 0xfff0;
        }
      * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x25 + 0x20) = 0x19;
      * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x24 + 0x20) = SpiByteFifoC$BIT_RATE - 20;
      while (* (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x16 + 0x20) & 0x80) {
#line 147
          ;
        }
#line 148
      while (* (volatile unsigned int *)(unsigned int )& * (volatile unsigned char *)(0x2C + 0x20) < timing) {
#line 148
          * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x24 + 0x20) = 0x0;
        }
#line 149
      * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x0D + 0x20) = 0xc0;






      * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x0F + 0x20) = 0x00;
      * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x18 + 0x20) |= 1 << 6;
      * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x18 + 0x20) &= ~(1 << 6);
      return SUCCESS;
    }
  return FAIL;
}

# 35 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/mica/SpiByteFifo.nc"
inline static   result_t MicaHighSpeedRadioM$SpiByteFifo$startReadBytes(uint16_t arg_0xa34c7d8){
#line 35
  unsigned char result;
#line 35

#line 35
  result = SpiByteFifoC$SpiByteFifo$startReadBytes(arg_0xa34c7d8);
#line 35

#line 35
  return result;
#line 35
}
#line 35
# 76 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/mica/hardware.h"
static __inline int TOSH_READ_RFM_RXD_PIN(void)
#line 76
{
#line 76
  return (* (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x16 + 0x20) & (1 << 2)) != 0;
}

static inline   
# 40 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/mica/RadioTimingC.nc"
uint16_t RadioTimingC$RadioTiming$getTiming(void)
#line 40
{


  * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x17 + 0x20) &= ~(1 << 4);
  while (TOSH_READ_RFM_RXD_PIN()) {
    }
#line 45
  * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x2E + 0x20) = 0x41;

  * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x36 + 0x20) = 0x1 << 5;

  while ((* (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x36 + 0x20) & (0x1 << 5)) == 0) {
    }
#line 50
  * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x18 + 0x20) |= 1 << 6;
  * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x18 + 0x20) &= ~(1 << 6);
  return ({
#line 52
    uint16_t __t;
#line 52
    bool bStatus;

#line 52
    bStatus = * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x3F + 0x20) & (1 << 7);
#line 52
     __asm volatile ("cli");__t = * (volatile unsigned int *)(unsigned int )& * (volatile unsigned char *)(0x26 + 0x20);
#line 52
    if (bStatus) {
#line 52
       __asm volatile ("sei");
      }
#line 52
    __t;
  }
  );
}

# 33 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/mica/RadioTiming.nc"
inline static   uint16_t MicaHighSpeedRadioM$RadioTiming$getTiming(void){
#line 33
  unsigned int result;
#line 33

#line 33
  result = RadioTimingC$RadioTiming$getTiming();
#line 33

#line 33
  return result;
#line 33
}
#line 33
static inline   
# 197 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/mica/MicaHighSpeedRadioM.nc"
result_t MicaHighSpeedRadioM$ChannelMon$startSymDetect(void)
#line 197
{
  uint16_t tmp;

  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 200
    {
      MicaHighSpeedRadioM$ack_count = 0;
      MicaHighSpeedRadioM$rec_count = 0;
      MicaHighSpeedRadioM$state = MicaHighSpeedRadioM$RX_STATE;
    }
#line 204
    __nesc_atomic_end(__nesc_atomic); }
  tmp = MicaHighSpeedRadioM$RadioTiming$getTiming();

  MicaHighSpeedRadioM$SpiByteFifo$startReadBytes(tmp);
  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 208
    {
      MicaHighSpeedRadioM$msg_length = MSG_DATA_SIZE - 2;
      MicaHighSpeedRadioM$calc_crc = 0;
      MicaHighSpeedRadioM$rec_ptr->time = tmp;
      MicaHighSpeedRadioM$rec_ptr->strength = 0;
    }
#line 213
    __nesc_atomic_end(__nesc_atomic); }
  MicaHighSpeedRadioM$RadioReceiveCoordinator$startSymbol();
  return SUCCESS;
}

# 38 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/mica/ChannelMon.nc"
inline static   result_t ChannelMonC$ChannelMon$startSymDetect(void){
#line 38
  unsigned char result;
#line 38

#line 38
  result = MicaHighSpeedRadioM$ChannelMon$startSymDetect();
#line 38

#line 38
  return result;
#line 38
}
#line 38
# 40 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/mica/SpiByteFifo.nc"
inline static   result_t SpiByteFifoC$SpiByteFifo$dataReady(uint8_t arg_0xa34d458){
#line 40
  unsigned char result;
#line 40

#line 40
  result = MicaHighSpeedRadioM$SpiByteFifo$dataReady(arg_0xa34d458);
#line 40

#line 40
  return result;
#line 40
}
#line 40
# 56 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/mica/SpiByteFifoC.nc"
void __attribute((signal))   __vector_17(void)
#line 56
{
  uint8_t temp = * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x0F + 0x20);


  * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x0F + 0x20) = SpiByteFifoC$nextByte;
  SpiByteFifoC$state = SpiByteFifoC$OPEN;






  SpiByteFifoC$SpiByteFifo$dataReady(temp);
}

# 66 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/ByteComm.nc"
inline static   result_t UARTM$ByteComm$rxByteReady(uint8_t arg_0xa4200e8, bool arg_0xa420230, uint16_t arg_0xa420388){
#line 66
  unsigned char result;
#line 66

#line 66
  result = FramerM$ByteComm$rxByteReady(arg_0xa4200e8, arg_0xa420230, arg_0xa420388);
#line 66

#line 66
  return result;
#line 66
}
#line 66
static inline   
# 77 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/UARTM.nc"
result_t UARTM$HPLUART$get(uint8_t data)
#line 77
{




  UARTM$ByteComm$rxByteReady(data, FALSE, 0);
  {
  }
#line 83
  ;
  return SUCCESS;
}

# 88 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/HPLUART.nc"
inline static   result_t HPLUARTM$UART$get(uint8_t arg_0xa459a58){
#line 88
  unsigned char result;
#line 88

#line 88
  result = UARTM$HPLUART$get(arg_0xa459a58);
#line 88

#line 88
  return result;
#line 88
}
#line 88
# 71 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/avrmote/HPLUARTM.nc"
void __attribute((signal))   __vector_18(void)
#line 71
{
  if (* (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x0B + 0x20) & 0x80) {
    HPLUARTM$UART$get(* (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x0C + 0x20));
    }
}

static inline  
# 202 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/FramerM.nc"
void FramerM$PacketUnknown(void)
#line 202
{
  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 203
    {
      FramerM$gFlags |= FramerM$FLAGS_UNKNOWN;
    }
#line 205
    __nesc_atomic_end(__nesc_atomic); }

  FramerM$StartTx();
}

static inline  
# 204 "TOSBaseM.nc"
TOS_MsgPtr TOSBaseM$UARTReceive$receive(TOS_MsgPtr Msg)
#line 204
{
  TOS_MsgPtr pBuf;

  {
  }
#line 207
  ;

  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 209
    {
      if (TOSBaseM$gfTxFlags & TOSBaseM$TXFLAG_BUSY) {
          pBuf = (void *)0;
        }
      else {
          pBuf = TOSBaseM$gpTxMsg;
          TOSBaseM$gfTxFlags |= TOSBaseM$TXFLAG_BUSY;
          TOSBaseM$gpTxMsg = Msg;
        }
    }
#line 218
    __nesc_atomic_end(__nesc_atomic); }

  if (pBuf == (void *)0) {
      pBuf = Msg;
    }
  else {
      TOS_post(TOSBaseM$UARTRcvdTask);
    }

  return pBuf;
}

# 75 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/ReceiveMsg.nc"
inline static  TOS_MsgPtr FramerM$ReceiveMsg$receive(TOS_MsgPtr arg_0xa2c3e00){
#line 75
  struct TOS_Msg *result;
#line 75

#line 75
  result = TOSBaseM$UARTReceive$receive(arg_0xa2c3e00);
#line 75

#line 75
  return result;
#line 75
}
#line 75
static inline  
# 231 "TOSBaseM.nc"
TOS_MsgPtr TOSBaseM$UARTTokenReceive$receive(TOS_MsgPtr Msg, uint8_t Token)
#line 231
{
  TOS_MsgPtr pBuf;

  {
  }
#line 234
  ;

  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 236
    {
      if (TOSBaseM$gfTxFlags & TOSBaseM$TXFLAG_BUSY) {
          pBuf = (void *)0;
        }
      else {
          pBuf = TOSBaseM$gpTxMsg;
          TOSBaseM$gfTxFlags |= TOSBaseM$TXFLAG_BUSY | TOSBaseM$TXFLAG_TOKEN;
          TOSBaseM$gpTxMsg = Msg;
          TOSBaseM$gTxPendingToken = Token;
        }
    }
#line 246
    __nesc_atomic_end(__nesc_atomic); }

  if (pBuf == (void *)0) {
      pBuf = Msg;
    }
  else {

      TOS_post(TOSBaseM$UARTRcvdTask);
    }

  return pBuf;
}

# 75 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/TokenReceiveMsg.nc"
inline static  TOS_MsgPtr FramerM$TokenReceiveMsg$receive(TOS_MsgPtr arg_0xa2af480, uint8_t arg_0xa2af5c8){
#line 75
  struct TOS_Msg *result;
#line 75

#line 75
  result = TOSBaseM$UARTTokenReceive$receive(arg_0xa2af480, arg_0xa2af5c8);
#line 75

#line 75
  return result;
#line 75
}
#line 75
static inline  
# 210 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/FramerM.nc"
void FramerM$PacketRcvd(void)
#line 210
{
  FramerM$MsgRcvEntry_t *pRcv = &FramerM$gMsgRcvTbl[FramerM$gRxTailIndex];
  TOS_MsgPtr pBuf = pRcv->pMsg;


  if (pRcv->Length >= (size_t )& ((struct TOS_Msg *)0)->data) {

      switch (pRcv->Proto) {
          case FramerM$PROTO_ACK: 
            break;
          case FramerM$PROTO_PACKET_ACK: 
            pBuf->crc = 1;
          pBuf = FramerM$TokenReceiveMsg$receive(pBuf, pRcv->Token);
          break;
          case FramerM$PROTO_PACKET_NOACK: 
            pBuf->crc = 1;
          pBuf = FramerM$ReceiveMsg$receive(pBuf);
          break;
          default: 
            FramerM$gTxUnknownBuf = pRcv->Proto;
          TOS_post(FramerM$PacketUnknown);
          break;
        }
    }

  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 235
    {
      if (pBuf) {
          pRcv->pMsg = pBuf;
        }
      pRcv->Length = 0;
      pRcv->Token = 0;
      FramerM$gRxTailIndex++;
      FramerM$gRxTailIndex %= FramerM$HDLC_QUEUESIZE;
    }
#line 243
    __nesc_atomic_end(__nesc_atomic); }
}

# 63 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/Random.nc"
inline static   uint16_t ChannelMonC$Random$rand(void){
#line 63
  unsigned int result;
#line 63

#line 63
  result = RandomLFSR$Random$rand();
#line 63

#line 63
  return result;
#line 63
}
#line 63
static inline   
# 151 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/mica/ChannelMonC.nc"
result_t ChannelMonC$ChannelMon$macDelay(void)
#line 151
{
  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 152
    {
      ChannelMonC$CM_search[0] = 0xff;
      if (ChannelMonC$CM_waiting == -1) {
          ChannelMonC$CM_waiting = (ChannelMonC$Random$rand() & 0x2f) + 80;
        }
    }
#line 157
    __nesc_atomic_end(__nesc_atomic); }

  return SUCCESS;
}

# 36 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/mica/ChannelMon.nc"
inline static   result_t MicaHighSpeedRadioM$ChannelMon$macDelay(void){
#line 36
  unsigned char result;
#line 36

#line 36
  result = ChannelMonC$ChannelMon$macDelay();
#line 36

#line 36
  return result;
#line 36
}
#line 36
static inline  
# 125 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/mica/MicaHighSpeedRadioM.nc"
result_t MicaHighSpeedRadioM$Send$send(TOS_MsgPtr msg)
#line 125
{
  uint8_t oldSendState;

#line 127
  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 127
    {
      oldSendState = MicaHighSpeedRadioM$send_state;
      if (MicaHighSpeedRadioM$send_state == MicaHighSpeedRadioM$IDLE_STATE) {
          MicaHighSpeedRadioM$send_state = MicaHighSpeedRadioM$SEND_WAITING;
          MicaHighSpeedRadioM$send_ptr = msg;
          MicaHighSpeedRadioM$tx_count = 1;
        }
    }
#line 134
    __nesc_atomic_end(__nesc_atomic); }

  if (oldSendState == MicaHighSpeedRadioM$IDLE_STATE) {
      return MicaHighSpeedRadioM$ChannelMon$macDelay();
    }
  else 
#line 138
    {
      return FAIL;
    }
}

# 58 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/BareSendMsg.nc"
inline static  result_t TOSBaseM$RadioSend$send(TOS_MsgPtr arg_0xa2c23d8){
#line 58
  unsigned char result;
#line 58

#line 58
  result = MicaHighSpeedRadioM$Send$send(arg_0xa2c23d8);
#line 58

#line 58
  return result;
#line 58
}
#line 58
# 57 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/mica/hardware.h"
static __inline void TOSH_CLR_RED_LED_PIN(void)
#line 57
{
#line 57
  * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x1B + 0x20) &= ~(1 << 2);
}

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 TOSBaseM$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 81
# 96 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/HPLUART.nc"
inline static   result_t HPLUARTM$UART$putDone(void){
#line 96
  unsigned char result;
#line 96

#line 96
  result = UARTM$HPLUART$putDone();
#line 96

#line 96
  return result;
#line 96
}
#line 96
# 77 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/avrmote/HPLUARTM.nc"
void __attribute((interrupt))   __vector_20(void)
#line 77
{
  HPLUARTM$UART$putDone();
}

static inline   
# 552 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/FramerM.nc"
result_t FramerM$ByteComm$txDone(void)
#line 552
{

  if (FramerM$gTxState == FramerM$TXSTATE_FINISH) {
      FramerM$gTxState = FramerM$TXSTATE_IDLE;
      TOS_post(FramerM$PacketSent);
    }

  return SUCCESS;
}

# 83 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/ByteComm.nc"
inline static   result_t UARTM$ByteComm$txDone(void){
#line 83
  unsigned char result;
#line 83

#line 83
  result = FramerM$ByteComm$txDone();
#line 83

#line 83
  return result;
#line 83
}
#line 83
#line 55
inline static   result_t FramerM$ByteComm$txByte(uint8_t arg_0xa40dc48){
#line 55
  unsigned char result;
#line 55

#line 55
  result = UARTM$ByteComm$txByte(arg_0xa40dc48);
#line 55

#line 55
  return result;
#line 55
}
#line 55
static inline   
# 482 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/FramerM.nc"
result_t FramerM$ByteComm$txByteReady(bool LastByteSuccess)
#line 482
{
  result_t TxResult = SUCCESS;
  uint8_t nextByte;

  if (LastByteSuccess != TRUE) {
      { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 487
        FramerM$gTxState = FramerM$TXSTATE_ERROR;
#line 487
        __nesc_atomic_end(__nesc_atomic); }
      TOS_post(FramerM$PacketSent);
      return SUCCESS;
    }

  switch (FramerM$gTxState) {

      case FramerM$TXSTATE_PROTO: 
        FramerM$gTxState = FramerM$TXSTATE_INFO;
      FramerM$gTxRunningCRC = crcByte(FramerM$gTxRunningCRC, FramerM$gTxProto);
      TxResult = FramerM$ByteComm$txByte(FramerM$gTxProto);
      break;

      case FramerM$TXSTATE_INFO: 
        nextByte = FramerM$gpTxBuf[FramerM$gTxByteCnt];

      FramerM$gTxRunningCRC = crcByte(FramerM$gTxRunningCRC, nextByte);
      FramerM$gTxByteCnt++;
      if (FramerM$gTxByteCnt >= FramerM$gTxLength) {
          FramerM$gTxState = FramerM$TXSTATE_FCS1;
        }

      TxResult = FramerM$TxArbitraryByte(nextByte);
      break;

      case FramerM$TXSTATE_ESC: 

        TxResult = FramerM$ByteComm$txByte(FramerM$gTxEscByte ^ 0x20);
      FramerM$gTxState = FramerM$gPrevTxState;
      break;

      case FramerM$TXSTATE_FCS1: 
        nextByte = (uint8_t )(FramerM$gTxRunningCRC & 0xff);
      FramerM$gTxState = FramerM$TXSTATE_FCS2;
      TxResult = FramerM$TxArbitraryByte(nextByte);
      break;

      case FramerM$TXSTATE_FCS2: 
        nextByte = (uint8_t )((FramerM$gTxRunningCRC >> 8) & 0xff);
      FramerM$gTxState = FramerM$TXSTATE_ENDFLAG;
      TxResult = FramerM$TxArbitraryByte(nextByte);
      break;

      case FramerM$TXSTATE_ENDFLAG: 
        FramerM$gTxState = FramerM$TXSTATE_FINISH;
      TxResult = FramerM$ByteComm$txByte(FramerM$HDLC_FLAG_BYTE);

      break;

      case FramerM$TXSTATE_FINISH: 
        case FramerM$TXSTATE_ERROR: 

          default: 
            break;
    }


  if (TxResult != SUCCESS) {
      FramerM$gTxState = FramerM$TXSTATE_ERROR;
      TOS_post(FramerM$PacketSent);
    }

  return SUCCESS;
}

# 75 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/ByteComm.nc"
inline static   result_t UARTM$ByteComm$txByteReady(bool arg_0xa4208b8){
#line 75
  unsigned char result;
#line 75

#line 75
  result = FramerM$ByteComm$txByteReady(arg_0xa4208b8);
#line 75

#line 75
  return result;
#line 75
}
#line 75
# 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 TRUE;
    }
  else {
      TOSH_sched_free = tmp;
      __nesc_atomic_end(fInterruptFlags);

      return FALSE;
    }
}

# 54 "C:/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();
    }
}

static 
# 268 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/FramerM.nc"
void FramerM$HDLCInitialize(void)
#line 268
{
  int i;

#line 270
  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 270
    {
      for (i = 0; i < FramerM$HDLC_QUEUESIZE; i++) {
          FramerM$gMsgRcvTbl[i].pMsg = &FramerM$gMsgRcvBuf[i];
          FramerM$gMsgRcvTbl[i].Length = 0;
          FramerM$gMsgRcvTbl[i].Token = 0;
        }
      FramerM$gTxState = FramerM$TXSTATE_IDLE;
      FramerM$gTxByteCnt = 0;
      FramerM$gTxLength = 0;
      FramerM$gTxRunningCRC = 0;
      FramerM$gpTxMsg = (void *)0;

      FramerM$gRxState = FramerM$RXSTATE_NOSYNC;
      FramerM$gRxHeadIndex = 0;
      FramerM$gRxTailIndex = 0;
      FramerM$gRxByteCnt = 0;
      FramerM$gRxRunningCRC = 0;
      FramerM$gpRxBuf = (uint8_t *)FramerM$gMsgRcvTbl[FramerM$gRxHeadIndex].pMsg;
    }
#line 288
    __nesc_atomic_end(__nesc_atomic); }
}

static   
# 66 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/mica/ChannelMonC.nc"
result_t ChannelMonC$ChannelMon$startSymbolSearch(void)
#line 66
{
  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 67
    {

      ChannelMonC$CM_state = ChannelMonC$IDLE_STATE;

      TOSH_SET_RFM_CTL0_PIN();
      TOSH_SET_RFM_CTL1_PIN();
      TOSH_CLR_RFM_TXD_PIN();






      * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x37 + 0x20) &= ~(1 << 7);
      * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x37 + 0x20) &= ~(1 << 6);
      * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x37 + 0x20) &= ~(1 << 7);
      * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x25 + 0x20) = 0x09;
      * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x23 + 0x20) = ChannelMonC$SAMPLE_RATE;
      * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x37 + 0x20) |= 1 << 7;
      * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x24 + 0x20) = 0x00;
      * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x17 + 0x20) |= 1 << 6;
    }
#line 88
    __nesc_atomic_end(__nesc_atomic); }
  return SUCCESS;
}



void __attribute((signal))   __vector_9(void)
#line 94
{
  uint8_t bit = TOSH_READ_RFM_RXD_PIN();

#line 96
  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 96
    {

      if (ChannelMonC$CM_state == ChannelMonC$IDLE_STATE) {
          ChannelMonC$CM_search[0] <<= 1;
          ChannelMonC$CM_search[0] = ChannelMonC$CM_search[0] | (bit & 0x1);
          if (ChannelMonC$CM_waiting != -1) {
              ChannelMonC$CM_waiting--;
              if (ChannelMonC$CM_waiting == 1) {
                  if ((ChannelMonC$CM_search[0] & 0xfff) == 0) {
                      ChannelMonC$CM_waiting = -1;
                      ChannelMonC$ChannelMon$idleDetect();
                    }
                  else 
#line 107
                    {
                      ChannelMonC$CM_waiting = (ChannelMonC$Random$rand() & 0x1f) + 30;
                    }
                }
            }
          if ((ChannelMonC$CM_search[0] & 0x777) == 0x707) {
              ChannelMonC$CM_state = ChannelMonC$START_SYMBOL_SEARCH;
              ChannelMonC$CM_search[0] = ChannelMonC$CM_search[1] = 0;
              ChannelMonC$CM_startSymBits = 30;
            }
        }
      else {
#line 117
        if (ChannelMonC$CM_state == ChannelMonC$START_SYMBOL_SEARCH) {
            unsigned int current = ChannelMonC$CM_search[ChannelMonC$CM_lastBit];

#line 119
            ChannelMonC$CM_startSymBits--;
            if (ChannelMonC$CM_startSymBits == 0) {
                ChannelMonC$CM_state = ChannelMonC$IDLE_STATE;
              }
            if (ChannelMonC$CM_state != ChannelMonC$IDLE_STATE) {
                current <<= 1;
                current &= 0x1ff;
                if (bit) {
#line 126
                  current |= 0x1;
                  }
#line 127
                if (current == 0x135) {
                    * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x37 + 0x20) &= ~(1 << 7);
                    ChannelMonC$CM_state = ChannelMonC$IDLE_STATE;
                    ChannelMonC$ChannelMon$startSymDetect();
                  }
                if (ChannelMonC$CM_state != ChannelMonC$IDLE_STATE) {
                    ChannelMonC$CM_search[ChannelMonC$CM_lastBit] = current;
                    ChannelMonC$CM_lastBit ^= 1;
                  }
              }
          }
        }
    }
#line 139
    __nesc_atomic_end(__nesc_atomic); }
#line 139
  return;
}

static   
# 80 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/mica/SecDedEncoding.nc"
result_t SecDedEncoding$Code$encode(char d)
#line 80
{
  uint8_t oldState;

#line 82
  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 82
    {
      oldState = SecDedEncoding$state;
      if (SecDedEncoding$state == SecDedEncoding$IDLE_STATE) {
          SecDedEncoding$state = SecDedEncoding$ENCODING_BYTE;
          SecDedEncoding$data1 = d;
        }
    }
#line 88
    __nesc_atomic_end(__nesc_atomic); }
  if (oldState == SecDedEncoding$IDLE_STATE) {
      SecDedEncoding$radio_encode_thread();
      return 1;
    }
  else {
      return 0;
    }
}

static   
# 299 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/mica/MicaHighSpeedRadioM.nc"
result_t MicaHighSpeedRadioM$Code$encodeDone(char data1)
#line 299
{
  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 300
    {
      MicaHighSpeedRadioM$encoded_buffer[(int )MicaHighSpeedRadioM$buf_end] = data1;
      MicaHighSpeedRadioM$buf_end++;
      MicaHighSpeedRadioM$buf_end &= 0x3;
      MicaHighSpeedRadioM$enc_count += 1;
    }
#line 305
    __nesc_atomic_end(__nesc_atomic); }
  return SUCCESS;
}

static   
# 71 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/mica/SpiByteFifoC.nc"
result_t SpiByteFifoC$SpiByteFifo$send(uint8_t data)
#line 71
{
  result_t rval = FAIL;

#line 73
  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 73
    {
      if (SpiByteFifoC$state == SpiByteFifoC$OPEN) {
          SpiByteFifoC$nextByte = data;
          SpiByteFifoC$state = SpiByteFifoC$FULL;
          rval = SUCCESS;
        }
      else {
#line 79
        if (SpiByteFifoC$state == SpiByteFifoC$IDLE) {
            SpiByteFifoC$state = SpiByteFifoC$OPEN;
            SpiByteFifoC$SpiByteFifo$dataReady(0);
            SpiByteFifoC$SlavePin$low();
            * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x18 + 0x20) &= ~(1 << 7);
            * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x17 + 0x20) |= 1 << 7;
            * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x0D + 0x20) = 0xc0;
            * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x0F + 0x20) = data;

            TOSH_CLR_RFM_CTL0_PIN();
            TOSH_SET_RFM_CTL1_PIN();

            * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x37 + 0x20) &= ~(1 << 6);
            * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x37 + 0x20) &= ~(1 << 7);
            * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x24 + 0x20) = 0;
            * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x23 + 0x20) = SpiByteFifoC$BIT_RATE;
            * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x25 + 0x20) = 0x19;
            rval = SUCCESS;
          }
        }
    }
#line 99
    __nesc_atomic_end(__nesc_atomic); }
#line 99
  return rval;
}

static   
# 309 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/mica/MicaHighSpeedRadioM.nc"
result_t MicaHighSpeedRadioM$SpiByteFifo$dataReady(uint8_t data)
#line 309
{
  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 310
    {
      if (MicaHighSpeedRadioM$state == MicaHighSpeedRadioM$TRANSMITTING_START) {
          MicaHighSpeedRadioM$SpiByteFifo$send(TOSH_MHSR_start[(int )MicaHighSpeedRadioM$tx_count]);
          MicaHighSpeedRadioM$tx_count++;
          if (MicaHighSpeedRadioM$tx_count == sizeof TOSH_MHSR_start) {
              MicaHighSpeedRadioM$state = MicaHighSpeedRadioM$TRANSMITTING;
              MicaHighSpeedRadioM$tx_count = 1;
            }
        }
      else {
#line 318
        if (MicaHighSpeedRadioM$state == MicaHighSpeedRadioM$TRANSMITTING) {
            MicaHighSpeedRadioM$SpiByteFifo$send(MicaHighSpeedRadioM$encoded_buffer[(int )MicaHighSpeedRadioM$buf_head]);
            MicaHighSpeedRadioM$buf_head++;
            MicaHighSpeedRadioM$buf_head &= 0x3;
            MicaHighSpeedRadioM$enc_count--;


            if (MicaHighSpeedRadioM$enc_count >= 2) {
                ;
              }
            else {
#line 327
              if (MicaHighSpeedRadioM$tx_count < MSG_DATA_SIZE) {
                  char next_data = ((char *)MicaHighSpeedRadioM$send_ptr)[(int )MicaHighSpeedRadioM$tx_count];

#line 329
                  MicaHighSpeedRadioM$Code$encode(next_data);
                  MicaHighSpeedRadioM$tx_count++;
                  if (MicaHighSpeedRadioM$tx_count <= MicaHighSpeedRadioM$msg_length) {
                      MicaHighSpeedRadioM$calc_crc = crcByte(MicaHighSpeedRadioM$calc_crc, next_data);
                    }
                  if (MicaHighSpeedRadioM$tx_count == MicaHighSpeedRadioM$msg_length) {


                      MicaHighSpeedRadioM$tx_count = MSG_DATA_SIZE - 2;
                      MicaHighSpeedRadioM$send_ptr->crc = MicaHighSpeedRadioM$calc_crc;
                    }
                  MicaHighSpeedRadioM$RadioSendCoordinator$byte(MicaHighSpeedRadioM$send_ptr, (uint8_t )MicaHighSpeedRadioM$tx_count);
                }
              else {
#line 341
                if (MicaHighSpeedRadioM$buf_head != MicaHighSpeedRadioM$buf_end) {
                    MicaHighSpeedRadioM$Code$encode_flush();
                  }
                else 
#line 343
                  {
                    MicaHighSpeedRadioM$state = MicaHighSpeedRadioM$SENDING_STRENGTH_PULSE;
                    MicaHighSpeedRadioM$tx_count = 0;
                  }
                }
              }
          }
        else {
#line 347
          if (MicaHighSpeedRadioM$state == MicaHighSpeedRadioM$SENDING_STRENGTH_PULSE) {
              MicaHighSpeedRadioM$tx_count++;
              if (MicaHighSpeedRadioM$tx_count == 3) {
                  MicaHighSpeedRadioM$state = MicaHighSpeedRadioM$WAITING_FOR_ACK;
                  MicaHighSpeedRadioM$SpiByteFifo$phaseShift();
                  MicaHighSpeedRadioM$tx_count = 1;
                  MicaHighSpeedRadioM$SpiByteFifo$send(0x00);
                }
              else {
                  MicaHighSpeedRadioM$SpiByteFifo$send(0xff);
                }
            }
          else {
#line 359
            if (MicaHighSpeedRadioM$state == MicaHighSpeedRadioM$WAITING_FOR_ACK) {
                data &= 0x7f;
                MicaHighSpeedRadioM$SpiByteFifo$send(0x00);
                if (MicaHighSpeedRadioM$tx_count == 1) {
                  MicaHighSpeedRadioM$SpiByteFifo$rxMode();
                  }
#line 364
                MicaHighSpeedRadioM$tx_count++;
                if (MicaHighSpeedRadioM$tx_count == MicaHighSpeedRadioM$ACK_CNT + 2) {
                    MicaHighSpeedRadioM$send_ptr->ack = data == 0x55;
                    MicaHighSpeedRadioM$state = MicaHighSpeedRadioM$IDLE_STATE;

                    MicaHighSpeedRadioM$SpiByteFifo$idle();
                    TOS_post(MicaHighSpeedRadioM$packetSent);
                  }
              }
            else {
#line 372
              if (MicaHighSpeedRadioM$state == MicaHighSpeedRadioM$RX_STATE) {
                  MicaHighSpeedRadioM$Code$decode(data);
                }
              else {
#line 374
                if (MicaHighSpeedRadioM$state == MicaHighSpeedRadioM$ACK_SEND_STATE) {
                    MicaHighSpeedRadioM$ack_count++;
                    if (MicaHighSpeedRadioM$ack_count > MicaHighSpeedRadioM$ACK_CNT + 1) {
                        MicaHighSpeedRadioM$state = MicaHighSpeedRadioM$RX_DONE_STATE;
                        MicaHighSpeedRadioM$SpiByteFifo$idle();
                        TOS_post(MicaHighSpeedRadioM$packetReceived);
                      }
                    else 
#line 380
                      {
                        MicaHighSpeedRadioM$SpiByteFifo$txMode();
                      }
                  }
                }
              }
            }
          }
        }
    }
#line 389
    __nesc_atomic_end(__nesc_atomic); }
#line 385
  return 1;
}

static   
# 102 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/mica/SpiByteFifoC.nc"
result_t SpiByteFifoC$SpiByteFifo$idle(void)
#line 102
{
  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 103
    {
      * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x0D + 0x20) = 0x00;
      * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x0F + 0x20) = 0x00;
      * (volatile unsigned char *)(unsigned int )& * (volatile unsigned char *)(0x25 + 0x20) = 0x00;
      SpiByteFifoC$nextByte = 0;
      SpiByteFifoC$SlavePin$high(FALSE);
      TOSH_MAKE_RFM_TXD_OUTPUT();
      TOSH_CLR_RFM_TXD_PIN();
      TOSH_CLR_RFM_CTL0_PIN();
      TOSH_CLR_RFM_CTL1_PIN();
      SpiByteFifoC$state = SpiByteFifoC$IDLE;
      SpiByteFifoC$nextByte = 0;
    }
#line 115
    __nesc_atomic_end(__nesc_atomic); }
  return SUCCESS;
}

static 
# 158 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/FramerM.nc"
result_t FramerM$StartTx(void)
#line 158
{
  result_t Result = SUCCESS;
  bool fInitiate = FALSE;

  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 162
    {
      if (FramerM$gTxState == FramerM$TXSTATE_IDLE) {
          if (FramerM$gFlags & FramerM$FLAGS_TOKENPEND) {
              FramerM$gpTxBuf = (uint8_t *)&FramerM$gTxTokenBuf;
              FramerM$gTxProto = FramerM$PROTO_ACK;
              FramerM$gTxLength = sizeof FramerM$gTxTokenBuf;
              fInitiate = TRUE;
              FramerM$gTxState = FramerM$TXSTATE_PROTO;
            }
          else {
#line 171
            if (FramerM$gFlags & FramerM$FLAGS_DATAPEND) {
                FramerM$gpTxBuf = (uint8_t *)FramerM$gpTxMsg;
                FramerM$gTxProto = FramerM$PROTO_PACKET_NOACK;
                FramerM$gTxLength = FramerM$gpTxMsg->length + (MSG_DATA_SIZE - DATA_LENGTH - 2);
                fInitiate = TRUE;
                FramerM$gTxState = FramerM$TXSTATE_PROTO;
              }
            else {
#line 178
              if (FramerM$gFlags & FramerM$FLAGS_UNKNOWN) {
                  FramerM$gpTxBuf = (uint8_t *)&FramerM$gTxUnknownBuf;
                  FramerM$gTxProto = FramerM$PROTO_UNKNOWN;
                  FramerM$gTxLength = sizeof FramerM$gTxUnknownBuf;
                  fInitiate = TRUE;
                  FramerM$gTxState = FramerM$TXSTATE_PROTO;
                }
              }
            }
        }
    }
#line 188
    __nesc_atomic_end(__nesc_atomic); }
#line 188
  if (fInitiate) {
      { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 189
        {
          FramerM$gTxRunningCRC = 0;
#line 190
          FramerM$gTxByteCnt = 0;
        }
#line 191
        __nesc_atomic_end(__nesc_atomic); }
      Result = FramerM$ByteComm$txByte(FramerM$HDLC_FLAG_BYTE);
      if (Result != SUCCESS) {
          { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 194
            FramerM$gTxState = FramerM$TXSTATE_ERROR;
#line 194
            __nesc_atomic_end(__nesc_atomic); }
          TOS_post(FramerM$PacketSent);
        }
    }

  return Result;
}

static   
# 110 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/UARTM.nc"
result_t UARTM$ByteComm$txByte(uint8_t data)
#line 110
{
  bool oldState;

  {
  }
#line 113
  ;

  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 115
    {
      oldState = UARTM$state;
      UARTM$state = TRUE;
    }
#line 118
    __nesc_atomic_end(__nesc_atomic); }
  if (oldState) {
    return FAIL;
    }
  UARTM$HPLUART$put(data);

  return SUCCESS;
}

static  
# 246 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/FramerM.nc"
void FramerM$PacketSent(void)
#line 246
{
  result_t TxResult = SUCCESS;

  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 249
    {
      if (FramerM$gTxState == FramerM$TXSTATE_ERROR) {
          TxResult = FAIL;
          FramerM$gTxState = FramerM$TXSTATE_IDLE;
        }
    }
#line 254
    __nesc_atomic_end(__nesc_atomic); }
  if (FramerM$gTxProto == FramerM$PROTO_ACK) {
      { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 256
        FramerM$gFlags ^= FramerM$FLAGS_TOKENPEND;
#line 256
        __nesc_atomic_end(__nesc_atomic); }
    }
  else {
      { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 259
        FramerM$gFlags ^= FramerM$FLAGS_DATAPEND;
#line 259
        __nesc_atomic_end(__nesc_atomic); }
      FramerM$BareSendMsg$sendDone((TOS_MsgPtr )FramerM$gpTxMsg, TxResult);
      { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 261
        FramerM$gpTxMsg = (void *)0;
#line 261
        __nesc_atomic_end(__nesc_atomic); }
    }


  FramerM$StartTx();
}

static   
# 70 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/RandomLFSR.nc"
uint16_t RandomLFSR$Random$rand(void)
#line 70
{
  bool endbit;
  uint16_t tmpShiftReg;

#line 73
  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 73
    {
      tmpShiftReg = RandomLFSR$shiftReg;
      endbit = (tmpShiftReg & 0x8000) != 0;
      tmpShiftReg <<= 1;
      if (endbit) {
        tmpShiftReg ^= 0x100b;
        }
#line 79
      tmpShiftReg++;
      RandomLFSR$shiftReg = tmpShiftReg;
      tmpShiftReg = tmpShiftReg ^ RandomLFSR$mask;
    }
#line 82
    __nesc_atomic_end(__nesc_atomic); }
  return tmpShiftReg;
}

static   
# 348 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/FramerM.nc"
result_t FramerM$ByteComm$rxByteReady(uint8_t data, bool error, uint16_t strength)
#line 348
{

  switch (FramerM$gRxState) {

      case FramerM$RXSTATE_NOSYNC: 
        if (data == FramerM$HDLC_FLAG_BYTE && FramerM$gMsgRcvTbl[FramerM$gRxHeadIndex].Length == 0) {
            FramerM$gMsgRcvTbl[FramerM$gRxHeadIndex].Token = 0;
            FramerM$gRxByteCnt = FramerM$gRxRunningCRC = 0;
            FramerM$gpRxBuf = (uint8_t *)FramerM$gMsgRcvTbl[FramerM$gRxHeadIndex].pMsg;
            FramerM$gRxState = FramerM$RXSTATE_PROTO;
          }
      break;

      case FramerM$RXSTATE_PROTO: 
        if (data == FramerM$HDLC_FLAG_BYTE) {
            break;
          }
      FramerM$gMsgRcvTbl[FramerM$gRxHeadIndex].Proto = data;
      FramerM$gRxRunningCRC = crcByte(FramerM$gRxRunningCRC, data);
      switch (data) {
          case FramerM$PROTO_PACKET_ACK: 
            FramerM$gRxState = FramerM$RXSTATE_TOKEN;
          break;
          case FramerM$PROTO_PACKET_NOACK: 
            FramerM$gRxState = FramerM$RXSTATE_INFO;
          break;
          default: 
            FramerM$gRxState = FramerM$RXSTATE_NOSYNC;
          break;
        }
      break;

      case FramerM$RXSTATE_TOKEN: 
        if (data == FramerM$HDLC_FLAG_BYTE) {
            FramerM$gRxState = FramerM$RXSTATE_NOSYNC;
          }
        else {
#line 384
          if (data == FramerM$HDLC_CTLESC_BYTE) {
              FramerM$gMsgRcvTbl[FramerM$gRxHeadIndex].Token = 0x20;
            }
          else {
              FramerM$gMsgRcvTbl[FramerM$gRxHeadIndex].Token ^= data;
              FramerM$gRxRunningCRC = crcByte(FramerM$gRxRunningCRC, FramerM$gMsgRcvTbl[FramerM$gRxHeadIndex].Token);
              FramerM$gRxState = FramerM$RXSTATE_INFO;
            }
          }
#line 392
      break;


      case FramerM$RXSTATE_INFO: 
        if (FramerM$gRxByteCnt > FramerM$HDLC_MTU) {
            FramerM$gRxByteCnt = FramerM$gRxRunningCRC = 0;
            FramerM$gMsgRcvTbl[FramerM$gRxHeadIndex].Length = 0;
            FramerM$gMsgRcvTbl[FramerM$gRxHeadIndex].Token = 0;
            FramerM$gRxState = FramerM$RXSTATE_NOSYNC;
          }
        else {
#line 402
          if (data == FramerM$HDLC_CTLESC_BYTE) {
              FramerM$gRxState = FramerM$RXSTATE_ESC;
            }
          else {
#line 405
            if (data == FramerM$HDLC_FLAG_BYTE) {
                if (FramerM$gRxByteCnt >= 2) {
                    uint16_t usRcvdCRC = FramerM$gpRxBuf[FramerM$gRxByteCnt - 1] & 0xff;

#line 408
                    usRcvdCRC = (usRcvdCRC << 8) | (FramerM$gpRxBuf[FramerM$gRxByteCnt - 2] & 0xff);
                    if (usRcvdCRC == FramerM$gRxRunningCRC) {
                        FramerM$gMsgRcvTbl[FramerM$gRxHeadIndex].Length = FramerM$gRxByteCnt - 2;
                        TOS_post(FramerM$PacketRcvd);
                        FramerM$gRxHeadIndex++;
#line 412
                        FramerM$gRxHeadIndex %= FramerM$HDLC_QUEUESIZE;
                      }
                    else {
                        FramerM$gMsgRcvTbl[FramerM$gRxHeadIndex].Length = 0;
                        FramerM$gMsgRcvTbl[FramerM$gRxHeadIndex].Token = 0;
                      }
                    if (FramerM$gMsgRcvTbl[FramerM$gRxHeadIndex].Length == 0) {
                        FramerM$gpRxBuf = (uint8_t *)FramerM$gMsgRcvTbl[FramerM$gRxHeadIndex].pMsg;
                        FramerM$gRxState = FramerM$RXSTATE_PROTO;
                      }
                    else {
                        FramerM$gRxState = FramerM$RXSTATE_NOSYNC;
                      }
                  }
                else {
                    FramerM$gMsgRcvTbl[FramerM$gRxHeadIndex].Length = 0;
                    FramerM$gMsgRcvTbl[FramerM$gRxHeadIndex].Token = 0;
                    FramerM$gRxState = FramerM$RXSTATE_NOSYNC;
                  }
                FramerM$gRxByteCnt = FramerM$gRxRunningCRC = 0;
              }
            else {
                FramerM$gpRxBuf[FramerM$gRxByteCnt] = data;
                if (FramerM$gRxByteCnt >= 2) {
                    FramerM$gRxRunningCRC = crcByte(FramerM$gRxRunningCRC, FramerM$gpRxBuf[FramerM$gRxByteCnt - 2]);
                  }
                FramerM$gRxByteCnt++;
              }
            }
          }
#line 440
      break;

      case FramerM$RXSTATE_ESC: 
        if (data == FramerM$HDLC_FLAG_BYTE) {

            FramerM$gRxByteCnt = FramerM$gRxRunningCRC = 0;
            FramerM$gMsgRcvTbl[FramerM$gRxHeadIndex].Length = 0;
            FramerM$gMsgRcvTbl[FramerM$gRxHeadIndex].Token = 0;
            FramerM$gRxState = FramerM$RXSTATE_NOSYNC;
          }
        else {
            data = data ^ 0x20;
            FramerM$gpRxBuf[FramerM$gRxByteCnt] = data;
            if (FramerM$gRxByteCnt >= 2) {
                FramerM$gRxRunningCRC = crcByte(FramerM$gRxRunningCRC, FramerM$gpRxBuf[FramerM$gRxByteCnt - 2]);
              }
            FramerM$gRxByteCnt++;
            FramerM$gRxState = FramerM$RXSTATE_INFO;
          }
      break;

      default: 
        FramerM$gRxState = FramerM$RXSTATE_NOSYNC;
      break;
    }

  return SUCCESS;
}

static  
# 102 "TOSBaseM.nc"
void TOSBaseM$UARTRcvdTask(void)
#line 102
{
  result_t Result;

  {
  }
#line 105
  ;
  TOSBaseM$gpTxMsg->group = TOS_AM_GROUP;
  Result = TOSBaseM$RadioSend$send(TOSBaseM$gpTxMsg);

  if (Result != SUCCESS) {
      { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 110
        TOSBaseM$gfTxFlags = 0;
#line 110
        __nesc_atomic_end(__nesc_atomic); }
    }
  else {
      TOSBaseM$Leds$redToggle();
    }
}

static   
# 87 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/UARTM.nc"
result_t UARTM$HPLUART$putDone(void)
#line 87
{
  bool oldState;

  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 90
    {
      {
      }
#line 91
      ;
      oldState = UARTM$state;
      UARTM$state = FALSE;
    }
#line 94
    __nesc_atomic_end(__nesc_atomic); }








  if (oldState) {
      UARTM$ByteComm$txDone();
      UARTM$ByteComm$txByteReady(TRUE);
    }
  return SUCCESS;
}

static 
# 469 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/FramerM.nc"
result_t FramerM$TxArbitraryByte(uint8_t Byte)
#line 469
{
  if (Byte == FramerM$HDLC_FLAG_BYTE || Byte == FramerM$HDLC_CTLESC_BYTE) {
      { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 471
        {
          FramerM$gPrevTxState = FramerM$gTxState;
          FramerM$gTxState = FramerM$TXSTATE_ESC;
          FramerM$gTxEscByte = Byte;
        }
#line 475
        __nesc_atomic_end(__nesc_atomic); }
      Byte = FramerM$HDLC_CTLESC_BYTE;
    }

  return FramerM$ByteComm$txByte(Byte);
}

