Ejemplo n.º 1
0
int main(void){unsigned short score;
  PLL_Init();  // Set the clocking to run at 80MHz from the PLL.
  LCD_Init();  // Initialize LCD
  LCD_Goto(0,0);
	score =0;
	long v2;
  LCD_SetTextColor(255,0,0); // yellow= red+green, no blue
  printf("score: %d", score);
  LCD_DrawLine(10,16,310,16,BURNTORANGE);
  Timer2_Init(4000000); // 20 times a second
	Timer3_Init(7256);	// 11.025 KHz
	InitEnemy();
	InitBunker();
	InitPlayer();
	InitMissile();
	InitLaser();
	Random_Init(1);
  EnableInterrupts();
	Fireflag=1;
	
while(1){
	if(Semaphore){
		DrawBuffer1();		
		Semaphore = 0;
    }
  }
}
Ejemplo n.º 2
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	   
	}	 
} 																						 
Ejemplo n.º 3
0
void main(void)
{	
	WDTCN = 0xde; // 禁止看门狗定时器
    WDTCN = 0xad;
	Init_Device();
	Timer3_Init(SYSCLOCK/12/800);
	EA=1;
	while(1)
	{;}


}
Ejemplo n.º 4
0
int main() {
	initBoard();
	initLCD();
	backlightOn();
	clearLCD();
	Timer3_Init();
	while(1)
	{
		LCDSnelheid();
		_delay_ms(500);
	}
		//MakeCircle(A, Dflt, Dflt, Dflt, Dflt, Dflt, Dflt, Dflt, Dflt, Dflt,
			//	Dflt, Dflt, Dflt, Dflt, Dflt, Dflt);

}
//debug code
int main(void){ volatile unsigned long delay;
  PLL_Init();                      // bus clock at 80 MHz
  SYSCTL_RCGC2_R |= SYSCTL_RCGC2_GPIOF; // activate port F
  delay = SYSCTL_RCGC2_R;          // allow time to finish activating
  GPIO_PORTF_DIR_R |= 0x0E;        // make PF3-1 output (PF3-1 built-in LEDs)
  GPIO_PORTF_AFSEL_R &= ~0x0E;     // disable alt funct on PF3-1
  GPIO_PORTF_DEN_R |= 0x0E;        // enable digital I/O on PF3-1
                                   // configure PF3-1 as GPIO
  GPIO_PORTF_PCTL_R = (GPIO_PORTF_PCTL_R&0xFFFF000F)+0x00000000;
  GPIO_PORTF_AMSEL_R = 0;          // disable analog functionality on PF
  LEDS = 0;                        // turn all LEDs off
//  Timer3_Init(&UserTask, 4000);    // initialize timer3 (20,000 Hz)
  Timer3_Init(&UserTask, 5000000); // initialize timer3 (16 Hz)
//  Timer3_Init(&UserTask, 80000000);// initialize timer3 (1 Hz)
//  Timer3_Init(&UserTask, 0xFFFFFFFF); // initialize timer23 (slowest rate)
  EnableInterrupts();

  while(1){
    WaitForInterrupt();
  }
}
Ejemplo n.º 6
0
/*******************************************************

目前暂时都是开环控制,没有闭环



******************************************************/
int main()
{
	float AngleRight = 0, AngleLift = 0;
	uint8_t flag = 0;
	
	
	delay_init(72);	
	Board_Init();
	MPU6050_Init();
	PWM_Init();
	OLED_Init();
	
//	
//=================================================//
// 初始化.... 风扇全都工作,免去启动长延时等待	
	Motor_Run(Motor_1, 0.2);
	Motor_Run(Motor_2, 0.2);
	Motor_Run(Motor_3, 0.2);
	Motor_Run(Motor_4, 0.2);
	delay_ms(1000);
	delay_ms(1000);
	
	Timer3_Init();
//=================================================//

	OLED_P8x16Str(0, 0, "Stone");
	OLED_P8x16Str(0, 2, "Y");
	OLED_P8x16Str(0, 4, "X");
	OLED_P8x16Str(0, 6, "pit:");
	OLED_P8x16Str(0, 6, "pit:        ");
	
	while(1)
	{
		AnglePendulum_CC(330);
//		StopPendulum_Y();
//		Motor_Run(Motor_1, 0);
//		Motor_Run(Motor_2, 0);
//		Motor_Run(Motor_3, 0.5);
//		Motor_Run(Motor_4, 0.1);
	}
	
	
	while(1)
	{
/***************************测试代码***********************************/
		
//		if(Angle_flag)
//		{
//			
//			Angle_flag = 0;
//			OLED_Shownumf(10, 2, 1, AngleMax_X);
//			OLED_Shownumf(10, 4, 1, AngleMin_X);
//			AngleMax_X = 0;
//			AngleMin_X = 0;
//			
//			
//		}
//		OLED_Shownumf(34, 6, 1, Angle_Last.rol);
//		max_p_ang_X(&AngleRight, &AngleLift);

//		Circle_CC(12.8);
//		 SimplePendulum_X_CC(18.8);
//		SimplePendulum_Y_CC(18.8);
//		SimplePendulum_X();			// X轴摆动
//		SimplePendulum_Y();		// Y轴摆动
//		AnglePendulum();			// 斜角摆动 ...效果不好  风机风力没有校正
//		Circle();							// 圆周.. 有可行性

/***************************测试代码***********************************/
	}
	
}
Ejemplo n.º 7
0
//-----------------------------------------------------------------------------
// MAIN Routine
//-----------------------------------------------------------------------------
//
// Main routine performs all configuration tasks, then loops forever sending
// and receiving SMBus data to the slave <SLAVE_ADDR>.
//
void main (void)
{
	unsigned char odoslat[4] = {0x00,0x00,0x12,0xFF};
   volatile unsigned char dat;         // Test counter
   unsigned char i;                    // Dummy variable counters

   PCA0MD &= ~0x40;                    // WDTE = 0 (watchdog timer enable bit)

   OSCICN |= 0x07;                     // Set internal oscillator to highest
                                       // setting of 24500000

   // If slave is holding SDA low because of an improper SMBus reset or error
   while(!SDA)
   {
      // Provide clock pulses to allow the slave to advance out
      // of its current state. This will allow it to release SDA.
      XBR1 = 0x40;                     // Enable Crossbar
      SCL = 0;                         // Drive the clock low
      for(i = 0; i < 255; i++);        // Hold the clock low
      SCL = 1;                         // Release the clock
      while(!SCL);                     // Wait for open-drain
                                       // clock output to rise
      for(i = 0; i < 10; i++);         // Hold the clock high
      XBR1 = 0x00;                     // Disable Crossbar
   }

   Port_Init ();                       // Initialize Crossbar and GPIO

   Timer1_Init ();                     // Configure Timer1 for use as SMBus
                                       // clock source

   Timer3_Init ();                     // Configure Timer3 for use with SMBus
                                       // low timeout detect

   SMBus_Init ();                      // Configure and enable SMBus

   EIE1 |= 0x01;                       // Enable the SMBus interrupt

   LED = 0;

   EA = 1;                             // Global interrupt enable

// TEST CODE-------------------------------------------------------------------

   dat = 0;                            // Output data counter
   NUM_ERRORS = 0;                     // Error counter
   while (1)
   {
      // SMBus Write Sequence
      if (dat < 4){
				SMB_DATA_OUT = odoslat[dat];              // Define next outgoing byte
      TARGET = SLAVE_ADDR; 				// Target the F3xx/Si8250 Slave for next
                                       // SMBus transfer
      SMB_Write();                     // Initiate SMBus write
			}
      // SMBus Read Sequence
     // TARGET = SLAVE_ADDR;             // Target the F3xx/Si8250 Slave for next
                                       // SMBus transfer
      //SMB_Read();

      // Check transfer data
      /*if(SMB_DATA_IN != SMB_DATA_OUT)  // Received data match transmit data?
      {
         NUM_ERRORS++;                 // Increment error counter if no match
      }*/

      // Indicate that an error has occurred (LED no longer lit)
      if (NUM_ERRORS > 0)
      {
         LED = 0;
      }
      else
      {
         LED = ~LED;
      }

      // Run to here to view the SMB_DATA_IN and SMB_DATA_OUT variables

      dat++;

      T0_Wait_ms (1);                  // Wait 1 ms until the next cycle
   }

// END TEST CODE---------------------------------------------------------------

}