예제 #1
0
/*----------------------------------------------------------------------------------------
函数名: TMRCBForSysTick
参数:
		None
返回值:
		None
描述:
		定时器回调函数,用于空闲计时、录音等待计时、识别计时、电量检测计时等等计时操作
----------------------------------------------------------------------------------------*/
void TMRCBForSysTick(void)
{
	g_cntSysTicks++;
	if(g_bHavePlayAction && !g_bContinueTick){
		g_cntSysTicks = 0;
		g_bHavePlayAction = 0;
	}
	if(g_bHaveKeyAction || g_bHaveEsrAction || g_bHaveRecAction || g_bHaveCamAction){
		g_cntSysTicks = 0;
		g_bHaveKeyAction = 0;
		g_bHaveEsrAction = 0;
		g_bHaveRecAction = 0;
		g_bHaveCamAction = 0;
		g_bContinueTick = 0;
	}

	//------------------------------
	if(g_bRecordStart)
		g_cntWaitForRecTicks++;
	else
		g_cntWaitForRecTicks = 0;

	//-----------------------------10s钟检测一次电量
	g_cntPwrCheckTicks++;
	if(g_cntPwrCheckTicks >= 10){
		g_bCheckPower = 1;
		g_cntPwrCheckTicks = 0;
	}
	//-----------------------------
	if(!(DrvGPIO_GetBit(GPA,15))){
		if(g_bLowPower){
			RED_LED_ON;
			if(g_cntLowPwrTicks % LOWPWR_REMINDER_TIME == 0)	g_bLowPwrAudio = 1;
			g_cntLowPwrTicks++;
		}else if(g_bServerLowPwr){
			g_cntLowPwrTicks = LOW_POWER_TIME;
		}else
			g_cntLowPwrTicks = 0;
	}

//	LOG("--%d\t%d\r\n",abc,abc1);
//	abc = 0;
//	abc1 = 0;
}
예제 #2
0
uint8_t BoxOpenCheck()
{
	KS = (uint8_t) DrvGPIO_GetBit(E_GPE, 5); 
	if(KS != KS_button)
	{
		KS_button = KS ; 
	    if( KS_button == 0 ) //闭合
		   	{ 
				 switch(LedTemp)
				 {
					case 	TOP_WHITE_ON  : Top_W_On();    		break ;  
					case 	TOP_IR850_ON  : Top_IR850_On( );	break ; 
					case 	TOP_IR940_ON  : Top_IR940_On( );	break ; 

					case 	LEFT_W_ON     : Left_W_On( );   	break ; 
					case 	RIGHT_W_ON 	  : Right_W_On( );	break ; 
					case 	LEFT_IR850_ON : Left_IR850_On();	break ; 
					case 	RIGHT_IR850_ON:	Right_IR850_On();	break ; 
                                                                      
					case 	BOT_W_ON   	  : Bot_W_On();			break ; 
					case 	BOT_IR_ON  	  : Bot_IR_On(); 		break ; 
					case 	RIGHT_UV_ON   : Right_UV_On(); 		break ; 
					case 	DB_UV_ON      : Double_UV_On(); 	break ; 
					case 	RIGHT_IR770_ON: Right_IR770_On();	break ;  
					case 	RIGHT_LASER_ON:	Right_Laser_On(); 	break ; 
					case 	C608_PWR_ON   :	C608_On(); 			break ;
					case 	DB_WT_UV_ON	  :	Double_WT_UV_On(); 	break ; 
					case    DB_UV_EXPOSURE1_ON : Double_UV_Exposure1_On();break ;
					case 	DB_UV_EXPOSURE2_ON : Double_UV_Exposure2_On();break ;
					
				 	default :	break ; 
				 }
		   	}
		   else
		   	{
				 LedTemp = System.Led.Statu ; 
			 	Light_Init() ; 
		    }				
	}
	if( KS ) return 0x01 ;
	else	return 0x00 ; 
}
예제 #3
0
unsigned char NRF24L01_TxPacket(unsigned char *txbuf)
{
	unsigned char sta;
	DrvGPIO_ClrBit(E_GPB, 1);	
  nrf_writebuf(W_TX_PAYLOAD,txbuf,TX_DATA_WITDH);//写数据到TX BUF  32个字节
 	DrvGPIO_SetBit(E_GPB,1);	// This device is now ready to receive one packet of 16 bytes payload from a TX device
	while(DrvGPIO_GetBit(E_GPB, 2)!=0);//等待发送完成
	sta=nrf_read(STATUS);  //读取状态寄存器的值	   
	nrf_write(W_REGISTER+STATUS,sta); //清除TX_DS或MAX_RT中断标志
	if(sta&0x10)//达到最大重发次数
	{
		nrf_wf(FLUSH_TX);//清除TX FIFO寄存器 
			nrf_write(W_REGISTER+STATUS,sta); //清除TX_DS或MAX_RT中断标志	
		sta=nrf_read(STATUS);  //读取状态寄存器的值	   
	
		return 0x10; 
	}
	if(sta&0x20)//发送完成
	{
		return 0x20;
	}
	return 0xff;//其他原因发送失败
}
예제 #4
0
//*****************************************************************************
//
//! \brief GPIO test.
//!
//! \param None  
//!
//! \return None  
//
//*****************************************************************************
void GpioTest(void)
{
    int32_t i32Err;

    UNLOCKREG();
    //
    // Enable high external clock and use it as system clock (HCLK)
    //
	  DrvSYS_Open(XTL_CLK);
	  
    //
    // Waiting for 12M Xtal stable
    //
    while (DrvSYS_GetChipClockSourceStatus(XTL_CLK) != 1);

    //
    // Configure Bit0 in Port1 to Output pin and Bit4 in Port3 to Input 
    // pin then close it                  
    //

    DrvGPIO_Open(E_PORT1, E_PIN0, E_IO_OUTPUT);
    DrvGPIO_Open(E_PORT3, E_PIN4, E_IO_INPUT);

    i32Err = 0;

    DrvGPIO_ClrBit(E_PORT1, E_PIN0);
    if (DrvGPIO_GetBit(E_PORT3, E_PIN4) != 0)
    {
        i32Err = 1;
    }

    DrvGPIO_SetBit(E_PORT1, E_PIN0);
    if (DrvGPIO_GetBit(E_PORT3, E_PIN4) != 1)
    {
        i32Err = 1;
    }

    DrvGPIO_Close(E_PORT1, E_PIN0);
    DrvGPIO_Close(E_PORT3, E_PIN4);

    //
    // GPIO Interrupt Test:P15, P22, P32(INT0) and P52(INT1) are used to test 
    // interrupt and control LEDs(P30)
    //

    //
    //Configure P30 for LED control
    //
    DrvGPIO_Open(E_PORT3, E_PIN0, E_IO_OUTPUT);

    //
    //Configure P15 as general GPIO interrupt
    //
    DrvGPIO_Open(E_PORT1, E_PIN5, E_IO_INPUT);
    
    //
    //The Quasi-bidirection mode could be used as input with pull up enable 
    //
    DrvGPIO_Open(E_PORT2, E_PIN2, E_IO_QUASI);

    //
    // Configure general interrupt callback function for P0/P1 and P2/P3/P4
    //
    DrvGPIO_SetIntCallback(P0P1Callback, P2P3P4Callback, P5Callback);

    DrvGPIO_EnableInt(E_PORT1, E_PIN5, E_IO_RISING, E_MODE_EDGE);

    //
    // IO_FALLING means low level trigger if it is in level trigger mode.
    //
    DrvGPIO_EnableInt(E_PORT2, E_PIN2, E_IO_FALLING, E_MODE_LEVEL);

    DrvGPIO_SetDebounceTime(0, E_DBCLKSRC_HCLK);
    DrvGPIO_EnableDebounce(E_PORT1, E_PIN5);
    DrvGPIO_EnableDebounce(E_PORT2, E_PIN2);

    DrvGPIO_EnableDebounce(E_PORT3, E_PIN2);
    DrvGPIO_EnableDebounce(E_PORT5, E_PIN2);
    
    //
    // Configure external interrupt.
    //
    DrvGPIO_InitFunction(FUNC_EXTINT0);
    DrvGPIO_InitFunction(FUNC_EXTINT1);
    DrvGPIO_EnableEINT(E_EINT0_PIN, E_IO_FALLING, E_MODE_EDGE, EINT0Callback);
    DrvGPIO_EnableEINT(E_EINT1_PIN, E_IO_BOTH_EDGE, E_MODE_EDGE, EINT1Callback);
}
예제 #5
0
void kumpul(){
	clr_all_pannal();
	uint8_t hasiluart[8];
	while(key==1){
       	DrvGPIO_ClrBit(E_GPC,12);
       	DrvSYS_Delay(10000);
       	DrvGPIO_ClrBit(E_GPB,0);
       	print_lcd(0,"Tap Kartu Anda");
       	print_lcd(1,"Pada Reader");
       	print_lcd(2,"Tekan Button");
       	print_lcd(3,"untuk Kembali");
       	if(DrvGPIO_GetBit(E_GPB,15)==0){
       	       		main();}
       	bacarfid();
		DrvUART_Read(UART_PORT0,hasiluart,1);
		if(hasiluart[0]=='B'){
						DrvGPIO_ClrBit(E_GPB,11);
			       		DrvSYS_Delay(100000);
			       		DrvGPIO_SetBit(E_GPB,11);
			       		DrvSYS_Delay(100000);
			       		DrvGPIO_ClrBit(E_GPB,11);
			       		DrvSYS_Delay(100000);
			       		DrvGPIO_SetBit(E_GPB,11);
			       		DrvSYS_Delay(100000);
			       		clr_all_pannal();
			       		goto benar;
		}
		if(hasiluart[0]!='B'){
			SYSCLK->PWRCON.XTL12M_EN = 1;//Enable 12MHz Crystal
			       		       							SYSCLK->CLKSEL0.HCLK_S = 0;
			       		       						LOCKREG();
			       		clr_all_pannal();
			       		print_lcd(0,"Maaf :(");
			       		print_lcd(1,"Nama kamu gak");
			       		print_lcd(2,"Ada di Basis Data");
			       		print_lcd(3,"COBA LAGI !!!");
			       		DrvGPIO_ClrBit(E_GPB,11);
			       						DrvGPIO_ClrBit(E_GPB,11);
			       			       		DrvSYS_Delay(500000);
			       			       		DrvGPIO_SetBit(E_GPB,11);
			       			       		DrvSYS_Delay(100000);
			       			       		DrvGPIO_ClrBit(E_GPB,11);
			       			       		DrvSYS_Delay(500000);
			       			       		DrvGPIO_SetBit(E_GPB,11);
			       			       		DrvSYS_Delay(100000);
			       			       		DrvGPIO_ClrBit(E_GPB,11);
			       			       		delay(5000000);
			       		kumpul();
			       	}
       	//key2=Scankey();
       	/*if(key2==2){
       		DrvGPIO_ClrBit(E_GPB,11);
       		DrvSYS_Delay(100000);
       		DrvGPIO_SetBit(E_GPB,11);
       		DrvSYS_Delay(100000);
       		DrvGPIO_ClrBit(E_GPB,11);
       		DrvSYS_Delay(100000);
       		DrvGPIO_SetBit(E_GPB,11);
       		DrvSYS_Delay(100000);
       		clr_all_pannal();
       	}*/
       	//mennu harus diubah klo uart dah jadi
		benar:
       	while(hasiluart[0]=='B'){
       		print_lcd(0,"Silakan Masukkan");
       		print_lcd(1,"Borang Kamu");
       		SYSCLK->PWRCON.XTL12M_EN = 1;//Enable 12MHz Crystal
       		       							SYSCLK->CLKSEL0.HCLK_S = 0;
       		       						LOCKREG();
       		       				        servo_buka();
       		       				        DrvSYS_Delay(10);
       		Scankey();
       		if(DrvGPIO_GetBit(E_GPA,0)==0){
       		    clr_all_pannal();
       		    print_lcd(0,"Terima Kasih :)");
       		    print_lcd(1,"Tito Alvi");
       		    hitung++;
       		 DrvGPIO_ClrBit(E_GPB,11);
       		 			       		DrvSYS_Delay(100000);
       		 			       		DrvGPIO_SetBit(E_GPB,11);
       		 			       		DrvSYS_Delay(100000);
       		 			       		DrvGPIO_ClrBit(E_GPB,11);
       		 			       		DrvSYS_Delay(100000);
       		 			       		DrvGPIO_SetBit(E_GPB,11);
       		 			       		DrvSYS_Delay(100000);
       		 			       	DrvGPIO_ClrBit(E_GPB,11);
       		 			       	DrvSYS_Delay(100000);
       		 			       	DrvGPIO_SetBit(E_GPB,11);
       		 			       	DrvSYS_Delay(100000);
       		    print_lcd(0,"Terima Kasih :)");
       			DrvSYS_Delay(2000000);
       			main();
       		       	}
       		while(DrvGPIO_GetBit(E_GPA,0)==0){ //sensor cahaya = GPA0 - SIG
       			       				         			       		main();}
       		}

       	}


       	       	}