#include "C:\\Documents and Settings\\Marek\\Desktop\\Bakalarka 2009\\PIC628A program\\StpDrvPic628\\StepperDriverPic628_Auto.h"


// **********
//
// Application Designer Variables
//
// **********
//
// This file is automatically generated. Any changes will be overwritten when
// the application is regenerated
//
void LoadOscCal();
// Conditional Defines
 // Port Input

#if (T2_Pre==1) // Timer 2
 #define vT2CON ((T2_Post-1)<<3)|(T2_En<<2)|(0)
#endif
#if (T2_Pre==4)
 #define vT2CON ((T2_Post-1)<<3)|(T2_En<<2)|(1)
#endif
#if (T2_Pre==16)
 #define vT2CON ((T2_Post-1)<<3)|(T2_En<<2)|(2)
#endif
#if T1_PSD==1 // Timer 1
 #define PSValue 0x00
#endif
#if T1_PSD==2
 #define PSValue 0x10
#endif
#if T1_PSD==4
 #define PSValue 0x20
#endif
#if T1_PSD==8
 #define PSValue 0x30
#endif


//
// Main function
//

void main()
{
  OPTION_REG&=0x7f;		// Pull ups on PORTB by default
 #if HASOSCCAL==1
  LoadOscCal();
 #endif
 
 // Initialisation Code
 T2CON=vT2CON;
 TMR2=0;
 TMR1L=TMR1H=0;
 T1CON=PSValue | EnTimer1 | ((!T1_UseOsc)<<TMR1CS) | ((!SyncT1Inp)<<NOT_T1SYNC) | (EnT1Osc<<T1OSCEN);
 

 // End Initialisation Code
 PORTA|=0xff;
 PORTB|=0xff;
 TRISB&=0x02;
 TRISA&=0xf1;
#if !InitialValue10
 Out10Port&=~(1<<Out10Bit); // Port Driver
#endif // Port Driver
 // Port Driver
#if !InitialValue8
 Out8Port&=~(1<<Out8Bit); // Port Driver
#endif // Port Driver
 // Port Driver
#if !InitialValue7
 Out7Port&=~(1<<Out7Bit); // Port Driver
#endif // Port Driver
 // Port Driver
#if !InitialValue6
 Out6Port&=~(1<<Out6Bit); // Port Driver
#endif // Port Driver
 // Port Driver
#if !InitialValue5
 Out5Port&=~(1<<Out5Bit); // Port Driver
#endif // Port Driver
 // Port Driver
#if !InitialValue4
 Out4Port&=~(1<<Out4Bit); // Port Driver
#endif // Port Driver
 // Port Driver
#if !InitialValue3
 Out3Port&=~(1<<Out3Bit); // Port Driver
#endif // Port Driver
 // Port Driver
#if !InitialValue2
 Out2Port&=~(1<<Out2Bit); // Port Driver
#endif // Port Driver
 // Port Driver
#if !InitialValue1
 Out1Port&=~(1<<Out1Bit); // Port Driver
#endif // Port Driver
 // Port Driver
#if !InitialValue0
 Out0Port&=~(1<<Out0Bit); // Port Driver
#endif // Port Driver
 // Port Driver
 
 UserInitialise();
 
 // Finally enable interrupts
  
 INTCON|=(1<<GIE);
 
 // Main Loop
 
 while(1)				
 {					// Loop forever
  UserLoop();
  #ifdef WatchDogUsed			
   #pragma asmline clrwdt		; Clear watchdog timer if used
  #endif
 }
}

//
// Interrupts
//
const int QuickInt=1;

void Interrupt()
{
 // Priority Interrupts first
 // Other Interrupts
 #pragma asm
  SETPCLATH UserInterrupt,-1 	; Set PCLATH
  goto UserInterrupt	    	; goto user interrupt
 UserIntReturn::	    	; Return to here after user routine
  clrf STATUS		; Clear RP0/RP1
  SETPCLATH IntRet,-1		; and set PCLATH back to return address 
 #pragma asmend
}

//
// Load oscillator calibration value on reset for 14 bit processors
//
#if HASOSCCAL==1
	#pragma asm
		module "LoadOscCal"
LoadOscCal::
		SETPCLATH OVRet,LoadOscCal
                call OVRet
                bsf STATUS,RP0
                movwf OSCCAL
                bcf STATUS,RP0
                MRET 0
                
                endmodule
                
		module "LoadOscCal" forced absolute _TOPROM+1
		 OVRet::
		 	retlw 0xff
		endmodule
	#pragma asmend
#endif


