G.3 Writing Scripts
www.ti.com
Writing Scripts
A script is simply a text file that contains data to send to the serial control buses. The scripting language issimple, as is the parser for the language. Therefore, although the program is not forgiving about mistakesmade in the source script file, the formatting of the file is simple. Consequently, mistakes are rare.
Each line in a script file is one command. Lines cannot be extended beyond one line. A line is terminatedby a carriage return.
The first character of a line is the command. Commands are:
ISet interface bus to userRead from the serial control buswWrite to the serial control bus#Comment
bBreak
dDelay
The first command, I, sets the interface to use for the commands to follow. This command must befollowed by one of the following parameters:
i2cstd Standard mode I
2
C bus
i2cfast Fast mode I
2
C bus
spi8 SPI bus with 8-bit register addressing
spi16 SPI bus with 16-bit register addressing
gpio Use the USB-MODEVM GPIO capability
For example, if a fast mode I
2
C bus is to be used, the script begins with:
I i2cfast
No data follows the break command. Anything following a comment command is ignored by the parser,provided that it is on the same line. The delay command allows the user to specify a time, in milliseconds,that the script pauses before proceeding.
Note: Unlike all other numbers used in the script commands, the delay time is entered in a decimalformat. Also, note that because of latency in the USB bus as well as the time it takes theprocessor on the USB-MODEVM to handle requests, the delay time may not be precise.
A series of byte values follows either a read or write command. Each byte value is expressed inhexadecimal, and each byte must be separated by a space. Commands are interpreted and sent to theTAS1020 by the program using the protocol described in Section G.1 .
The first byte following a read or write command is the I
2
C slave address of the device (if I
2
C is used) orthe first data byte to write (if SPI is used—note that SPI interfaces are not standardized on protocols, sothe meaning of this byte varies with the device being addressed on the SPI bus). The second byte is thestarting register address that data is written to (again, with I
2
C; SPI varies—see Section G.1 for additionalinformation about what variations may be necessary for a particular SPI mode). Following these two bytesare data, if writing; if reading, the third byte value is the number of bytes to read, (expressed inhexadecimal).
For example, to write the values 0xAA 0x55 to an I
2
C device with a slave address of 0x90, starting at aregister address of 0x03, one would write:#example scriptI i2cfast
w 90 03 AA 55r 90 03 2
SLAU286 – June 2009 USB-MODEVM Protocol 49Submit Documentation Feedback