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

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

?? smac_per_tx.c

?? mc13213無線串口程序
?? C
字號:
/****************************************************************************
application smac_per_tx.c.
This is a basic PER test.  The TX portion of the application
sends out 1000 packets.

Author: Freescale

Application Note: 
\****************************************************************************/

#include <hidef.h> /* for EnableInterrupts macro */
#include "pub_def.h"
#include "APP_SMAC_API.h"
#include "freescale_radio_hardware.h"
#include "smac_per_tx.h"
#include "eventDefs.h"
#include "timer.h"
#include "ledFunctions.h"
#include "kbi.h"
#if SMAC_FEATURE_OTAP == TRUE
#include "APP_OTAP_API.h"
#endif // SMAC_FEATURE_OTAP == TRUE
#if SMAC_FEATURE_SECURITY == TRUE
#include "APP_security_API.h"
#endif // SMAC_FEATURE_SECURITY == TRUE
#if (EMBEDDED_BOOTLOADER == TRUE)  
#include "bootloader user api.h"
#endif

#if SMAC_FEATURE_OTAP == TRUE
#include "APP_OTAP_API.h"
#endif // SMAC_FEATURE_OTAP == TRUE

#if SMAC_FEATURE_SECURITY == TRUE
#include "APP_security_API.h"
#endif // SMAC_FEATURE_SECURITY == TRUE

/* Global Variables */
byte gu8RTxMode; /* needed for s-mac, application can read this variable */
				/* rtx_mode is the software state variable of the radio */
				/* This variable reflects the current state of MC13192 */
int app_status = 0; 
byte led_status = 0;
UINT8 gu8Channel = CHANNEL_NUMBER;
UINT16 gu16Events = 0;
extern UINT16 gu16msTimer;
extern UINT16 gu16timerEvent[2];

void main(void) {

	tRxPacket rx_packet;  //SMAC structure for RX packets
	tTxPacket tx_packet;	//SMAC structure for TX packets
	byte rx_data_buffer[20];	//Data buffer to hold RX data, if you want larger packets change 20 to what you need.
	byte tx_data_buffer[20];	//Data buffer to hold TX data, if you want larger packets change 20 to what you need.
	UINT16 loop;
	UINT8 i;
	UINT16 packet_count;
	
	//Initialize the packet.
  tx_packet.u8DataLength = 0;				//Set TX default to 0
  tx_packet.pu8Data = &tx_data_buffer[0];	//Load the address of our txbuffer into tx structure.
  rx_packet.u8DataLength = 0;				//Set RX default to 0
  rx_packet.pu8Data = &rx_data_buffer[0];	//Load the address of our rxbuffer into rx structure
  rx_packet.u8MaxDataLength = 100;		//Define the max buffer we are interested in.
  rx_packet.u8Status = 0;					//initialize the status packet to 0.
  

  
   MCUInit();		//Initialize the mcu, setup GPIOs, SPI, clock scheme, etc.
   RadioInit();
   KBIInit();
   
   KBI_ENABLEINTERRUPTS;  
   app_init();
  		
	(void)MLMESetMC13192ClockRate(0);  /* Set initial Clk speed from MC13192s CLKO*/
	UseExternalClock();	/* switch clock sources to EXTERNAL clock */
	
	/* include your start up code here */	
  EnableInterrupts; /* Turn on system interrupts */
	(void)MLMESetChannelRequest(CHANNEL_NUMBER);	//Set channel zero, can be changed to users preference
	
#if (EMBEDDED_BOOTLOADER == TRUE)
  boot_init();  //Initialize the bootloader...in bootloader user api.c
#endif 
	
  /******************************************************************
  To adjust output power call the MLME_MC13192_PA_output_adjust() with:
  
  MAX_POWER     (+3 to +5dBm)
  NOMINAL_POWER (0 dBm)
  MIN_POWER     ~(-16dBm)
  
  or somewhere custom ? (0-15, 11 (NOMINAL_POWER) being Default power)

	******************************************************************/
  //MLMEMC13192PAOutputAdjust(MAX_POWER);	//Set MAX power setting
  //MLMEMC13192PAOutputAdjust(MIN_POWER);	//Set MIN power setting
  (void)MLMEMC13192PAOutputAdjust(OUTPUT_POWER);	//Set Nominal power setting	
  
  
  
  #if (EMBEDDED_BOOTLOADER == TRUE)
      boot_call();  //Checks for user request for bootloader.
                    //Runs bootloader if requested.  Code will not return.
  #endif 
  
	app_status = INITIAL_STATE;		//Set the initial app_status of the application state variable to INITIAL_STATE
		
	//Loop forever
	for (;;) {

		switch (app_status) {
			case INITIAL_STATE:		//Walk the LEDs
				//For TX
				LED1 = LED_OFF;		//Turn off all LEDs
				LED2 = LED_OFF;
				LED3 = LED_OFF;
				LED4 = LED_OFF;
				
				LED1 = LED_ON;									//Lights LED1
				for (loop = 0; loop < LED_DELAY; loop++);		
				LED1 = LED_OFF; LED2 = LED_ON;					//Lights LED2, Turns off LED1
				for (loop = 0; loop < LED_DELAY; loop++);
				LED2 = LED_OFF; LED3 = LED_ON;					//Lights LED3, Turns off LED2
				for (loop = 0; loop < LED_DELAY; loop++);
				LED3 = LED_OFF; LED4 = LED_ON;					//Lights LED4, Turns off LED3
				for (loop = 0; loop < LED_DELAY; loop++);
				LED4 = LED_OFF;									//Turns off LED4
				LED1 = LED_ON; 
				app_status = IDLE_STATE;	//Switch app status to TX_STATE
				for (i=0; i<18; i++) {
				   tx_data_buffer[i] = 0;
				}
				tx_packet.u8DataLength = 18;	//Set the data length of the packet.  in this case, 6.
				packet_count=0;
				break;
				
								
			case TX_STATE:		 
				
				//Load the tx buffer with the ZigBee packet.
				
				if (MCPSDataRequest(&tx_packet) == SUCCESS)	//TX Packet, Blocking will stay here until the packet is in the air
				LED1 ^=1;
				//MLME_RX_enable_request(&rx_packet,DELAY_COUNT);	//Now turn on the RX with a timeout of DELAY_COUNT
				if (packet_count < TEST_NUM)
				   app_status = DELAY_STATE ; 	//Set app_status as waiting for ack. 
			   else
				   app_status = FINAL_STATE;				
				
            packet_count++;
				break;
				
			case RX_STATE:
				MLMERXEnableRequest(&rx_packet,0); //Zero means wait forever with RX ON.
				break;
				
			case RESET_STATE:
				//MC13192 Reset, reinitialize and return to default state (TX_STATE).
				RadioInit();
				app_status = INITIAL_STATE;
				break;
				
			case RECEIVER_ALWAYS_ON:
				break;
				
			case WAITING_FOR_ACK:
				/* At this point only two things happen, 1-we receive the ack packet or 2-timeout.
				Either way the TX will leave this state and continue. Low power mode could be placed here
				because both 1 and 2 are interrupt driven, in this case we keep it simple */
				
				break;
				
			case SET_LEDS:
				
				/* This state takes the power value from the ack and turns on the appropriate LEDs */
				
				LED1 ^= 1;	/* Toggle LED1 whenever an ack is received. (blinks LED1) */
				switch (led_status) {
					case 0:
						LED2 = LED_OFF; LED3 = LED_OFF; LED4 = LED_OFF; //At spec (-88)
						break;
					case 1:
						LED2 = LED_ON; LED3 = LED_OFF; LED4 = LED_OFF; //spec < reading < -80
						break;
					case 2:
						LED2 = LED_ON; LED3 = LED_ON; LED4 = LED_OFF; //spec < reading < -60
						break;
					case 3:
						LED2 = LED_ON; LED3 = LED_ON; LED4 = LED_ON; //reading < -40
						break;
					default:
					break;
				}
				app_status = DELAY_STATE;	//Take the app state and wait for some time to retransmit.
				break;
				
			case DELAY_STATE:
				//Sets the TX rate, small DELAY_COUNT means TX rate is fast while larger values slow it down.
            delay(3);
				app_status = TX_STATE;	//After the delay, retransmit
 				break;
 				
 		   case IDLE_STATE:
		      break;
 			
		   case FINAL_STATE:
		      tx_packet.pu8Data[0] = 'D';
		      tx_packet.pu8Data[1] = 'O';
		      tx_packet.pu8Data[2] = 'N';
		      tx_packet.pu8Data[3] = 'E';
		      tx_packet.pu8Data[4] = 'D';
		      tx_packet.pu8Data[5] = 'O';
		      tx_packet.pu8Data[6] = 'N';
		      tx_packet.pu8Data[7] = 'E';
		      tx_packet.pu8Data[8] = '\0';
		      tx_packet.u8DataLength = 9;
		      
		      for (i=0; i<20; i++) {
		         for (loop = 0; loop < DELAY_COUNT; loop++);
		         (void)MCPSDataRequest(&tx_packet);
		         app_status = FINAL_STATE;
		      }
		      LED1 = LED_OFF;
		      app_status = IDLE_STATE;
		      
			default:
				break;
			
		}
		
		/* Check for events */
		  
		  /* Check for debounce timer (TIMER1) */
        if ((gu16Events & TIMER_EVENT1) != 0) {
            gu16Events &= ~TIMER_EVENT1; /* Clear the event */
            gu16timerEvent[1] = 0; /* Turn off the timer */
        }
       
       
        /* See if a Channel Request has been made */	      
        if ((gu16Events & KBI3_EVENT) != 0) {
            #if BUZZER_ENABLED
               BUZZER = BUZZER_ON;
            #endif
               delay(10);
            #if BUZZER_ENABLED
               BUZZER = BUZZER_OFF;
            #endif
               gu16Events &= ~KBI3_EVENT; /* Clear the event */
        	      if (gu8Channel == 15) {
        	         gu8Channel = 0;  
        	      } else {
        	         gu8Channel += 1;
        	      }
        	      
        	      
        	      /* Actually Switch Channels now that the ack is received */
        	      (void)MLMESetChannelRequest(gu8Channel);
        	      
        	      /* Now notify user that channel has changed */
        	      setLedsMode(LED_HEX_MODE, (UINT8)(gu8Channel), 100, LED_NO_FLAGS);
               setLed(0, 0);  /* Turn off all the LEDs*/       	      
        	      KBI1SC |= 0x02; /* Enable Interrupts */
        }
        
                /* See if START TX has been hit */	      
        if ((gu16Events & KBI2_EVENT) != 0) {
            #if BUZZER_ENABLED
               BUZZER = BUZZER_ON;
            #endif
               delay(10);
            #if BUZZER_ENABLED
               BUZZER = BUZZER_OFF;
            #endif
               gu16Events &= ~KBI2_EVENT; /* Clear the event */
               packet_count=0;
               setLedsMode(LED_DIGIT_MODE, (UINT16) 8421, 10, LED_NO_FLAGS);
               for (i=0; i<18; i++) {
				      tx_data_buffer[i] = i;
				   }
   				tx_packet.u8DataLength = 18;	//Set the data length of the packet.  in this case, 6.
   				packet_count=0;

               app_status = TX_STATE;
        }
	}
}


void MCPSDataIndication(tRxPacket *rx_packet) {

	if (rx_packet->u8Status == TIMEOUT) {

		/* Put timeout condition code here */
		
		app_status = TX_STATE;	//If timeout occurs, simply set back to TX_STATE to transmit again.

	}

	if (rx_packet->u8Status == SUCCESS) {	//Good packet received.

		//Check to see if it is an "ACKx" packet....
		if (rx_packet->pu8Data[0] == 'A' &&
			rx_packet->pu8Data[1] == 'C' &&
			rx_packet->pu8Data[2] == 'K') {
			
			//Good ACK packet read the power level byte
			led_status = rx_packet->pu8Data[3];	//Store power level into global led_status
			app_status = SET_LEDS;				//Set app_status to process the LEDs
			
		}
		else {
			//A good packet was received but it is not the ack packet we want.
			//Whenever a good packet is received the radio will default back to idle, so
			//retransmit by setting state variable to TX_STATE.  This resets the machine.
			app_status = TX_STATE;
		}
	}		
}

void MLMEMC13192ResetIndication() {
	//Notifies you that the MC13192 has been reset.
	//Application must handle this here.

	app_status = RESET_STATE;	//MC13192 reset, re-initialize.

}

void app_init() {
  
  
  /* Init LED's 1-OFF 0-ON */
	LED1 = 1; /* Default is off */
	LED2 = 1;
	LED3 = 1;
	LED4 = 1;
	
	LED1DIR = 1; /*Set the DDIR register as Outputs for the LED pins*/
	LED2DIR = 1;
	LED3DIR = 1;
	LED4DIR = 1;
	
	/* Set Push button pull ups */
	PB0PU = 1;
	PB1PU = 1;
	PB2PU = 1;
	PB3PU = 1;

  /* OTAP entry */
  #if SMAC_FEATURE_OTAP == TRUE
  if (PB0 == 0){
    KBI1SC = 0x00; /* Turn On Interrupts */
    OTAPActivate();
  }
  #endif // SMAC_FEATURE_OTAP == TRUE
  
   /* Setup Timer 1 */
     /* Setup Timer 1 */
  TPM1MOD = 625; /* Set the timer for a 26ms timer rate (1/8E6) * 128 * 625 = 10msec */
                 /* Timer rate = (1/BUSCLOCK) * TIMER_PRESCALER * TIMER MOD */
  TPM1SC = 0x4F; /* Timer divide by 128. (16uS timebase for 8MHz bus clock). interrupt on*/
	
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
在线播放中文字幕一区| 一本久久综合亚洲鲁鲁五月天 | 亚洲欧美中日韩| 视频一区国产视频| 成人av资源下载| 日韩精品一区在线观看| 亚洲精品老司机| 国产.精品.日韩.另类.中文.在线.播放| 欧美三日本三级三级在线播放| 国产精品久久久久久久久免费丝袜| 麻豆精品久久久| 欧美日韩激情在线| 亚洲欧美偷拍三级| 成人综合日日夜夜| 精品国产不卡一区二区三区| 亚洲国产一区视频| 91一区一区三区| 国产欧美精品一区二区三区四区| 免费成人结看片| 欧美老肥妇做.爰bbww视频| 亚洲柠檬福利资源导航| 丁香天五香天堂综合| 久久亚洲精精品中文字幕早川悠里| 午夜精品成人在线| 欧美日韩一区 二区 三区 久久精品| 国产精品久久久久久久蜜臀| 国产福利一区二区三区视频在线| 精品国产91乱码一区二区三区| 三级在线观看一区二区| 精品视频一区二区三区免费| 亚洲麻豆国产自偷在线| 91视频观看免费| 综合久久久久综合| 91美女片黄在线观看91美女| 国产精品视频线看| a亚洲天堂av| 国产精品第一页第二页第三页| 国产精一品亚洲二区在线视频| 亚洲精品一线二线三线| 国产美女精品在线| 久久精品亚洲乱码伦伦中文| 国产精品夜夜嗨| 国产欧美精品在线观看| 成人高清视频在线| 亚洲欧美在线另类| 色88888久久久久久影院野外| 亚洲欧美一区二区三区极速播放| 91在线你懂得| 亚洲精选在线视频| 欧美色窝79yyyycom| 亚洲成人免费观看| 51久久夜色精品国产麻豆| 秋霞午夜av一区二区三区| 日韩午夜精品电影| 激情综合网天天干| 国产网站一区二区三区| 99精品久久只有精品| 亚洲免费成人av| 欧美日韩一区二区不卡| 免费观看成人鲁鲁鲁鲁鲁视频| 欧美大片在线观看| 国产99久久久国产精品潘金网站| 中文字幕亚洲不卡| 色妞www精品视频| 亚洲午夜电影在线| 欧美一区二区美女| 国产精品综合一区二区三区| 中文字幕av不卡| 91福利在线导航| 石原莉奈在线亚洲二区| 久久色在线视频| 99久久久国产精品| 亚洲成人高清在线| 精品国产免费一区二区三区四区| 国产999精品久久| 亚洲一区二区成人在线观看| 337p亚洲精品色噜噜| 国产一区亚洲一区| 亚洲视频网在线直播| 在线不卡免费av| 丁香一区二区三区| 亚洲国产精品一区二区久久恐怖片| 欧美久久久久免费| 国产99久久久国产精品潘金| 亚洲最大成人网4388xx| 欧美电影免费观看高清完整版在 | 日韩国产一区二| 26uuu精品一区二区| aaa国产一区| 午夜激情一区二区| 国产亚洲综合色| 在线观看区一区二| 亚洲特级片在线| 国产真实精品久久二三区| 久久久影院官网| 97久久精品人人爽人人爽蜜臀| 亚洲少妇中出一区| 欧美区在线观看| 国产在线精品免费av| 国产欧美日韩不卡| 日本高清不卡一区| 久久精品国产一区二区三区免费看 | 日韩激情av在线| 久久亚洲捆绑美女| 97久久超碰国产精品| 亚洲一区在线免费观看| 日韩欧美不卡在线观看视频| 国产很黄免费观看久久| 一区二区在线观看不卡| 欧美一级久久久久久久大片| 国产不卡在线一区| 午夜电影一区二区| 欧美国产亚洲另类动漫| 欧美老女人在线| eeuss影院一区二区三区| 奇米精品一区二区三区四区| 日韩理论片一区二区| 欧美一区二区三区成人| 91欧美一区二区| 国产揄拍国内精品对白| 亚洲与欧洲av电影| 中文字幕精品一区二区三区精品| 欧美日韩一区三区| 成人高清免费在线播放| 国产最新精品免费| 亚洲国产欧美在线| 136国产福利精品导航| 日韩欧美国产一区二区三区| 色94色欧美sute亚洲线路一ni| 国产一区二区三区四| 天堂久久久久va久久久久| 日韩伦理av电影| 国产女同互慰高潮91漫画| 日韩精品专区在线影院观看| 在线视频国内自拍亚洲视频| 99这里只有久久精品视频| 久热成人在线视频| 日韩精品一区第一页| 亚洲自拍偷拍综合| 日韩一区欧美小说| 中文字幕第一区第二区| 久久精品在线观看| 久久色视频免费观看| 日韩视频在线你懂得| 欧美三级日本三级少妇99| 一本高清dvd不卡在线观看| 国产99久久精品| 成人精品电影在线观看| 成人高清视频在线| www.爱久久.com| 成人av电影在线网| 成人av免费在线| 99国产精品久久久久久久久久 | 精品视频一区二区三区免费| 色综合久久综合网欧美综合网| www.在线成人| av中文字幕一区| 91网站视频在线观看| 91香蕉视频mp4| 欧美亚洲综合网| 制服丝袜中文字幕一区| 欧美一二三区在线观看| 欧美不卡激情三级在线观看| 日韩精品在线看片z| 久久精品亚洲乱码伦伦中文| 中文天堂在线一区| 一区二区三区在线观看国产| 一区二区欧美视频| 欧美a一区二区| 国产91富婆露脸刺激对白| 99re这里只有精品视频首页| 91色婷婷久久久久合中文| 欧美性生活一区| 欧美xxxxxxxx| 国产精品美女久久久久久2018| 一区二区三区在线免费观看| 日本女人一区二区三区| 国产在线播放一区| 91小视频免费看| 日韩一区二区三区电影| 久久婷婷一区二区三区| 亚洲欧美另类图片小说| 日韩精品一二区| gogogo免费视频观看亚洲一| 欧美视频中文字幕| 精品国产成人在线影院 | 精品嫩草影院久久| 国产精品免费网站在线观看| 亚洲综合一二三区| 国产一区不卡视频| 欧美日韩中字一区| 久久久久久久综合日本| 亚洲精品高清在线| 国产伦精一区二区三区| 色欧美88888久久久久久影院| 精品国产乱码久久久久久免费| 亚洲伦在线观看| 国产精品一二三区| 7777精品伊人久久久大香线蕉| 国产精品天天看|