Exemple #1
0
int main (void)
{
	
	int start_position = 42; //zmienna pomocniczne do sterowania serwami	
	__disable_irq();	
	temp1=temp2=start_position;
	Clock_Initialize();
	GPIO_Initialize();
	Timer1_init();
  Timer2_init();

  __enable_irq();
	FPTB->PDOR =0;	
	NVIC->ICER[0]|=(1UL<<(30%32))|(1UL<<(31%32));
	NVIC->ISER[0]|=(1UL<<(30%32))|(1UL<<(31%32));
	
	
	
	
  while(1){
		
		if( !(FPTB->PDIR&(1<<0))){
			prawo(700);
			}
		if(!(FPTB->PDIR&(1<<1))){
			lewo(700);
		}
	}
}
Exemple #2
0
int main(void) {


	inir();
	intic();
	RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOD, ENABLE);

		GPIO_InitStructure.GPIO_Pin = GPIO_Pin_15 | GPIO_Pin_14 | GPIO_Pin_13
				| GPIO_Pin_12;
		GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
		GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
		GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
		GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
		GPIO_Init(GPIOD, &GPIO_InitStructure);

	RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA, ENABLE);
		GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4 | GPIO_Pin_5 | GPIO_Pin_6 | GPIO_Pin_7 /*| GPIO_Pin_2 | GPIO_Pin_3*/;
		GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
		GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
		GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
		GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
		GPIO_Init(GPIOA, &GPIO_InitStructure);


	stop();
	int a=0;
	char b=0;
	while (1) {
		static int count = 0;
		static int i;
//			TIM2->CCR4 = 4200;
//			TIM2->CCR3 = 4200;
		//for (i = 0; i < 10000000; ++i);
		//printf("%d\r\n", ++count);
		do{
		 b=usartGetChar();
		 printf("%d\n", b);
		 if(b==1){
			 przod();
			 GPIO_SetBits(GPIOD, GPIO_Pin_15);
			 GPIO_ResetBits(GPIOD, GPIO_Pin_14|GPIO_Pin_13|GPIO_Pin_12);
		 }
		 else if(b==2){
			 prawo();
			 GPIO_SetBits(GPIOD, GPIO_Pin_12);
			 GPIO_ResetBits(GPIOD, GPIO_Pin_14|GPIO_Pin_13|GPIO_Pin_15);
		 }
		else if(b==3){
			 tyl();
			 GPIO_SetBits(GPIOD, GPIO_Pin_13);
			 GPIO_ResetBits(GPIOD, GPIO_Pin_14|GPIO_Pin_12|GPIO_Pin_15);
		}
		else if(b==4){
		 			 lewo();
		 	 GPIO_SetBits(GPIOD, GPIO_Pin_14);
		 	 GPIO_ResetBits(GPIOD, GPIO_Pin_13|GPIO_Pin_12|GPIO_Pin_15);
		 }
		else if(b==5){
		 			 stop();
		 			GPIO_ResetBits(GPIOD, GPIO_Pin_14|GPIO_Pin_13|GPIO_Pin_12|GPIO_Pin_15);
		}
		else if(b>10&&b<22){
			f_Z(b);
		}
		else{
			f_V(b);
		}



		}while(USART_GetFlagStatus(USART3, USART_FLAG_RXNE) == RESET);

	}
}