Protocol
The Protocol interface uses the device Digital Pattern Generator and Logic Analyzer resources to transfer data using UART, SPI, and I2C protocols.
When the Debug option is enabled, the Logic Analyzer can be used to investigate the signals. In this case, the Protocol instrument will not receive data, it will only send data.
1. UART

The UART settings contain the following:
- TX/RX: selects the digital signal used to transmit and to receive data.
- Polarity: selects between standard and inverted signal polarity.
- Bits: specifies the number of data bits in a transmission word.
- Parity: selects between Odd, Even, Mark (High), and Space (Low) parity modes.
- Stop: specify the stop length in bits.
- Rate: specifies the speed or bits per second.
- Ending: selects the line ending between nothing, carriage return, line feed, CR LF, and LF CR.
The TX field contains a text box to type the characters to send. With Auto option, the typed characters are immediately sent, or by pressing the Send send button. File content can also be sent using the button below the text box.
The RX field contains the enable button to receive data and the option to print the sent TX data as well. The received data is printed with blue, the sent with green, and eventual errors with red. The unprintable characters codes are displayed between braces.
2. SPI
The SPI interface implements a protocol master controller. It allows sending and receiving data in single, dual, and quad modes. The select signal is activate from software, therefore it does not have exact timing with the bit serialization. The larger transfers with more bits that the custom Patterns or Logic Analyzer device buffer are split to separate transfers.
On the Analog Discovery, the Patterns buffer size is 1k or 16k bits, and the Logic is 4k or 16k bits.

The SPI settings contain the following:
- Select/Active: specifies the slave or chip select signal with low or high active level.
- Clock: specifies the clock signal.
- Polarity/Phase: selects the polarity and phase.
- Frequency: specifies the clock signal frequency.
- DQ#: specifies the data signals, DQ0-MOSI, DQ1-MISO, and DQ2/3 used in quad SPI mode.
- First bit: selects the bit transmission order, Most or Least Significant bit first.
- First word: selects the word transmission order, Most or Least Significant word first.
- Initial DQ#: selects the initial drive of the data signals.
The Simple mode lets you create simple transmissions and contains the following options:
- Mode: selects the transmission mode between Read Write to DQ0 from DQ1, Read from DQ1 MISO, Write to DQ0 MOSI, Read0 from DQ0 in 3-wire SPI mode, Dual/Quad Read/Write.
- Command bits: specifies the command word length.
- Command: specifies the command word(s), which will be sent on DQ0 before the coming read or write operation.
- Word bits: specifies the word length.
- Words: shows the number of words for write or specifies for read transfer.
- Write: specifies the word(s) to send in binary, decimal, or hexadecimal format. The data can be imported from binary or text file using the Open button.
- Read: shows the read word(s). The data can be saved to binary or text file using the Save or Append buttons.

The Custom mode lets you write communication script with the following functions:
- Start(): Activates the select signal. Return true on success, otherwise returns false.
- Stop(): Deactivates the select signal. Return true on success, otherwise false.
- ReadWrite( bits per work , { word1, word2... | [word1, word2...] } ): 4-wire SPI data transfer. Returns the read array of words.
- Write( bits per work , { word1, word2... | [word1, word2...] } ): 3 or 4-wire SPI data write. Returns true on success, otherwise returns false.
- Read( bits per work , number of words to read): 4-wire SPI data read. Returns the read array of words from DQ1.
- Read0( bits per work , number of words to read): 3-wire SPI data read. Returns the read array of words from DQ0.
- WriteDual( bits per work , { word1, word2... | [word1, word2...] } ): Dual SPI data write to DQ0,1. Returns true on success, otherwise return false.
- ReadDual( bits per work , number of words to read ): Dual SPI data read from DQ0,1. Returns the read array of words.
- WriteQuad( bits per work , { word1, word2... | [word1, word2...] } ): Quad SPI data write to DQ0,1,2,3. Returns the read array of words.
- ReadQuad( bits per work , number of words to read ): Dual SPI data read from DQ0,1,2,3. Returns the read array of words.
- DQ#.Initial.text: Lets you specify the initial values.
- DIO.: Lets you set (the ones are not declared as SPI signal) and read the digital pins.
- Besides these, you can access the SPI settings like Select, Clock, etc.
Under the examples menu, you can find scripts for some Pmods/ICs.

The Sensor mode lets you write communication script, which will be executed at precise timing with the following functions:
- initialize(): Function called at the beginning of script execution. It is useful to initialize the device and storage files.
- loop(): Function called for specified number of Iterations and at specified Rate. It is useful to collect, decode, and store sensor data. Use only static data transfer calls!
- finish(): Function called at the end of script execution. It is useful to send terminate commands to the device, summarize measurements, etc.
When the Sensor is executed, first the loop function is called to build the transmission bit sequence without performing it on the device. The bit sequence length is limited by the device Pattern or Logic buffer size. After the initialize function, the loop transmission sequence is performed for the given number of iterations, then the loop function is called to decode the received data, and finally the finish function is called.
3. I2C
The I2C interface implements a protocol master controller. The transfer length is limited to the custom Patters or Logic Analyzer device buffer size. The read operations with sub-address use restart and transfer length is limited to less than half of the device buffer size. The write operations aren't stopped on not acknowledge, but the appropriate error is shown in the software.

The I2C settings contain the following:
- SCL: specifies the clock signal.
- SDA: specifies the data signal.
- Frequency: specifies the clock signal frequency.
- DQ#: specifies the data signals, DQ0-MOSI, DQ1-MISO, and DQ2/3 used in quad SPI mode
The Simple mode lets you create simple transmissions and contains the following options:
- Address: specifies 7 bit I2C address.
- SubAddress: specifies I2C sub-address that will lead the write operations and it will be written before read operation with restart.
- Read / Bytes: executes the read operation for the specified number of bytes. The read data byte(s) are show in the row below and can be saved to binary or text file using the Save or Append buttons.
- Write / Bytes: executes the write operation of given bytes specified in the field below in binary, decimal, or hexadecimal format. The data can be imported from binary or text file using the Open button.

The Custom mode lets you write communication script with the following functions:
- Clear(): Returns true when the bus is free. It will try to resolve the SDA hold down issue.
- Read( address ): Returns true when acknowledged, otherwise false.
- Read( address, count of bytes ): Returns the read bytes array from the specified address.
- Read( address, [sub address byte1, byte2...], count of bytes ): Returns the read bytes array from the specified deice address and sub-address using repeated start.
- Write( address ): Returns true when acknowledged, otherwise false.
- Write( address, byte1, byte2...):
- Write( address, [byte1, byte2... ] } ): Returns zero on success, or -1 on address NotAcKnowled, or the NAK byte index.
- DIO.: Lets you set (the ones are not declared as SPI signal) and read the digital pins.
- Besides these, you can access the I2C settings SCK, SDA, Frequency.
Under the examples menu you, can find scripts for some Pmods/ICs.

The Sensor mode lets you write communication script, which will be executed at precise timing with the following functions:
- initialize(): Function called at the beginning of script execution. It is useful to initialize the device and storage files.
- loop(): Function called for specified number of Iterations and at specified Rate. It is useful to collect, decode, and store sensor data. Use only static data transfer calls!
- finish(): Function called at the end of script execution. It is useful to send terminate commands to the device, summarize measurements, etc.
When the Sensor is executed, first the loop function is called to build the transmission bit sequence without performing it on the device. The bit sequence length is limited by the device Pattern or Logic buffer size. After the initialize function, the loop transmission sequence is performed for the given number of iterations, then the loop function is called to decode the received data, and finally the finish function is called.