SPI serial controller. More...
Public Member Functions | |
PvDeviceSPIBus () | |
Constructor. | |
~PvDeviceSPIBus () | |
Destructor. | |
PvResult | Open (IPvDeviceAdapter *aDevice, PvDeviceSerial aPort=PvDeviceSerialBulk0) |
Open an SPI channel to the device on given port. More... | |
PvResult | Close () |
Close the SPI channel to the device. More... | |
bool | IsOpened () |
Test whether SPI is opened or not. More... | |
PvResult | BurstRead (unsigned char *aBuffer, uint32_t aBufferSize, uint32_t &aBytesRead, uint32_t aTimeout=0) |
Retrieve bytes read back from a device. More... | |
PvResult | BurstWriteAndRead (unsigned char *aWriteBuffer, uint32_t aWriteBufferSize, uint32_t aReadBufferSize=0, bool aWriteRead=false, bool aSSNFlagOn=false) |
Send a command to the camera and/or expect data back for maximum transfers of 255 bytes. More... | |
Static Public Member Functions | |
static bool | IsSupported (IPvDeviceAdapter *aDevice, PvDeviceSerial aPort=PvDeviceSerialBulk0) |
Test whether the device supports SPI and if it is available. The device should be connected. The BulkSelector of the device should be set appropriately (e.g. if SPI is supposed to be on Bulk0, then BulkSelector should be set to Bulk0, otherwise even if the device supports SPI, this function will return false). Consult with device documentation on when and on which port SPI is supported and available. More... | |
SPI serial controller.
The PvDeviceSPIBus lets you send commands to your camera and receive the camera's replies.
SPI uses the concept of a master and slave, where the master controls the clock and initiates reads and writes. For PvDeviceSPIBus, the Pleora Video Interface is the SPI master. The SPI slave is typically a camera, but could be any SPI-capable device connected to the Pleora Video Interface.
The PvDeviceSPIBus methods manage the entire Pleora Video Interface and camera communication required to send a message to the camera. It does not however do the configuration and setting the mode to SPI (these should be done through the GenICam interface before write/read functions are called). For example if SPI is on Bulk0, then BulkSelector needs to be set to Bulk0 The BurstWriteAndRead can be used to :
For the complete hardware-level transactions for all PvDeviceSPIBus methods, see your hardware guide.
To send SPI-protocol serial commands to your camera:
PvResult PvDeviceSPIBus::BurstRead | ( | unsigned char * | aBuffer, |
uint32_t | aBufferSize, | ||
uint32_t & | aBytesRead, | ||
uint32_t | aTimeout = 0 |
||
) |
Retrieve bytes read back from a device.
Wait aTimeOut milliseconds for the data read. The data read should have been initiated by either a ReadOnly or WriteRead using BurstWriteAndRead
[out] | aBuffer | A pointer to the data being received from the camera. |
[in] | aBufferSize | The buffer's anticipated size. BurstRead never returns with a buffer size larger than the originally specified aBufferSize. |
[out] | aBytesRead | The number of bytes read. Maximum of 255 bytes |
[in] | aTimeout | Time out in milliseconds before returning if no data is received |
PvResult PvDeviceSPIBus::BurstWriteAndRead | ( | unsigned char * | aWriteBuffer, |
uint32_t | aWriteBufferSize, | ||
uint32_t | aReadBufferSize = 0 , |
||
bool | aWriteRead = false , |
||
bool | aSSNFlagOn = false |
||
) |
Send a command to the camera and/or expect data back for maximum transfers of 255 bytes.
The BurstWriteAndRead method sends a message, aBuffer, to the SPI-capable camera and or expects aReadBufferSize bytes to come back (read). There are four modes: 1) Write-Only: Write aWriteBufferSize bytes to SPI. Can hold SSNFlagOn high. aWriteRead should be false aReadBufferSize should be 0 2) Read-Only: schedule a read of aReadBufferSize bytes. aWriteBufferSize is 0. No write is done, but a read is scheduled 3) Write-Read: N bytes are written while M bytes are read back. aWriteRead and aSSNFlagOn should be false. 4) Write-Read: N bytes are written and read back. aWriteRead is true. aSSNFlagOn should be false
[in] | aWriteBuffer | A pointer to the data being sent to the camera. is ignored if Read-Only |
[in] | aWriteBufferSize | The write buffer's size. Should be 0 in Read-only mode, Maximum of 255 bytes |
[in] | aReadBufferSize | Number of bytes to read back (0 for Write-Only mode), Maximum of 255 bytes |
[in] | aWriteRead | true for Write-Read of same number of bytes |
[in] | aSSNFlagOn | when in Write-Only mode, whether to keep SS_N flag on |
bool PvDeviceSPIBus::IsOpened | ( | ) |
Test whether SPI is opened or not.
|
static |
Test whether the device supports SPI and if it is available. The device should be connected. The BulkSelector of the device should be set appropriately (e.g. if SPI is supposed to be on Bulk0, then BulkSelector should be set to Bulk0, otherwise even if the device supports SPI, this function will return false). Consult with device documentation on when and on which port SPI is supported and available.
[in] | aDevice | A pointer to connected device to test support for SPI |
[in] | aPort | Port to check support for SPI (Bulk0 default if not specified) |
PvResult PvDeviceSPIBus::Open | ( | IPvDeviceAdapter * | aDevice, |
PvDeviceSerial | aPort = PvDeviceSerialBulk0 |
||
) |
Open an SPI channel to the device on given port.
aDevice should be connected already. Will return error if device is not connect or SPI is not supported or unavailable Note that the BulkSelector and BulkMode registers should be set appropriately before calling open. For example if SPI is supported on Bulk0, then BulkSelector should be set to Bulk0 and BulkMode set to SPI before calling open. Open does not set these. In other words, it is assumed that the bulk mode has been set to SPI already using GenICam Interface before open is called
[in] | aDevice | A pointer to connected device to open an SPI channel to |
[in] | aPort | Port to use for SPI (Bulk0 default if not specified) |
Copyright (c) 2002-2021 Pleora Technologies Inc.
www.pleora.com