Cheetah v3 05
Cheetah v3 05
Cheetah v3 05
Features
SPI Master
Full Duplex SPI at 40 MHz
Unsupported Overclocking up to 50 MHz
All Modes Supported
High-Speed USB Device (480 Mbps transfer to host PC)
Actual Host Data Throughput Nearly 100% of SPI Clock Rate
Windows, Linux and Mac OS X compatible
Cheetah SPI
Host Adapter
Low cost
Summary
The CheetahTM SPI Host Adapter is a high-speed SPI shifter that is capable of
communicating over an SPI serial bus at up to 50 MHz.
www.totalphase.com
1
1.1
General Overview
SPI Background
SPI History
SPI is a serial communication bus developed by Motorola. It is a full-duplex protocol which
functions on a master-slave paradigm that is ideally suited to data streaming applications.
SPI Theory of Operation
SPI requires four signals: clock (SCLK), master output/slave input (MOSI), master input/slave
output (MISO), slave select (SS).
Master
Slave 1
SCLK
SCLK
MOSI
MOSI
MISO
MISO
SS1
SS
SS2
SS3
Slave 2
SCLK
MOSI
MISO
SS
Slave 3
SCLK
MOSI
MISO
SS
Three signals are shared by all devices on the SPI bus: SCLK, MOSI and MISO. SCLK is
generated by the master device and is used for synchronization. MOSI and MISO are the data
lines. The direction of transfer is indicated by their names. Data is always transferred in both
directions in SPI, but an SPI device interested in only transmitting data can choose to ignore
the receive bytes. Likewise, a device only interested in the incoming bytes can transmit dummy
bytes.
Each device has its own SS line. The master pulls low on a slaves SS line to select a device
for communication.
The exchange itself has no pre-defined protocol. This makes it ideal for data-streaming applications. Data can be transferred at high speed, often into the range of the tens of megahertz.
www.totalphase.com
CPHA = 1
CPOL = 0
sample
MODE 0
MODE 1
MODE 2
MODE 3
CPOL = 1
sample
sample
sample
www.totalphase.com
2
2.1
Hardware Specifications
Connector Specification
The ribbon cable connector is a standard 0.100 (2.54mm) pitch IDC type connector. This
connector will mate with a standard keyed boxed header.
Alternatively, a split cable is available which connects to the ribbon cable and provides individual
leads for each pin.
Orientation
The ribbon cable pin order follows the standard convention. The red line indicates the first
position. When looking at your Cheetah adapter in the upright position (Figure 3), pin 1 is in the
top left corner and pin 10 is in the bottom right corner.
If you flip your Cheetah adapter over (Figure 4) such that the text on the serial number label is
in the proper upright position, the pin order is as shown in the following diagram.
Figure 4: The Cheetah SPI Host Adapter in the upside down position.
Pin 1 is located in the lower left corner of the connector and Pin 10 is located in the upper right corner of
the connector.
Order of Leads
1.
2.
3.
4.
5.
www.totalphase.com
SS2
GND
SS3
NC/+5V
MISO
NC/+5V
SCLK
MOSI
SS1
GND
Ground
GND (Pin 2):
GND (Pin 10):
It is imperative that the Cheetah adapters ground lead is connected to the ground of the target
system. Without a common ground between the two, the signaling will be unpredictable and
communication will likely be corrupted. Two ground pins are provided to ensure a secure ground
path.
SPI Pins
SCLK (Pin 7):
Serial Clock control line that is driven by the master and regulates the flow of the data bits.
MOSI (Pin 8):
Master Out Slave In this data line supplies output data from the master which is shifted into
the slave.
MISO (Pin 5):
Master In Slave Out this data line supplies the output data from the slave to the input of the
master.
SS1 (Pin 9):
Primary Slave Select the primary control line that allows slaves to be turned on and off via
hardware control. (This SS is in the same location as the SS line of the Aardvark and Beagle
products.)
SS2 (Pin 1):
Second Slave Select an additional control line that allows slaves to be turned on and off via
hardware control.
SS2 (Pin 3):
Third Slave Select an additional control line that allows slaves to be turned on and off via
hardware control.
Powering Downstream Devices
It is possible to power a downstream target, such as an SPI EEPROM with the Cheetah
adapters power (which is provided by the USB bus). It is ideal if the downstream device does
not consume more than 2030 mA. The Cheetah adapter is compatible with USB hubs as well
www.totalphase.com
2.2
2.3
USB 2.0
The Cheetah adapter is a High-Speed USB 2.0 device. It can be plugged into either a highspeed or full-speed port. However, a high-speed port must be used to achieve full throughput
at high data rates (SPI clock rates >3 Mbps).
2.4
Temperature Specifications
The Cheetah adapter is designed to be operated at room temperature (1035C). The electronic
components are rated for standard commercial specifications (070C). However, the plastic
housing, along with the ribbon and USB cables, may not withstand the higher end of this range.
Any use of the Beagle device outside the room temperature specification will void the hardware
warranty.
www.totalphase.com
2.5
SS
te
tsac
tclk
tcsd
SCLK
top
MOSI
toh
B7
B6
tis
MISO
B7
B0
tih
X
B0
B6
SS
tsac
DATA
tud
tud
BYTE0
BYTE1
tcsd
BYTE2
Symbol
tclk
te
tsac
tcsd
top
toh
tis
tih
tud
Parameter
Clock period
Output Enable to SS control delay
SS# assertion to first clock edge
SS# deassertion from last clock edge
MOSI propagation time
MOSI hold time
MISO setup time
MISO hold time
User Insertable Delay
Min
25
8
6.5
1.5
0
0.5
4.8
0
8
Max
10000
8
7
2
5.8
0.5
N/A
N/A
232
Units
ns
tclk
tclk
tclk
ns
tclk
ns
ns
tclk
Notes:
www.totalphase.com
www.totalphase.com
3
3.1
Software
Compatibility
Overview
The Cheetah software is offered as a 32-bit or 64-bit Dynamic Linked Library (or shared object).
The specific compatibility for each operating system is discussed below. Be sure the device
driver has been installed before plugging in the Cheetah adapter.
Windows Compatibility
The Cheetah software is compatible with Windows XP (SP2 or later, 32-bit only), Windows
Vista (32-bit and 64-bit), and Windows 7 (32-bit and 64-bit). Windows 2000 and legacy 16-bit
Windows 95/98/ME operating systems are not supported.
Linux Compatibility
The Cheetah software is compatible with all standard 32-bit and 64-bit distributions of Linux with
kernel 2.6 and integrated USB support. When using the 32-bit library on a 64-bit distribution,
the appropriate 32-bit system libraries are also required.
Mac OS X Compatibility
The Cheetah software is compatible with Intel versions of Mac OS X 10.4 Tiger, 10.5 Leopard,
and 10.6 Snow Leopard. Installation of the latest available update is recommended.
3.2
www.totalphase.com
www.totalphase.com
10
3.3
www.totalphase.com
11
3.4
3.5
3.6
www.totalphase.com
12
www.totalphase.com
13
Hence, the DLL is not compatible with any firmware less than version 1.15 and the firmware
is not compatible with any DLL less than version 1.20. In this example, the version number
constraints are satisfied and the DLL can safely connect to the target firmware without error. If
there is a version mismatch, the API calls to open the device will fail. See the API documentation
for further details.
3.7
www.totalphase.com
14
The above situation will pass the appropriate version checks. The compatibility check is performed within the binding. If there is a version mismatch, the API function will return an error
code, CH_INCOMPATIBLE_LIBRARY.
Customizations
While the provided language bindings stubs are fully functional, it is possible to modify the code
found within this file according to specific requirements imposed by the application designer.
For example, in the C bindings one can modify the DLL search and loading behavior to conform
to a specific paradigm. See the comments in cheetah.c for more details.
3.8
Application Notes
Threading
The Cheetah DLL is designed for single-threaded environments so as to allow for maximum
cross-platform compatibility. If the application design requires multi-threaded use of the Cheetah functionality, each Cheetah API call can be wrapped with a thread-safe locking mechanism
before and after invocation.
It is the responsibility of the application programmer to ensure that the Cheetah open and close
operations are thread-safe and cannot happen concurrently with any other Cheetah operations.
However, once a Cheetah device is opened, all operations to that device can be dispatched to
a separate thread as long as no other threads access that same Cheetah device.
www.totalphase.com
15
www.totalphase.com
16
4
4.1
Firmware
Philosophy
The firmware included with the Cheetah adapter provides for the analysis of the supported
protocols. It is installed at the factory during manufacturing. Updates to this firmware are
provided through a device upgrade utility. The Cheetah software automatically detects firmware
compatibility and will inform the user if an upgrade is required.
4.2
Procedure
Firmware upgrades should be conducted using the procedure specified in the README.txt that
accompanies the particular firmware revision.
www.totalphase.com
17
5
5.1
API Documentation
Introduction
The API documentation describes the Cheetah Rosetta C bindings.
5.2
5.3
unsigned
unsigned
unsigned
unsigned
signed
signed
signed
signed
char
short
int
long long
char
short
int
long long
u08;
u16;
u32;
u64;
s08;
s16;
s32;
s64;
www.totalphase.com
18
www.totalphase.com
19
5.4
General
Interface
Find Devices (ch_find_devices)
int ch_find_devices (int
nelem,
u16 * devices);
Return Value
This function returns the number of devices found, regardless of the array size.
Specific Error Codes
None.
Details
Each element of the array is written with the port number.
Devices that are in use are ORed with CH_PORT_NOT_FREE (0x8000). Under Linux, such devices correspond to Cheetah adapters that are currently in use. Under Windows, such devices
are currently in use, but it is not known if the device is a Cheetah adapter.
Example:
Devices are attached to port 0, 1, 2.
Ports 0 and 2 are available, and port 1 is in-use.
devices = { 0x0000, 0x8001, 0x0002 }
If the input array is NULL, it is not filled with any values.
If there are more devices than the array size (as specified by nelem), only the first nelem port
numbers will be written into the array.
Find Devices (ch_find_devices_ext)
int ch_find_devices_ext (int
num_devices,
u16 * devices,
int
num_ids,
u32 * unique_ids);
Get a list of ports and unique IDs to which Cheetah devices are attached.
Arguments
num_devices: maximum number of devices to return
devices: array into which the port numbers are returned
num_ids: maximum number of device IDs to return
unique_ids: array into which the unique IDs are returned
www.totalphase.com
20
Return Value
This function returns a Cheetah handle, which is guaranteed to be greater than zero if valid.
Specific Error Codes
CH_UNABLE_TO_OPEN: The specified port is not connected to a Cheetah device or the port is
already in use.
CH_INCOMPATIBLE_DEVICE: There is a version mismatch between the DLL and the hardware.
The DLL is not of a sufficient version for interoperability with the hardware version or vice
versa. See ch_open_ext() for more information.
Details
This function is recommended for use in simple applications where extended information is not
required. For more complex applications, the use of ch_open_ext() is recommended.
Open a Cheetah device (ch_open_ext)
Cheetah ch_open_ext (int port_number, CheetahExt *ch_ext);
Open the Cheetah port, returning extended information in the supplied structure.
Arguments
port_number: same as ch_open
ch_ext: pointer to pre-allocated structure for extended version information available on open
Return Value
This function returns a Cheetah handle, which is guaranteed to be greater than zero if valid.
www.totalphase.com
21
Details
If 0 is passed as the pointer to the structure ch_ext, this function will behave exactly like
ch_open().
The CheetahExt structure is described below:
struct CheetahExt {
CheetahVersion
version;
/* Features of this device. */
int
features;
}
The CheetahVersion structure describes the various version dependencies of Cheetah components. It can be used to determine which component caused an incompatibility error.
struct CheetahVersion {
/* Software and hardware versions. */
u16 software;
u16 firmware;
u16 hardware;
/*
* Hardware revisions that are compatible with this
* software version. The top 16 bits gives the maximum
* accepted hardware revision. The lower 16 bits gives
* the minimum accepted hardware revision.
*/
u32 hw_revs_for_sw;
/*
* Firmware revisions that are compatible with this
* software version. The top 16 bits gives the maximum
* accepted firmware revision. The lower 16 bits gives
* the minimum accepted firmware revision.
*/
u32 fw_revs_for_sw;
/*
* Driver revisions that are compatible with this
* software version. The top 16 bits gives the maximum
* accepted driver revision. The lower 16 bits gives
www.totalphase.com
22
The structure is zeroed before the open is attempted. It is filled with whatever information
is available. For example, if the hardware version is not filled, then the device could not be
queried for its version number.
This function is recommended for use in complex applications where extended information is
required. For simpler applications, the use of ch_open() is recommended.
Close a Cheetah (ch_close)
int ch_close (Cheetah cheetah);
Return Value
The number of adapters closed is returned on success. This will usually be 1.
Specific Error Codes
None.
Details
If the handle argument is zero, the function will attempt to close all possible handles, thereby
closing all open Cheetah adapters. The total number of Cheetah adapters closed is returned
by the function.
Get Port (ch_port)
int ch_port (Cheetah cheetah);
www.totalphase.com
23
Return Value
The port number corresponding to the given handle is returned. It is a zero-based number.
Specific Error Codes
None.
Details
None.
Get Unique ID (ch_unique_id)
u32 ch_unique_id (Cheetah cheetah);
Return Value
This function returns the unique ID for this Cheetah adapter. The IDs are guaranteed to be
non-zero if valid. The ID is the unsigned integer representation of the 10-digit serial number.
Specific Error Codes
None.
Details
None.
Status String (ch_status_string)
const char *ch_status_string (int status);
Return Value
This function returns a human readable string that corresponds to status. If the code is not
valid, it returns a NULL string.
Specific Error Codes
None.
Details
None.
www.totalphase.com
24
Return the version matrix for the device attached to the given handle.
Arguments
cheetah: handle of a Cheetah adapter
version: pointer to pre-allocated structure
Return Value
A Cheetah status code is returned with CH_OK on success.
Specific Error Codes
None.
Details
If the handle is 0 or invalid, only the software version is set.
See the details of ch_open_ext for the definition of CheetahVersion.
Sleep (ch_sleep_ms)
u32 ch_sleep_ms (u32 milliseconds);
Return Value
This function returns the number of milliseconds slept.
Specific Error Codes
None.
Details
This function provides a convenient cross-platform function to sleep the current thread using
standard operating system functions.
The accuracy of this function depends on the operating system scheduler. This function will
return the number of milliseconds that were actually slept.
Target Power (ch_target_power)
int ch_target_power (Cheetah cheetah, u08 power_mask);
www.totalphase.com
25
CH_TARGET_POWER_OFF
CH_TARGET_POWER_ON
CH_TARGET_POWER_QUERY
The current state of the target power pins on the Cheetah adapter will be returned. The configuration will be described by the same values as in the table above.
Specific Error Codes
None.
Details
Both target power pins are controlled together. Independent control is not supported. This
function may be executed in any operation mode.
Host Interface Speed (ch_host_ifce_speed)
int ch_host_ifce_speed (Cheetah cheetah);
Return Value
This function returns enumerated values specifying the USB speed at which the host computer
is communicating with the given Cheetah device. See Table 3.
Table 3: Host interface speed enumerated types
CH_HOST_IFCE_FULL_SPEED
Full speed (12Mbps) interface
CH_HOST_IFCE_HIGH_SPEED
High Speed (480Mbps) interface
www.totalphase.com
26
5.5
SPI Interface
SPI Overview
In order to use the Cheetah API to send SPI data across the bus at high speed, commands are
accumulated in a queue until a call is made to batch shift all of the queued commands. The
sequence of commands in the command queue for a typical SPI transaction is:
1. Call ch_spi_queue_clear to clear the command queue.
2. Call ch_spi_queue_oe to add a command to the queue to enable the Cheetah devices
outputs on the SPI bus.
3. Call ch_spi_queue_ss to add a command to the queue to enable the slave select signal.
4. Call ch_spi_queue_byte and ch_spi_queue_array to queue data to be sent across
the SPI bus.
5. Call ch_spi_queue_ss to queue a command to disable the slave select signal.
6. Optionally, call ch_spi_queue_oe to queue a command to disable the outputs of the
Cheetah device.
7. Call ch_spi_batch_shift to send the accumulated accumulated commands across
the SPI bus.
Please note that the queue is not cleared after it has been executed. This allows the same
queue to be executed multiple times without re-queuing commands. The only way to clear a
queue is by calling ch_spi_queue_clear.
If the user wishes to repeat the exact same shift sequence on the bus, the last step can be
executed without the preceding ones. Also, the OE enable commands and SS assert/deassert
commands are held persistent on the Cheetah device. For example, if the SS line is left asserted
after one transaction, it will stay asserted until modified in a subsequent transaction.
The data sent from the slave device to the Cheetah device across the MISO line will be filled into
the data_in parameter of the ch_spi_batch_shift function. Also, ch_spi_batch_length
can be called prior to calling ch_spi_batch_shift to find out how large of an array needs to
be allocated for the data_in argument.
The SPI master and slave must both be configured to use the same bit protocol (mode). Prior
to sending any data across the SPI bus, the application should call ch_spi_configure and
ch_spi_bitrate to set the proper configuration for the SPI communication.
This architecture for the Cheetah API allows for maximum flexibility of the control lines (SS1,
SS2, and SS3) and provides for a mechanism to avoid expensive USB scheduling delays (as
described in a previous section of this datasheet). For example, one can send several separate
SPI packets with the following sequence:
1. Assert the OE.
www.totalphase.com
27
www.totalphase.com
28
Return Value
This function returns the actual bitrate set.
Specific Error Codes
None.
Details
The power-on default bitrate is 1 MHz.
Only certain discrete bitrates are supported by the Cheetah adapter. As such, this actual bitrate
set will be less than or equal to the requested bitrate unless the requested value is less than
100 kHz, in which case the Cheetah adapter will default to 100 kHz. The maximum supported
speed for the Cheetah adapter is 50 MHz.
If bitrate_khz is 0, the function will set the bit rate to the minimum value, 100 kHz.
Configure SPI Bus Parameters (ch_spi_configure)
int ch_spi_configure (Cheetah
CheetahSpiPolarity
CheetahSpiPhase
CheetahSpiBitorder
u08
cheetah,
polarity,
phase,
bitorder,
ss_polarity);
Return Value
www.totalphase.com
29
CH_SPI_PHASE_SETUP_SAMPLE
nal
Sample on the trailing edge of the clock signal
CH_SPI_BITORDER_MSB
CH_SPI_BITORDER_LSB
Return Value
A Cheetah status code is returned with CH_OK on success.
Specific Error Codes
None.
Details
All queued data and commands are removed from the queue.
www.totalphase.com
30
Return Value
A Cheetah status code is returned with CH_OK on success.
Specific Error Codes
None.
Details
This function enables and disables the outputs on the Cheetah device. When enabled, the
Cheetah device connects to the SPI bus and is ready to drive the signal lines. When the
Cheetah output enable is disabled, the device disconnects from the bus and each signal line is
held at their current values with very weak internal pull-up or pull-down on the Cheetah device.
Call this function to enable the Cheetah outputs before calling any of the other queue functions.
Queue Slave Select Signals (ch_spi_queue_ss)
int ch_spi_queue_ss (Cheetah cheetah,
u08
active);
Return Value
A Cheetah status code is returned with CH_OK on success.
Specific Error Codes
None.
Details
This function adds a command to the batch queue to assert/deassert the SPI slave select lines.
The active parameter is a bit mask. For example, setting active to 0x05 would mean that
SS3 and SS1 are asserted and SS2 is deasserted. The polarity of the slave select is determined
from a previous call to ch_spi_configure.
www.totalphase.com
31
Queue a byte value to be sent across the bus one or more times.
Arguments
cheetah: handle of a Cheetah adapter
count: number of bytes to put in queue
data_out: value of the byte to queue
Return Value
Returns the actual number of times the byte in data_out was added to the queue. This should
equal count.
Specific Error Codes
None.
Details
Queues count number of bytes to send and sets each byte to the value of data_out.
For this command, and the ch_spi_queue_array command, the polarity, phase, and bit ordering will be determined by the configuration set with the ch_spi_configure function.
Queue a Byte Array (ch_spi_queue_array)
int ch_spi_queue_array (Cheetah
u16
const u08 *
cheetah,
num_bytes,
data_out);
Return Value
Returns the number of bytes queued. This should equal num_bytes.
Specific Error Codes
None.
Details
The array will be processed with a minimal run length encoding algorithm, so repeated sequences of single bytes will be sent more efficiently. This helps reduce outgoing (host to Cheetah) bandwidth on the USB bus.
For this command, and the ch_spi_queue_byte command, the polarity, phase, and bit ordering will be determined by the configuration set with the ch_spi_configure function.
www.totalphase.com
32
Return Value
Returns the actual number of cycles of delay that were queued.
Specific Error Codes
None.
Details
Queues cycles amount of delay on the bus. These are in units of clock cycles as set with
ch_spi_bitrate. The delays can only be queued in multiples of 8. The function will return
the actual number of cycles queued. The requested number of cycles will be rounded up to the
next multiple of 8.
The requested number of cycles must be greater than zero and less than or equal to 232 9. If
the requested number of cycles is out of bounds, no delay is queued and the function will return
0.
Queue a Delay in Nanoseconds (ch_spi_queue_delay_ns)
int ch_spi_queue_delay_ns (Cheetah cheetah,
int
nanoseconds);
Return Value
Returns the actual number of nanoseconds of delay that were queued.
Specific Error Codes
None.
Details
Queues nanoseconds amount of delay on the bus. The fundamental unit of delay that can be
queued on the Cheetah SPI bus is 8 times the clock period. Therefore, requested delay will
be rounded up to the next even multiple of this time span. The function will return the actual
number of nanoseconds queued.
The requested number of nanoseconds must be greater than zero and less than or equal to 2
seconds. If the requested number of nanoseconds is out of bounds, no delay is queued and the
function will return 0.
www.totalphase.com
33
cheetah);
Return Value
Returns the number of data bytes in the queue. This does not include the commands (SS
assertion, OE, etc). It only corresponds to the number of bytes that will be shifted out on the
SPI bus. The value returned is also the number of bytes to expect from the slave device when
the currently queued commands are executed.
Specific Error Codes
None.
Details
None.
Execute SPI Shift (ch_spi_batch_shift)
int ch_spi_batch_shift (Cheetah
int
u08 *
cheetah,
num_bytes,
data_in);
Return Value
The number of bytes sent by the Cheetah device across the SPI bus.
Specific Error Codes
CH_SPI_BATCH_EMPTY_QUEUE: The queue was empty.
Details
This function performs all of the accumulated commands in the queue and shifts them in order
onto the SPI bus. After the operation completes, the batch queue is not cleared. Therefore, this
function may be called repeatedly if the same sequence of commands is to be shifted across
the bus multiple times.
As data is shifted by the Cheetah device onto the MOSI line, the slave device will shift the same
amount of data back across the MISO line. This function will put the first num_bytes number
of bytes received from the slave device into the data_in array. To ensure that all of the data
from the slave device is captured, call ch_spi_batch_length to determine how much data to
expect from the slave device. Setting num_bytes to 0 is permissible for cases where the data
from slave device is not required and can simply be discarded.
www.totalphase.com
34
cheetah);
Submit the SPI shift operations in the queue for asynchronous execution.
Arguments
cheetah: handle of a Cheetah adapter
Return Value
The number of bytes to be sent by the Cheetah device across the SPI bus.
Specific Error Codes
CH_SPI_BATCH_EMPTY_QUEUE: The queue was empty.
CH_SPI_ASYNC_MAX_REACHED: The maximum number of outstanding asynchronous batches
has been reached.
CH_SPI_ASYNC_EXCESS_DELAY: The queue has a queued delay after the last shifted byte,
which is not permissible for asynchronous batch shifting.
Details
This function will submit the current batch queue asynchronously to the Cheetah. A temporary
outgoing buffer will be created to store the batch queue. An internal incoming buffer will be
also created to asynchronously capture the slave response data. The application programmer
does not have to explicitly manage these two buffers. The function will immediately return after
queuing this batch onto the USB, rather than waiting for the shift to complete on the SPI bus.
At this point, the application can submit another batch to the queue. This can be done immediately by submitting the same queue a second time without altering it the application
simply needs to call ch_spi_async_submit again. Or, the application may clear the queue
and assemble a different batch all together (see the ch_spi_queue family of functions). Any
subsequent calls to ch_spi_async_submit will again create a temporary outgoing buffer and
copy the current batch into it. Likewise, a temporary incoming buffer will also be created.
Note that the submitted batch should be sufficiently long (in real time) so that it does not complete before the application can submit more batches (and also collect the first batch). This will
allow the adjacent batches to shift with very little delay between them. How long to be safe?
First, there is always the possibility that the applications process could be scheduled out by the
operating system before it has an opportunity to submit the subsequent batch. The operating
system scheduler timeslice may be as much as 10 ms. Therefore, submitted batches should
be long enough to bridge one, if not two, time slices. Second, if the application is performing
its own functions between the submission of two batches, the length of the batches should be
long enough to accommodate the CPU time of those functions.
Keep in mind that there can significant memory overhead for each asynchronous batch:
www.totalphase.com
35
cheetah,
num_bytes,
data_in);
Return Value
The number of bytes sent by the Cheetah device across the SPI bus.
Specific Error Codes
CH_SPI_ASYNC_EMPTY: There are no outstanding asynchronous batches to be collected.
Details
This function can be called at anytime after submitting a batch for asynchronous processing. It
will block until the first pending batch completes. For example, if there are 5 batches outstanding, this function will return after 1 batch has fully completed, leaving the other 4 batches still
outstanding.
The function will fill the user-supplied buffer with the incoming MISO data for the completed
batch. The incoming data will be copied from the internal incoming buffer originally created
by ch_spi_async_submit into the user supplied data_in buffer. The internal buffers (both
outgoing and incoming) for the completed batch will be deleted before this function returns to
the application.
If ch_close is called without collecting pending asynchronous batches, those batches will be
canceled, even if they are in progress. All temporary buffers will be freed as well.
A suggested mode of operation would be as follows:
www.totalphase.com
36
www.totalphase.com
37
5.6
Error Codes
Table 7: Cheetah API Error Codes
Literal Name
CH_OK
CH_UNABLE_TO_LOAD_LIBRARY
CH_UNABLE_TO_LOAD_DRIVER
CH_UNABLE_TO_LOAD_FUNCTION
CH_INCOMPATIBLE_LIBRARY
CH_INCOMPATIBLE_DEVICE
CH_INCOMPATIBLE_DRIVER
CH_COMMUNICATION_ERROR
CH_UNABLE_TO_OPEN
CH_UNABLE_TO_CLOSE
CH_INVALID_HANDLE
CH_CONFIG_ERROR
CH_UNKNOWN_PROTOCOL
CH_STILL_ACTIVE
CH_FUNCTION_NOT_AVAILABLE
CH_OS_ERROR
CH_SPI_WRITE_ERROR
CH_SPI_BATCH_EMPTY_QUEUE
CH_SPI_BATCH_SHORT_BUFFER
CH_SPI_ASYNC_EMPTY
CH_SPI_ASYNC_PENDING
CH_SPI_ASYNC_MAX_REACHED
CH_SPI_ASYNC_EXCESS_DELAY
www.totalphase.com
Value
0
-1
-2
-3
-4
-5
-6
-7
-8
-9
-10
-11
-12
-13
-14
-15
-100
-101
-102
-103
-104
-105
-106
38
6
6.1
Legal / Contact
Disclaimer
All of the software and documentation provided in this datasheet, is copyright Total Phase, Inc.
(Total Phase). License is granted to the user to freely use and distribute the software and
documentation in complete and unaltered form, provided that the purpose is to use or evaluate
Total Phase products. Distribution rights do not include public posting or mirroring on Internet
websites. Only a link to the Total Phase download area can be provided on such public websites.
Total Phase shall in no event be liable to any party for direct, indirect, special, general, incidental, or consequential damages arising from the use of its site, the software or documentation
downloaded from its site, or any derivative works thereof, even if Total Phase or distributors
have been advised of the possibility of such damage. The software, its documentation, and
any derivative works is provided on an as-is basis, and thus comes with absolutely no warranty, either express or implied. This disclaimer includes, but is not limited to, implied warranties
of merchantability, fitness for any particular purpose, and non-infringement. Total Phase and
distributors have no obligation to provide maintenance, support, or updates.
Information in this document is subject to change without notice and should not be construed as
a commitment by Total Phase. While the information contained herein is believed to be accurate,
Total Phase assumes no responsibility for any errors and/or omissions that may appear in this
document.
6.2
6.3
Contact Information
Total Phase can be found on the Internet at http://www.totalphase.com/. If you have supportrelated questions, please email the product engineers at support@totalphase.com. For sales
inquiries, please contact sales@totalphase.com.
20062009 Total Phase, Inc.
All rights reserved.
www.totalphase.com
39
List of Figures
1
SPI Modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
26
26
29
. . . . . . . . . . . . . . . . . . . . . . . . . . .
30
38
List of Tables
. . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . .
30
Contents
1 General Overview
SPI History . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
SPI Modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
SPI References
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2 Hardware Specifications
2.1 Connector Specification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Orientation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Order of Leads . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Ground . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
SPI Pins . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
ESD protection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Power Consumption . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
www.totalphase.com
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
SPI Waveforms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Speeds . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Pin Driving . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
40
3.1 Compatibility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Windows Compatibility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Linux Compatibility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Mac OS X Compatibility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Driver Installation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Driver Removal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
10
11
UDEV . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
11
USB Hotplug . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
11
11
12
12
Detecting Ports . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
12
12
DLL Philosophy
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
12
DLL Location . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
13
DLL Versioning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
14
14
Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
14
Versioning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
15
Customizations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
15
15
Threading
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
15
16
4 Firmware
17
4.1 Philosophy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
17
4.2 Procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
17
5 API Documentation
www.totalphase.com
18
5.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
18
18
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
18
5.4 General . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
20
Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
20
20
20
21
21
23
41
23
24
24
Version (ch_version) . . . . . . . . . . . . . . . . . . . . . . . . . . . .
25
Sleep (ch_sleep_ms) . . . . . . . . . . . . . . . . . . . . . . . . . . . .
25
25
26
27
SPI Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
27
SPI Functions
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
29
29
29
30
31
31
32
. . . . . . . . . . . . . . . .
32
33
33
34
34
35
36
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
6 Legal / Contact
www.totalphase.com
38
39
6.1 Disclaimer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
39
39
39
42