<root>
<document scada='0' schema='102' license='1,mnfisher,5YZWG2' title='' description='' fcversion='524801' target='ARD.ATMEGA.Arduino Nano 328' >
	<config data='' clkspd='16000000' simspd='1' usewdt='0' constif='0' Use3V3='0' />
	<plugins >
		<dll_models enabled='1' />
	</plugins>
	<supplement use='1' head='/* Define Timer1 Prescaler here */
#define c_start_pulse_timer	0x01  // Timer1 runs without Prescaler, 135ns tick @ 7,3728MHz
#define c_stop_pulse_timer	0x00

#define us2cnt(us) ((unsigned int)((unsigned long)(us) / (1000000L / (float)((unsigned long)MX_CLK_SPEED/ 1L))))



#define WAIT_100us	us2cnt(100)		// 100us, used to count 100ms

// define J1850 VPW timing requirements in accordance with SAE J1850 standard
// all pulse width times in us
// transmitting pulse width
#define TX_SHORT	us2cnt(64)		// Short pulse nominal time
#define TX_LONG		us2cnt(128)		// Long pulse nominal time
#define TX_SOF		us2cnt(200)		// Start Of Frame nominal time
#define TX_EOD		us2cnt(200)		// End Of Data nominal time
#define TX_EOF		us2cnt(280)		// End Of Frame nominal time
#define TX_BRK		us2cnt(300)		// Break nominal time
#define TX_IFS		us2cnt(300)		// Inter Frame Separation nominal time


#define RX_SHORT_MIN	us2cnt(34)	// minimum short pulse time
#define RX_SHORT_MAX	us2cnt(96)	// maximum short pulse time
#define RX_LONG_MIN		us2cnt(96)	// minimum long pulse time
#define RX_LONG_MAX		us2cnt(163)	// maximum long pulse time
#define RX_SOF_MIN		us2cnt(163)	// minimum start of frame time
#define RX_SOF_MAX		us2cnt(239)	// maximum start of frame time
#define RX_EOD_MIN		us2cnt(163)	// minimum end of data time
#define RX_EOD_MAX		us2cnt(239)	// maximum end of data time
#define RX_EOF_MIN		us2cnt(239)	// minimum end of frame time, ends at minimum IFS
#define RX_BRK_MIN		us2cnt(239)	// minimum break time
#define RX_IFS_MIN		us2cnt(280)	// minimum inter frame separation time, ends at next SOF

static inline void timer1_ctrl(uint8_t val)
{
    TCCR1B = val;
}

static inline void timer1_start(void)
{
    TCCR1B = c_start_pulse_timer;
    TCNT1 = 0;
}

static inline void timer1_stop(void)
{
    TCCR1B = c_stop_pulse_timer;
}

static inline void timer1_set(uint16_t val)
{
    TCNT1 = val;
}' body='' />
	<debug />
	<traces />
	<ghost >
		<FK2 >
			<data name='FK2D0' port='4294967295' pin='4294967295' />
			<data name='FK2D1' port='4294967295' pin='4294967295' />
			<data name='FK2D2' port='4294967295' pin='4294967295' />
			<data name='FK2D3' port='4294967295' pin='4294967295' />
			<data name='FK2D4' port='4294967295' pin='4294967295' />
			<data name='FK2D5' port='4294967295' pin='4294967295' />
			<data name='FK2D6' port='4294967295' pin='4294967295' />
			<data name='FK2D7' port='4294967295' pin='4294967295' />
			<data name='FK2D8' port='4294967295' pin='4294967295' />
			<data name='FK2D9' port='4294967295' pin='4294967295' />
			<data name='FK2D10' port='4294967295' pin='4294967295' />
			<data name='FK2D11' port='4294967295' pin='4294967295' />
			<data name='FK2D12' port='4294967295' pin='4294967295' />
			<data name='FK2D13' port='4294967295' pin='4294967295' />
			<data name='FK2D14' port='4294967295' pin='4294967295' />
			<data name='FK2D15' port='4294967295' pin='4294967295' />
			<data name='FK2A0' port='4294967295' pin='4294967295' />
			<data name='FK2A1' port='4294967295' pin='4294967295' />
			<data name='FK2A2' port='4294967295' pin='4294967295' />
			<data name='FK2A3' port='4294967295' pin='4294967295' />
			<data name='FK2A4' port='4294967295' pin='4294967295' />
			<data name='FK2A5' port='4294967295' pin='4294967295' />
		</FK2>
		<ICD >
			<data name='AnalogPrescaleValue' value='19' />
			<data name='DigitalSampleRate' value='100000' />
			<data name='BreakpointCount' value='8' />
			<data name='CallStackDepthCount' value='8' />
			<data name='ClockPort' value='1' />
			<data name='ClockPin' value='1' />
			<data name='DataPort' value='1' />
			<data name='DataPin' value='0' />
			<data name='UseDefaultPins' value='1' />
			<data name='WrapEnabled' value='1' />
			<data name='CommsDelayOverridden' value='0' />
			<data name='CommsDelay' value='11' />
			<data name='CalculatedCommsDelay' value='11' />
			<data name='AnalogEB2PrescaleValue' value='2' />
			<data name='DigitalEB2SampleRate' value='100000' />
		</ICD>
		<pins >
			<digital A='0' B='0' C='0' D='0' E='0' F='0' G='0' H='0' I='0' J='0' K='0' L='0' M='0' N='0' O='0' P='0' Q='0' R='0' S='0' T='0' U='0' V='0' W='0' X='0' Y='0' Z='0' />
			<analog A='0' B='0' C='0' D='0' E='0' F='0' G='0' H='0' I='0' J='0' K='0' L='0' M='0' N='0' O='0' P='0' Q='0' R='0' S='0' T='0' U='0' V='0' W='0' X='0' Y='0' Z='0' />
		</pins>
	</ghost>
	<components >
		<settings autoimg='1' center='1' unitscale='0' fixedscale='0' fixedx='1' fixedy='1' fixedz='1' headcode='0' />
		<definition guid='1cb9d9dd-f7b2-4b64-bfea-97dab2989b27' vstate='40' vmin='0' vmaj='1' srcleaf='' visiblename='' description='' category='' catenable='1' author='' manuname='' manucode='' sysinfo='0' keywords='' dynamic='1' scadaCompatible='0' embeddedCompatible='1' 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' scadavisible='1' interactive='1' solid='1' layer='0' poslock='0' >
			<resources />
			<properties >
				<property name='data' target='data_pin' typeid='5' hidden='0' locked='0' info='' />
			</properties>
			<values >
				<value target='data_pin' data='$PORTD.3' />
			</values>
			<events />
			<apis />
			<variables >
				<variable public='0' >
					<def class_type='variable' name='RX_SOF_MIN' type='u16' description='' isconst='0' isinit='0' usrinit='0' setinit='' />
				</variable>
				<variable public='0' >
					<def class_type='variable' name='TX_LONG' type='u16' description='' isconst='0' isinit='0' usrinit='0' setinit='' />
				</variable>
				<variable public='0' >
					<def class_type='variable' name='J1850_RETURN_CODE_BUS_ERROR' type='s16' description='' isconst='1' isinit='1' usrinit='3' setinit='3' />
				</variable>
				<variable public='0' >
					<def class_type='variable' name='counter' type='u16' description='' isconst='0' isinit='0' usrinit='0' setinit='' />
				</variable>
				<variable public='0' >
					<def class_type='variable' name='TX_EOF' type='u16' description='' isconst='0' isinit='0' usrinit='0' setinit='' />
				</variable>
				<variable public='0' >
					<def class_type='variable' name='J1850_RETURN_CODE_DATA' type='s16' description='' isconst='1' isinit='1' usrinit='6' setinit='6' />
				</variable>
				<variable public='0' >
					<def class_type='variable' name='RX_BRK_MIN' type='u16' description='' isconst='0' isinit='0' usrinit='0' setinit='' />
				</variable>
				<variable public='0' >
					<def class_type='variable' name='TX_EOD' type='u16' description='' isconst='0' isinit='0' usrinit='0' setinit='' />
				</variable>
				<variable public='0' >
					<def class_type='variable' name='RX_SHORT_MIN' type='u16' description='' isconst='0' isinit='0' usrinit='0' setinit='' />
				</variable>
				<variable public='0' >
					<def class_type='variable' name='J1850_RETURN_CODE_UNKNOWN' type='s16' description='' isconst='1' isinit='1' usrinit='0' setinit='0' />
				</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='TX_SHORT' type='u16' description='' isconst='0' isinit='0' usrinit='0' setinit='' />
				</variable>
				<variable public='0' >
					<def class_type='variable' name='J1850_RETURN_CODE_BUS_BUSY' type='s16' description='' isconst='1' isinit='1' usrinit='2' setinit='2' />
				</variable>
				<variable public='0' >
					<def class_type='variable' name='RX_EOD_MIN' type='u16' description='' isconst='0' isinit='0' usrinit='0' setinit='' />
				</variable>
				<variable public='0' >
					<def class_type='variable' name='J1850_RETURN_CODE_NO_DATA' type='s16' description='' isconst='1' isinit='1' usrinit='5' setinit='5' />
				</variable>
				<variable public='0' >
					<def class_type='variable' name='RX_IFS_MAX' type='u16' description='' isconst='0' isinit='0' usrinit='0' setinit='' />
				</variable>
				<variable public='0' >
					<def class_type='variable' name='TX_BRK' type='u16' description='' isconst='0' isinit='0' usrinit='0' setinit='' />
				</variable>
				<variable public='0' >
					<def class_type='variable' name='WAIT_100us' type='u16' description='' isconst='0' isinit='0' usrinit='0' setinit='' />
				</variable>
				<variable public='0' >
					<def class_type='variable' name='RX_EOF_MIN' type='u16' description='' isconst='0' isinit='0' usrinit='0' setinit='' />
				</variable>
				<variable public='0' >
					<def class_type='variable' name='J1850_RETURN_CODE_DATA_ERROR' type='s16' description='' isconst='1' isinit='1' usrinit='4' setinit='4' />
				</variable>
				<variable public='0' >
					<def class_type='variable' name='RX_LONG_MAX' type='u16' description='' isconst='0' isinit='0' usrinit='0' setinit='' />
				</variable>
				<variable public='0' >
					<def class_type='variable' name='TX_SOF' type='u16' description='' isconst='0' isinit='0' usrinit='0' setinit='' />
				</variable>
				<variable public='0' >
					<def class_type='variable' name='RX_SOF_MAX' type='u16' description='' isconst='0' isinit='0' usrinit='0' setinit='' />
				</variable>
				<variable public='0' >
					<def class_type='variable' name='RX_IFS_MIN' type='u16' description='' isconst='0' isinit='0' usrinit='0' setinit='' />
				</variable>
				<variable public='0' >
					<def class_type='variable' name='J1850_RETURN_CODE_OK' type='s16' description='' isconst='1' isinit='1' usrinit='1' setinit='1' />
				</variable>
				<variable public='0' >
					<def class_type='variable' name='RX_SHORT_MAX' type='u16' description='' isconst='0' isinit='0' usrinit='0' setinit='' />
				</variable>
				<variable public='0' >
					<def class_type='variable' name='TX_IFS' type='u16' description='' isconst='0' isinit='0' usrinit='0' setinit='' />
				</variable>
				<variable public='0' >
					<def class_type='variable' name='RX_LONG_MIN' type='u16' description='' isconst='0' isinit='0' usrinit='0' setinit='' />
				</variable>
				<variable public='0' >
					<def class_type='variable' name='RX_EOD_MAX' type='u16' description='' isconst='0' isinit='0' usrinit='0' setinit='' />
				</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='J1850_CRC' description='Calculate CRC on J1850 message frame' >
						<return name='Return' type='u8' description='' isconst='0' isinit='0' usrinit='0' setinit='' />
						<param name='msg' type='T8*' description='Message (max size 12 bytes) done as string to avoid copy' isconst='0' isinit='0' usrinit='&quot;&quot;' setinit='' >
							<array size='12' />
						</param>
						<param name='n' type='u8' description='Number of bytes in message' isconst='0' isinit='0' usrinit='0' setinit='' />
						<local name='crc' type='u8' description='' isconst='0' isinit='1' usrinit='255' setinit='0xff' />
						<local name='poly' type='u8' description='' isconst='0' isinit='0' usrinit='0' setinit='' />
						<local name='i' type='u8' description='' isconst='0' isinit='0' usrinit='0' setinit='' />
						<local name='nbit' type='u8' description='' isconst='0' isinit='0' usrinit='0' setinit='' />
						<local name='mask' type='u8' description='' isconst='0' isinit='0' usrinit='0' setinit='' />
						<command class_type='loop' title='For each byte in message' cmdcolor='12615680' cmdcolor_sec='15376912' type='2' forvar='.i' exp='.n' >
							<flowline >
								<command class_type='calculation' title='Initialise bit mask' cmdcolor='16760919' cmdcolor_sec='16760832' >
									<exp exp='.mask = 0x80' />
								</command>
								<command class_type='loop' title='For each bit in the byte' cmdcolor='12615680' cmdcolor_sec='15376912' type='2' exp='8' >
									<flowline >
										<command class_type='decision' title='If &apos;1&apos; bit at current position' cmdcolor='12615680' cmdcolor_sec='15376912' exp='.mask &amp; .msg[.i]' swap='0' >
											<flowline >
												<command class_type='decision' title='Define polynomial' cmdcolor='12615680' cmdcolor_sec='15376912' exp='.crc &amp; 0x80' swap='0' >
													<flowline >
														<command class_type='calculation' title='Calculation' cmdcolor='16760919' cmdcolor_sec='16760832' >
															<exp exp='.poly = 1' />
														</command>
													</flowline>
													<flowline >
														<command class_type='calculation' title='Calculation' cmdcolor='16760919' cmdcolor_sec='16760832' >
															<exp exp='.poly = 0x1c' />
														</command>
													</flowline>
												</command>
												<command class_type='calculation' title='Calculation' cmdcolor='16760919' cmdcolor_sec='16760832' >
													<exp exp='.crc = ((.crc &lt;&lt; 1) | 1) ^ .poly' />
												</command>
											</flowline>
											<flowline >
												<command class_type='decision' title='Decision' cmdcolor='12615680' cmdcolor_sec='15376912' exp='.crc &amp; 0x80' swap='0' >
													<flowline >
														<command class_type='calculation' title='Calculation' cmdcolor='16760919' cmdcolor_sec='16760832' >
															<exp exp='.poly = 0x1D' />
														</command>
													</flowline>
													<flowline >
														<command class_type='calculation' title='Calculation' cmdcolor='16760919' cmdcolor_sec='16760832' >
															<exp exp='.poly = 0' />
														</command>
													</flowline>
												</command>
												<command class_type='calculation' title='Calculation' cmdcolor='16760919' cmdcolor_sec='16760832' >
													<exp exp='.crc = (.crc &lt;&lt; 1) ^ .poly' />
												</command>
											</flowline>
										</command>
										<command class_type='calculation' title='Calculation' cmdcolor='16760919' cmdcolor_sec='16760832' >
											<exp exp='.mask = .mask &gt;&gt; 1' />
										</command>
									</flowline>
								</command>
							</flowline>
						</command>
						<command class_type='calculation' title='Return the CRC value' cmdcolor='16760919' cmdcolor_sec='16760832' >
							<exp exp='.Return = ~ .crc' />
						</command>
					</flowline>
				</macro>
				<macro >
					<flowline name='Rcv_Msg' description='Receive a msg from J1850 bus - returns no bytes received or error code (with bit 7 set)
' >
						<return name='Return' type='u8' description='' isconst='0' isinit='0' usrinit='0' setinit='' />
						<param name='msg' type='u8' description='buffer for message - max of 12 bytes' isconst='0' isinit='0' usrinit='&quot;&quot;' setinit='' >
							<array size='12' />
						</param>
						<local name='nbytes' type='u8' description='' isconst='0' isinit='0' usrinit='0' setinit='' />
						<local name='bit_state' type='u8' description='' isconst='0' isinit='0' usrinit='0' setinit='' />
						<local name='time' type='u16' description='' isconst='0' isinit='0' usrinit='0' setinit='' />
						<local name='tcnt1_buf' type='u8' description='' isconst='0' isinit='0' usrinit='0' setinit='' />
						<local name='cur_byte' type='u8' description='' isconst='0' isinit='0' usrinit='0' setinit='' />
						<command class_type='call' title='Call Macro' cmdcolor='1879295' cmdcolor_sec='5751039' macro='TimerStart' />
						<command class_type='loop' title='Wait for data pin to go low (start msg?)' cmdcolor='12615680' cmdcolor_sec='15376912' type='0' exp='data_pin = 1' >
							<flowline >
								<command class_type='call' title='Call Macro' cmdcolor='1879295' cmdcolor_sec='5751039' macro='GetTime' >
									<return exp='.time' />
								</command>
								<command class_type='decision' title='Check for timeout' cmdcolor='12615680' cmdcolor_sec='15376912' exp='.time &gt;= WAIT_100us' swap='0' >
									<flowline >
										<command class_type='calculation' title='Calculation' cmdcolor='16760919' cmdcolor_sec='16760832' >
											<exp exp='.Return = J1850_RETURN_CODE_NO_DATA | 0x80' />
										</command>
										<command class_type='goto' title='Goto Connection Point' cmdcolor='12615680' cmdcolor_sec='15376912' labelid='0' labelname='' />
									</flowline>
									<flowline />
								</command>
							</flowline>
						</command>
						<command class_type='call' title='Now wait for SOF' cmdcolor='1879295' cmdcolor_sec='5751039' macro='TimerStart' />
						<command class_type='loop' title='Wait for SOF' cmdcolor='12615680' cmdcolor_sec='15376912' type='0' exp='data_pin = 0' >
							<flowline >
								<command class_type='call' title='Call Macro' cmdcolor='1879295' cmdcolor_sec='5751039' macro='GetTime' >
									<return exp='.time' />
								</command>
								<command class_type='decision' title='Check for timeout' cmdcolor='12615680' cmdcolor_sec='15376912' exp='.time &gt;= RX_SOF_MAX' swap='0' >
									<flowline >
										<command class_type='calculation' title='Calculation' cmdcolor='16760919' cmdcolor_sec='16760832' >
											<exp exp='.Return = J1850_RETURN_CODE_BUS_ERROR | 0x80' />
										</command>
										<command class_type='goto' title='Goto Connection Point' cmdcolor='12615680' cmdcolor_sec='15376912' labelid='0' labelname='' />
									</flowline>
									<flowline />
								</command>
							</flowline>
						</command>
						<command class_type='call' title='Call Macro' cmdcolor='1879295' cmdcolor_sec='5751039' macro='TimerStop' >
							<return exp='.time' />
						</command>
						<command class_type='decision' title='Check for minimum length of SOF..' cmdcolor='12615680' cmdcolor_sec='15376912' exp='.time &lt; RX_SOF_MIN' swap='0' >
							<flowline >
								<command class_type='calculation' title='Calculation' cmdcolor='16760919' cmdcolor_sec='16760832' >
									<exp exp='.Return = J1850_RETURN_CODE_BUS_ERROR | 0x80' />
								</command>
								<command class_type='goto' title='Goto Connection Point' cmdcolor='12615680' cmdcolor_sec='15376912' labelid='0' labelname='' />
							</flowline>
							<flowline />
						</command>
						<command class_type='call' title='Call Macro' cmdcolor='1879295' cmdcolor_sec='5751039' macro='Is_J1850_Active' >
							<return exp='.bit_state' />
						</command>
						<command class_type='call' title='Call Macro' cmdcolor='1879295' cmdcolor_sec='5751039' macro='TimerStart' />
						<command class_type='loop' title='Try and receive up to 12 bytes data ' cmdcolor='12615680' cmdcolor_sec='15376912' type='2' forvar='.nbytes' exp='12' >
							<flowline >
								<command class_type='calculation' title='Set current data to 0' cmdcolor='16760919' cmdcolor_sec='16760832' >
									<exp exp='.cur_byte = 0' />
								</command>
								<command class_type='loop' title='For each of 8 bits' cmdcolor='12615680' cmdcolor_sec='15376912' type='2' exp='8' >
									<flowline >
										<command class_type='calculation' title='Shift received data left to make room for next bit' cmdcolor='16760919' cmdcolor_sec='16760832' >
											<exp exp='.cur_byte = .cur_byte &lt;&lt; 1' />
										</command>
										<command class_type='loop' title='Wait for change in bus state' cmdcolor='12615680' cmdcolor_sec='15376912' type='0' exp='Is_J1850_Active () = .bit_state' >
											<flowline >
												<command class_type='call' title='Call Macro' cmdcolor='1879295' cmdcolor_sec='5751039' macro='GetTime' >
													<return exp='.time' />
												</command>
												<command class_type='decision' title='Check for EOD' cmdcolor='12615680' cmdcolor_sec='15376912' exp='.time &gt;= RX_EOD_MIN' swap='0' >
													<flowline >
														<command class_type='calculation' title='Calculation' cmdcolor='16760919' cmdcolor_sec='16760832' >
															<exp exp='.Return = .nbytes' />
														</command>
														<command class_type='goto' title='Goto Connection Point' cmdcolor='12615680' cmdcolor_sec='15376912' labelid='0' labelname='' />
													</flowline>
													<flowline />
												</command>
											</flowline>
										</command>
										<command class_type='call' title='Call Macro' cmdcolor='1879295' cmdcolor_sec='5751039' macro='Is_J1850_Active' >
											<return exp='.bit_state' />
										</command>
										<command class_type='call' title='Call Macro' cmdcolor='1879295' cmdcolor_sec='5751039' macro='GetTime' >
											<return exp='.tcnt1_buf' />
										</command>
										<command class_type='call' title='Call Macro' cmdcolor='1879295' cmdcolor_sec='5751039' macro='TimerStart' />
										<command class_type='decision' title='Was data pulse too short' cmdcolor='12615680' cmdcolor_sec='15376912' exp='.tcnt1_buf &lt; RX_SHORT_MIN' swap='0' >
											<flowline >
												<command class_type='calculation' title='Calculation' cmdcolor='16760919' cmdcolor_sec='16760832' >
													<exp exp='.Return = J1850_RETURN_CODE_BUS_ERROR | 0x80' />
												</command>
												<command class_type='goto' title='Goto Connection Point' cmdcolor='12615680' cmdcolor_sec='15376912' labelid='0' labelname='' />
											</flowline>
											<flowline />
										</command>
										<command class_type='decision' title='Check for short active pulse' cmdcolor='12615680' cmdcolor_sec='15376912' exp='(.tcnt1_buf &lt; RX_SHORT_MAX) AND !Is_J1850_Active ()' swap='0' >
											<flowline >
												<command class_type='calculation' title='Calculation' cmdcolor='16760919' cmdcolor_sec='16760832' >
													<exp exp='.cur_byte = .cur_byte | 1' />
												</command>
											</flowline>
											<flowline />
										</command>
										<command class_type='decision' title='Check for long passive pulse &apos;1&apos; bit' cmdcolor='12615680' cmdcolor_sec='15376912' exp='(.tcnt1_buf &gt; RX_LONG_MIN) AND (.tcnt1_buf &lt; RX_LONG_MAX)' swap='0' >
											<flowline >
												<command class_type='calculation' title='Calculation' cmdcolor='16760919' cmdcolor_sec='16760832' >
													<exp exp='.cur_byte = .cur_byte | 1' />
												</command>
											</flowline>
											<flowline />
										</command>
									</flowline>
								</command>
								<command class_type='calculation' title='Store data to buffer' cmdcolor='16760919' cmdcolor_sec='16760832' >
									<exp exp='.msg[.nbytes] = .cur_byte' />
								</command>
							</flowline>
						</command>
						<command class_type='calculation' title='Calculation' cmdcolor='16760919' cmdcolor_sec='16760832' >
							<exp exp='.Return = .nbytes' />
						</command>
						<command class_type='label' title='Exit Point' cmdcolor='12615680' cmdcolor_sec='15376912' labelid='0' labelname='A' />
						<command class_type='call' title='Call Macro' cmdcolor='1879295' cmdcolor_sec='5751039' macro='TimerStop' />
					</flowline>
				</macro>
				<macro >
					<flowline name='TimerStop' description='Stop timer 1 and return current value of TCNT1' >
						<return name='Return' type='u16' description='' isconst='0' isinit='0' usrinit='0' setinit='' />
						<command class_type='native' title='C Code' ccode='FCR_RETVAL = TCNT1;
timer1_stop();' cmdcolor='7687168' cmdcolor_sec='8152576' language='C' />
					</flowline>
				</macro>
				<macro >
					<flowline name='GetTime' description='Get current value of TCNT1' >
						<return name='Return' type='u16' description='' isconst='0' isinit='0' usrinit='0' setinit='' />
						<command class_type='native' title='C Code' ccode='FCR_RETVAL = TCNT1;' cmdcolor='7687168' cmdcolor_sec='8152576' language='C' />
					</flowline>
				</macro>
				<macro >
					<flowline name='Is_J1850_Active' description='' >
						<return name='Return' type='b1' description='' isconst='0' isinit='0' usrinit='0' setinit='' />
						<command class_type='calculation' title='Calculation' cmdcolor='16760919' cmdcolor_sec='16760832' >
							<exp exp='.Return = (data_pin == 0)' />
						</command>
					</flowline>
				</macro>
				<macro >
					<flowline name='TimerStart' description='' >
						<return name='Return' type='v0' description='' isconst='0' isinit='0' usrinit='' setinit='' />
						<command class_type='native' title='C Code' ccode='timer1_start();' cmdcolor='7687168' cmdcolor_sec='8152576' language='C' />
					</flowline>
				</macro>
				<macro >
					<flowline name='Main' description='' >
						<return name='Return' type='v0' description='' isconst='0' isinit='0' usrinit='' setinit='' />
						<local name='msg' type='u8' description='' isconst='0' isinit='0' usrinit='&quot;&quot;' setinit='' >
							<array size='12' />
						</local>
						<local name='error' type='u8' description='' isconst='0' isinit='0' usrinit='0' setinit='' />
						<command class_type='call' title='Call Component Macro' cmdcolor='1879295' cmdcolor_sec='5751039' component='UART1' macro='Initialise' />
						<command class_type='call' title='Initialise the j1850 variables' cmdcolor='1879295' cmdcolor_sec='5751039' macro='Initialise' />
						<command class_type='loop' title='Loop' cmdcolor='12615680' cmdcolor_sec='15376912' type='0' exp='1' >
							<flowline >
								<command class_type='call' title='Call Macro' cmdcolor='1879295' cmdcolor_sec='5751039' macro='Rcv_Msg' >
									<return exp='.error' />
									<argument exp='.msg' />
								</command>
								<command class_type='decision' title='Decision' cmdcolor='12615680' cmdcolor_sec='15376912' exp='.error | 0x80' swap='0' >
									<flowline />
									<flowline >
										<command class_type='call' title='Call Component Macro' cmdcolor='1879295' cmdcolor_sec='5751039' component='UART1' macro='SendString' >
											<argument exp='&quot;Got message :-) &quot;' />
										</command>
										<command class_type='call' title='Call Component Macro' cmdcolor='1879295' cmdcolor_sec='5751039' component='UART1' macro='SendNumber' >
											<argument exp='.error' />
										</command>
										<command class_type='call' title='Call Component Macro' cmdcolor='1879295' cmdcolor_sec='5751039' component='UART1' macro='SendString' >
											<argument exp='&quot;\r\n&quot;' />
										</command>
									</flowline>
								</command>
							</flowline>
						</command>
					</flowline>
				</macro>
				<macro >
					<flowline name='Initialise' description='Initialise j1850 bus and variables' >
						<return name='Return' type='v0' description='' isconst='0' isinit='0' usrinit='' setinit='' />
						<command class_type='comment' title='' comment='ToDo - enable pull-ups on data pin..' textarea='12,0,12,0' cmdcolor='10944511' cmdcolor_sec='11465458' />
						<command class_type='native' title='Copy the defined counts to FC variables' ccode='FCV_RX_SOF_MIN = RX_SOF_MIN;
FCV_RX_SOF_MAX = RX_SOF_MAX;
FCV_WAIT_100US = WAIT_100us;
FCV_RX_SOF_MAX = RX_SOF_MAX;
FCV_RX_SOF_MIN = RX_SOF_MIN;
FCV_RX_EOD_MIN = RX_EOD_MIN;
FCV_RX_SHORT_MAX = RX_SHORT_MAX;
FCV_RX_SHORT_MIN = RX_SHORT_MIN;
FCV_RX_LONG_MIN = RX_LONG_MIN;
FCV_RX_LONG_MAX = RX_LONG_MAX;' cmdcolor='7687168' cmdcolor_sec='8152576' language='C' />
					</flowline>
				</macro>
			</macros>
			<component class_type='ref' guid='c73616d1-7ad0-45d9-aada-69ccfa4c5efc' vmin='0' vmaj='2' codename='UART1' x='0' y='0' z='0' xsz='64' ysz='32' zsz='1.53' xang='0' yang='0' zang='0' xquat='0' yquat='0' zquat='0' wquat='1' visible='1' scadavisible='1' interactive='1' solid='1' layer='1' poslock='0' >
				<resources />
				<properties />
				<values >
					<value target='cal_uart::CHANNEL' data='001' />
					<value target='cal_uart::BAUD_LIST' data='004' />
					<value target='cal_uart::BAUD' data='9600' />
					<value target='cal_uart::DBITS' data='008' />
					<value target='cal_uart::RETURN' data='000' />
					<value target='cal_uart::ECHO' data='000' />
					<value target='cal_uart::UseTX' data='1' />
					<value target='cal_uart::TX' data='$PORTD.1' />
					<value target='cal_uart::OutputPins' data='007' />
					<value target='cal_uart::TXAlt' data='0' />
					<value target='cal_uart::UseRX' data='1' />
					<value target='cal_uart::RX' data='$PORTD.0' />
					<value target='cal_uart::InputPins' data='013' />
					<value target='cal_uart::RXAlt' data='0' />
					<value target='cal_uart::FLOWEN' data='000' />
					<value target='cal_uart::RTS' data='$PORTB.2' />
					<value target='cal_uart::CTS' data='$PORTB.1' />
					<value target='label' data='UART' />
					<value target='cal_uart::ScopeTraces' data='0' />
					<value target='cal_uart::ConsoleData' data='0' />
					<value target='cal_uart::ConsoleColumns' data='64' />
					<value target='cal_uart::DataSource' data='000' />
					<value target='cal_uart::com_port' data='000' />
					<value target='cal_uart::Injector' data='000' />
				</values>
				<events />
				<apis />
				<variables />
				<macros />
			</component>
		</component>
	</components>
	<scadaresourcelookup />
	<keymap />
	<panel2d shadows='0' lighting='2' brightness='0' >
		<background rgb='7292207' img='' style='0' />
		<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='2' brightness='0' perspective='1' >
		<background rgb='8409120' img='' style='0' />
		<table rgb='7360576' img='' style='0' size='0' />
		<camera xe='0' ye='0' ze='425.029' xt='0' yt='0' zt='0' xquat='0' yquat='0' zquat='0' wquat='1' />
		<camerakey0 xe='0' ye='0' ze='300' xt='0' yt='0' zt='0' xquat='0' yquat='0' zquat='0' wquat='1' />
		<camerakey1 xe='-3.67394e-14' ye='0' ze='-300' xt='0' yt='0' zt='0' xquat='0' yquat='1' zquat='0' wquat='6.12323e-17' />
		<camerakey2 xe='0' ye='-300' ze='6.66134e-14' xt='0' yt='0' zt='0' xquat='-0.707107' yquat='0' zquat='0' wquat='0.707107' />
		<camerakey3 xe='-3.67394e-14' ye='300' ze='6.66134e-14' xt='0' yt='0' zt='0' xquat='-4.32978e-17' yquat='0.707107' zquat='0.707107' wquat='4.32978e-17' />
		<camerakey4 xe='-300' ye='-6.66134e-14' ze='6.66134e-14' xt='0' yt='0' zt='0' xquat='-0.5' yquat='0.5' zquat='0.5' wquat='0.5' />
		<camerakey5 xe='300' ye='-6.66134e-14' ze='6.66134e-14' xt='0' yt='0' zt='0' xquat='-0.5' yquat='-0.5' zquat='-0.5' wquat='0.5' />
		<camerakey6 xe='-173.205' ye='-173.205' ze='173.205' xt='0' yt='0' zt='0' xquat='-0.424708' yquat='0.17592' zquat='0.339851' wquat='0.820473' />
	</panel3d>
	<layout >
		<view type='0' name='Initialise' mode='0' placement='LAAAAAAAAAABAAAA---------------------.kCAAAeAAAApwUAAKsCAAA' zoom='75' scrollx='0' scrolly='0' flags='0' />
		<view type='0' name='Rcv_Msg' mode='0' placement='LAAAAAAAAAABAAAA---------------------wUAAAAeAAAA1wIAAKsCAAA' zoom='75' scrollx='10' scrolly='3234' flags='0' />
		<view type='0' name='Main' mode='0' placement='LAAAAAAAAAABAAAA---------------------wUAAAAeAAAA1wIAAKsCAAA' zoom='75' scrollx='0' scrolly='226' flags='0' />
		<view type='0' name='Is_J1850_Active' mode='0' placement='LAAAAAAAAAABAAAA---------------------wUAAAAeAAAA1wIAAKsCAAA' zoom='75' scrollx='0' scrolly='0' flags='0' />
		<view type='0' name='TimerStop' mode='2' placement='LAAAAAAAAAABAAAA---------------------wUAAAAeAAAA1wIAAKsCAAA' zoom='75' scrollx='0' scrolly='0' flags='0' />
		<view type='0' name='GetTime' mode='0' placement='LAAAAAAAAAABAAAA---------------------wUAAAAeAAAA1wIAAKsCAAA' zoom='75' scrollx='0' scrolly='0' flags='0' />
		<view type='0' name='TimerStart' mode='0' placement='LAAAAAAAAAABAAAA---------------------wUAAAAeAAAA1wIAAKsCAAA' zoom='75' scrollx='0' scrolly='0' flags='0' />
		<view type='0' name='TimerStop' mode='0' placement='LAAAAAAAAAABAAAA---------------------wUAAAAeAAAA1wIAAKsCAAA' zoom='75' scrollx='0' scrolly='0' flags='0' />
		<view type='0' name='J1850_CRC' mode='0' placement='LAAAAAAAAAABAAAA---------------------wUAAAAeAAAA1wIAAKsCAAA' zoom='100' scrollx='0' scrolly='0' flags='0' />
	</layout>
</document>
</root>
