/******************************************************************************
*
* Centre for Applied Cybernetics, Brno University of Technology
* (c) Copyright 2005 Brno University of Technology
* ALL RIGHTS RESERVED.
*
* Freescale Semiconductor Inc.
* (c) Copyright 2004-2006 Freescale Semiconductor, Inc.
* ALL RIGHTS RESERVED.
*
******************************************************************************
*
* @file      main.c   
*
* @author    Petr Blaha
* @author    Pavel Vaclavek 
* 
* @version   2.0.1.2
*
* @date      September-19-2006
* 
* @brief	 Demonstration example 
*
* @remark	 To be used together with Matlab exaple Pcontrol.mdl
*
*******************************************************************************
*
* The main file of SFIO Toolbox demonstration example for DSP56F8xxx
*
******************************************************************************/

#include "qs.h"

#include "occs.h"
#include "sys.h"
#include "intc.h"
#include "gpio.h"
#include "cop.h"
#include "sci.h"
#include "spi.h"
#include "adc.h"
#include "fcan.h"
#include "qtimer.h"
#include "decoder.h"
#include "pwm.h"
#include "tsensor.h"
#include "freemaster.h"

#include "sfio.h"
#include "RotatePsiS.h"
#include "AdjustModulePsiS.h"
#include "ComputeUS.h"
#include "SelectAlpha.h"
#include "TestCurrent.h"
#include "LimitStatorVoltage.h"
#include "PDSFC.h"

//#include "pdsfc.h"


void main (void) 
{
	/* initialize the device pins first */
	ioctl(SYS, SYS_INIT, NULL);
	ioctl(GPIO_A, GPIO_INIT, NULL);
	ioctl(GPIO_B, GPIO_INIT, NULL);
	ioctl(GPIO_C, GPIO_INIT, NULL);
	ioctl(GPIO_D, GPIO_INIT, NULL);
	ioctl(GPIO_E, GPIO_INIT, NULL);
	ioctl(GPIO_F, GPIO_INIT, NULL);
	
	/* serial port initialization - only to set baud rate register */
	ioctl(SCI_0, SCI_INIT, NULL);
    
	/* initialize SFIO engine */
	SFIO_Init();
  
  	/* block functions registration */
  	 SFIO_RegisterMatlabBlock(RotatePsiS);
  	 SFIO_RegisterMatlabBlock(AdjustModulePsiS);
  	 SFIO_RegisterMatlabBlock(ComputeUS);
  	 SFIO_RegisterMatlabBlock(SelectAlpha);
  	 SFIO_RegisterMatlabBlock(TestCurrent);
  	 SFIO_RegisterMatlabBlock(LimitStatorVoltage);
  	  	
  	/* initialize interrupt controller and enable interrupts */
    ioctl(INTC, INTC_INIT, NULL);
    archEnableInt();

	/* infinite loop */
	while(1)
	{
	}
}


