예제 #1
0
/** Realtime callback function.
 *
 * This event simulates an elapsed 1ms.
 */
void realtime_tick (void)
{
#define FIRQ_FREQ 8
#define PERIODIC_FREQ 16

	static unsigned long next_firq_time = FIRQ_FREQ;
	static unsigned long next_periodic_time = PERIODIC_FREQ;

#ifdef CONFIG_SIM
	/* Update all of the simulator modules that need periodic processing */
	sim_time_step ();
#endif

	/* Simulate an IRQ every 1ms */
	if (linux_irq_enable)
	{
#ifdef CONFIG_GEN_RTT
		exec_rtt ();
#else
		tick_driver ();
#endif
	}

#ifdef CONFIG_FIRQ
	/* Simulate an FIRQ every 8ms */
	if (linux_firq_enable)
	{
		while (realtime_read () >= next_firq_time)
		{
			do_firq ();
			next_firq_time += FIRQ_FREQ;
		}
	}
#endif

	/* Call periodic processes every 16ms */
	if (realtime_read () >= next_periodic_time)
	{
		db_periodic ();
		if (likely (periodic_ok))
			do_periodic ();
		next_periodic_time += PERIODIC_FREQ;
	}
}
예제 #2
0
int main()
{
	
    TRACE_CONFIGURE(DBGU_STANDARD, 115200, BOARD_MCK);
    printf("-- USB Device CDC Serial Project %s --\n\r", SOFTPACK_VERSION);
    printf("-- %s\n\r", BOARD_NAME);
    printf("-- Compiled: %s %s --\n\r", __DATE__, __TIME__);

    // If they are present, configure Vbus & Wake-up pins
    //PIO_InitializeInterrupts(0);
	
	//-------- Init parameters --------------
	printf("INIT Parameters\n\r");
	init_parameters();
	
	//-------- Load parameters from Flash --------------
	printf("Load parameters from Flash\n\r");
	FLASH_LoadSettings();
	
    //-------- Init UART --------------
	printf("USB Seriel INIT\n\r");
	samserial_init();
	
	//-------- Init ADC without Autostart --------------
	printf("Init ADC\n\r");
    initadc(0);
	
	//-------- On USB recived byte call this function --------------
	printf("Init Callback for USB\n\r");
    samserial_setcallback(&usb_characterhandler);
	
	//-------- Init Motor driver --------------
	printf("Init Motors\n\r");
    motor_setup();
	
	//-------- Init Heater I/O  --------------
	printf("Init Heaters\n\r");
    heaters_setup();
	
    //-------- Start SYSTICK (1ms) --------------
	printf("Configuring systick.\n\r");
	SysTick_Configure(1, BOARD_MCK/1000, SysTick_Handler);
	
	//-------- Timer 0 for Stepper --------------
	printf("Init Stepper IO\n\r");
    stepper_setup();	//Timer for Stepper


	//-------- Timer 0 for Stepper --------------
	printf("Configuring Timer 0 Stepper\n\r");
    ConfigureTc0_Stepper();	//Timer for Stepper
	
	//-------- Timer 1 for heater PWM --------------
	printf("Configuring Timer 1 PWM.\n\r");
	ConfigureTc_1();

	//-------- Init Planner Values --------------
	printf("Plan Init\n\r");
	plan_init();
	
	//-------- Check for SD card presence -------
//	sdcard_handle_state();
	
	//motor_enaxis(0,1);
    //motor_enaxis(1,1);
	while (1)
	{
  		//uncomment to use//sprinter_mainloop();
    	//main loop events go here

		do_periodic();
    	
		if(buflen < (BUFSIZE-1))
			get_command();

    	if(buflen > 0)
		{
			
			//-------- Check and execute G-CODE --------------
			process_commands();

			//-------- Increment G-Code FIFO  --------------
			buflen = (buflen-1);
			bufindr++;
			if(bufindr == BUFSIZE) bufindr = 0;
			
		}
		  
    }
}