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

📄 main.c

📁 TI的CC1110、CC2510、CC2430射频SOC的驱动程序
💻 C
字号:
/*******************************************************************************
* main.c
*
* Copyright 1994-2006 XiaoCui' Technology Co.,Ltd.
*
* DESCRIPTION: -
*
* modification history
* --------------------
* - 01a, 15.07.2008, cuiqingwei written
*
*******************************************************************************/

#include "hal.h"
#include "uart.h"
#include  "main.h"
/*-------------------------------------*
 *	              宏定义               *
 *----------------------------------------------------------------------------*/

#define LED_INIT() 		P1DIR = 0x02 	// P10 定义为输出
#define LED 			P1_1			// 定义LED1为P10口控制

/*-------------------------------------*
 *	            变量定义               *
 *----------------------------------------------------------------------------*/

//byte rfSendBuf[25];

/*-------------------------------------*
 *	            函数定义               *
 *----------------------------------------------------------------------------*/


void main(void)
{	

   //     byte RfRecvLength;
          byte *Rssi,*Lqi;
   //     byte RfRecvtimeOut;

        IEN0=0;
        IEN1=0;

        Port_Init();
        UART0_Init();
        Timer0_Init();

	SET_MAIN_CLOCK_SOURCE(CRYSTAL);

	DISABLE_ALL_INTERRUPTS();

	INT_GLOBAL_ENABLE(true);
	
	LED_INIT();
	halRfConfig(400500);
	halWait(250);
	
   //   RfRecvtimeOut=200;
        index=0;

        UartReceive_Buf[0]=0x1B;
        UartReceive_Buf[1]=0x40;
        UartReceiveLen=2;

         WDT_ON();

	while (1)
	{
                CLR_WDT();

                if(UartReceiveLen)
                {
                    CLR_WDT();
                    halWait(150);
                    EA=0;
                    if(RFSendFlg)
                      halRfSendPacket(UartReceive_Buf,UartReceiveLen);
                    else
                      UART0_SendData(UartReceive_Buf,UartReceiveLen);
                    RFSendFlg = 0;
                    UartReceiveLen=0;
                    LED = !LED;
                    EA=1;
                }

                halRfReceivePacket(Rssi,Lqi);

                if((index>0)&&(index<69)&&(pPayload[0]==0x68)&&(pPayload[index-2]==0x16))
                {
                    CLR_WDT();
                    index--;
                    UART0_SendData(pPayload,index);
                    LED = !LED;

                }




		//halWait(250);
               //halWait(250);

		
	}

}


/*
************************************************************
*Description:初始化IO端口
*Arguments  :none
*Returns    :none
*Notes      :
************************************************************
*/
void Port_Init(void)
{
      P0SEL=0x0C;  //P0_2,P0_3  UART0
      P0DIR=0x08;
      P1SEL=0X00;
      P1DIR=0x02;
      P2SEL=0X00;
      PERCFG=0X02;   // UART0 0 location,UART1 1 location
}
/*
************************************************************
*Description:开启WDT
*Arguments  :none
*Returns    :none
*Notes      :
************************************************************
*/
void WDT_ON(void)
{

    WDCTL = 0x00;
    WDCTL = 0x08;


}
void CLR_WDT(void)
{

    WDCTL = 0xA8;
    WDCTL = 0x58;

}

/*------------------------------------------------------------------------------
										  0ooo
								ooo0     (   )
								(   )     ) /
								 \ (     (_/
	    				          \_)        By:cuiqingwei [gary]
------------------------------------------------------------------------------*/

⌨️ 快捷键说明

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