示例#1
0
文件: delay.c 项目: knkp/stellarap
void delay_init()
{
  //configure timer1 for one shot intervals and assign interrupt routine
  ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER1);
  ROM_TimerConfigure(TIMER1_BASE,TIMER_CFG_ONE_SHOT);
  ROM_TimerControlStall(TIMER1_BASE, TIMER_A, true);
  TimerIntRegister(TIMER1_BASE, TIMER_A, delay_isr);

}
示例#2
0
void ping0InitPeriph( void ) {
	//
	// Disable timer and set parameters
	//
	ROM_TimerDisable( TIMER_BASE_PING0,	TIMER_PING0 );
	ROM_TimerPrescaleSet( TIMER_BASE_PING0, TIMER_PING0, 0 );
	ROM_TimerPrescaleMatchSet( TIMER_BASE_PING0, TIMER_PING0, 0 );
	ROM_TimerControlStall( TIMER_BASE_PING0, TIMER_PING0, false );

	IntPrioritySet( TIMER_INT_PING0, 0x40 ); // set to a middle priority group
	//
	// Register inerrupt
	//
	TimerIntRegister( TIMER_BASE_PING0, TIMER_PING0, &ping0Int );
}
示例#3
0
void motor_init()
{
  unsigned long timer;

  //configure timer0 for one shot intervals and assign interrupt routine
  ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0);
  ROM_TimerConfigure(TIMER0_BASE,TIMER_CFG_ONE_SHOT);
  ROM_TimerControlStall(TIMER0_BASE, TIMER_A, true);
  TimerIntRegister(TIMER0_BASE, TIMER_A, Timer0A_ISR);
  ROM_TimerIntEnable(TIMER0_BASE, TIMER_TIMA_TIMEOUT); 

  //setup RGB led outputs. 
  ROM_SysCtlPeripheralEnable(LED_PERIPH);
  ROM_GPIOPinTypeGPIOOutput(LED_PORT, LED_R | LED_G | LED_B );

  //enable peripherals used for motor
  ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
  ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
  ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);
  ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);
  
  //set motor pins to outputs
  ROM_GPIOPinTypeGPIOOutput(GPIO_PORTA_BASE, MOTOR_PORTA_PINS );
  ROM_GPIOPinTypeGPIOOutput(GPIO_PORTB_BASE, MOTOR_PORTB_PINS );
  ROM_GPIOPinTypeGPIOOutput(GPIO_PORTD_BASE, MOTOR_PORTD_PINS );
  ROM_GPIOPinTypeGPIOOutput(GPIO_PORTE_BASE, MOTOR_PORTE_PINS );


  //make sure motors are disabled and step pins are low
  motor_disable();
  motor_unstep();

  //start the timer.  the ISR will run at the minimum rate 
  //interval until there is a block to execute.
  timer=calculate_timer(MIN_STEP_RATE);
  ROM_TimerLoadSet(TIMER0_BASE,TIMER_A, timer);
  ROM_TimerEnable(TIMER0_BASE,TIMER_A);
}