<root>
<document schema='101' license='50,Dev User,XDKHX7' title='' description='' target='PIC16.33E.33EP256MU806' >
	<config data='!0,ffff!10,ffff!20,ffbf!30,ffff!40,ffff!50,ffff!60,ffff%0,1%1,1%4,3%10,7%17,1%20,3%22,1%25,1%26,2%30,f%34,1%35,1%36,1%37,1%40,7%43,1%44,1%50,3%52,1%55,1%60,1%61,1%64,3' clkspd='12000000' simspd='1' usewdt='0' constif='0' />
	<plugins >
		<dll_dbg_icd enabled='0' >
			<data name='debug' value='1' />
			<data name='userpins' value='0' />
			<data name='speed' value='0' />
			<data name='usev9' value='0' />
			<data name='breaks' value='8' />
			<data name='stacks' value='8' />
			<data name='clkport' value='1' />
			<data name='clkbit' value='6' />
			<data name='dataport' value='1' />
			<data name='databit' value='7' />
			<data name='monitor' value='1' />
			<data name='ictloop' value='0' />
			<data name='ictrate' value='20000' />
			<data name='ictmask' value='0' />
		</dll_dbg_icd>
		<dll_models enabled='1' />
		<dll_upgrader enabled='1' />
		<dll_webhelp enabled='1' />
	</plugins>
	<supplement use='0' head='' body='' />
	<debug />
	<components >
		<settings autoimg='1' center='1' unitscale='0' fixedscale='0' fixedx='1' fixedy='1' fixedz='1' headcode='0' />
		<definition guid='ccffdd71-4fab-4d02-8e00-4fbaad5bbce8' vstate='40' vmin='0' vmaj='1' srcleaf='' visiblename='FTDI (FT800)' description='The FT800 provides a powerful feature set in a small package to create dynamic HMI interfaces.
The device supports line by line graphics rendering to 1/16 of a pixel on displays with resolution up to 512 x 512 with 262K colours.
The chip includes a touch controller for sensing touch feedback from a TFT display with a resistive touch panel as well as a sound synthesizer and audio playback with a PWM output to drive a speaker.' category='Misc' catenable='1' author='MatrixTSL' manuname='FTDI' manucode='FT800' sysinfo='0' keywords='FTDI|USB|FT800|gLCD' dynamic='0' iconpath='' />
		<component class_type='root' codename='panel' x='0' y='0' z='0' xsz='1' ysz='1' zsz='1' xang='0' yang='0' zang='0' xquat='0' yquat='0' zquat='0' wquat='1' visible='1' interactive='1' solid='1' layer='0' poslock='0' >
			<resources />
			<properties >
				<property name='CS Pin' target='CSPin' typeid='5' hidden='0' locked='0' info='' />
				<property name='Power Pin' target='PwrPin' typeid='5' hidden='0' locked='0' info='' />
				<property name='Width' target='Width' typeid='21' hidden='0' locked='0' info='Active width of LCD display' />
				<property name='Height' target='Height' typeid='21' hidden='0' locked='0' info='Active height of LCD display' />
				<property name='HCycle' target='HCycle' typeid='21' hidden='0' locked='0' info='Total number of clocks per line' />
				<property name='HOffset' target='HOffset' typeid='21' hidden='0' locked='0' info='Start of active line' />
				<property name='HSync0' target='HSync0' typeid='21' hidden='0' locked='0' info='Start of horizontal sync pulse' />
				<property name='HSync1' target='HSync1' typeid='21' hidden='0' locked='0' info='End of horizontal sync pulse' />
				<property name='VCycle' target='VCycle' typeid='21' hidden='0' locked='0' info='Total number of lines per screen' />
				<property name='VOffset' target='VOffset' typeid='21' hidden='0' locked='0' info='Start of active screen' />
				<property name='VSync0' target='VSync0' typeid='21' hidden='0' locked='0' info='Start of vertical sync pulse' />
				<property name='VSync1' target='VSync1' typeid='21' hidden='0' locked='0' info='End of vertical sync pulse' />
				<property name='PixelClock' target='PixelClock' typeid='21' hidden='0' locked='0' info='Pixel Clock
' />
				<property name='Swizzle' target='Swizzle' typeid='21' hidden='0' locked='0' info=' Define RGB output pins' />
				<property name='Clock Polarity' target='ClkPol' typeid='21' hidden='0' locked='0' info='Define active edge of PCLK
' />
			</properties>
			<values >
				<value target='CSPin' data='' />
				<value target='PwrPin' data='' />
				<value target='Width' data='320' />
				<value target='Height' data='240' />
				<value target='HCycle' data='408' />
				<value target='HOffset' data='70' />
				<value target='HSync0' data='0' />
				<value target='HSync1' data='10' />
				<value target='VCycle' data='263' />
				<value target='VOffset' data='13' />
				<value target='VSync0' data='0' />
				<value target='VSync1' data='2' />
				<value target='PixelClock' data='8' />
				<value target='Swizzle' data='2' />
				<value target='ClkPol' data='0' />
			</values>
			<events />
			<apis />
			<variables >
				<variable public='0' >
					<def class_type='variable' name='FT800_CORERST' type='s16' description='Reset core - all registers default' isconst='1' isinit='1' usrinit='104' setinit='0x68' />
				</variable>
				<variable public='0' >
					<def class_type='variable' name='PointY' type='u32' description='' isconst='0' isinit='1' usrinit='2176' setinit='136 * 16' />
				</variable>
				<variable public='0' >
					<def class_type='variable' name='BLACK' type='s16' description='' isconst='1' isinit='1' usrinit='0' setinit='0x000000' />
				</variable>
				<variable public='0' >
					<def class_type='variable' name='PointX' type='u32' description='' isconst='0' isinit='1' usrinit='1536' setinit='96 * 16' />
				</variable>
				<variable public='0' >
					<def class_type='variable' name='RED' type='s32' description='' isconst='1' isinit='1' usrinit='16711680' setinit='0xFF0000' />
				</variable>
				<variable public='0' >
					<def class_type='variable' name='ramDisplayList' type='u32' description='Set beginning of display list memory' isconst='0' isinit='1' usrinit='1048576' setinit='0x100000' />
				</variable>
				<variable public='0' >
					<def class_type='variable' name='FT800_CLK48M' type='s16' description='Select 48MHz PLL' isconst='1' isinit='1' usrinit='98' setinit='0x62' />
				</variable>
				<variable public='0' >
					<def class_type='variable' name='BLUE' type='s16' description='' isconst='1' isinit='1' usrinit='255' setinit='0x0000FF' />
				</variable>
				<variable public='0' >
					<def class_type='variable' name='false' type='b1' description='' isconst='1' isinit='1' usrinit='0' setinit='0' />
				</variable>
				<variable public='0' >
					<def class_type='variable' name='MEM_READ' type='s16' description='FT800 Host Memory Read' isconst='1' isinit='1' usrinit='0' setinit='0x00' />
				</variable>
				<variable public='0' >
					<def class_type='variable' name='MEM_WRITE' type='s16' description='FT800 Host Memory Write' isconst='1' isinit='1' usrinit='128' setinit='0x80' />
				</variable>
				<variable public='0' >
					<def class_type='variable' name='GREEN' type='s32' description='' isconst='1' isinit='1' usrinit='65280' setinit='0x00FF00' />
				</variable>
				<variable public='0' >
					<def class_type='variable' name='PointSize' type='u16' description='Default Dot Size' isconst='0' isinit='1' usrinit='256' setinit='0x100' />
				</variable>
				<variable public='0' >
					<def class_type='variable' name='FT800_CLK36M' type='s16' description='Select 36MHz PLL' isconst='1' isinit='1' usrinit='97' setinit='0x61' />
				</variable>
				<variable public='0' >
					<def class_type='variable' name='FT800_PWRDOWN' type='s16' description='Place FT800 in Power Down (core off)' isconst='1' isinit='1' usrinit='80' setinit='0x50' />
				</variable>
				<variable public='0' >
					<def class_type='variable' name='FT800_SLEEP' type='s16' description='Place FT800 in Sleep (clk off)' isconst='1' isinit='1' usrinit='66' setinit='0x42' />
				</variable>
				<variable public='0' >
					<def class_type='variable' name='FT800_ACTIVE' type='s16' description='Initializes FT800' isconst='1' isinit='1' usrinit='0' setinit='0x00' />
				</variable>
				<variable public='0' >
					<def class_type='variable' name='FT800_STANDBY' type='s16' description='Place FT800 in Standby (clk running)' isconst='1' isinit='1' usrinit='65' setinit='0x41' />
				</variable>
				<variable public='0' >
					<def class_type='variable' name='FT800_CLKEXT' type='s16' description='Select external clock source' isconst='1' isinit='1' usrinit='68' setinit='0x44' />
				</variable>
				<variable public='0' >
					<def class_type='variable' name='Colour' type='u32' description='' isconst='0' isinit='0' usrinit='0' setinit='' />
				</variable>
				<variable public='0' >
					<def class_type='variable' name='WHITE' type='s32' description='' isconst='1' isinit='1' usrinit='16777215' setinit='0xFFFFFF' />
				</variable>
				<variable public='0' >
					<def class_type='variable' name='true' type='b1' description='' isconst='1' isinit='1' usrinit='1' setinit='1' />
				</variable>
			</variables>
			<macros >
				<macro >
					<flowline name='IncrementCommandOffset' description='Adds commandSize to the currentOffset.
Checks for 4K ring-buffer offset roll-over 
' >
						<return name='Return' type='u16' description='' isconst='0' isinit='0' usrinit='0' setinit='' />
						<param name='currentOffset' type='u16' description='graphics processor command list pointer' isconst='0' isinit='0' usrinit='0' setinit='' />
						<param name='commandSize' type='u8' description='number of bytes to increment the offset' isconst='0' isinit='0' usrinit='0' setinit='' />
						<command class_type='calculation' title='Calculate Address' >
							<exp exp='.Return = .currentOffset + .commandSize' />
						</command>
						<command class_type='decision' title='Check for address rollover' exp='.Return &gt; 4095' swap='0' >
							<flowline >
								<command class_type='calculation' title='Roll over pointer' >
									<exp exp='.Return = .Return - 4096' />
								</command>
							</flowline>
							<flowline />
						</command>
					</flowline>
				</macro>
				<macro >
					<flowline name='MemRead16' description='Reads a single unsigned int from the FT800 internal address space' >
						<return name='Return' type='u16' description='' isconst='0' isinit='0' usrinit='0' setinit='' />
						<param name='Address' type='u32' description='' isconst='0' isinit='0' usrinit='0' setinit='' />
						<local name='low' type='u8' description='' isconst='0' isinit='0' usrinit='0' setinit='' />
						<local name='med' type='u8' description='' isconst='0' isinit='0' usrinit='0' setinit='' />
						<local name='high' type='u8' description='' isconst='0' isinit='0' usrinit='0' setinit='' />
						<command class_type='calculation' title='Work out address bytes' >
							<exp exp='.low = .Address &amp; 0xFF' />
							<exp exp='.med = .Address &gt;&gt; 8' />
							<exp exp='.high = .Address / 65536' />
							<exp exp='.high = .high | MEM_READ' />
						</command>
						<command class_type='calculation' title='CS Low - Device Enable' >
							<exp exp='CSPin = 0' />
						</command>
						<command class_type='call' title='Send Address Byte' component='cal_spi1' macro='Master_Byte' >
							<argument exp='.high' />
						</command>
						<command class_type='call' title='Send Address Byte' component='cal_spi1' macro='Master_Byte' >
							<argument exp='.med' />
						</command>
						<command class_type='call' title='Send Address Byte' component='cal_spi1' macro='Master_Byte' >
							<argument exp='.low' />
						</command>
						<command class_type='call' title='Dummy Byte' component='cal_spi1' macro='Master_Byte' >
							<argument exp='0' />
						</command>
						<command class_type='call' title='Read Data Byte' component='cal_spi1' macro='Master_Byte' >
							<return exp='.Return' />
							<argument exp='0' />
						</command>
						<command class_type='call' title='Read Data Byte' component='cal_spi1' macro='Master_Byte' >
							<return exp='.low' />
							<argument exp='0' />
						</command>
						<command class_type='calculation' title='Combine Data Bytes' >
							<exp exp='.Return = .Return | (.Low &lt;&lt; 8)' />
						</command>
						<command class_type='calculation' title='CS High - Device Disable - Process CMD' >
							<exp exp='CSPin = 1' />
						</command>
					</flowline>
				</macro>
				<macro >
					<flowline name='MemRead8' description='Reads a single data byte from the FT800 internal address space' >
						<return name='Return' type='u8' description='' isconst='0' isinit='0' usrinit='0' setinit='' />
						<param name='Address' type='u32' description='' isconst='0' isinit='0' usrinit='0' setinit='' />
						<local name='low' type='u8' description='' isconst='0' isinit='0' usrinit='0' setinit='' />
						<local name='med' type='u8' description='' isconst='0' isinit='0' usrinit='0' setinit='' />
						<local name='high' type='u8' description='' isconst='0' isinit='0' usrinit='0' setinit='' />
						<command class_type='calculation' title='Work out address bytes' >
							<exp exp='.Low = .Address &amp; 0xFF' />
							<exp exp='.Med = .Address &gt;&gt; 8' />
							<exp exp='.High = .Address / 65536' />
							<exp exp='.High = .High | MEM_READ' />
						</command>
						<command class_type='calculation' title='CS Low - Device Enable' >
							<exp exp='CSPin = 0' />
						</command>
						<command class_type='call' title='Send Address Byte' component='cal_spi1' macro='Master_Byte' >
							<argument exp='.High' />
						</command>
						<command class_type='call' title='Send Address Byte' component='cal_spi1' macro='Master_Byte' >
							<argument exp='.Med' />
						</command>
						<command class_type='call' title='Send Address Byte' component='cal_spi1' macro='Master_Byte' >
							<argument exp='.Low' />
						</command>
						<command class_type='call' title='Dummy Byte' component='cal_spi1' macro='Master_Byte' >
							<argument exp='0' />
						</command>
						<command class_type='call' title='Read Data Byte' component='cal_spi1' macro='Master_Byte' >
							<return exp='.Return' />
							<argument exp='0' />
						</command>
						<command class_type='calculation' title='CS High - Device Disable - Process CMD' >
							<exp exp='CSPin = 1' />
						</command>
					</flowline>
				</macro>
				<macro >
					<flowline name='MemRead32' description='Reads a single unsigned long from the FT800 internal address space' >
						<return name='Return' type='u32' description='' isconst='0' isinit='0' usrinit='0' setinit='' />
						<param name='Address' type='u32' description='' isconst='0' isinit='0' usrinit='0' setinit='' />
						<local name='low' type='u8' description='' isconst='0' isinit='0' usrinit='0' setinit='' />
						<local name='med' type='u8' description='' isconst='0' isinit='0' usrinit='0' setinit='' />
						<local name='high' type='u8' description='' isconst='0' isinit='0' usrinit='0' setinit='' />
						<command class_type='calculation' title='Work out address bytes' >
							<exp exp='.low = .Address &amp; 0xFF' />
							<exp exp='.med = .Address &gt;&gt; 8' />
							<exp exp='.high = .Address / 65536' />
							<exp exp='.high = .high | MEM_READ' />
						</command>
						<command class_type='calculation' title='CS Low - Device Enable' >
							<exp exp='CSPin = 0' />
						</command>
						<command class_type='call' title='Send Address Byte' component='cal_spi1' macro='Master_Byte' >
							<argument exp='.high' />
						</command>
						<command class_type='call' title='Send Address Byte' component='cal_spi1' macro='Master_Byte' >
							<argument exp='.med' />
						</command>
						<command class_type='call' title='Send Address Byte' component='cal_spi1' macro='Master_Byte' >
							<argument exp='.low' />
						</command>
						<command class_type='call' title='Dummy Byte' component='cal_spi1' macro='Master_Byte' >
							<argument exp='0' />
						</command>
						<command class_type='call' title='Read Data Byte' component='cal_spi1' macro='Master_Byte' >
							<return exp='.Return' />
							<argument exp='0' />
						</command>
						<command class_type='call' title='Read Data Byte' component='cal_spi1' macro='Master_Byte' >
							<return exp='.low' />
							<argument exp='0' />
						</command>
						<command class_type='call' title='Read Data Byte' component='cal_spi1' macro='Master_Byte' >
							<return exp='.med' />
							<argument exp='0' />
						</command>
						<command class_type='call' title='Read Data Byte' component='cal_spi1' macro='Master_Byte' >
							<return exp='.high' />
							<argument exp='0' />
						</command>
						<command class_type='calculation' title='CS High - Device Disable - Process CMD' >
							<exp exp='CSPin = 1' />
						</command>
						<command class_type='calculation' title='Combine Data Bytes' >
							<exp exp='.Return = .Return | (.low &lt;&lt; 8)' />
							<exp exp='.Return = .Return + (.med * 65536)' />
							<exp exp='.Return = .Return + (.high * 16777216)' />
						</command>
					</flowline>
				</macro>
				<macro >
					<flowline name='MemWrite16' description='Writes a unsigned int value to the FT800 internal address space' >
						<param name='Address' type='u32' description='' isconst='0' isinit='0' usrinit='0' setinit='' />
						<param name='Data' type='u16' description='' isconst='0' isinit='0' usrinit='0' setinit='' />
						<local name='Low' type='u8' description='' isconst='0' isinit='0' usrinit='0' setinit='' />
						<local name='Med' type='u8' description='' isconst='0' isinit='0' usrinit='0' setinit='' />
						<local name='High' type='u8' description='' isconst='0' isinit='0' usrinit='0' setinit='' />
						<command class_type='calculation' title='Work out address bytes' >
							<exp exp='.Low = .Address &amp; 0xFF' />
							<exp exp='.Med = .Address &gt;&gt; 8' />
							<exp exp='.High = .Address / 65536' />
							<exp exp='.High = .High | MEM_WRITE' />
						</command>
						<command class_type='calculation' title='CS Low - Device Enable' >
							<exp exp='CSPin = 0' />
						</command>
						<command class_type='call' title='Send Address Byte' component='cal_spi1' macro='Master_Byte' >
							<argument exp='.High' />
						</command>
						<command class_type='call' title='Send Address Byte' component='cal_spi1' macro='Master_Byte' >
							<argument exp='.Med' />
						</command>
						<command class_type='call' title='Send Address Byte' component='cal_spi1' macro='Master_Byte' >
							<argument exp='.Low' />
						</command>
						<command class_type='call' title='Send Data Byte' component='cal_spi1' macro='Master_Byte' >
							<argument exp='.Data' />
						</command>
						<command class_type='call' title='Send Data Byte' component='cal_spi1' macro='Master_Byte' >
							<argument exp='.Data &gt;&gt; 8' />
						</command>
						<command class_type='calculation' title='CS High - Device Disable - Process CMD' >
							<exp exp='CSPin = 1' />
						</command>
					</flowline>
				</macro>
				<macro >
					<flowline name='MemWrite8' description='Writes a byte value to the FT800 internal address space' >
						<param name='Address' type='u32' description='' isconst='0' isinit='0' usrinit='0' setinit='' />
						<param name='Data' type='u8' description='' isconst='0' isinit='0' usrinit='0' setinit='' />
						<local name='Low' type='u8' description='' isconst='0' isinit='0' usrinit='0' setinit='' />
						<local name='Med' type='u8' description='' isconst='0' isinit='0' usrinit='0' setinit='' />
						<local name='High' type='u8' description='' isconst='0' isinit='0' usrinit='0' setinit='' />
						<command class_type='calculation' title='Work out address bytes' >
							<exp exp='.Low = .Address &amp; 0xFF' />
							<exp exp='.Med = .Address &gt;&gt; 8' />
							<exp exp='.High = .Address / 65536' />
							<exp exp='.High = .High | MEM_WRITE' />
						</command>
						<command class_type='calculation' title='CS Low - Device Enable' >
							<exp exp='CSPin = 0' />
						</command>
						<command class_type='call' title='Send Address Byte' component='cal_spi1' macro='Master_Byte' >
							<argument exp='.High' />
						</command>
						<command class_type='call' title='Send Address Byte' component='cal_spi1' macro='Master_Byte' >
							<argument exp='.Med' />
						</command>
						<command class_type='call' title='Send Address Byte' component='cal_spi1' macro='Master_Byte' >
							<argument exp='.Low' />
						</command>
						<command class_type='call' title='Send Data Byte' component='cal_spi1' macro='Master_Byte' >
							<argument exp='.Data' />
						</command>
						<command class_type='calculation' title='CS High - Device Disable - Process CMD' >
							<exp exp='CSPin = 1' />
						</command>
					</flowline>
				</macro>
				<macro >
					<flowline name='CommandWrite' description='Sends FT800 command' >
						<param name='Command' type='u8' description='' isconst='0' isinit='0' usrinit='0' setinit='' />
						<command class_type='calculation' title='CS Low - Device Enable' >
							<exp exp='CSPin = 0' />
						</command>
						<command class_type='call' title='Send command' component='cal_spi1' macro='Master_Byte' >
							<argument exp='.Command' />
						</command>
						<command class_type='call' title='Command needs two or more 0&apos;s' component='cal_spi1' macro='Master_Byte' >
							<argument exp='0' />
						</command>
						<command class_type='call' title='Command needs two or more 0&apos;s' component='cal_spi1' macro='Master_Byte' >
							<argument exp='0' />
						</command>
						<command class_type='calculation' title='CS High - Device Disable - Process CMD' >
							<exp exp='CSPin = 1' />
						</command>
					</flowline>
				</macro>
				<macro >
					<flowline name='Loop' description='Repetitive activities - Draw a dot on the LCD
Continually change colors from white to red and back' >
						<local name='BuffRd' type='u16' description='' isconst='0' isinit='0' usrinit='0' setinit='' />
						<local name='BuffWr' type='u16' description='' isconst='0' isinit='0' usrinit='0' setinit='' />
						<local name='CmdOffset' type='u16' description='' isconst='0' isinit='0' usrinit='0' setinit='' />
						<command class_type='loop' title='Loop' type='0' exp='.BuffWr != .BuffRd' start='0' >
							<flowline >
								<command class_type='call' title='Call Macro' macro='MemRead16' >
									<return exp='.BuffRd' />
									<argument exp='0x1024e4' />
								</command>
								<command class_type='call' title='Call Macro' macro='MemRead16' >
									<return exp='.BuffWr' />
									<argument exp='0x1024e8' />
								</command>
							</flowline>
						</command>
						<command class_type='calculation' title='Calculation' >
							<exp exp='.CmdOffset = .BuffWr' />
						</command>
						<command class_type='decision' title='Decision' exp='Colour != WHITE' swap='0' >
							<flowline >
								<command class_type='calculation' title='Calculation' >
									<exp exp='Colour = WHITE' />
								</command>
							</flowline>
							<flowline >
								<command class_type='calculation' title='Calculation' >
									<exp exp='Colour = RED' />
								</command>
							</flowline>
						</command>
						<command class_type='call' title='Start the display list' macro='MemWrite32' >
							<argument exp='0x108000 + .CmdOffset' />
							<argument exp='0xffffff00' />
						</command>
						<command class_type='call' title='Update the command pointer' macro='IncrementCommandOffset' >
							<return exp='.CmdOffset' />
							<argument exp='.CmdOffset' />
							<argument exp='4' />
						</command>
						<command class_type='call' title='Set the default clear color to black' macro='MemWrite32' >
							<argument exp='0x108000 + .CmdOffset' />
							<argument exp='0x02000000 | BLACK' />
						</command>
						<command class_type='call' title='Update the command pointer' macro='IncrementCommandOffset' >
							<return exp='.CmdOffset' />
							<argument exp='.CmdOffset' />
							<argument exp='4' />
						</command>
						<command class_type='call' title='Clear the screen - this and the previous prevent artifacts' macro='MemWrite32' >
							<argument exp='0x108000 + .CmdOffset' />
							<argument exp='0x26000007' />
						</command>
						<command class_type='call' title='Update the command pointer' macro='IncrementCommandOffset' >
							<return exp='.CmdOffset' />
							<argument exp='.CmdOffset' />
							<argument exp='4' />
						</command>
						<command class_type='call' title='Set the color of the following item' macro='MemWrite32' >
							<argument exp='0x108000 + .CmdOffset' />
							<argument exp='0x04000000 | Colour' />
						</command>
						<command class_type='call' title='Update the command pointer' macro='IncrementCommandOffset' >
							<return exp='.CmdOffset' />
							<argument exp='.CmdOffset' />
							<argument exp='4' />
						</command>
						<command class_type='call' title='Select the size of the dot to draw' macro='MemWrite32' >
							<argument exp='0x108000 + .CmdOffset' />
							<argument exp='0x0D000000 | PointSize' />
						</command>
						<command class_type='call' title='Update the command pointer' macro='IncrementCommandOffset' >
							<return exp='.CmdOffset' />
							<argument exp='.CmdOffset' />
							<argument exp='4' />
						</command>
						<command class_type='call' title='Indicate to draw a point (dot)' macro='MemWrite32' >
							<argument exp='0x108000 + .CmdOffset' />
							<argument exp='0x1F000000 | 2' />
						</command>
						<command class_type='call' title='Update the command pointer' macro='IncrementCommandOffset' >
							<return exp='.CmdOffset' />
							<argument exp='.CmdOffset' />
							<argument exp='4' />
						</command>
						<command class_type='call' title='Set the point center location' macro='MemWrite32' >
							<argument exp='0x108000 + .CmdOffset' />
							<argument exp='0x40000000 | (PointX &lt;&lt; 15) | PointY' />
						</command>
						<command class_type='call' title='Update the command pointer' macro='IncrementCommandOffset' >
							<return exp='.CmdOffset' />
							<argument exp='.CmdOffset' />
							<argument exp='4' />
						</command>
						<command class_type='call' title='End the point' macro='MemWrite32' >
							<argument exp='0x108000 + .CmdOffset' />
							<argument exp='0x21000000' />
						</command>
						<command class_type='call' title='Update the command pointer' macro='IncrementCommandOffset' >
							<return exp='.CmdOffset' />
							<argument exp='.CmdOffset' />
							<argument exp='4' />
						</command>
						<command class_type='call' title='Instruct the graphics processor to show the list' macro='MemWrite32' >
							<argument exp='0x108000 + .CmdOffset' />
							<argument exp='0x00000000' />
						</command>
						<command class_type='call' title='Update the command pointer' macro='IncrementCommandOffset' >
							<return exp='.CmdOffset' />
							<argument exp='.CmdOffset' />
							<argument exp='4' />
						</command>
						<command class_type='call' title='Make this list active' macro='MemWrite32' >
							<argument exp='0x108000 + .CmdOffset' />
							<argument exp='0xffffff01' />
						</command>
						<command class_type='call' title='Update the command pointer' macro='IncrementCommandOffset' >
							<return exp='.CmdOffset' />
							<argument exp='.CmdOffset' />
							<argument exp='4' />
						</command>
						<command class_type='call' title='Update the ring buffer pointer' macro='MemWrite16' >
							<argument exp='0x1024e8' />
							<argument exp='.CmdOffset' />
						</command>
						<command class_type='delay' title='Wait a half-second to observe the changing color' exp='500' type='1' />
					</flowline>
				</macro>
				<macro >
					<flowline name='Main' description='' >
						<command class_type='call' title='Call Macro' macro='Initialise' />
						<command class_type='loop' title='Loop' type='0' exp='1' >
							<flowline >
								<command class_type='call' title='Call Macro' macro='Loop' />
							</flowline>
						</command>
					</flowline>
				</macro>
				<macro >
					<flowline name='MemWrite32' description='Writes a unsigned long value to the FT800 internal address space' >
						<param name='Address' type='u32' description='' isconst='0' isinit='0' usrinit='0' setinit='' />
						<param name='Data' type='u32' description='' isconst='0' isinit='0' usrinit='0' setinit='' />
						<local name='Low' type='u8' description='' isconst='0' isinit='0' usrinit='0' setinit='' />
						<local name='Med' type='u8' description='' isconst='0' isinit='0' usrinit='0' setinit='' />
						<local name='High' type='u8' description='' isconst='0' isinit='0' usrinit='0' setinit='' />
						<local name='DatH' type='u8' description='' isconst='0' isinit='0' usrinit='0' setinit='' />
						<local name='DatH2' type='u8' description='' isconst='0' isinit='0' usrinit='0' setinit='' />
						<command class_type='calculation' title='Work out address bytes' >
							<exp exp='.Low = .Address &amp; 0xFF' />
							<exp exp='.Med = .Address &gt;&gt; 8' />
							<exp exp='.High = .Address / 65536' />
							<exp exp='.High = .High | MEM_WRITE' />
							<exp exp='' />
							<exp exp='.DatH = .Data / 65536' />
							<exp exp='.DatH2 = .Data / 16777216' />
						</command>
						<command class_type='calculation' title='CS Low - Device Enable' >
							<exp exp='CSPin = 0' />
						</command>
						<command class_type='call' title='Send Address Byte' component='cal_spi1' macro='Master_Byte' >
							<argument exp='.High' />
						</command>
						<command class_type='call' title='Send Address Byte' component='cal_spi1' macro='Master_Byte' >
							<argument exp='.Med' />
						</command>
						<command class_type='call' title='Send Address Byte' component='cal_spi1' macro='Master_Byte' >
							<argument exp='.Low' />
						</command>
						<command class_type='call' title='Send Data Byte' component='cal_spi1' macro='Master_Byte' >
							<argument exp='.Data' />
						</command>
						<command class_type='call' title='Send Data Byte' component='cal_spi1' macro='Master_Byte' >
							<argument exp='.Data &gt;&gt; 8' />
						</command>
						<command class_type='call' title='Send Data Byte' component='cal_spi1' macro='Master_Byte' >
							<argument exp='.DatH' />
						</command>
						<command class_type='call' title='Send Data Byte' component='cal_spi1' macro='Master_Byte' >
							<argument exp='.DatH2' />
						</command>
						<command class_type='calculation' title='CS High - Device Disable - Process CMD' >
							<exp exp='CSPin = 1' />
						</command>
					</flowline>
				</macro>
				<macro >
					<flowline name='Initialise' description='System initialization routines.  Executed once on reset.
Returns 0 if device not detected or 1 if device is correctly initialised.' >
						<return name='Return' type='u8' description='' isconst='0' isinit='0' usrinit='0' setinit='' />
						<local name='RetVal' type='u8' description='' isconst='0' isinit='0' usrinit='0' setinit='' />
						<local name='duty' type='u8' description='' isconst='0' isinit='0' usrinit='0' setinit='' />
						<command class_type='calculation' title='Enable Power Pin' >
							<exp exp='PwrPin = 1' />
						</command>
						<command class_type='calculation' title='Disable SPI Device' >
							<exp exp='CSPin = 1' />
						</command>
						<command class_type='call' title='Startup SPI' component='cal_spi1' macro='Master_Init' />
						<command class_type='delay' title='Delay' exp='20' type='1' />
						<command class_type='calculation' title='Disable Power Pin' >
							<exp exp='PwrPin = 0' />
						</command>
						<command class_type='delay' title='Delay' exp='20' type='1' />
						<command class_type='calculation' title='Enable Power Pin' >
							<exp exp='PwrPin = 1' />
						</command>
						<command class_type='delay' title='Delay' exp='20' type='1' />
						<command class_type='call' title='Start FT800' macro='CommandWrite' >
							<argument exp='FT800_ACTIVE' />
						</command>
						<command class_type='delay' title='Delay' exp='5' type='1' />
						<command class_type='call' title='Set FT800 for external clock' macro='CommandWrite' >
							<argument exp='FT800_CLKEXT' />
						</command>
						<command class_type='delay' title='Delay' exp='5' type='1' />
						<command class_type='call' title='Set FT800 for 48MHz PLL' macro='CommandWrite' >
							<argument exp='FT800_CLK48M' />
						</command>
						<command class_type='delay' title='Delay' exp='5' type='1' />
						<command class_type='call' title='Read ID register' macro='MemRead8' >
							<return exp='.RetVal' />
							<argument exp='0x102400' />
						</command>
						<command class_type='decision' title='Read ID register - is it 0x7C?' exp='.RetVal != 0x7C' swap='0' >
							<flowline >
								<command class_type='calculation' title='Calculation' >
									<exp exp='.Return = 0' />
								</command>
								<command class_type='goto' title='Goto Connection Point' labelid='0' labelname='' />
							</flowline>
							<flowline />
						</command>
						<command class_type='call' title='Set PCLK to zero - don&apos;t clock the LCD until later' macro='MemWrite8' >
							<argument exp='0x10246c' />
							<argument exp='0' />
						</command>
						<command class_type='call' title='Turn off backlight' macro='MemWrite8' >
							<argument exp='0x1024c4' />
							<argument exp='0' />
						</command>
						<command class_type='comment' title='' comment='Initialise Display
' textarea='12,0,12,0' />
						<command class_type='call' title='Active display width' macro='MemWrite16' >
							<argument exp='0x102430' />
							<argument exp='Width' />
						</command>
						<command class_type='call' title='total number of clocks per line, incl front/back porch' macro='MemWrite16' >
							<argument exp='0x102428' />
							<argument exp='HCycle' />
						</command>
						<command class_type='call' title='start of active line' macro='MemWrite16' >
							<argument exp='0x10242c' />
							<argument exp='HOffset' />
						</command>
						<command class_type='call' title='start of horizontal sync pulse' macro='MemWrite16' >
							<argument exp='0x102434' />
							<argument exp='HSync0' />
						</command>
						<command class_type='call' title='End of horizontal sync pulse' macro='MemWrite16' >
							<argument exp='0x102438' />
							<argument exp='HSync1' />
						</command>
						<command class_type='call' title='active display height' macro='MemWrite16' >
							<argument exp='0x102444' />
							<argument exp='Height' />
						</command>
						<command class_type='call' title='total number of lines per screen, incl pre/post' macro='MemWrite16' >
							<argument exp='0x10243c' />
							<argument exp='VCycle' />
						</command>
						<command class_type='call' title='start of active screen' macro='MemWrite16' >
							<argument exp='0x102440' />
							<argument exp='VOffset' />
						</command>
						<command class_type='call' title='start of vertical sync pulse' macro='MemWrite16' >
							<argument exp='0x102448' />
							<argument exp='VSync0' />
						</command>
						<command class_type='call' title='End of vertical sync pulse' macro='MemWrite16' >
							<argument exp='0x10244C' />
							<argument exp='VSync1' />
						</command>
						<command class_type='call' title='FT800 output to LCD - pin order' macro='MemWrite8' >
							<argument exp='0x102460' />
							<argument exp='Swizzle' />
						</command>
						<command class_type='call' title='LCD data is clocked in on this PCLK edge' macro='MemWrite8' >
							<argument exp='0x102468' />
							<argument exp='ClkPol' />
						</command>
						<command class_type='comment' title='' comment='Disable Touch
' textarea='50,1,50,1' />
						<command class_type='call' title='Disable touch' macro='MemWrite8' >
							<argument exp='0x1024f0' />
							<argument exp='0' />
						</command>
						<command class_type='call' title='Eliminate any false touches' macro='MemWrite16' >
							<argument exp='0x102504' />
							<argument exp='0' />
						</command>
						<command class_type='comment' title='' comment='Disable Audio
' textarea='50,1,50,1' />
						<command class_type='call' title='turn recorded audio volume down' macro='MemWrite8' >
							<argument exp='0x10247c' />
							<argument exp='0' />
						</command>
						<command class_type='call' title='turn synthesizer volume down' macro='MemWrite8' >
							<argument exp='0x102480' />
							<argument exp='0' />
						</command>
						<command class_type='call' title='set synthesizer to mute' macro='MemWrite16' >
							<argument exp='0x102484' />
							<argument exp='0x6000' />
						</command>
						<command class_type='comment' title='' comment='Initial Display List - Enable display
' textarea='50,1,50,1' />
						<command class_type='calculation' title='start of Display List' >
							<exp exp='ramDisplayList = 0x100000' />
						</command>
						<command class_type='call' title='Clear Color RGB' macro='MemWrite32' >
							<argument exp='ramDisplayList' />
							<argument exp='0x02000000' />
						</command>
						<command class_type='calculation' title='point to next location' >
							<exp exp='ramDisplayList = ramDisplayList + 4' />
						</command>
						<command class_type='call' title='Clear 00100110' macro='MemWrite32' >
							<argument exp='ramDisplayList' />
							<argument exp='0x26000007' />
						</command>
						<command class_type='calculation' title='point to next location' >
							<exp exp='ramDisplayList = ramDisplayList + 4' />
						</command>
						<command class_type='call' title='DISPLAY command' macro='MemWrite32' >
							<argument exp='ramDisplayList' />
							<argument exp='0x00000000' />
						</command>
						<command class_type='call' title='DISPLAY command' macro='MemWrite32' >
							<argument exp='0x102450' />
							<argument exp='0x2' />
						</command>
						<command class_type='calculation' title='start of Display List' >
							<exp exp='ramDisplayList = 0x100000' />
						</command>
						<command class_type='call' title='Read the FT800 GPIO register for a read/modify/write operation' macro='MemRead8' >
							<return exp='.RetVal' />
							<argument exp='0x102490' />
						</command>
						<command class_type='calculation' title='set bit 7 of FT800 GPIO register (DISP) - others are inputs' >
							<exp exp='.RetVal = .RetVal | 0x80' />
						</command>
						<command class_type='call' title='Enable the DISP signal to the LCD panel' macro='MemWrite8' >
							<argument exp='0x102490' />
							<argument exp='.RetVal' />
						</command>
						<command class_type='call' title='Now start clocking data to the LCD panel' macro='MemWrite8' >
							<argument exp='0x10246c' />
							<argument exp='PixelClock' />
						</command>
						<command class_type='calculation' title='Calculation' >
							<exp exp='.duty = 0' />
						</command>
						<command class_type='loop' title='Loop' type='0' exp='.duty &lt;= 128' >
							<flowline >
								<command class_type='call' title='Turn on backlight - ramp up slowly to full brighness' macro='MemWrite8' >
									<argument exp='0x1024c4' />
									<argument exp='.duty' />
								</command>
								<command class_type='calculation' title='Calculation' >
									<exp exp='.duty = .duty + 1' />
								</command>
								<command class_type='delay' title='Delay' exp='10' type='1' />
							</flowline>
						</command>
						<command class_type='calculation' title='Calculation' >
							<exp exp='.Return = 1' />
						</command>
						<command class_type='label' title='Connection Point' labelid='0' labelname='A' />
					</flowline>
				</macro>
			</macros>
			<component class_type='ref' guid='c67171df-0ad6-4b11-8361-cfe14b072847' vmin='0' vmaj='1' codename='cal_spi1' x='0' y='0' z='0' xsz='25' ysz='25' zsz='25' xang='0' yang='0' zang='0' xquat='0' yquat='0' zquat='0' wquat='1' visible='1' interactive='1' solid='1' layer='1' poslock='0' >
				<resources />
				<properties />
				<values >
					<value target='ENABLED' data='1' />
					<value target='REF' data='1' />
					<value target='CHANNEL' data='001' />
					<value target='MOSI' data='$PORTD.1' />
					<value target='MOSIPins' data='008' />
					<value target='MISO' data='' />
					<value target='MISOPins' data='013' />
					<value target='CLK' data='$PORTF.4' />
					<value target='CLKPins' data='004' />
					<value target='SS' data='' />
					<value target='PR_SCALE' data='004' />
					<value target='BMODE' data='2' />
					<value target='CKP' data='000' />
					<value target='CKE' data='001' />
					<value target='SMP' data='000' />
					<value target='MOSI_PORT' data='$PORTD.1' />
					<value target='MOSI_TRIS' data='$PORTD.1' />
					<value target='MOSI_PIN' data='1' />
					<value target='MISO_PORT' data='' />
					<value target='MISO_TRIS' data='' />
					<value target='MISO_PIN' data='0' />
					<value target='SCK_PORT' data='$PORTF.4' />
					<value target='SCK_TRIS' data='$PORTF.4' />
					<value target='SCK_PIN' data='4' />
					<value target='SS_PORT' data='' />
					<value target='SS_TRIS' data='' />
					<value target='SS_PIN' data='0' />
					<value target='Remappable' data='1' />
					<value target='MOSIReg' data='008' />
					<value target='CLKREG' data='004' />
					<value target='MOSIRPNUM' data='5' />
					<value target='CLKRPNUM' data='6' />
					<value target='MISORPREG' data='RPINR20bits.SDI1R' />
					<value target='CS_PORT' data='' />
				</values>
				<events />
				<apis />
				<variables />
				<macros />
			</component>
		</component>
	</components>
	<keymap />
	<panel2d shadows='0' lighting='2' brightness='0' perspective='0' >
		<background rgb='15335401' img='' style='4294967295' />
		<camera xe='0' ye='0' ze='300' xt='0' yt='0' zt='0' xquat='0' yquat='0' zquat='0' wquat='1' />
	</panel2d>
	<panel3d shadows='0' lighting='0' brightness='0' perspective='0' >
		<background rgb='15335401' img='' style='0' />
		<table rgb='16777215' img='' style='4294967295' size='0' />
		<camera xe='0' ye='0' ze='300' xt='0' yt='0' zt='0' xquat='0' yquat='0' zquat='0' wquat='1' />
	</panel3d>
	<layout >
		<view type='0' name='Loop' mode='0' placement='LAAAAAAAAAABAAAA---------------------wAAAAAUAAAATgUAAJEDAAA' zoom='75' scrollx='0' scrolly='0' flags='0' />
		<view type='0' name='Main' mode='0' placement='LAAAAAAAAAABAAAA---------------------wAAAAAUAAAATgUAAJEDAAA' zoom='75' scrollx='0' scrolly='0' flags='0' />
		<view type='0' name='Initialise' mode='0' placement='LAAAAAAAAAABAAAA---------------------wAAAAAUAAAATgUAAJEDAAA' zoom='75' scrollx='0' scrolly='3157' flags='0' />
		<view type='0' name='IncrementCommandOffset' mode='0' placement='LAAAAAAAAAABAAAA---------------------wAAAAAUAAAATgUAAJEDAAA' zoom='75' scrollx='0' scrolly='0' flags='0' />
		<view type='0' name='CommandWrite' mode='0' placement='LAAAAAAAAAABAAAA---------------------wAAAAAUAAAATgUAAJEDAAA' zoom='75' scrollx='0' scrolly='0' flags='0' />
		<view type='0' name='MemRead16' mode='0' placement='LAAAAAAAAAABAAAA---------------------wAAAAAUAAAATgUAAJEDAAA' zoom='75' scrollx='0' scrolly='0' flags='0' />
		<view type='0' name='MemRead32' mode='0' placement='LAAAAAAAAAABAAAA---------------------wAAAAAUAAAATgUAAJEDAAA' zoom='75' scrollx='0' scrolly='0' flags='0' />
		<view type='0' name='MemRead8' mode='0' placement='LAAAAAAAAAABAAAA---------------------wAAAAAUAAAATgUAAJEDAAA' zoom='75' scrollx='0' scrolly='0' flags='0' />
		<view type='0' name='MemWrite8' mode='0' placement='LAAAAAAAAAABAAAA---------------------wAAAAAUAAAATgUAAJEDAAA' zoom='75' scrollx='0' scrolly='0' flags='0' />
		<view type='0' name='MemWrite32' mode='0' placement='LAAAAAAAAAABAAAA---------------------wAAAAAUAAAATgUAAJEDAAA' zoom='75' scrollx='0' scrolly='0' flags='0' />
		<view type='0' name='MemWrite16' mode='0' placement='LAAAAAAAAAABAAAA---------------------wAAAAAUAAAATgUAAJEDAAA' zoom='75' scrollx='0' scrolly='0' flags='0' />
	</layout>
</document>
</root>
