/*********************************************************************
 *                    Flowcode Custom Component Code
 *
 * File: PIC_Custom.c
 *
 * (c) 2009 Matrix Multimedia Ltd.
 * http://www.matrixmultimedia.com
 *
 * Software License Agreement
 *
 * The software supplied herewith by Matrix Multimedia Ltd (the
 * “Company”) for its Flowcode graphical programming language is
 * intended and supplied to you, the Company’s customer, for use
 * solely and exclusively on the Company's products. The software
 * is owned by the Company, and is protected under applicable
 * copyright laws. All rights are reserved. Any use in violation
 * of the foregoing restrictions may subject the user to criminal
 * sanctions under applicable laws, as well as to civil liability
 * for the breach of the terms and conditions of this licence.
 *
 * THIS SOFTWARE IS PROVIDED IN AN “AS IS” CONDITION. NO WARRANTIES,
 * WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED
 * TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
 * PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE COMPANY SHALL NOT,
 * IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR
 * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
 *
 * Changelog:
 *
 *  date  | by | description
 * -------+----+-----------------------------------------------------
 * 240407 | ST | Created
 * 111111 | ST | Made much simpler
 *        |    |
 *        |    |
 *        |    |
 *        |    |
 ********************************************************************/

/*********************************************************************

 Return & parameter types:
   void
   char
   short
   char*

 Pin directions:
   0 = OUTPUT
   2 = INPUT
   3 = BIDIRECTIONAL

**********************************************************************

[Settings]
CLSID={DA77448F-7831-4F3E-969E-6AE4EE551B6F}
IsAnalogue=0
MultipleAllowed=0
Description=Custom Flowcode Component

**********************************************************************

[Port]
DesiredPort=0
PortMandatory=0
SamePortAsID=0

[Pins]
Count=0

[PinPort]
# PORTA = 0
# PORTB = 1
# PORTC = 2
# PORTD = 3
# PORTE = 4

[PinDesiredBit]

[PinDirection]
# DIR_INPUT = 2
# DIR_OUTPUT = 0
# DIR_BIDIRECTIONAL = 3

[PinMustUsePort]
# boolean

[SamePortAsPinX]
# -1 = any pin
# otherwise, the pin number

[PinMustUsePin]
# boolean

[PinValue]
# boolean (0 = off, 1 = on)

**********************************************************************

[MacroNames]
Count=1
1=LCD_Writ_Bus



[MacroReturns]
1=void




[MacroIsPrivate]
1=0




[MacroParameters_LCD_Writ_Bus]
Count=2
1=VH
2=VL

[MacroParamTypes_LCD_Writ_Bus]
1=char
2=char



/*********************************************************************/

/********************************************************************
 * ADDITIONAL CODE
 ********************************************************************/

/*DefinesCode_Start*/

/**** Macro Substitutions ****
a = Port for lower 8 bits of data
b = Port for higher 8 bits of data
c = User Define 3
d = User Define 4
e = User Define 5
f = User Define 6
g = User Define 7
h = User Define 8
i = User Define 9
j = User Define 10
******************************/

//common defines
#define MX_PORT1 	portb
#define MX_TRIS1  	trisb
#define MX_PORT2  	portc
#define MX_TRIS2  	trisc
#define MX_CONTROL  	porta
#define MX_CONTROL_TRIS trisa
#define MX_RS 	 	0
#define MX_CS  		1
#define MX_WR  		2
#define MX_RST 		3


/*DefinesCode_End*/

/*InitialisationCode_Start*/

MX_TRIS1 = 0;
MX_TRIS2 = 0;
MX_CONTROL_TRIS = 0;

fcolorr=0;
fcolorg=0;
fcolorb=0;

bcolorr=255;
bcolorg=255;
bcolorb=255;



/*InitialisationCode_End*/

/*InterruptCode_Start*/
/*InterruptCode_End*/

/********************************************************************
 * FUNCTIONS
 ********************************************************************/

vvoid LCD_Writ_Bus(char VH, char VL)
{ 
/*Macro_LCD_Writ_Bus_Start*/
   

	MX_PORT1 = VH;
	MX_PORT2 = VL;

	FC_CAL_Bit_Low(MX_CONTROL, MX_WR);			
	FC_CAL_Bit_High(MX_CONTROL, MX_WR);			

/*Macro_LCD_Writ_Bus_End*/
}



