//************************************************************************************
//**  
//**  File name:     C:\Users\Venelin\Desktop\Projects\Flowcode2.c
//**  Title:         
//**  Description:   
//**  
//**  Generated by:  Flowcode v5.4.0.0
//**  Date:          Wednesday, October 28, 2015 17:53:36
//**  Licence:       Professional
//**  Registered to: Venelin
//**  Licence key:   0BRD53
//**  
//**  
//**  http://www.matrixmultimedia.com
//**  
//************************************************************************************


#define MX_PIC

#define MX_USES_UINT8 1
#define MX_USES_SINT16 0
#define MX_USES_CHAR 0
#define MX_USES_FLOAT 0
#define MX_USES_SINT32 0
#define MX_USES_BOOL 1
#define MX_USES_UINT16 0
#define MX_USES_UINT32 0
//Defines for microcontroller
#define P16F887
#define FC_CAL_PIC
#define MX_ADC
#define MX_ADC_TYPE_7
#define MX_ADC_BITS_10
#define MX_EE
#define MX_EE_TYPE2
#define MX_EE_SIZE 256
#define MX_SPI_1
#define MX_SPI_1_MISO_PORT portc
#define MX_SPI_1_MISO_TRIS trisc
#define MX_SPI_1_MISO_PIN 4
#define MX_SPI_1_MOSI_PORT portc
#define MX_SPI_1_MOSI_TRIS trisc
#define MX_SPI_1_MOSI_PIN 5
#define MX_SPI_1_CLK_PORT portc
#define MX_SPI_1_CLK_TRIS trisc
#define MX_SPI_1_CLK_PIN 3
#define MX_SPI_1_SS_PORT portc
#define MX_SPI_1_SS_TRIS trisc
#define MX_UART_1
#define MX_UART_1_TX_PORT portc
#define MX_UART_1_TX_TRIS trisc
#define MX_UART_1_TX_PIN 6
#define MX_UART_1_RX_PORT portc
#define MX_UART_1_RX_TRIS trisc
#define MX_UART_1_RX_PIN 7
#define MX_I2C
#define MX_MI2C
#define MX_I2C_1
#define MX_I2C_1_SDA_PORT portc
#define MX_I2C_1_SDA_TRIS trisc
#define MX_I2C_1_SDA_PIN 4
#define MX_I2C_1_SCL_PORT portc
#define MX_I2C_1_SCL_TRIS trisc
#define MX_I2C_1_SCL_PIN 3
#define MX_PWM
#define MX_PWM_CNT 2
#define MX_PWM_PSCA1
#define MX_PWM_PSCA4
#define MX_PWM_PSCA16
#define MX_PWM_1_PORT portc
#define MX_PWM_1_TRIS trisc
#define MX_PWM_1_PIN 2
#define MX_PWM_2_PORT portc
#define MX_PWM_2_TRIS trisc
#define MX_PWM_2_PIN 1

//Functions
#define MX_CLK_SPEED 8000000
#ifdef _BOOSTC
#include <system.h>
#endif
#ifdef HI_TECH_C
#include <pic.h>
#endif

//Configuration data
#ifdef _BOOSTC
#pragma DATA 0x2007, 0x21c1
#endif
#ifdef HI_TECH_C
__CONFIG(0x21c1);
#endif
#ifdef _BOOSTC
#pragma DATA 0x2008, 0x3fff
#endif
#ifdef HI_TECH_C
__CONFIG(0x3fff);
#endif

//Internal functions
#include "C:\Program Files (x86)\Flowcode\v5\FCD\internals.c"

//Macro function declarations


//Variable declarations
#define FCV_FALSE (0)
#define FCV_TRUE (1)




//LED(0): //Defines:

/**** Macro Substitutions ****
a = Unique Reference
b = LED Port Letter
c = LED Pin Number
d = LED Active Polarity
******************************/

#define LED_1__LED_PORT		portd
#define LED_1__LED_TRIS		trisd
#define LED_1__LED_PIN		1
#define LED_1__LED_POLE		1




//LED(0): //Macro function declarations

void FCD_LED0_LEDOn();
void FCD_LED0_LEDOff();



//LED(0): //Macro implementations


void FCD_LED0_LEDOn()
{
	
		#if( LED_1__LED_POLE == 1)									//Active high polarity
			FC_CAL_Bit_High_DDR( LED_1__LED_PORT , LED_1__LED_TRIS , LED_1__LED_PIN );
		#else													//Active low polarity
			FC_CAL_Bit_Low_DDR( LED_1__LED_PORT , LED_1__LED_TRIS , LED_1__LED_PIN );
		#endif

}

void FCD_LED0_LEDOff()
{
	
		#if( LED_1__LED_POLE == 1)									//Active high polarity
			FC_CAL_Bit_Low_DDR( LED_1__LED_PORT	, LED_1__LED_TRIS , LED_1__LED_PIN );
		#else													//Active low polarity
			FC_CAL_Bit_High_DDR( LED_1__LED_PORT , LED_1__LED_TRIS , LED_1__LED_PIN );
		#endif

}

#include "C:\Program Files (x86)\Flowcode\v5\CAL\includes.c"

//Macro implementations



void main()
{
	//Initialization
	ansel = 0;
anselh = 0;


	//Interrupt initialization code
	option_reg = 0xC0;


	//Comment:
	//Using IO icons

	//Clear Port D
	//Output: 0 -> PORTD
	trisd = 0x00;
	portd = (0);

	//Light an LED (D1)
	//Output: 1 -> PORTD
	trisd = trisd & 0xFD;
	portd = (portd & 0xFD) | ((1) & 0x02);

	//Delay
	//Delay: 1 s
	delay_s(1);

	//Comment:
	//Using component macros

	//Call Component Macro
	//Call Component Macro: LEDOff()
	FCD_LED0_LEDOff();

	//Delay
	//Delay: 1 s
	delay_s(1);

	//Call Component Macro
	//Call Component Macro: LEDOn()
	FCD_LED0_LEDOn();

	mainendloop: goto mainendloop;
}

void MX_INTERRUPT_MACRO(void)
{
}



