亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? halstack.c

?? zigbeeC++的源代碼
?? C
?? 第 1 頁 / 共 2 頁
字號:
  {
    ISFLUSHRX;
    ISFLUSHRX;
  }

  RFIF &= ~IRQ_TXDONE;      //Clear the RF TXDONE flag
  INT_SETFLAG_RF(INT_CLR);  //Clear processor interrupt flag

  //write packet length
  RFD = len;
  //write the packet. Use 'flen' as the last two bytes are added automatically
  //At some point, change this to use DMA
  while (flen) {RFD = *frm; frm++; flen--;}

  // If the RSSI value is not valid, enable receiver
  if(RSSIL == 0x80)
  {
    ISRXON;
    // Turning on Rx and waiting 320u-sec to make the RSSI value become valid.
    halWait(1);
  }

  doIEEE_backoff();
  //Transmitting
  ISTXONCCA;       //TODO: replace this with IEEE Backoff

  if(FSMSTATE > 30)  //is TX active?
  {
    // Asserting the status flag and enabling ACK reception if expected.
    phyTxStartCallBack();
    res = LRWPAN_STATUS_SUCCESS;
    RFIM |= IRQ_TXDONE;             //enable IRQ_TXDONE interrupt
    DEBUG_CHAR( DBG_TX,DBG_CHAR_TXSTART);
  }
  else
  {
    ISFLUSHTX;               //empty buffer
    res = LRWPAN_STATUS_PHY_CHANNEL_BUSY;
    RFIM &= ~IRQ_TXDONE;     //mask interrupt
    DEBUG_CHAR( DBG_TX,DBG_CHAR_TXBUSY);
  }
  return(res);
}

#ifdef  LRWPAN_ASYNC_INTIO

#if defined(IAR8051)
#pragma vector=URX0_VECTOR
#endif
#if defined(HI_TECH_C)
ROM_VECTOR(URX0_VECTOR,urx0_service_IRQ);
#endif

INTERRUPT_FUNC urx0_service_IRQ(void){

   BYTE x,y;

   serio_rxHead++;
   if (serio_rxHead == LRWPAN_ASYNC_RX_BUFSIZE ) serio_rxHead = 0;
   x = serio_rxHead;  //use tmp variables because of Volatile decl
   y = U0DBUF;
   serio_rxBuff[x] = y;
}

#endif



//This timer interrupt is the periodic interrupt for
//evboard functions

#ifdef LRWPAN_ENABLE_SLOW_TIMER

#if defined(IAR8051)
#pragma vector=T2_VECTOR
#endif
#if defined(HI_TECH_C)
ROM_VECTOR(T2_VECTOR,t2_service_IRQ);
#endif

INTERRUPT_FUNC t2_service_IRQ(void){
  UINT32 t;

  INT_GLOBAL_ENABLE(INT_OFF);
  INT_SETFLAG_T2(INT_CLR); //clear processor interrupt flag
   //compute next compare value by reading current timer value, adding offset
  t = 0x0FF & T2OF0;
  t += (((UINT16)T2OF1)<<8);
  t += (((UINT32) T2OF2 & 0x0F)<<16);
  t += T2CMPVAL;  //add offset
  T2PEROF0 = t & 0xFF;
  T2PEROF1 = (t >> 8) & 0xFF;
  //enable overflow count compare interrupt
  T2PEROF2 = ((t >> 16)&0x0F) | 0x20;
  T2CNF = 0x03; //this clears the timer2 flags
  evbIntCallback();  //Evaluation board callback
  usrSlowTimerInt();  //user level interrupt callback
  INT_GLOBAL_ENABLE(INT_ON);
}
#endif




//interrupt for RF error
//this interrupt is same priority as FIFOP interrupt,
//but is polled first, so will occur first.

#if defined(IAR8051)
#pragma vector=RFERR_VECTOR
#endif
#if defined(HI_TECH_C)
ROM_VECTOR(RFERR_VECTOR,rf_error_IRQ);
#endif
INTERRUPT_FUNC rf_error_IRQ(void)
{
   INT_GLOBAL_ENABLE(INT_OFF);

   // If Rx overflow occurs, the Rx FiFo is reset.
   // The Rx DMA is reset and reception is started over.
   if(FSMSTATE == 17)
   {
      DEBUG_CHAR( DBG_ITRACE,DBG_CHAR_TXBUSY);
      STOP_RADIO();
      ISFLUSHRX;
      ISFLUSHRX;
      ISRXON;
   }
   else if(FSMSTATE == 56)
   {
      DEBUG_CHAR( DBG_ITRACE,DBG_CHAR_RXOFLOW);
      ISFLUSHTX;
   }

   INT_SETFLAG_RFERR(INT_CLR);

   INT_GLOBAL_ENABLE(INT_ON);
}


//This interrupt used for both TX and RX
#if defined(IAR8051)
#pragma vector=RF_VECTOR
#endif
#if defined(HI_TECH_C)
ROM_VECTOR(RF_VECTOR,spp_rf_IRQ);
#endif

INTERRUPT_FUNC spp_rf_IRQ(void)
{
  //used by spp_rf_IRQ


  BYTE flen;
  BYTE enabledAndActiveInterrupt;
  BYTE *ptr, *rx_frame;
  BYTE ack_bytes[5];
  BYTE crc;
  //define alternate names for readability in this function
#define  fcflsb ack_bytes[0]
#define  fcfmsb  ack_bytes[1]
#define  dstmode ack_bytes[2]
#define  srcmode ack_bytes[3]


  INT_GLOBAL_ENABLE(INT_OFF);
  enabledAndActiveInterrupt = RFIF;
  RFIF = 0x00;                        // Clear all radio interrupt flags
  INT_SETFLAG_RF(INT_CLR);    // Clear MCU interrupt flag
  enabledAndActiveInterrupt &= RFIM;
  // complete frame has arrived
  if(enabledAndActiveInterrupt & IRQ_FIFOP)
  {
    DEBUG_CHAR( DBG_ITRACE,DBG_CHAR_RXRCV );
    //if last packet has not been processed, we just
    //read it but ignore it.
    ptr = NULL; //temporary pointer
    flen = RFD & 0x7f;  //read the length
    if (flen == LRWPAN_ACKFRAME_LENGTH) {
      //this should be an ACK.
      //read the packet, do not allocate space for it
      DEBUG_CHAR( DBG_ITRACE,DBG_CHAR_ACKPKT );
      ack_bytes[0]= flen;
      ack_bytes[1] =  RFD;  //LSB Frame Control Field
      ack_bytes[2] = RFD;   //MSB Frame Control Field
      ack_bytes[3] = RFD;   //dsn
      ack_bytes[4] = RFD;   //RSSI
      crc = RFD;
      //check CRC
      if (crc & 0x80){
        // CRC ok, perform callback if this is an ACK
        macRxCallback(ack_bytes, ack_bytes[4]);
      }

    }else {
      //not an ack packet, lets do some more early rejection
      // that the CC2430 seems to not do that we want to do.
      //read the fcflsb, fcfmsb
      fcflsb = RFD;
      fcfmsb = RFD;
      if (!local_radio_flags.bits.listen_mode) {
        //only reject if not in listen mode
        //get the src, dst addressing modes
        srcmode = LRWPAN_GET_SRC_ADDR(fcfmsb);
        dstmode = LRWPAN_GET_DST_ADDR(fcfmsb);
        if ((srcmode == LRWPAN_ADDRMODE_NOADDR) && (dstmode == LRWPAN_ADDRMODE_NOADDR)) {
          //reject this packet, no addressing info
          goto do_rxflush;
        }
      }

      if (!macRxBuffFull()) {
        //MAC TX buffer has room
        //allocate new memory space
        //read the length
        rx_frame = MemAlloc(flen+1);
        ptr = rx_frame;
      } else {
        //MAC RX buffer is full
        DEBUG_CHAR( DBG_ITRACE,DBG_CHAR_MACFULL );
      }

      // at this point, if ptr is null, then either
      // the MAC RX buffer is full or there is  no
      // free memory for the new frame, or the packet is
      // going to be rejected because of addressing info.
      // In these cases, we need to
      // throw the RX packet away
      if (ptr == NULL) {
        //just flush the bytes
        goto do_rxflush;
      }else {
        //save packet, including the length
        *ptr = flen; ptr++;
        //save the fcflsb, fcfmsb bytes
        *ptr = fcflsb; ptr++; flen--;
        *ptr = fcfmsb; ptr++; flen--;
        //get the rest of the bytes
        while (flen) { *ptr = RFD;  flen--; ptr++; }
        //do RX callback
        //check the CRC
        if (*(ptr-1) & 0x80) {
          //CRC good
          //change the RSSI byte from 2's complement to unsigned number
          *(ptr-2) = *(ptr-2) + 0x80;
          phyRxCallback();
          macRxCallback(rx_frame, *(ptr-2));
        }else {
          // CRC bad. Free the packet
          MemFree(rx_frame);
        }
      }
    }

    //flush any remaining bytes
  do_rxflush:
      ISFLUSHRX;
      ISFLUSHRX;

    //don't know why, but the RF flags have to be cleared AFTER a read is done.
    RFIF = 0x00;
    INT_SETFLAG_RF(INT_CLR);    // Clear MCU interrupt flag
    //don't know why, but the interrupt mask has to be set again here for some reason.
    //the processor receives packets, but does not generate an interrupt
    RFIM |= IRQ_FIFOP;
  }//end receive interrupt (FIFOP)

  // Transmission of a packet is finished. Enabling reception of ACK if required.
  if(enabledAndActiveInterrupt & IRQ_TXDONE)
  {
    //Finished TX, do call back
    DEBUG_CHAR( DBG_ITRACE,DBG_CHAR_TXFIN );
    phyTxEndCallBack();
    macTxCallback();
    // Clearing the tx done interrupt enable
    RFIM &= ~IRQ_TXDONE;

  }
  usrIntCallback();
  INT_GLOBAL_ENABLE(INT_ON);

#undef  fcflsb
#undef  fcfmsb
#undef  dstmode
#undef  srcmode
}



//software delay, waits is in milliseconds
void halWait(BYTE wait){
   UINT32 largeWait;

   if(wait == 0)
   {return;}
   largeWait = ((UINT16) (wait << 7));
   largeWait += 114*wait;


   largeWait = (largeWait >> CLKSPD);
   while(largeWait--);

   return;
}

void halWaitMs(const UINT32 msecs){
  UINT32 towait;

  towait = msecs;
  while (towait > 100) {
    halWait(100);
    towait -= 100;
  }
  halWait(towait);
}


void halShutdown(void) {
  //disable some interrupts
  #ifdef LRWPAN_ENABLE_SLOW_TIMER
  INT_ENABLE_T2(INT_OFF);
  #endif
  //disable RADIO interrupts
  //Radio RF interrupt
  INT_ENABLE_RF(INT_OFF);
  //enable RX RFERR interrupt on processor
  INT_ENABLE_RFERR(INT_OFF);
  //shutoff the analog power to the radio
  RFPWR = RFPWR | (1<<3);    //RFPWR.RREG_RADIO_PD = 1;

}

void halWarmstart(void) {
  UINT32 myticks;
   //re-enable the timer interrupt
  #ifdef LRWPAN_ENABLE_SLOW_TIMER
  INT_ENABLE_T2(INT_ON);
  #endif
  //turn on the radio again
  RFPWR = RFPWR & ~(1<<3);    //RFPWR.RREG_RADIO_PD = 0;
  //wait for power to stabilize
  myticks = halGetMACTimer();
  while (halMACTimerNowDelta(myticks) < MSECS_TO_MACTICKS(10)) {
    //check the power up bit, max time is supposed to be 2 ms
    if (!(RFPWR & ~(1<<4))) break;
  }
 }



//this is provided as an example
//will go into power mode 1, and use the sleep
//timer to wake up.
//Caution: Use of power down mode 2 caused erratic
//results after power up, I am not sure if was due
//to parts of RAM not retaining their value or what.
void halSleep(UINT32 msecs) {
  UINT32 t;
  UINT32 delta;
  BOOL gie_status;

  SAVE_AND_DISABLE_GLOBAL_INTERRUPT(gie_status);
  //read the sleep timer
  delta = (32768 * msecs)/1000;
  t = 0xFF & ST0;
  t += (((UINT16)ST1)<<8);
  t += (((UINT32) ST2 & 0xFF)<<16);

  //compute the compare value
  t = (t + delta)&0x00FFFFFF;
  //write the new sleep timer value
  ST2 = (t >> 16)&0xFF;
  ST1 = (t >> 8)&0xFF;
  ST0 = t & 0xFF;
  //clear the sleep flag, enable the interrupt
  IRCON = IRCON & 0x7F; //clear the sleep flag IRCON.STIF = 0;
  IEN0 = IEN0 | (1<<5); //enable the interrupt  IEN0.STIE = 1;

  ENABLE_GLOBAL_INTERRUPT();  //interrupts must be enabled to wakeup!
  //configure the power mode and sleep
  //SET_POWER_MODE(POWER_MODE_2);
  SET_POWER_MODE(POWER_MODE_1);
  //wake up!
  //disable sleep interrupt
  DISABLE_GLOBAL_INTERRUPT();
  IEN0 = IEN0 & ~(1<<5);  // IEN0.STIE = 0;

  //wait for everything to power back up
  while(!XOSC_STABLE);          \
  asm("NOP");
  RESTORE_GLOBAL_INTERRUPT(gie_status);
};




INT16 halGetAdcValue(){
   INT16 value;
   value = ((INT16)ADCH) << 8;
   value |= (INT16)ADCL;
   return value;
}


//functions used by EVboard.

//-----------------------------------------------------------------------------
// See hal.h for a description of this function.
//-----------------------------------------------------------------------------
INT16 halAdcSampleSingle(BYTE reference, BYTE resolution, UINT8 input) {
    /*BYTE volatile temp;
    INT16 value;

    //reading out any old conversion value
    temp = ADCH;
    temp = ADCL;


    ADC_ENABLE_CHANNEL(input);
    ADC_STOP();

    ADC_SINGLE_CONVERSION(reference | resolution | input);

    while (!ADC_SAMPLE_READY());

    ADC_DISABLE_CHANNEL(input);

    value = (((INT16)ADCH) << 8);
    value |= ADCL;

    resolution >>= 3;
    return value >> (8 - resolution);*/
    BYTE volatile temp;
    INT16 value;

    //reading out any old conversion value
    temp = ADCH;
    temp = ADCL;


    ADC_ENABLE_CHANNEL(input);

    ADC_STOP();

    halWait(5);

    ADC_SINGLE_CONVERSION(reference | resolution | input);

    while (!ADC_SAMPLE_READY());

    ADC_DISABLE_CHANNEL(input);

    value = ADCL;
    value |= (((INT16)ADCH) << 8);

    if(value & 0x8000)
    {
		value = ~value + 1;
    }

    resolution >>= 3;
    value >>= (7 - resolution);
	asm("nop");
	asm("nop");
    return value;
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲免费在线视频一区 二区| 国产综合成人久久大片91| 中文字幕一区二区三区av| 日本一区二区三级电影在线观看 | 亚洲小说春色综合另类电影| ●精品国产综合乱码久久久久| 国产精品视频一二三区| 国产精品久久久久久户外露出 | 亚洲女同一区二区| 日韩理论片在线| 亚洲三级理论片| 一区二区在线观看免费视频播放| 亚洲免费在线看| 亚洲风情在线资源站| 日韩福利视频网| 美国欧美日韩国产在线播放| 激情综合色丁香一区二区| 精品一区二区免费| 国产成人精品免费| 99综合电影在线视频| 欧美在线高清视频| 欧美高清性hdvideosex| 91精品国产免费久久综合| 精品少妇一区二区三区免费观看 | 日本一区二区视频在线| 亚洲色图欧美激情| 亚洲午夜成aⅴ人片| 青青草97国产精品免费观看| 国产一区二区调教| 91丝袜高跟美女视频| 欧美久久久久久久久| 欧美videos大乳护士334| 国产校园另类小说区| 中文字幕一区二区三| 丝瓜av网站精品一区二区| 国产呦萝稀缺另类资源| 色综合久久久久综合体桃花网| 在线免费亚洲电影| 欧美精品一区视频| 自拍偷拍欧美精品| 日本中文字幕一区二区视频| 国产一区二区三区免费播放 | 中文字幕中文字幕在线一区| 一区二区不卡在线视频 午夜欧美不卡在| 一区二区视频在线看| 免费在线观看视频一区| 成人教育av在线| 欧美三级日本三级少妇99| 久久久久久久久久久久久夜| 一区二区高清免费观看影视大全| 狠狠色2019综合网| 91高清视频免费看| 黄色日韩网站视频| 色噜噜狠狠色综合欧洲selulu| 日韩欧美成人午夜| 亚洲日本一区二区三区| 蜜桃免费网站一区二区三区| av一二三不卡影片| 日韩欧美123| 伊人开心综合网| 福利一区二区在线观看| 欧美日韩高清一区二区不卡| 中文字幕国产一区二区| 日韩avvvv在线播放| 91丝袜高跟美女视频| 亚洲精品在线观| 香蕉影视欧美成人| 色噜噜狠狠成人中文综合 | 亚洲成人免费在线观看| 粗大黑人巨茎大战欧美成人| 3d成人动漫网站| 亚洲免费电影在线| 成人天堂资源www在线| 精品久久久久一区| 亚洲不卡一区二区三区| 色综合一个色综合| 欧美国产精品劲爆| 国产美女精品人人做人人爽| 欧美欧美午夜aⅴ在线观看| 亚洲免费观看高清完整版在线观看 | 亚洲最大成人综合| 成人a区在线观看| 精品第一国产综合精品aⅴ| 天堂午夜影视日韩欧美一区二区| 91视频91自| 国产女人18水真多18精品一级做| 精品一区二区在线视频| 91精品国产aⅴ一区二区| 亚洲愉拍自拍另类高清精品| 99久久国产综合色|国产精品| 国产欧美视频一区二区三区| 激情五月激情综合网| 欧美成人一区二区| 青椒成人免费视频| 欧美一卡2卡三卡4卡5免费| 亚洲一区在线观看免费 | 成年人网站91| 国产亚洲精品中文字幕| 久久精品国产亚洲高清剧情介绍| 欧美精品99久久久**| 午夜久久福利影院| 欧美高清视频在线高清观看mv色露露十八 | 欧美亚洲国产一区二区三区| 亚洲欧美激情视频在线观看一区二区三区 | 日本美女视频一区二区| 欧美日韩一区二区电影| 亚洲一区二区三区四区在线| 91福利视频网站| 性久久久久久久久| 91精品欧美福利在线观看| 日韩国产一二三区| 日韩欧美国产系列| 国产一区二区视频在线播放| 国产视频一区在线播放| 懂色av一区二区夜夜嗨| 国产精品高潮呻吟久久| 色综合久久66| 天天色图综合网| 欧美一级片免费看| 国模一区二区三区白浆| www精品美女久久久tv| 成人黄色片在线观看| 一区二区三区中文字幕精品精品 | 成人三级伦理片| 亚洲色图在线看| 欧美日韩精品二区第二页| 日韩不卡免费视频| 久久蜜桃一区二区| 91网上在线视频| 日韩成人一级片| 久久美女高清视频 | 亚洲欧洲另类国产综合| 91久久精品国产91性色tv | 色先锋久久av资源部| 婷婷综合在线观看| 精品国产亚洲一区二区三区在线观看| 国内外成人在线| 亚洲欧美日韩在线| 日韩无一区二区| 波多野结衣中文一区| 亚洲一区二区三区爽爽爽爽爽| 91精品婷婷国产综合久久| 国产成人精品一区二区三区四区 | 激情综合色播激情啊| 国产精品久久久久三级| 欧美日韩高清影院| 国产盗摄女厕一区二区三区| 一区二区三区四区国产精品| 日韩一区二区免费高清| 成人亚洲精品久久久久软件| 亚洲影视在线播放| 26uuu欧美| 欧美综合视频在线观看| 国产一区二区在线看| 亚洲在线成人精品| 中文字幕欧美三区| 5月丁香婷婷综合| 国产成人av在线影院| 亚洲成av人片在线观看| 国产日韩一级二级三级| 这里只有精品99re| 91一区一区三区| 国精产品一区一区三区mba视频 | 成人少妇影院yyyy| 琪琪一区二区三区| 亚洲欧洲中文日韩久久av乱码| 精品久久久久久久人人人人传媒| 91在线免费视频观看| 韩国一区二区三区| 午夜天堂影视香蕉久久| 国产精品国产自产拍高清av王其| 日韩欧美国产成人一区二区| 在线影院国内精品| 丰满少妇在线播放bd日韩电影| 日韩**一区毛片| 亚洲一卡二卡三卡四卡五卡| 国产精品色婷婷久久58| 精品久久久三级丝袜| 欧美日韩激情在线| 色综合色综合色综合色综合色综合| 精品一区二区三区免费播放| 丝袜诱惑亚洲看片| 一区二区三区在线观看欧美| 中文一区二区在线观看| 精品日韩在线一区| 制服丝袜亚洲播放| 欧美在线不卡视频| 色综合色综合色综合色综合色综合| 国产91在线看| 国产一区二区视频在线| 蜜臀av性久久久久av蜜臀妖精 | 久久99精品国产.久久久久久| 一区二区三区四区蜜桃| 亚洲色欲色欲www| 国产精品久久久久国产精品日日 | 国产91丝袜在线18| 国产高清不卡一区| 国产一区 二区| 精品在线播放午夜| 久久国产三级精品|