void SF_rem()
{
  unsigned char i,temp[6];
  char txte[4],txtex[4];
  int val=0;
  long adr=0x111111;

  for(i=0;i<6;i++) {
    temp[i] = SerialFlash_ReadByte(adr);
    ByteToStr(temp[i],txte);
    ByteToStr(arm[i],txtex);
    if(temp[i]!=arm[i]) val=1;
    adr+=0x000020;
  }

  Delay_ms(3000);
  for(i=0;i<6;i++) arm[i]=0;
  strcpy(Label24.Caption,"");
  DrawScreen(&System_Log_Screen);
  if(val==0) {
    a=0;
    Box30.Color=0x00008040;
    Box36.Color=0x00008040;
    Image65.Visible=1;
    Image66.Visible=0;
    strcpy(Label25.Caption,"DISARMED");
    strcpy(Label8.Caption,"DISARMED");
  }
}
Example #2
0
/****************************************************************************************
*函数名:CheckPBReady

*描  述:检查是否收到+PBREADY;

*****************************************************************************************/ 
BOOL CTCPIPDlg::CheckPBReady()
{
    int timeout;  // 超时次数变量;

	timeout = 0;
	do
    {   
    	timeout++;
    	
		memset(gRecieveBuffer,0x00,sizeof(gRecieveBuffer));
		RecieveFromUart(gRecieveBuffer); //获得返回值信息
		
		if( strstr((char *)gRecieveBuffer,"+PBREADY")>0 )
		{// 说明收到+PBREADY,退出;
			break;
		}
		Delay_ms(300);  // 延时300ms;
	}while(timeout<50);	  
	
	if( timeout>=50 )
	{	// 报错;
		return FALSE;// 没有收到;
	}

	return TRUE; 
}
Example #3
0
/***************************************************************************************
*函数名:CheckCSQ

*描  述:检查信号强度;

*****************************************************************************************/ 
BOOL CTCPIPDlg::CheckCSQ()
{
    int timeout;  // 超时次数变量;

	timeout = 0;
	do
    {   
	    timeout++;

		SendATCommand("at+csq\r",7); // 通过串口发送AT+CSQ回车
		
		Delay_ms(100);                 // 延时100ms;
		
		memset(gRecieveBuffer,0x00,sizeof(gRecieveBuffer));
		RecieveFromUart(gRecieveBuffer); //获得返回值信息
		
		if( strstr((char *)gRecieveBuffer,"+CSQ:99,99")==0 )
		{// 说明检查的不是99,99,有信号,退出;
			break;
		}
	}while(timeout<50);	  
	
	if( timeout>=50 )
	{	// 报错;
		return FALSE;// 没有信号;
	}

	return TRUE; 
}
Example #4
0
//************************************
//5.2WIFI控制
//******************************
Ctrlwifi()
{
  unchar i = 0;
  switch(MenuStatus)
  {
  case 2:
  //  POWRONWIFI;
    
    Str_8x16(1,0,"正在启动WIFI");
    //Init_Uart1;
    while(!DialWIFI())
    {
      if(i++>5)
      {
       Str_8x16(1,0,"启动WIFI失败"); 
   //    POWEROFFWIF;
       Delay_ms(2000);
      MenuStatus = 3;
      return;
      }
  
    }
   Str_8x16(1,0,"启动WIFI成功"); 
   WIFI_RX_CONNECT==2;//默认启动文件传输。
   MenuStatus = 1000;       
    break;
  case 1000:
    //接收wifi客户端软件的命令。
    
    break;
    
    
  }
}
void main() {            // ABRE FUNCAO PRINCIPAL: MAIN
ADCON1 = 0x06;           // CONFIGURA ENTRADAS AN COMO E/S DIGITAIS
CMCON = 7;               // DESLIGA COMPARADORES
// CONFIGURACOES E/S E ESTADOS INICIAIS [BINARIO]
TRISA = 0b00000000;            PORTA = 0b00000000;
TRISB = 0b00000000;            PORTB = 0b00000000;
TRISC = 0b00000000;            PORTC = 0b00000000;
TRISD = 0b00000000;            PORTD = 0b00000000;
TRISE = 0b00000000;            PORTE = 0b00000000;
// ESTADOS INICIAIS DOS ACESSORIOS
RELE_1 = 0;
RELE_2 = 0;
BARRA_LEDS_1 = 0;
BARRA_LEDS_2 = 0;
RESIST = 0;
VENT = 0;
BUZZER = 0;
// PISCAR OS ACESSORIOS INDEFINIDAMENTE
while (1){
RELE_1 =          ~ RELE_1;
RELE_2 =          ~ RELE_2;
BARRA_LEDS_1 =    ~ BARRA_LEDS_1;
BARRA_LEDS_2 =    ~ BARRA_LEDS_2;
RESIST =          ~ RESIST;
VENT =            ~ VENT;
BUZZER =          ~ BUZZER;
Delay_ms(750);
}             // FECHA WHILE
}             // FECHA MAIN
void applicationTask()
{
    int16_t valueX;
    int16_t valueY;
    int16_t valueZ;
    uint8_t txtX[ 15 ];
    uint8_t txtY[ 15 ];
    uint8_t txtZ[ 15 ];

    valueX = accel_readXaxis();
    valueY = accel_readYaxis();
    valueZ = accel_readZaxis();

    IntToStr( valueX, txtX );
    IntToStr( valueY, txtY );
    IntToStr( valueZ, txtZ );

    mikrobus_logWrite( " Axis X :", _LOG_TEXT );
    mikrobus_logWrite( txtX, _LOG_LINE );

    mikrobus_logWrite( " Axis Y :", _LOG_TEXT );
    mikrobus_logWrite( txtY, _LOG_LINE );

    mikrobus_logWrite( " Axis Z :", _LOG_TEXT );
    mikrobus_logWrite( txtZ, _LOG_LINE );

    mikrobus_logWrite("----------------", _LOG_LINE);

    Delay_ms( 5000 );
}
Example #7
0
void device_HW_reset(void)
{
	GPIO_ResetBits(WIZ_RESET_PORT, WIZ_RESET_PIN);
	Delay_us(8);
	GPIO_SetBits(WIZ_RESET_PORT, WIZ_RESET_PIN);
	Delay_ms(50);
}
Example #8
0
void gsm4_send_sms( uint8_t* rsp, uint8_t rsp_len )
{
    at_cmd( "AT+CMGS=\"0643280993\"" );
    at_cmd_addition( "Hello it's me, Hexiwear! :)" );
    Delay_ms( 1000 );
    sent_f = true;
}
Example #9
0
static void pw1_pid(void)
{
	rt_uint32_t key_value;
//	static double coefy2a = 0.8;
    
	while(1)
	{
		LCD_Clear();
		LCD_SetXY(0,0);     LCD_WriteString("=====sonic_test=====");
		LCD_SetXY(0, 1);    LCD_WriteString("1.front pid");
        LCD_SetXY(0, 2);    LCD_WriteString("2.f->pid");
        LCD_SetXY(0, 3);    LCD_WriteString("3.side pid");
        LCD_SetXY(0, 4);    LCD_WriteString("4.s->pid"); 
        LCD_SetXY(10, 1);   LCD_WriteString("5.fs pid");
		
		if(rt_mb_recv(&Mb_Key, &key_value, RT_WAITING_NO) == RT_EOK)
		{
			switch(key_value)
			{
				case key1:      pole_sonic(0x01);                break;
				case key2:      _input_pid(&sPos_Pid[eF_sonic]); break; 
                case key3:      pole_sonic(0x02);                break; 
                case key4:      _input_pid(&sPos_Pid[eS_sonic]); break;
                case key5:      pole_sonic(0x03);                break;
                case keyback:   return;
			}
		}
		Delay_ms(10);
	}
}
Example #10
0
uint32_t testNOR(uint32_t startAddress, uint32_t size, uint16_t bufferSize) {
	uint8_t index;
	uint16_t numWord;
	uint16_t check;
	uint8_t startBlock = startAddress / NORFLASH_SECTOR_SIZE;
	uint8_t endBlock = (startAddress + size) / NORFLASH_SECTOR_SIZE;
	NORFLASH_Status status;
	NORFLASH_Id chipId;

	NORFLASH_Init();
//	for (index = startBlock; index <= endBlock; index++) {
//		status = NORFLASH_EraseBlockNum(index);
//	}
//	SerialSendBytes("Start writing.\r\n", 16);
//	for (numWord = 0; numWord < size; numWord++) {
//		NORFLASH_WriteWord(startAddress + numWord, numWord);
//	}
//	SerialSendBytes("Memory written.\r\n", 17);

	char testLine[24] = "Addr:xxxxxxxx :  yyyy \r\n";
	for (numWord = 0; numWord < size; numWord++) {
		check = NORFLASH_ReadWord(startAddress + numWord);
		getHexFromLong(testLine + 5, startAddress + numWord, 8);
		getHexFromLong(testLine + 17, check, 4);
		Delay_ms(1);
		SerialSendBytes(testLine, 24);
	}

	return 0;
}
/**************************************************************************************************
* Init MCU
**************************************************************************************************/
void Init_MCU() {

  // Set PORTB8/7 to Open Drain output mode
  GPIO_Config(&GPIOB_BASE, _GPIO_PINMASK_8, _GPIO_CFG_SPEED_50MHZ | _GPIO_CFG_OTYPE_OD | _GPIO_CFG_MODE_OUTPUT);
  GPIO_Config(&GPIOB_BASE, _GPIO_PINMASK_7, _GPIO_CFG_SPEED_50MHZ | _GPIO_CFG_OTYPE_OD | _GPIO_CFG_MODE_OUTPUT);

  GPIO_Digital_Output(&GPIOD_ODR, _GPIO_PINMASK_12);                            // LED GREEN
  GPIO_Digital_Output(&GPIOD_ODR, _GPIO_PINMASK_13);                            // LED ORANGE
  GPIO_Digital_Output(&GPIOD_ODR, _GPIO_PINMASK_14);                            // LED RED
  GPIO_Digital_Output(&GPIOD_BASE, _GPIO_PINMASK_15);                           // LED BLUE
  GPIO_Digital_Output(&GPIOC_ODR, _GPIO_PINMASK_5);                             // RF_STB
  GPIO_Digital_Output(&GPIOE_ODR, _GPIO_PINMASK_4);                             // RF_RST
  GPIO_Digital_Output(&GPIOA_IDR, _GPIO_PINMASK_0);                             // Button

  GPIO_Alternate_Function_Enable(&_GPIO_MODULE_USART2_PA23);
  UART2_Init_Advanced(19200, _UART_8_BIT_DATA, _UART_NOPARITY, _UART_ONE_STOPBIT, &_GPIO_MODULE_USART2_PA23);
  //****************************************************************************
/*UART3_Init_Advanced(9600, _UART_8_BIT_DATA, _UART_NOPARITY, _UART_ONE_STOPBIT, &_GPIO_MODULE_USART3_PB10_11);
  Delay_ms(100);
  USART3_CR1bits.RXNEIE = 1;       // enable uart rx interrupt
  NVIC_IntEnable(IVT_INT_USART3);  // enable interrupt vector
  Delay_ms(100);                        // Wait for UART module to stabilize*/
  //****************************************************************************
  UART6_Init_Advanced(19200, _UART_8_BIT_DATA, _UART_NOPARITY, _UART_ONE_STOPBIT, &_GPIO_MODULE_USART6_PC67 );
  Delay_ms(100);
  
  // Enable Usart Receiver interrupt:
  USART6_CR1bits.RXNEIE = 1;         // enable uart rx interrupt
  NVIC_IntEnable(IVT_INT_USART6);    // enable interrupt vector
  Enableinterrupts();
}
/* Funcion usada en modo automatico para esquivar obstaculo */
void darVuelta(){
girarDerecha();
avanzarVehiculo();
Delay_ms(1000);
girarIzquierda();
avanzarVehiculo();
}
Example #13
0
void CC2500_Reset(void)
{
	CC2500_SendSpiData(CCxxx0_SIDLE);

	Delay_ms(20);

	CC2500_Select();

	Delay_ms(20);

	CC2500_NoSelect();

	Delay_ms(40);

	CC2500_SendSpiData(CCxxx0_SRES);
}
void SF_mem()
{
  unsigned char i,l,cnt[4];
  long adr=0x111111;

  for(i=0;i<6;i++) {
    SerialFlash_WriteByte(arm[i],adr);
    adr+=0x000020;
  }

  strcpy(Label24.Caption,"  ******");
  DrawScreen(&System_Log_Screen);
  for(l=0;l<10;l++) {
    ByteToStr(10-l,cnt);
    strcpy(Label25.Caption,"      ");
    strcat(Label25.Caption,cnt);
    DrawScreen(&System_Log_Screen);
    FT812_Sound_SetAndPlay(_FT812_SOUND_CLICK,_FT812_SOUND_PITCH_B3,vol);
    Delay_ms(1000);
  }
  Box30.Color=0x00FF0000;
  Box36.Color=0x00FF0000;
  Image65.Visible=0;
  Image66.Visible=1;
  strcpy(Label25.Caption,"   ARMED");
  strcpy(Label8.Caption,"   ARMED");
}
Example #15
0
//LCD退出休眠状态
void LCD_ExitSleep()	//_ILI9340C(void)
{
  LCD_WRITE_CMD(0x11);//Exit Sleep
  Delay_ms(120);
  LCD_WRITE_CMD(0x29);//Display on
  LCD_WRITE_CMD(0x2c); 
}
Example #16
0
/**
* @brief	获取按键是否按下
* @param	GPIOx 按键端口组
* @param	kpin  端口引脚
* @retval\n	0表示没有按下否则返回按下的时间(ms)
* @remarks 是KeyDown的扩展功能,能返回该按键长按的时间(ms),
*		最长时间为500ms。当一个按键有按下、长按若干S时用它实现
*/
int16_t KeyDown_Ex(GPIO_TypeDef* GPIOx,uint16_t kpin)
{
	static GPIO_TypeDef* oldGPIOx = 0;
	static uint16_t oldkpin = 0;
	uint16_t i;
	
// 	if(kpin == 0 && GPIOx == 0) {
// 		oldGPIOx = 0;
// 		oldkpin = 0;
// 		return 1;
// 	}
// 	if(oldGPIOx == GPIOx && oldkpin == kpin) {
// 		if(GPIO_ReadInputDataBit(GPIOx,kpin) == Key_Signal) {
// 			return 0;
// 		}
// 		else {
// 			oldGPIOx = 0;
// 			oldkpin = 0;
// 		}
// 	}
	//if((GPIOx->IDR & kpin) == 0) {

	i = 0;
	while(i < 500 && GPIO_ReadInputDataBit(GPIOx,kpin) == Key_Signal) {
		Delay_ms(10);
		i+= 10;
	}
	return i;
}
Example #17
0
int main(void)
{
    uint8_t i;
    uint8_t tri_table[] = {                     // triangular wave data table
        0x80, 0x84, 0x88, 0x8C, 0x90, 0x94, 0x98, 0x9C, 0xA0, 0xA4,
        0xA8, 0xAC, 0xB0, 0xB4, 0xB8, 0xBC, 0xC0, 0xC4, 0xC8, 0xCC,
        0xD0, 0xD4, 0xD8, 0xDC, 0xE0, 0xE4, 0xE0, 0xDC, 0xD8, 0xD4,
        0xD0, 0xCC, 0xC8, 0xC4, 0xC0, 0xBC, 0xB8, 0xB4, 0xB0, 0xAC,
        0xA8, 0xA4, 0xA0, 0x9C, 0x98, 0x94, 0x90, 0x8C, 0x88, 0x84,
        0x80, 0x7C, 0x78, 0x74, 0x70, 0x6C, 0x68, 0x64, 0x60, 0x5C,
        0x58, 0x54, 0x50, 0x4C, 0x48, 0x44, 0x40, 0x3C, 0x38, 0x34,
        0x30, 0x2C, 0x28, 0x24, 0x20, 0x1C, 0x20, 0x24, 0x28, 0x2C,
        0x30, 0x34, 0x38, 0x3C, 0x40, 0x44, 0x48, 0x4C, 0x50, 0x54,
        0x58, 0x5C, 0x60, 0x64, 0x68, 0x6C, 0x70, 0x74, 0x78, 0x7C
    };

    MCU_initialize();                           // initialize MCU
    Delay_ms(50);                               // wait for system stabilization
    LCD_initialize();                           // initialize text LCD module

    LCD_string(0x80, "  DAC0800 D/A   ");       // display title
    LCD_string(0xC0, "Triangular Wave ");

    while (1) {
        for (i = 0; i < 100; i++) {             // output D/A
            PORTB = tri_table[i];
            Delay_us(10);
        }
    }

    return 0;
}
Example #18
0
int8_t KeyDown(GPIO_TypeDef* GPIOx,uint16_t kpin)
{
	static GPIO_TypeDef* oldGPIOx = 0;
	static uint16_t oldkpin = 0;
	
	if(kpin == 0 && GPIOx == 0) {
		oldGPIOx = 0;
		oldkpin = 0;
		return 1;
	}
	if(oldGPIOx == GPIOx && oldkpin == kpin) {
		if(GPIO_ReadInputDataBit(GPIOx,kpin) == Key_Signal) {
			return 0;
		}
		else {
			oldGPIOx = 0;
			oldkpin = 0;
		}
	}
	//if((GPIOx->IDR & kpin) == 0) {
	if(GPIO_ReadInputDataBit(GPIOx,kpin) == Key_Signal) {
		Delay_ms(40);
		//if((GPIOx->IDR & kpin) == 0) {
		if(GPIO_ReadInputDataBit(GPIOx,kpin) == Key_Signal) {
			oldGPIOx = GPIOx ;
			oldkpin = kpin;
			//while(GPIO_ReadInputDataBit(GPIOx,kpin) == Key_Signal);
			
			return 1;
		}
	}
	return 0;
}
Example #19
0
void wizpf_led_trap(uint8 repeat)
{
	wizpf_led_set(WIZ_LED1, VAL_OFF);
	wizpf_led_set(WIZ_LED2, VAL_OFF);
	while(1) {
		Delay_ms(1500);
		for(uint32 i=0; i<repeat; i++) {
			wizpf_led_set(WIZ_LED1, VAL_TOG);
			wizpf_led_set(WIZ_LED2, VAL_TOG);
			Delay_ms(200);
			wizpf_led_set(WIZ_LED1, VAL_TOG);
			wizpf_led_set(WIZ_LED2, VAL_TOG);
			Delay_ms(200);
		}
	}
}
Example #20
0
void main(void)
{
    uint16_t i, j, k;

    Kit_initialize();                           // initialize OK-89S52 kit
    Delay_ms(50);                               // wait for system stabilization
    LCD_initialize();                           // initialize text LCD module
    Beep();

    LCD_string(0x80, " Multiplication ");       // display title
    LCD_string(0xC0, "   0 * 0 = 00   ");

    while (1) {
        for (i = 2; i <= 9; i++) {
            for (j = 1; j <= 9; j++) {
                LCD_command(0xC3);              // display multiplicand
                LCD_data(i + '0');
                LCD_command(0xC7);              // display multiplier
                LCD_data(j + '0');
                k = Mul_8bit(i, j);             // call assembly routine(1)
                LCD_command(0xCB);              // display multiplication
                LCD_2d(k);
                Delay_1sec();                   // call assembly routine(2)
            }
            Beep();
        }
    }
}
Example #21
0
void main(void)
{
    uint16_t i, j, time;
    float x, y;

    Kit_initialize();                           // initialize OK-89S52 kit
    Delay_ms(50);                               // wait for system stabilization
    LCD_initialize();                           // initialize text LCD module
    Beep();

    TMOD = 0x01;                                // Timer 0, mode 1
    TCON = 0x10;                                // TR0=1
    TH0 = 0;                                    // clear Timer 0
    TL0 = 0;

    LCD_string(0x80, " Execution Time ");       // display title
    LCD_string(0xC0, "   00000 [us]   ");

    for (i = 1, x = 0.0; i <= 20; i++) {
        j = i + 500;                            // integer addition
        j = i * 500;                            // integer multiplication
        x += 12.34;                             // real addition
        y = x * 56.78 * j;                      // real & integer
    }

    time = TH0 * 256 + TL0;                     // read Timer 0
    LCD_command(0xC3);                          // display execution time
    LCD_5d(time / 2);

    while (1) ;
}
void SP_BT_US1Press() {
                               if(Press>=10)
                               {
                               EEPROM_Write(0x00, StartVoltset);
                               Delay_ms(50);
                               EEPROM_Write(0x01, StepVoltset);
                               Delay_ms(50);
                               EEPROM_Write(0x02, StopVoltset);
                               Delay_ms(50);
                               EEPROM_Write(0x06,PulseRate);
                               Delay_ms(50);
                               EEPROM_Write(0x05, ZapNum);
                               EEPROM_Write(0x04, ZapNum>>8);
                               Delay_ms(50);
                               Press=0;
                               }
void main() {       //função principal
   for(;;){         //inicio do laço de repetição infinito
      if(P1_0_bit==0){    //inicio do teste condicional se o Bit 0 da porta 1 é igual a 0
         P0_4_bit=0;      //Pino 4 da porta 0 recebe 0 (acende o led)
         Delay_ms(500);   //Função de espera, o MCU fica 250 milessegundos parado
      }                   //fim do teste condicional
      if(!P1_1_bit){      //inicio do teste condicional se o Bit 1 da porta 1 é igual a 0
                          //a ! quer dizer NÃO
         P0=255;          //envia 255 decimal para a porta 0
         Delay_ms(250);   //Função de espera, o MCU fica 250 milessegundos parado
      }
      if(P1_2_bit==0){
         loopFuncao();
      }
    }
}
Example #24
0
void ISD2100_power_up()
{
  SSB_LO
  ISD2100_send_data(0x10);
  SSB_HI
  Delay_ms(1);
}
Example #25
0
/****************************************************************************************
*函数名:CheckCCID

*描  述:检查sim卡;

*****************************************************************************************/ 
BOOL CTCPIPDlg::CheckCCID()
{
    int timeout;  // 超时次数变量;

	timeout = 0;
	do
    {   
	    timeout++;

		SendATCommand("at+ccid\r",8); // 通过串口发送AT+CSQ回车
		
		Delay_ms(200);                 // 延时200ms;
		
		memset(gRecieveBuffer,0x00,sizeof(gRecieveBuffer));
		RecieveFromUart(gRecieveBuffer); //获得返回值信息
		
		if( strstr((char *)gRecieveBuffer,"ERROR")==0 )
		{// 说明返回值不是ERROR,表示读取sim卡的CCID成功,退出;
			break;
		}
	}while(timeout<50);	  
	
	if( timeout>=50 )
	{	// 报错;
		return FALSE;// 读取SIM卡失败;可能是没有插卡或者卡接触不良;
	}

	return TRUE; 
}
Example #26
0
void ISD2100_power_down()
{
  SSB_LO
  ISD2100_send_data(0x12);
  SSB_HI
  Delay_ms(1);
}
Example #27
0
/****************************************************************************************
*函数名:CheckAT

*描  述:检查信号强度;

*****************************************************************************************/ 
BOOL CTCPIPDlg::CheckAT()
{
    int timeout;  // 超时次数变量;

	timeout = 0;
	do
    {   
	    timeout++;

		SendATCommand("at\r",3); // 通过串口发送AT回车
		
		Delay_ms(100);                 // 延时100ms;
		
		memset(gRecieveBuffer,0x00,sizeof(gRecieveBuffer));
		RecieveFromUart(gRecieveBuffer); //获得返回值信息
		
		if( strstr((char *)gRecieveBuffer,"OK")>0 )
		{// 说明串口通,退出;
			break;
		}
	}while(timeout<50);	  
	
	if( timeout>=50 )
	{	// 报错;
		return FALSE;
	}

	return TRUE; 
}
Example #28
0
void Reset_W5200(void)
{
	GPIO_ResetBits(GPIOB, WIZ_RESET);
	Delay_us(2);  
	GPIO_SetBits(GPIOB, WIZ_RESET);
	Delay_ms(150);  
}
Example #29
0
/****************************************************************************************
*函数名:CheckCreg

*描  述:检查网络注册状态;

*****************************************************************************************/ 
BOOL CTCPIPDlg::CheckCreg()
{
    int timeout;  // 超时次数变量;
    	
	timeout = 0;
	do
    {   
	    timeout++;

		SendATCommand("at+creg?\r",9); // 通过串口发送AT+CREG?回车
		
		Delay_ms(200);                 // 延时200ms;
		
		memset(gRecieveBuffer,0x00,sizeof(gRecieveBuffer));
		RecieveFromUart(gRecieveBuffer); //获得返回值信息
		
		if( strstr((char *)gRecieveBuffer,"+CREG: 0,1")>0 ||  strstr((char *)gRecieveBuffer,"+CREG: 0,5")>0 )
		{// 如果返回值为+CREG: 0,1或+CREG: 0,5,则网络注册成功
			break;
		}
	}while(timeout<50);	  
	
	if( timeout>=50 )
	{// 报错;说明网络注册失败!
		return FALSE;// 网络注册失败;
	}
	
	return TRUE;
}
Example #30
0
//**********************************************************************************
//无线模块初始化
void CC_Init()
{
  CLI();
  CC_RESET();
  CC_RfConfig(&rfSettings7680);

  //CC_RfConfig(&rfSettings1200);
 // CC_WrReg(CCxxx0_SYNC1,0xa4 );//缺省值是D391
 // CC_WrReg(CCxxx0_SYNC0,0x25 );
  //CC_WrReg(CCxxx0_SYNC1,0x08 );//缺省值是D391
  //CC_WrReg(CCxxx0_SYNC0,0x00 );
  //CC_WrReg(CCxxx0_SYNC1,Sync0 );
  //CC_WrReg(CCxxx0_SYNC0,Sync1 );

  CC_PaTable(PAMAX);

   CC_WrReg(CCxxx0_MCSM1,0x00 );//0x0f取消CCA,收发总回到RX 不能,否则不能自动校正频率
  //CC_WrReg(CCxxx0_MCSM1,0x30 );//复位值0x30 有CCA,收发回IDLE
 // CC_WHITE(1);
 
  CC_FEC(1);
  Delay_ms(20);
  CC_RxOn();
  //GIFR=0xE0;//clr int
  
  //CC_Test();
  SEI();
}