Exemple #1
0
int main(void)
{	
	delay_init();	    	 //延时函数初始化	  
	uart_init(115200);
	TLV5616_Init();
	TLV5616_SetOutput_Voltage(500);
	IIC_Init();					//初始化ADS1115的I2C	
	KEY_Init();
	Uc1701_Init();
	clear_screen(0x55);
	TIM2_Int_Init(14999,71);//15ms
	TIM3_Int_Init(19999,71);//1Mhz的计数频率,计数到19999为20ms  
	TIM4_Int_Init(4999,71);//5ms
	while(1)
	{
		delay_ms(2);
	}
}
Exemple #2
0
 int main(void)
 {	
		delay_init();
		NVIC_Configuration();        /*设置NVIC中断分组2:2位抢占优先级,2位响应优先级*/
		LED_Init();
		MotorPin_Init();             /*舵机初始化信号线引脚*/		     
		USART1_Config();
		Init_TotalArray();           /*计算执行数组*/
	  Exti_Init();
    TIM3_Int_Init(100,100);	 
	  TIM4_Int_Init(10000,7199);   /*定时1S*/
		//TIM_Cmd(TIM3, DISABLE);                        /*接收到指令之后,再打开TIM3*/		
	  //while(!rece_flag);
	 
		while(1)
		{                                               /*警告:外部中断ABCDEF的顺序不要颠倒*/
						
				if(rece_flag==1)
					{
						
						  if(rece_string[0]=='#')
							{
							      TIM_Cmd(TIM3, DISABLE);         /*先关闭TIM3,避免全局变量被修改*/	
										motor_speed=250;
										SolvecubeArray_ToBufferArray();
							}
					
				    change();		
						TIM_Cmd(TIM3, ENABLE);     /*接收到指令之后,再打开TIM3*/					 			
						rece_flag=0;
					
					}
					
				if(flag_vpwm==1)	  
					{
						vpwm();				             /*插补角度*/
						flag_vpwm=0;
					}	
					
		}
		
}		
Exemple #3
0
 int main(void)
 {		
	u16 sta , i=0;
	int t = 200;
	delay_init();	    	 //延时函数初始化	
	LED_Init();
	LED0 = 0;delay_ms(200); LED0 = 1;
	LED1 = 0;delay_ms(200); LED1 = 1;
	LED2 = 0;delay_ms(200); LED2 = 1;
	LED3 = 0;delay_ms(200); LED3 = 1;
	 
	NVIC_Configuration(); 	 //设置NVIC中断分组2:2位抢占优先级,2位响应优先级
	uart_init(9600);	 	//串口初始化为9600
	 
	EXTIX_Init( );
 	NRF24L01_Init();    	//初始化NRF24L01 
	
	NRF24L01_RX_Mode();		
 	while(NRF24L01_Check() == 1)//检查NRF24L01是否在位.	
	{
			LED3=!LED3;				printf("NRF ERROR!!\r\n");

			delay_ms(100 );
	}
	printf("NRF okk!!\r\n");
	sta=NRF24L01_Read_Reg(STATUS);  //读取状态寄存器的值    	 
	NRF24L01_Write_Reg(WRITE_REG_NRF+STATUS,sta); //清除TX_DS或MAX_RT中断标志
	NRF24L01_Write_Reg(FLUSH_RX,0xff);//清除RX FIFO寄存器
	
	
	TIM2_PWM_Init(999,9);  //PWM OUT
	TIM3_Int_Init(0xffff,71);  //做计时器用

	IIC_Init();	 
	InitMPU6050();
	Init_HMC5883();
	suanfa_GetOrigin(); //初始欧拉角 
	

	
	TIM4_Int_Init(49,7199);	  		//PID调速中断 放在最后初始化,防止打断角度校准
	LOCK = 1;
	UN_LOCK = 0;
	
	while(1){
		
		
		if(LOCK)
		{
			
			lock();
			LED0 = 0;delay_ms(500);LED0 = 1;
			Power = 0;
			Target_x = 0;
			Target_y = 0;
				
		}
		
		if(UN_LOCK)
		{
			suanfa();
			printf("%.2lf  %.2lf  %.2lf\r\n",EA.Roll,EA.Pitch,EA.Yaw);	
// 			TIM_Cmd(TIM4, ENABLE);
			Data_Receive_Anl();
		}
		
// 		printf("--p\r\n");
			 
			
					}
}