1315 I2C MASTER CONNECTOR

1435 I2C MASTER CONNECTOR

CONTROLS - COMMAND AND BUS

COMMAND QUEUE and LOAD
	The command queue displays a list of the commands to be compiled into I2C tokens.  Commands and data may be separated by either tabs or spaces when composing the loadable script files, but only spaces are allowed for direct entry in the script window.  All whitespace between command elements counts as a single separator.  A fixed space font is used to enhance readability and allow easy alignment of command elements into columns.  The command data is not case sensitive.  Double clicking the command queue window will clear it.

	When a script collection is loaded from a file, sub scripts are split into blocks of commands where each block is begun with a Title preceeded by a semicolon.  The first 18 blocks that begin with a line starting with a semi colon are loaded into the one-click buttons titled with that line.  If more than 18 such blocks are encountered, the remainder will populate the script drop down list.  Comments starting in the leftmost column may begin with a single forward or back slash.  Comments after the leftmost column may begin with a semicolon, forward or back slash character with at least one space or tab between it and the last symbol on the line.

;This is the title
Start
/Set the address
Write   0x95
\Start reading data
Read   ack   ;first byte
Read   ack
Read   nak   \Last byte is nak or nack
stop             /This is a stop

;This is the next title
Start
/...and so on

I2C BUS ACTIVITY
	The I2C bus activity window translates received I2C response tokens into an easily readable format, similar to the compiler input.  This window is not editable and double clicking clears it.
	
	Note that the response data is fed into a 256 byte recirculating buffer that is transmitted at once after the entire script has been executed:  If the response from a script gets too long, the buffer may be overwritten resulting in response token loss which would appear as if the front end of a script sequence was lost.  This buffer should be large enough for most transactions, i.e. start+address+64 sequential reads+stop and command overhead.

CONTINUOUS RX
	When unchecked, the I2C bus activity window is cleared each time a new response from the I2C master is received.  When checked, each newly received and decoded response is added to the bottom of the I2C bus activity window which may be cleared by double clicking.

CONTROLS - EXECUTION

COMPILE/TRANSMIT
	The current COMMAND QUEUE will be compiled and transmitted to the selected serial port.  If no port is currently open, the queue will only be compiled but not transmitted.

ONE CLICK COMMANDS
	When checked, a single press of a loaded command button will send the selected script to the command queue which will then be processed.  Otherwise the selected script will only be copied to the queue where it may then be edited.

CONTROLS - TOKENS

SCRIPTING TOKENS
	The script compiler reads these names from the command queue and converts them to a compressed token stream for the I2C master.  As soon as the entire script is loaded into the I2C master, an I2C transaction (without serial character transfer delays) is generated on the bus.  Case is not important where token command and data separation may be accomplished any number of tabs or spaces, e.g. whitespace.  Notepad is the preferred entry method and .TXT the preferred file extension for creating and saving scripts as it does not include any non-ASCII information.

ONE CLICK TOKENS
	When checked, clicking the token menu on the right will compile and transmit the selected token immediately.  This helps when manually bit banging the I2C and GPO lines when debugging the I2C interface.

CONTROLS - CONFIGURATION

PING
	This control will retrieve the firmware version and current settings from the I2C Master module.  These include interface voltage, Speed, Trigger-on-edge and Edge settings. All settings except for interface voltage are static and will be re loaded at power on.  The interface voltage at power up is set to 2.5V, i.e. a safe non-zero level.

STORE LAST
	The last successfully compiled token list is stored into on board EEPROM when the "Store Last" button is pressed. If available this is what will be run when Trigger-on-edge is enabled and that interrupt edge occurs.  The current speed setting is stored as well so that even if the module is in Slow mode, a stored script which was run originally in Fast mode will run in Fast mode.  The current speed for new scripts will be maintained.  If no command list is available for storage, an 'Empty buffer' message will be generated.

RUN STORED
	This allows a stored script to be verified before the Trigger-on-edge function is activated. If no commands have been stored, an 'Empty buffer' message will be generated.  The first time that the stored command is run, a 1mS delay will be incurred as the stored script is transferred into the active script memory.  If no other script has been run, subsequent executions will be more or less immediate.

H>L and L>H
	These control the edge detection of the Trigger-on-edge logic.  When the selected edge is detected at the GPI pin, the stored script (If available) will be run.

ON and OFF
	This turns on and off the Trigger-on-edge function.

SLOW and FAST
	These select the CURRENT interface speed, either 100 or 400kbps respectively.

CONTROLS - Misc

HELP
	Displays this help screen.

VERSION INFO
	Displays the revision history for this program.

EXAMPLE COMMANDS
	Selecting a command from the drop down list will insert one of the example scripts for controlling an LM75 temperature sensor.

TRANSMIT BUFFER
	This window shows the command and token sequence for the last executed script or token to be compiled and transmitted to the I2C master.  If a valid serial port has not been selected, this shows what would have been transmitted.

RECEIVE BUFFER
	This window shows the last complete response received by the GUI from the I2C master.

LANGUAGE - I2C TOKENS

	These tokens are entered or loaded into the command queue window and then translated into ASCII hex data that is transmitted as a block to the I2C master hardware.  The processor in the I2C master converts the ASCII hex data and stores it into a binary script buffer that is processed when the block has been completely received.

STANDARD I2C TOKENS									
Start  	---		Generate a Start (or Repeated Start) condition
Write 		0xNN  		Write data 0xNN to the slave, may be hex or decimal
Read		Ack		Read byte from the slave, low acknowledge bit on the ninth clock
Read		Nack		Read data from the slave, end with a high not-acknowledge bit
Read		Nak		Same as "Read Nack"
Stop		---		Generate a Stop condition

BUS TIMING TOKENS									
Speed?	---		Read the current bus speed, Slow=100kbps, Fast=400kbps
Delayu	0xNN		Delay (0xNN+20) micro-seconds, may be hex or decimal
Delaym	0xNN		Delay (0xNN milli-seconds) + 20 micro-seconds, hex or decimal
	
GPIO CONTROL TOKENS (The GPx pins are all 5V logic in and out)			
GP0LO	---		Drives the GP0 pin low (4.2uS execution time for GPx commands)
GP0HI	---		Drives the GP0 pin high
GP1LO	---		Drives the GP1 pin low		
GP1HI	---		Drives the GP1 pin high
GP2LO	---		Drives the GP2 pin low	
GP2HI	---		Drives the GP2 pin high
GP3LO	---		Drives the GP3 pin low	
GP3HI	---		Drives the GP3 pin high
GPPIN?	---		Reads the current state of the interrupt and GPx pins
GPDIR?	---		Reads the current direction registers of all GPx pins (0=Out/1=In)
GPDIR	1111		Sets the direction of all GPx pins (0=Out/1=In)	
Int?		---		Reads the current state of the interrupt pin

INTERFACE VOLTAGE CONTROL TOKENS							
SetV		Open		Disconnects internal voltage from the interface voltage pin
SetV		2.5		Sets the interface voltage to 2.5V
SetV		3.0		Sets the interface voltage to 3.0V
SetV		3.5		Sets the interface voltage to 3.5V
SetV		4.0		Sets the interface voltage to 4.0V
SetV		4.5		Sets the interface voltage to 4.5V
SetV		5.0		Sets the interface voltage to 5.0V
SetVx            3.300                Sets voltage to any value from 0.000 to 5.000V

I2C BUS CONTROL TOKENS   								
SCL0		---		Drives the SCL line low (5uS execution for SCL/SDA commands)
SCL1		---		Releases the SCL line
SDA0		---		Drives the SDA line low
SDA1		---		Releases the SDA line
SCL?		---		Read the state of the SCL line (12uS for I2C bus state queries)
SDA?		---		Read the current level of the SDA line

PROTOCOL - COMMAND PARSING

Command		Section	Description						
$aaccdd...dd[cr]	$		Frame start
			aa		Multidrop unit address (Always 0)
			cc		ASCII Hex command code
			dd...dd		ASCII Hex command data
			[cr]		Carriage return frame terminator

PROTOCOL - RESPONSE PARSING

Response		Section	Description						
!aaccdd...dd%[cr]	!		Frame start
			aa		Multidrop unit address (Always 0)
			cc		ASCII Hex command code
			dd...dd		ASCII Hex response data or...
			%		Command execution code		
					a	Ack, execution OK
					n	nAck, Execution failed
					f	Error in command framing
					?	Command not recognized
			[cr]		Carriage return frame terminator

PROTOCOL - CONTROL COMMANDS

Command		Response	Description						
$0010cctt...tt[cr]	!0010r...r[cr]	Tokenized I2C script			
					cc	Token count + 1, ASCII Hex
					tt...tt	Tokens, ASCII Hex
					r...r	Response Tokens, ASCII/Hex
						(See breakdown in next section)
$0011[cr]		!0011a[cr]	Store last script to EEPROM
			!0011e[cr]	No script to store
$0012[cr]		!0012a[cr]	Replay script from EEPROM
			!0012e[cr]	No script to replay
$0013[cr]		!0013a[cr]	Interrupt Edge=High-to-Low
$0014[cr]		!0014a[cr]	Interrupt Edge=Low-to-High
$0015[cr]		!0015a[cr]	Interrupt EdgeTrigger=On
$0016[cr]		!0016a[cr]	Interrupt EdgeTrigger=Off
$0017[cr]		!0017a[cr]	I2C Speed=Slow(100kbps)
$0018[cr]		!0018a[cr]	I2C Speed=Fast(400kbps)
$0019[cr]		!0019vvvvste[cr]	Report current configuration		
					vvvv	VSlave (mV)
					s	0=Slow(100kbps)
						1=Fast(400kbps)
					t	0=Edge trigger off
						1=Edge trigger on
					t	0=Edge High-to-Low
						1=Edge Low-to-High
(None)		!0020i[cr]	Interrupt pin has changed state		
					i	0=Now low
						1=Now high
$00FF[cr]		!00FFa[cr]	For 1319 hardware, switch to bus sniff mode

PROTOCOL - I2C TOKENS

	TxTokens are two character ASCII hex values, '00' to 'FF'. RxTokens are mixed ASCII hex and ASCII characters. The modules token parser converts the TxTokens to binary, processes the tokens and then transmits the entire response AFTER all the commands have completed so that no response related delays are inserted into the command stream.

TxToken	RxToken	Description							
00		S		Generate I2C Start condition
01 hh		Whha		Write 0xhh to the bus, slave responded with Ack
		Whhn		Write 0xhh to the bus, slave responded with nAck
02		Rhha		Read 0xhh from bus then Ack the transfer
03		Rhhn		Read 0xhh from bus then nAck the transfer
04		P		Generate I2C Stop condition

05 hh		Dhh		Delay (0xhh+1)uS
06 hh		dhh		Delay (0xhh+1)mS

10		sn		Querry bus speed			
				n	0	100kbps
					1	400kbps

20		20		Drive GPO 0 Low
21		21		Drive GPO 0 High
30		30		Drive GPO 1 Low
31		31		Drive GPO 1 High
40		40		Drive GPO 2 Low
41		41		Drive GPO 2 High
50		50		Drive GPO 3 Low
51		51		Drive GPO 3 High

60		6n		Read interrupt pin state			
				n	0	Low
					1	High

7n		7n		Set bus voltage, stepwise		
				n	0	No drive, slave supplied
					1	2.5V
					2	3.0V
					3	3.5V
					4	4.0V
					5	5.0V

76nnnn	76		Set bus voltage (1435 HW)		
				nnnn	0x0000 to 0x1388
					(0.000 to 5.000V)

80		80		Drive SCL Low
81		81		Drive SCL High
82		82		Drive SDA Low
83		83		Drive SDA High

90		9n		Read SCL pin state			
				n	0	Low
				n	1	High

92		9n		Read SDA pin state			
				n	2	Low
					3	High

A0		A0izyxw	Read all GPI/GPIO pin states (1435 HW)	
				i	GPI	0 	Low
						1	High
				z	GPIO3	0	Low
						1	High
				y	GPIO2	0	Low
						1	High
				x	GPIO1	0	Low
						1	High
				w	GPIO0	0	Low
						1	High
				
A1		A1zyxw		Read all GPIO directions	 (1435 HW)	
				z	GPIO3	0	Output
						1	Input
				y	GPIO2	0	Output
						1	Input
				x	GPIO1	0	Output
						1	Input
				w	GPIO0	0	Output
						1	Input

A2zyxw	A2		Set all GPIO directions (1435 HW)	
				z	GPIO3	0	Output
						1	Input
				y	GPIO2	0	Output
						1	Input
				x	GPIO1	0	Output
						1	Input
				w	GPIO0	0	Output
						1	Input

HARDWARE - I2C LEVEL SHIFTING
	
	  The on board I2C level shifter circuitry allows slaves from 1.5 to 5.5vdc to be connected where the slave reference voltage is the voltage present on the VIO pin.

	In the 1315 module the SDA and SCL lines are pulled up to the VIO pin through 10K resistors and through 4.7K resistors to 5V on the processor side of the level shifter.  VIO can be supplied by the module using a programmable resistor network with approximately 500 ohms of output impedance and 1mA drive capability.  If a VIO voltage is detected at boot up greater than 1.25v, the resistor network will be shut off, otherwise it will default to 2.5vdc.  
	
	In the 1435 module the SDA and SCL lines are pulled up to the VIO pin through 2.2K resistors and through 2.2K resistors to 5V on the processor side of the level shifter. VIO can be supplied by the module using a programmable DC power supply and overload protection circuit.  The overload circuit can supply up to 200mA from 1.8 to 5V from the regulator with a current limit between 200 and 400mA.  Setting the regulator voltage below 1.8V will result in an unpredictable output on the VIO pin but will not cause damage.  If loaded beyond its limit, the output will be shut down and then periodically reset until the overload condition is removed providing continuous short circuit protection.   If overloaded to its limit, the module will light the red lamp continuously (Along with the blinking green monitor lamp) and can be reset by setting the regulator momentarily to "Open".  If and external VIO reference is used, set the regulator to "Open" which disables the regulator.  If a VIO voltage is detected at boot up greater than 1.8V then the regulator will be disabled otherwise it will be set to 2.5V.

HARDWARE - GPI INTERRUPT
	
	The 1315 module general purpose input (GPI) pin is pulled to ground through a 1M resistor and has 1V VIL and 4V VIH input thresholds with a maximum input voltage of 7.5V.

	The 1435 module GPI pin is pulled to ground through a 1M resistor with a series 1K resistor clamped to ground with a 5.6V zener and has 0.5V VIL and 1.5V VIH input thresholds with a maximum input voltage of 15V.

HARDWARE - GPO/GPIO
	
	The 1315 module has four general purpose outputs (GPO) that can be set to either ground or 5V with 25mA of source or sink capability.

	The 1435 module has four general purpose input-outputs (GPIO) that can be set to either  ground, 5V or high impedance input,  In output mode, these can source or sink 25mA each.  In input mode these have 0.8V VIL and 2.0V VIH input thresholds.  Note that these pins are not pulled low or high so it is not suggested that they be left floating while set to inputs.

HARDWARE - 5VDC POWER JUMPER
	
	On the 1315 module, the VIO pin (Pin 5) on the I2C interface connector is normally just for supplying the proper bias for the level shifter circuitry from the slave.  If you want to use the on board 5V regulator output, jumper E1+E2 that will force the  slave reference for the I2C SCL and SDA level shifter to operate at 5.0vdc..  This output is capable of 500mA at 5V with the AC adapter provided:  The user is responsible for monitoring the temperature rise of the 1315 hardware, generated by the 5V on-board regulator when this power option is used.