Exemple #1
0
  int main(void)
 {
	 u8 t=0;	
	 u16 Time=0,dis_pre=0;
	 float V_ave;	//平均速度
	 char code_ave[5],code_v[5],code_vr[5], mileage[5];//信息储存数组
	 
	delay_init(72);	    	 			//延时函数初始化	  
	Stm32_Clock_Init(9);		  //系统时钟设置
	uart_init(72,9600);	 	 		  //串口初始化为9600
	usmart_dev.init(72);			//初始化USMART	
	EXTIX_Init();							//外部中断初始化
	TIM3_Int_Init(5000,7199); //10Khz的计数频率,计数到5000为500ms 
	LCD_Init();				 				//  PE.ALL,PD1~5  
	LCD_Display_Dir(1);				//设置显示方向为横屏显示
	LED_Init();		  					//初始化与LED连接的硬件接口
	KEY_Init();								//初始化按键

		while(RTC_Init())
		{	//等待RTC初始化
			delay_ms(200);
			printf("rtc waiting```\r\n");
		} 
		printf("finish\n");
		display_jing();
		//初始化完成
   while(1)
	{	
		POINT_COLOR=RED;
		if(t!=calendar.sec)		//时间更新后显示新时间
		{
				t=calendar.sec;	
				LCD_ShowNum(200,135,calendar.min,2,32);		
				LCD_ShowString(230,135,200,32,32,":");			
				LCD_ShowNum(248,135,calendar.sec,2,32);
			
				Time = 60*calendar.min+calendar.sec;//比赛用时
				if(dis_pre != quanshu_tenfold)			//有位移变化
				{
					V_ave=(0.154*quanshu_tenfold)/Time;
					dis_pre = quanshu_tenfold;
					sprintf(code_ave,"%.2f",V_ave);	
					LCD_ShowString(100,200,200,32,32,code_ave);//修改一下位置
					
				}
		}
			
		sprintf(code_v,"%.2f",V);					//float 转 字符串  
		LCD_ShowString(365,275,200,32,32,code_v);		//速度
		
		sprintf(code_vr,"%d",V_RPM);					//float 转 字符串  
		LCD_ShowString(365,275,200,32,32,code_vr);		//转速
 
		sprintf(mileage,"%.2f",0.154*quanshu_tenfold);
		LCD_ShowString(250,225,200,24,32,mileage);	//里程
		
	  display_dong(V_RPM,V,50);
		delay_ms(300);
	}
 }
Exemple #2
0
int main(void)
{ 		
	Stm32_Clock_Init(9);
//		u16 temp;
	NVIC_Configuration();
	UART1_init(72,115200); 
	delay_init();  
	//初始化串口1;
	
	pid_Init();

	LED_Init();
	EXTIX_Init();
	Adc_Init();		


	Motor_Init(999,0);	
	
	HC05_Init();
	while(mpu_dmp_init());	 

// 	TIM5_Init(999,72);
	TIM2_Int_Init(999,72);//定时器3配置,1ms中断一次

	
	while(1)
	{
//		CtrlAttiAng();
//	PWM_test();
//	COMMPC_TEST();	
//	Get_angle();
//	u2_printf("hell");
	test_SendPC();//测试向PC发送协议数据,用于调控
	} 	
}
Exemple #3
0
int main(void)
{	
//	u8 i;		   	
 	Stm32_Clock_Init(9); //system clock init   always init first
	IO_Init();
	delay_init(72);	     //delay init
<<<<<<< HEAD
Exemple #4
0
int main(void)
{		
 	Stm32_Clock_Init(9); //system clock init   always init first
	IO_Init();
	delay_init(72);	     //delay init
	uart_init(72,115200);  //uart init
	PWM4_Init(150,18000);				 // ultra ping sig

//	PWM2_2Init(100,1800);	 //count to 100, freq/1800	 //IR aqusition pulse
	Timer3_Init(65535,256);	  //time refrence for echo/ultrasonic

//	setup 5 for motors?
	Timer2_Init(65535,10);	// motor try1
	motor_Init();

	EXTIX_Init();
//	Adc_Init();
//	LED0_PWM_VAL2_2=0x44;
//	LED0_PWM_VAL2_1=0x34;
	LED0_PWM_VAL4=0x34;
	IRO=0;//turn on IR LEDs

   	while(1)
	{	
		printf("adcx1\tadcx2\tadcx3\tadcx4\tGyro\tBatt\techo\n");
		printf("%u\t%u\t%u\t%u\t%u\t%u\t%u",adcx1,adcx2,adcx3,adcx4,Gyro_raw,Batt,echo);
		printf("\n");
	//	USART1->DR=echo/0xff;
	//	while((USART1->SR&0X40)==0);//wait for transfer to compleate
		LED0=!LED0; 
		delay_us(100000);//wait for the end of transmission	   
	}	 
} 																						 
Exemple #5
0
int main(void)
{
	u8 key;
	Stm32_Clock_Init(336,8,2,7);
	delay_init(168);
	LED_Init();
	BEEP_Init();
	KEY_Init();
	LED0 = 0;	//点亮红灯
	
	while(1)
	{
		key = KEY_Scan(0);
//		key = KEY_Scan_Custom(0);
		if(key)//有按键按下
		{
			switch(key)
			{
				case WKUP_PRES: BEEP = !BEEP;break;
				case KEY2_PRES: LED0 = !LED0;break;
				case KEY1_PRES: LED1 = ~LED1;break;
				case KEY0_PRES: LED1 = !LED1; LED0 = !LED0;break;
			}
		}
		else
			delay_ms(10);
	}
	
}
Exemple #6
0
int main(void)
{				  
	
	Stm32_Clock_Init(PLL_FACTOR); //?????? 8*9=72Mhz ADC1
	OS_Init();
	Shedule();
		 
}
Exemple #7
0
int main(void)
{
	u8 key,fontok=0; 
   	Stm32_Clock_Init(9);	//系统时钟设置
	delay_init(72);			//延时初始化
	uart_init(72,115200); 	//串口1初始化 
	LCD_Init();				//初始化液晶 
	LED_Init();         	//LED初始化	 
	KEY_Init();				//按键初始化	 
	usmart_dev.init(72);	//usmart初始化	
 	USART2_Init(36,115200);	//初始化串口2 
	TP_Init();				//初始化触摸屏
	mem_init(SRAMIN);		//初始化内部内存池	    
 	exfuns_init();			//为fatfs相关变量申请内存  
  	f_mount(0,fs[0]); 		//挂载SD卡 
	key=KEY_Scan(0);  
	if(key==KEY_RIGHT)		//强制校准
	{
		LCD_Clear(WHITE);	//清屏
		TP_Adjust();  		//屏幕校准 
		TP_Save_Adjdata();	  
		LCD_Clear(WHITE);	//清屏
	}
	fontok=font_init();		//检查字库是否OK
	if(fontok||key==KEY_DOWN)//需要更新字库				 
	{
		LCD_Clear(WHITE);		   	//清屏
 		POINT_COLOR=RED;			//设置字体为红色	   	   	  
		LCD_ShowString(60,50,200,16,16,"ALIENTEK STM32");
		while(SD_Initialize())		//检测SD卡
		{
			LCD_ShowString(60,70,200,16,16,"SD Card Failed!");
			delay_ms(200);
			LCD_Fill(60,70,200+60,70+16,WHITE);
			delay_ms(200);		    
		}								 						    
		LCD_ShowString(60,70,200,16,16,"SD Card OK");
		LCD_ShowString(60,90,200,16,16,"Font Updating...");
		key=update_font(20,110,16,0);//从SD卡更新
		while(key)//更新失败		
		{			 		  
			LCD_ShowString(60,110,200,16,16,"Font Update Failed!");
			delay_ms(200);
			LCD_Fill(20,110,200+20,110+16,WHITE);
			delay_ms(200);		       
		} 		  
		LCD_ShowString(60,110,200,16,16,"Font Update Success!");
		delay_ms(1500);	
		LCD_Clear(WHITE);//清屏	       
	}  
	sim900a_test();
}
Exemple #8
0
int main(void)
{			
 	Stm32_Clock_Init(9); //系统时钟设置
	delay_init(72);	     //延时初始化
	uart_init(72,9600);  //串口初始化 
	LED_Init();		  	 //初始化与LED连接的硬件接口
	Timerx_Init(5000,7199);//10Khz的计数频率,计数到5000为500ms  
   	while(1)
	{
		LED0=!LED0;
		delay_ms(200);		   
	}	 
}
Exemple #9
0
//Mini STM32开发板范例代码1
//跑马灯实验		   
//正点原子@ALIENTEK
//技术论坛:www.openedv.com	  
int main(void)
{				  
	Stm32_Clock_Init(9); //系统时钟设置
	delay_init(72);	     //延时初始化
	LED_Init();		  	 //初始化与LED连接的硬件接口
	while(1)
	{
		LED0=0;
		LED1=1;
		delay_ms(300);
		LED0=1;
		LED1=0;
		delay_ms(300);
	}	 
}
Exemple #10
0
int main(void)
{ 
	u16 val;
	Stm32_Clock_Init(336,8,2,7);
	delay_init(168);
	uart_init(84,115200);
	Holl_Init();
	lcd.Init();
	
	while(1)
	{
		//val=Get_Adc(Holl1_CH5);
		
		delay_ms(500);
	}
}
int main(void)
{		
 
		
 	Stm32_Clock_Init(9); //系统时钟设置
	delay_init(72);	     //延时初始化
	uart_init(72,9600);  //串口初始化 
	LED_Init();		  	 //初始化与LED连接的硬件接口
	PWM_Init(54000,2);	 //不分频。PWM频率=72000/900=80Khz
   	while(1)			 //理论算出为(9000,15)示波器显示为周期2.000ms
	{
 	LED0_PWM_VAL=13500;//1 out	   
	}	 					
	
     	
	
}
int main(void)
{		
 
		
 	Stm32_Clock_Init(9); //系统时钟设置
	delay_init(72);	     //延时初始化
	uart_init(72,9600);  //串口初始化 
	LED_Init();		  	 //初始化与LED连接的硬件接口
	PWM_Init(32400,2);	 //不分频。PWM频率=72000/900=80Khz
   	while(1)
	{
 		LED0_PWM_VAL=21600;	
			//sync
	}	 
	
     	
	
}
Exemple #13
0
void Sys_Init(void)
{
	u8 key,fontok=0;  
	Stm32_Clock_Init(9);	//系统时钟设置
	delay_init(72);			//延时初始化
	uart_init(72,115200); 	//串口1初始化 
	LCD_Init();				//初始化液晶 
	LED_Init();         	//LED初始化	 
	KEY_Init();				//按键初始化	 	
 	USART2_Init(36,115200);	//初始化串口2 
	mem_init();		        //初始化内部内存池	    
 	exfuns_init();			//为fatfs相关变量申请内存  
    f_mount(fs[0],"0:",1); 	//挂载SD卡  
	key = KEY_Scan(0);  
	fontok = font_init();		//检查字库是否OK
	if(fontok||key == KEY1_PRES)//需要更新字库 (KEY1按下或字库丢失)				 
	{
		LCD_Clear(WHITE);		   	//清屏
 		POINT_COLOR=RED;			//设置字体为红色	   	   	  
		LCD_ShowString(70,50,200,16,16,"GSM  TEST");
		while(SD_Initialize())		//检测SD卡
		{
			LCD_ShowString(60,70,200,16,16,"SD Card Failed!");
			delay_ms(200);
			LCD_Fill(60,70,200+60,70+16,WHITE);
			delay_ms(200);		    
		}								 						    
		LCD_ShowString(60,70,200,16,16,"SD Card OK");
		LCD_ShowString(60,90,200,16,16,"Font Updating...");
		key = update_font(20,110,16);    //更新字库
		while(key)  //更新失败		
		{			 		  
			LCD_ShowString(60,110,200,16,16,"Font Update Failed!");
			delay_ms(200);
			LCD_Fill(20,110,200+20,110+16,WHITE);
			delay_ms(200);		       
		} 		  
		LCD_ShowString(60,110,200,16,16,"Font Update Success!");
		delay_ms(1500);	
		LCD_Clear(WHITE);//清屏	       
	} 
}
Exemple #14
0
int main(void)
{
	Stm32_Clock_Init(9);
	JTAG_Set(1);
	Wave.init();
  Motor.Init();
  Sensor.Init();
	BatteryCheckInit();
  Timer.Init(72);
  LED_Init();
//  Timer.Run();
//  delay_init(72);
  
//  while(1)
//  {
//     delay_ms(500);
//    LED=~LED;
//    
//  }
  // LED=0;
  if(!MPU.Init())
	{
		while(mpu_dmp_init())
		{
			delay_ms(500);
			//  LED=~LED;
		}
	}
	//mpu_dmp_get_data();
  
  LED=0;
	
	UART.Init(72,115200,OnRecvData);
	UART.SendByte(0);
	UART.SendByte(0xff);
	UART.SendByte(0x55);
	
	RC522.Init();
	RC522.SetCallBack(ReadCard);
	
	Timer.Start(0,UartProtocol.Check);
  Timer.Start(0,tick1);
  Timer.Start(10,DetectionLogic.LogicRun);
	Timer.Start(1,Sensor.LoopScan);
	PathList=pathbuff;
	DetectionLogic.Init();
	DetectionLogic.RegisterEvent(ActionType.EnterWay,inway);
	DetectionLogic.RegisterEvent(ActionType.EnterPoint,inPoint);
	DetectionLogic.RegisterEvent(ActionType.turnDone,turndone);
	DetectionLogic.Control->StopRun();
	lastAction=0xff;
	//DetectionLogic.LoadDefConfig(pathbuff );
  //Timer.Start(500,led);
	Timer.Start(0,RC522.ReadLoop);
	Timer.Start(500,UpdateBatteryValue);
	
  UartProtocol.Init(buffdata);
	UartProtocol.AutoAck(ENABLE);
	UartProtocol.RegisterCmd(Alive,AliveEvent);
  UartProtocol.RegisterCmd(GetData,GetDataEvent);
	UartProtocol.RegisterCmd(SetData,SetDataEvent);
	
	while(1)
		Timer.Run();
	
	
}
Exemple #15
0
int main(void){		 
		u8 t;u8 len;u8 try = 0;u8 flag = 0;
		u16 times = 0,time = 0,time1 = 0,time2 = 0,time3 = 0,time4 = 0,HBNum = 0,SDNum = 0;
	
		Stm32_Clock_Init(9);

		delay_init(72);
		
 		uart_init(72,115200);
		
		LED_Init();
	

		KEY_Init();
		delay_ms(4000);
	//	delay_ms(3600);
		printf("\r\n");
		printf("      ,:::                               ;B@          \r\n");
		printf("     B@B@B@BZ                            7@B          \r\n");
		printf("     @BJ   @B5  rXO8L.   rL ,qP7     ;PE,rB@   7kOZY. \r\n");
		printf("     @@7   B@J X@EuU@BJ  B@B@B@@@   @B@B@B@B  GBZY5B@,\r\n");
		printf("     @B@B@B@P       Z@B  @BO   @Bi PB@   YB@       MBu\r\n");
		printf("     B@Orr:    2@BEu@BB  B@u   @@: M@M   :@B  kB@NUB@v\r\n");
		printf("     @B2       @@r  B@B  @BZ   @B; rB@r r@B@  B@:  @BU\r\n");
		printf("     B@u       7@B@@PBM  B@1   B@:  vB@B@7@B  vB@B@P@L\r\n");
		printf("                          .::::::.                \r\n");
		printf("                      :uk00Ur:   .., UB@r         \r\n");
		printf("                   v@BO7.      ,.     :P@.        \r\n");
		printf("                 1@M:        MB@B@.               \r\n");
		printf("               i@G         .@B@B@B,       @7      \r\n");
		printf("              F@.          @B@@u          ..      \r\n");
		printf("             qM            ,@Mi     ZB@L          \r\n");
		printf("            LN                     1B@F    r7     \r\n");
		printf("            q                       Gi     ,,  r  \r\n");
		printf("           :.                                  @  \r\n");
		printf("                 .u@@B@B@Er                   ,Br \r\n");
		printf("               :B@@@@@B@B@@@F                 B@k \r\n");
		printf("              LB@B@B@B@B@B@B@B:             ,B@@N \r\n");
		printf("             .B@B@@@@@B@@@@@B@BBi         iBB@B@r \r\n");
		printf("             B@B@B@B@B@B@B@B@B@B@B@0k5S0@B@B@B@B  \r\n");
		printf("            ,@@@B@B@B@B@B@B@B@B@B@B@@@B@B@@@B@BL  \r\n");
		printf("            .B@B@B@B@B@B@B@B@B@B@B@B@@@B@B@B@BM   \r\n");
		printf("             .B@@@B@B@B@B@@@B@@@B@B@B@B@B@@@B@    \r\n");
		printf("               B@@@B@B@@@B@@@B@B@B@B@B@B@B@B0     \r\n");
		printf("                u@B@B@B@@@B@@@B@@@B@B@B@B@B:      \r\n");
		printf("                  FB@B@B@B@B@B@B@MB@@B@B@i        \r\n");
		printf("                    :ZB@B@B@@@B@B@B@BBY.          \r\n");
		printf("                         :77vi:,..                \r\n");
//		delay_ms(2000);



		printf("Stm32_Clock_Init(72MHz).\r\n\r\n");
		delay_ms(200);
		printf("delay_init.\r\n\r\n");
		delay_ms(200);
		printf("uart_init(115200).\r\n\r\n");
		delay_ms(200);
		printf("LED_Init.\r\n\r\n");
		delay_ms(200);
		printf("KEY_Init.\r\n\r\n");
		delay_ms(300);
		printf("SYS Boot completly!.\r\n\r\n");







		

		printf("\r\n");
		printf("\r\n");
		printf("\r\n");
		printf("\r\n");
		printf("\r\n");
		printf("--------Help--------\r\n\r\n");
		printf("Panda>");
		while(1){
		 	if(USART_RX_STA&0x8000){
				len = USART_RX_STA&0x3fff;

				for(t = 0;t < len;t ++){
					USART1 -> DR = USART_RX_BUF[t];
					while((USART1 -> SR & 0X40) == 0);
				}
				printf("\r\nPanda>");
				if(((USART_RX_BUF[0]=='h' || USART_RX_BUF[0]=='H' )&& USART_RX_BUF[1]=='e' && USART_RX_BUF[2]=='l' && USART_RX_BUF[3]=='p' )&& len == 4){
					printf("	1.'L'to control LED e.g.L1up Lalldown\r\n");
					printf("	2.Press buttons on the board\r\n");
					printf("	3.'V'to check version\r\n");
					printf("Panda>");
					time ++;
				}
				if((USART_RX_BUF[0]=='l' || USART_RX_BUF[0]=='L') && (len == 4 || len == 6 || len == 8)){
					
					if(USART_RX_BUF[1]=='1'){
						if((USART_RX_BUF[2]=='u' || USART_RX_BUF[2]=='U') && len == 4){
							LED1 = 0;
							time ++;
						}else if((USART_RX_BUF[2]=='d' || USART_RX_BUF[2]=='D') && len == 6){
						 	LED1 = 1;
							time ++;
						}
						
					}
					if(USART_RX_BUF[1]=='2'){
						if((USART_RX_BUF[2]=='u' || USART_RX_BUF[2]=='U') && len == 4){
							LED2 = 0;
							time ++;
						}else if((USART_RX_BUF[2]=='d' || USART_RX_BUF[2]=='D') && len == 6){
						 	LED2 = 1;
							time ++;
						}
						
					}
					if(USART_RX_BUF[1]=='3'){
						if((USART_RX_BUF[2]=='u' || USART_RX_BUF[2]=='U') && len == 4){
							LED3 = 0;
							time ++;
						}else if((USART_RX_BUF[2]=='d' || USART_RX_BUF[2]=='D') && len == 6){
						 	LED3 = 1;
							time ++;
						}
					}
					if(USART_RX_BUF[1]=='4'){
						if((USART_RX_BUF[2]=='u' || USART_RX_BUF[2]=='U') && len == 4){
							LED4 = 0;
							time ++;
						}else if((USART_RX_BUF[2]=='d' || USART_RX_BUF[2]=='D') && len == 6){
						 	LED4 = 1;
							time ++;
						}
					}
					if((USART_RX_BUF[1]=='a' || USART_RX_BUF[1]=='A') && (len == 6 || len == 8)){
						if((USART_RX_BUF[4]=='u' || USART_RX_BUF[4]=='U') && len == 6){
							LED1 = 0;
							LED2 = 0;
							LED3 = 0;
							LED4 = 0;
							time ++;
						}else if((USART_RX_BUF[4]=='d' || USART_RX_BUF[4]=='D') && len == 8){
						 	LED1 = 1;
							LED2 = 1;
							LED3 = 1;
							LED4 = 1;
							time ++;
						}
					}
				//	printf("unknow command.");
					printf("\r\nPanda>");
				}
				if((USART_RX_BUF[0]=='v' || USART_RX_BUF[0]=='V' ) && len == 1){
					printf("	Panda V0.3 2015.5");
					printf("\r\nPanda>");
					time ++;
				}
				if((USART_RX_BUF[0]=='p' && USART_RX_BUF[1]=='a' && USART_RX_BUF[2]=='n' && USART_RX_BUF[3]=='d' && USART_RX_BUF[4]=='a' ) && len == 5){
					printf("	Designed by Joe.\r\n");
					printf("	Wait for more fun!");
					printf("\r\nPanda>");
					time ++;
				}
				if((USART_RX_BUF[0]=='l' && USART_RX_BUF[1]=='s' ) && len == 2){
					printf("	.");
					printf("\r\nPanda>");
					time ++;
				}
				if(time == 0){
					printf("unknow command!");
					printf("\r\nPanda>");

				}
				
				time = 0;
				USART_RX_STA = 0;
			}else{
				times ++;
				if(times % 20 == 0){
				//	time ++;
					t = KEY_Scan(1);
					if(t == KEY1_PRES){
						time1++;
						printf("KEY1_PRES %dtimes",time1);
						printf("\r\nPanda>");
					}
					if(t == KEY2_PRES){
						time2++;
						printf("KEY2_PRES %dtimes",time2);
						printf("\r\nPanda>");
					}
					if(t == KEY3_PRES){
						time3++;
						printf("KEY3_PRES %dtimes",time3);
						printf("\r\nPanda>");
					}
					if(t == KEY4_PRES){
						time4++;
						printf("KEY4_PRES %dtimes",time4);
						printf("\r\nPanda>");
					}
				//	printf("\r\nqiaosiyi\r\n");
				}
				if(times % 5000 == 0){	//if you want send bumb packet frequently ,set this parami by 200
					//missions
				}

				if(times % 30 == 0){
					//missions
				}
				delay_ms(10);
			}
		}
}