Aardvark Control Center User's Manual v3.51
| Prev: Modules | Table of Contents | Next: Notes |
- 5 Batch Instruction Commands
5 Batch Instruction Commands
5.1 Notes on Batch Instructions
Unless specified otherwise, all arguments to a batch instruction are “1” to enable/request the specified parameter, or “0” to disable/not request the specified parameter.
5.2 General Commands
Configure
<configure i2c="i2c"
spi="spi"
gpio="gpio"
tpower="tpower"
pullups="pullups"/>
Activate/Deactivate individual sub-systems and features
Parameters
- i2c
Enable I2C.- spi
Enable SPI.- gpio
Enable GPIO.- tpower
Enable Target Power on pins 4 and 6.- pullups
Enable pullup resistors on the I2C lines: SCL and SDA.
Details
It is not possible to activate I2C, SPI and GPIO all at the same time. The possible combinations are:
i2c |
spi |
gpio |
Configuration |
“1” |
“1” |
“0” |
I2C and SPI enabled |
“1” |
“0” |
“1” |
I2C enabled and SPI pins used as GPIO |
“0” |
“1” |
“1” |
SPI enabled and I2C pins used as GPIO |
“0” |
“0” |
“1” |
I2C and SPI pins used as GPIO |
Please see the Aardvark I2C/SPI Embedded Systems Interface Datasheet for more information about supplying target power and I2C pullup resistors.
sleep
<sleep ms="ms"/>
Set the Aardvark adapter to sleep for a number of milliseconds
Parameters
- ms
Requested number of milliseconds to sleep.
5.3 I2C Commands
i2c_bitrate
<i2c_bitrate khz="khz"/>
Set the I2C bitrate in kilohertz.
Parameters
- khz
The requested bitrate in kHz.
Details
The default power-on bitrate is 100khz
Only certain discrete bitrates are supported by the Aardvark I2C master interface. As such, this actual bitrate set will be less than or equal to the requested bitrate.
The actual bitrate is returned in the Transaction Log. Please see the Aardvark I2C/SPI Embedded Systems Interface Datasheet for more information.
i2c_write
<i2c_write addr="addr"
count="count"
nostop="nostop"
ten_bit_addr="ten_bit_addr"
combined_fmt="combined_fmt"
radix="radix">
message
</i2c_write>
Write a stream of bytes to the I2C slave device.
Parameters
- addr
The slave from which to read. The slave address can be specified in decimal or hexadecimal notation.- count
The number of bytes to write (maximum 65535).- nostop
Request that no stop condition is issued on the I2C bus after the transaction completes.- ten_bit_addr
Request that the provided address is treated as a 10-bit address.- combined_fmt
Request that the Philips combined format is followed during a I2C read operation. This only has an effect when used in conjunction with 10-bit addressing.- radix
The base of the number system of the message, with the value being 10 for decimal, or 16 for hexadecimal.- message
The message to transmit as a space separated list of numbers.
Details
For ordinary 7-bit addressing, the lower 7 bits of the addr should correspond to the slave address. The topmost bits are ignored. The Aardvark I2C subsystem will assemble the address along with the R/W bit after grabbing the bus. For 10- bit addressing, the lower 10 bits of addr should correspond to the slave address. The Aardvark adapter will then assemble the address into the proper format as described in the Philips specification. There is a limitation that a maximum of only 65534 bytes can be written in a single transaction if the 10-bit addressing mode is used.
The slave_addr 0x00 has been reserved in the II2C protocol specification for general call addressing. I2C slaves that are enabled to respond to a general call will acknowledge this address. The general call is not treated specially in the Aardvark I2C master. The user of this API can manually assemble the first data byte if the hardware address programming feature with general call is required.
Please see the Aardvark I2C/SPI Embedded Systems Interface Datasheet for more information.
i2c_read
<i2c_read addr="addr"
count="count"
nostop="nostop"
ten_bit_addr="ten_bit_addr"
combined_fmt="combined_fmt"/>
Read a stream of bytes from the I2C slave device.
Parameters
- addr
The slave from which to read. The slave address can be specified in decimal or hexadecimal notation.- count
The number of bytes to write (maximum 65535).- nostop
Request that no stop condition is issued on the I2C bus after the transaction completes.- ten_bit_addr
Request that the provided address is treated as a 10-bit address.- combined_fmt
Request that the Philips combined format is followed during a I2C read operation. This only has an effect when used in conjunction with 10-bit addressing.
Details
For ordinary 7-bit addressing, the lower 7 bits of the addr should correspond to the slave address. The topmost bits are ignored. The Aardvark I2C subsystem will assemble the address along with the R/W bit after grabbing the bus. For 10- bit addressing, the lower 10 bits of addr should correspond to the slave address. The Aardvark adapter will then assemble the address into the proper format as described in the Philips specification, namely by first issuing an write transaction on the bus to specify the 10-bit slave and then a read transaction to read the requested number of bytes. The initial write transaction can be skipped if the Combined Format feature is requested in conjunction with the 10-bit addressing functionality.
Please see the Aardvark I2C/SPI Embedded Systems Interface Datasheet for more information.
i2c_free_bus
<i2c_free_bus/>
Free the Aardvark I2C subsystem from a held bus condition (e.g., no stop).
Parameters
None
Details
If the Aardvark I2C subsystem had executed a master transaction and is holding the bus due to a previous nostop flag, this function will issue the stop command and free the bus.
Please see the Aardvark I2C/SPI Embedded Systems Interface Datasheet for more information.
5.4 SPI Commands
spi_config
<spi_config polarity="polarity"
phase="phase"
bitorder="bitorder"
ss="ss"/>
Configure the SPI master interface.
Parameters
- polarity
Set as either “rising/falling” or “falling/rising”.- phase
Set as either “sample/setup” or “setup/sample”.- bitorder
Set as either “msb” or “lsb”.- ss
Set as either “active_low” or “active_high”.
Details
These configuration parameters specify how to clock the bits that are sent and received on the Aardvark SPI interface.
The polarity option specifies which transition constitutes the leading edge and which transition is the falling edge. For example, “rising/falling” would configure the SPI to idle the SCLK clock line low. The clock would then transition low-to-high on the leading edge and high-to-low on the trailing edge.
The phase option determines whether to sample or setup on the leading edge. For example, “sample/setup” would configure the SPI to sample on the leading edge and setup on the trailing edge. The bitorder option is used to indicate whether LSB or MSB is shifted first.
The ss option is used change the output polarity on the SS line. For example, “active_low” will pull the SS line low to active the slave device.
Please see the Aardvark I2C/SPI Embedded Systems Interface Datasheet for more information.
spi_bitrate
<spi_bitrate khz="khz"/>
Set the SPI bitrate in kilohertz.
Parameters
- khz
The requested bitrate in kHz.
Details
The power-on default bitrate is 1000 kHz. Only certain discrete bitrates are supported by the Aardvark adapter. As such, this actual bitrate set will be less than or equal to the requested bitrate unless the requested value is less than 125 kHz, in which case the Aardvark adapter will default to 125 kHz.
The actual bitrate is returned in the Transaction Log.
Please see the Aardvark I2C/SPI Embedded Systems Interface Datasheet for more information.
spi_write
<spi_write count="count"
radix="radix">
message
</spi_write>
Write a stream of bytes to the downstream SPI slave device and read back the full-duplex response.
Parameters
- count
The number of bytes to write (maximum 65535).- radix
The base of the number system of the message, with the value being 10 for decimal, or 16 for hexadecimal.- message
The message to transmit as a space separated list of numbers.
Details
If count is 0, no bytes will be written to the slave. However, the slave select line will be dropped for 5-10 microseconds. This can be useful in sending a signal to a downstream SPI slave without actually sending any bytes. For example, if an SPI slave has tied the slave select to an interrupt line and it sees the line is toggled without any bytes sent, it can interpret the action as a command to prepare its firmware for an subsequent reception of bytes.
Please see the Aardvark I2C/SPI Embedded Systems Interface Datasheet for more information.
5.5 GPIO Commands
The following table maps the named lines on the Aardvark I2C/SPI output cable to bit positions in the direction and pullups masks. All GPIO API functions will index these lines through a single 8-bit masked value. Thus, each bit position in the mask can be referred back its corresponding line through the mapping described below.
Pin # |
Bit Value |
Description |
Pin 1 |
0x01 |
I2C SCL line |
Pin 3 |
0x02 |
I2C SDA line |
Pin 5 |
0x04 |
SPI MISO line |
Pin 7 |
0x08 |
SPI SCK line |
Pin 8 |
0x10 |
SPI MOSI line |
Pin 9 |
0x20 |
SPI SS line |
gpio_config
<gpio_config direction="direction"
pullups="pullups"/>
Configure the GPIO interface.
Parameters
- direction
A single byte value where each bit corresponds to the physical line as defined in Table 3. If a line’s bit is 0, the line is configured as an input. Otherwise it will be an output.- pullups
A single byte value where each bit corresponds to the physical line as defined in Table 3. If a line’s bit is 1, the line’s pullup is active whenever the line is configured as an input. Otherwise the pullup will be deactivated.
Details
Please see the Aardvark I2C/SPI Embedded Systems Interface Datasheet for more information.
gpio_get
<gpio_get/>
Get the value of current GPIO inputs.
Parameters
None
Details
A line’s bit position in the mask will be 0 if it is configured as an output or if it corresponds to a subsystem that is still active.
Please see the Aardvark I2C/SPI Embedded Systems Interface Datasheet for more information.
gpio_set
<gpio_set value="value"/>
Set the value of current GPIO outputs.
Parameters
- value
A bitmask as defined in Table 3 specifying which outputs should be set to logic high and which should be set to logic low.
Details
If a line is configured as an input or not activated for GPIO, the output value will be cached. The next time the line is an output and activated for GPIO, the output value previously set will automatically take effect.
Please see the Aardvark I2C/SPI Embedded Systems Interface Datasheet for more information.
| Prev: Modules | Table of Contents | Next: Notes |
