#ifndef MAINDEMO_H
#define MAINDEMO_H

#include <p18cxxx.h>
#include <delays.h>		//need it for software delay. Source code
						//at C:\MCC18\h and C:\MCC18\src\traditional\delays
						//Under Build options, make sure the search path
						//C:\MCC18\h is there for Library Search Path

//Uncomment this to make the output HEX of this project 
//to be able to be bootloaded using the HID bootloader
//#define PROGRAMMABLE_WITH_USB_HID_BOOTLOADER		
#define CLOCK_FREQ 			48000000
#define GetSystemClock()  	CLOCK_FREQ    

#define HIGH	1
#define LOW		0

/** L E D ***********************************************************/
#define mLED_g              LATCbits.LATC3
#define mLED_r              LATCbits.LATC7
#define mLED_b              LATCbits.LATC6

#define mLED_g_On()         {mLED_g = 0; LATAbits.LATA5 = 0;}
#define mLED_r_On()         {mLED_r = 0; LATAbits.LATA5 = 0;}
#define mLED_b_On()         {mLED_b = 0; LATAbits.LATA5 = 0;}

#define mLED_g_Off()        mLED_g = 1;
#define mLED_r_Off()        mLED_r = 1;
#define mLED_b_Off()        mLED_b = 1;

#define mLED_g_Toggle()     mLED_g = !mLED_g;
#define mLED_r_Toggle()     mLED_r = !mLED_r;
#define mLED_b_Toggle()     mLED_b = !mLED_b;

#define mInitAllLEDs()      {mLED_g_Off(); mLED_r_Off(); mLED_b_Off(); TRISCbits.TRISC3 = 0; \
							TRISCbits.TRISC7 = 0; TRISCbits.TRISC6 = 0; TRISAbits.TRISA5 = 0;}

#define mLED_All_Off()		{mLED_g_Off(); mLED_r_Off(); mLED_b_Off();LATAbits.LATA5 = 1;}

// Switch to maintain power from battery
#define softPowerKey		PORTBbits.RB0
#define softPowerKeyInit()  TRISBbits.TRISB0 = 1

#define batteryMonCtrl		LATEbits.LATE7
#define batteryMonInit()	{TRISEbits.TRISE7 = 0; TRISAbits.TRISA2 = 1; batteryMonCtrl = 0;}

#define usbSenseInput		PORTBbits.RB1
#define usbSenseInit()		TRISBbits.TRISB1 = 1


#endif	