#include <DspFtdiVNC1.h>
Classes | |
class | tcFtdiParser |
struct | tsCommandMbxData |
struct | tsResponse |
Public Types | |
enum | teError { eeInProgress, eeSuccess, eeTimedOut, eeBadCommand, eeCommandFailed, eeNoDisk } |
enum | teResponseClass { eeSectorRead, eeResponseData, eeResponsePrompt } |
enum | teCommandSet { ShortCommandSetMsg = 0x10, ExtendedCommandSetMsg = 0x11, UseAsciiMsg = 0x90, UseBinaryMsg = 0x91, FirmwareVersionMsg = 0x13, SetBaudMsg = 0x14, SectorDumpMsg = 0x03, SectorWriteMsg = 0x92, IdentifyDiskDrive = 0x0F, SelectSourceDisk = 0x41, SelectTargetDisk = 0x42, QueryPort1Msg = 0x2B, QueryPort2Msg = 0x2C, QueryDeviceMsg = 0x85, SetCurrentMsg = 0x86 } |
enum | teOperatingMode { eeCommand, eeData } |
Public Member Functions | |
tcDspFtdiVNC1 (tcDspSerial *mpSerial, tcDspOutputLatch *apLatch, unsigned int apLatchID[4]) | |
This constructor is used to open an interface to a FTDI VNC1 device via the provided serial interface. | |
~tcDspFtdiVNC1 () | |
void | ResetDevice (tcDspOutputLatch *apLatch, unsigned int apLatchID[4]) |
Reset the device. | |
void | Initialize (int anBaud, int anThreadPri) |
Initialize the class. | |
bool | GetVersion (char *apBuff, int &arBuffLen) |
Get the FTDI firmware version (via the FWV command);. | |
void | SetDebugMode (bool abOn) |
Enter / Exit debug mode (suspend message parsing). | |
void | SetBaudRate (int anBaud) |
Set the FTDI chip baud rate. | |
void | SetMediaCallback (unsigned char anDeviceId, tfMediaCallback afCallback, void *apUserArg) |
Sets the callback for USB detected/removed. | |
void | StartReceive () |
Starts the receive parser. | |
void | WaitParserStart () |
Sleeps until the parser is alive. | |
void | SetMode (teOperatingMode apMode) |
void | SetCurrentDevice (int anDeviceId) |
Sets the current device. | |
bool | SetCurrentDisk (int anDeviceId) |
For VDFC firmware, to set the selected disk. | |
bool | StorageDevicePresent (unsigned int offset) |
int | WriteSector (char anDeviceId, unsigned int anSector, void *apData, int anBytes) |
Writes a sector on a BOMS device. | |
int | ReadSector (char anDeviceId, unsigned int anSector, void *apBuffer, int anBytes) |
Reads a sector on a BOMS device. | |
int | GetBOMSDevice (int mnStartDevice) |
int | GetNumSectors (int mnDevice) |
Gets the number of sectors on a BOMS device. | |
int | SendCommand (char *buff, int len) |
Sends a command. | |
int | GetData (char *buff, int len, int timeout=0) |
Gets data from the FTDI interface. | |
int | ReadResponse (char *buff, int len) |
Gets data from the FTDI interface, waiting for a prompt afterwords. | |
void | CallbackMediaState (unsigned char anDeviceId, bool mbPresent) |
Calls the callback associated with the device. | |
Static Public Member Functions | |
static void | ReceiveDispatch (Arg) |
Static dispatch for receive thread. | |
Static Public Attributes | |
static const int | cnBaud9600 = 0x004138 |
static const int | cnBaud19200 = 0x00809C |
static const int | cnBaud115200 = 0x00001A |
static const int | cnBaud921600 = 0x008003 |
static const int | cnBaud1000000 = 0x000003 |
static const int | cnBaud1500000 = 0x000002 |
static const int | cnBaud2000000 = 0x000001 |
static const int | cnBaud3000000 = 0x000000 |
static const int | DeviceInsertedP1 = 0x3144 |
static const int | DeviceRemovedP1 = 0x3152 |
static const int | DeviceInsertedP2 = 0x3244 |
static const int | DeviceRemovedP2 = 0x3252 |
static const int | ErrorNoDisk = 0x444E |
static const int | ErrorBadCommand = 0x4342 |
static const int | ErrorCommandFailed = 0x4643 |
static const int | MONITOR_EVENT_BYTE = 0x44 |
static const int | TYPE_BOMS = 0x20 |
Protected Member Functions | |
bool | DevicePresent (unsigned int offset, int anTypeMask) |
Returns true if a device with the appropriate type mask is present. | |
void | SetShortCommandMode () |
Sets VNC1L to use short commands. | |
bool | LookForPrompt () |
Read from serial until we get the prompt. | |
Protected Attributes | |
teOperatingMode | meMode |
int | mnDataReqBit |
int | mnDataAckBit |
tcDspSerial * | mpSerial |
TSK_Handle | mhReceiveThrd |
int | mnCurrentDevice |
tcFtdiParser * | mpParser |
LCK_Handle | mhCommandLck |
MBX_Handle | mhCommandMbx |
SEM_Handle | mhCommandComplete |
bool | mbPort1Present |
bool | mbPort2Present |
tfMediaCallback | mfMediaCallback |
void * | mpUserArgs [16] |
tcDspFtdiVNC1::tcDspFtdiVNC1 | ( | tcDspSerial * | apSerialInterface, | |
tcDspOutputLatch * | apLatch, | |||
unsigned int | apLatchID[4] | |||
) |
This constructor is used to open an interface to a FTDI VNC1 device via the provided serial interface.
[in] | apSerialInterface | Pointer to the serial interface for the device. |
[in] | apLatch | Pointer to an output latch controlling Chip Select. |
[in] | apLatchID | Array of latch IDs to use for this device.
|
MityDSP::tcDspFtdiVNC1::~tcDspFtdiVNC1 | ( | ) |
void tcDspFtdiVNC1::ReceiveDispatch | ( | Arg | ftdiVNC1 | ) | [static] |
Static dispatch for receive thread.
[in] | ftdiVNC1 | pointer to VNC1 object |
void tcDspFtdiVNC1::ResetDevice | ( | tcDspOutputLatch * | apLatch, | |
unsigned int | apLatchID[4] | |||
) |
Reset the device.
Reset the FTDI VNC1 device using the provided latch and set its i/o mode to serial.
[in] | apLatch | Pointer to an output latch controlling Chip Select. |
[in] | apLatchID | Array of latch IDs to use for this device.
|
To reset the device, we do the following dance...
void tcDspFtdiVNC1::Initialize | ( | int | anBaud, | |
int | anThreadPri | |||
) |
Initialize the class.
Sets the baud rate for the interface and launches receive thread for the parser.
[in] | anBaud | Baud rate to use for FTDI interface |
[in] | anThreadPri | Priority for the USB receive thread |
bool tcDspFtdiVNC1::GetVersion | ( | char * | apBuff, | |
int & | arBuffLen | |||
) |
Get the FTDI firmware version (via the FWV command);.
wait a bit
void tcDspFtdiVNC1::SetDebugMode | ( | bool | abOn | ) |
Enter / Exit debug mode (suspend message parsing).
Disables the parser so debug commands can be issued.
void tcDspFtdiVNC1::SetBaudRate | ( | int | anBaud | ) |
Set the FTDI chip baud rate.
Set the baud rate to the FTDI interface.
[in] | anBaud | Baud rate to use |
void tcDspFtdiVNC1::SetMediaCallback | ( | unsigned char | anDeviceId, | |
tfMediaCallback | afCallback, | |||
void * | apUserArg | |||
) |
Sets the callback for USB detected/removed.
[in] | anDeviceId | USB device index |
[in] | afCallback | Callback |
[in] | apUserArg | Pointer to a user arguement to be provided to the callback |
void tcDspFtdiVNC1::StartReceive | ( | ) |
void tcDspFtdiVNC1::WaitParserStart | ( | ) |
void tcDspFtdiVNC1::SetMode | ( | teOperatingMode | apMode | ) |
void tcDspFtdiVNC1::SetCurrentDevice | ( | int | anDeviceId | ) |
Sets the current device.
Currently disabled for VDFC firmware.
[in] | anDeviceId | Id of device to select |
TJI 9/17/09 - The VDFC firmware does not understand this command, we need to use the internal state.
bool tcDspFtdiVNC1::SetCurrentDisk | ( | int | anDeviceId | ) |
For VDFC firmware, to set the selected disk.
anDeviceId | the device id (0[Port1]-1[Port2]) |
bool tcDspFtdiVNC1::StorageDevicePresent | ( | unsigned int | offset | ) |
[in] | offset | device number |
int tcDspFtdiVNC1::WriteSector | ( | char | anDeviceId, | |
unsigned int | anSector, | |||
void * | apData, | |||
int | anBytes | |||
) |
Writes a sector on a BOMS device.
[in] | anDeviceId | the device id |
[in] | anSector | sector number |
[in] | apData | data to write |
[in] | anBytes | number of bytes to write (should be 512) |
int tcDspFtdiVNC1::ReadSector | ( | char | anDeviceId, | |
unsigned int | anSector, | |||
void * | apBuffer, | |||
int | anBytes | |||
) |
Reads a sector on a BOMS device.
[in] | anDeviceId | the device id |
[in] | anSector | sector number |
[out] | apBuffer | buffer for data read |
[in] | anBytes | size of buffer |
int tcDspFtdiVNC1::GetBOMSDevice | ( | int | anStartDevice | ) |
[in] | anStartDevice | device number |
int tcDspFtdiVNC1::GetNumSectors | ( | int | anDeviceId | ) |
Gets the number of sectors on a BOMS device.
[in] | anDeviceId | device number (0 or 1) |
int tcDspFtdiVNC1::SendCommand | ( | char * | buff, | |
int | len | |||
) |
Sends a command.
[in] | buff | data to send |
[in] | len | number of bytes to send |
int tcDspFtdiVNC1::GetData | ( | char * | buff, | |
int | len, | |||
int | timeout = 0 | |||
) |
Gets data from the FTDI interface.
[out] | buff | buffer to send |
[in] | len | size in bytes of buffer |
[in] | timeout |
int tcDspFtdiVNC1::ReadResponse | ( | char * | buff, | |
int | len | |||
) |
Gets data from the FTDI interface, waiting for a prompt afterwords.
[out] | buff | buffer to send |
[in] | len | size in bytes of buffer |
void tcDspFtdiVNC1::CallbackMediaState | ( | unsigned char | anDeviceId, | |
bool | abPresent | |||
) |
Calls the callback associated with the device.
[in] | anDeviceId | USB device index |
[in] | abPresent | true if device is present |
bool tcDspFtdiVNC1::DevicePresent | ( | unsigned int | offset, | |
int | anTypeMask | |||
) | [protected] |
Returns true if a device with the appropriate type mask is present.
[in] | offset | the device id |
[in] | anTypeMask | type of device |
void tcDspFtdiVNC1::SetShortCommandMode | ( | ) | [protected] |
bool tcDspFtdiVNC1::LookForPrompt | ( | ) | [protected] |
Read from serial until we get the prompt.
Looks for a prompt on the FTDI interface.
const int MityDSP::tcDspFtdiVNC1::cnBaud9600 = 0x004138 [static] |
const int MityDSP::tcDspFtdiVNC1::cnBaud19200 = 0x00809C [static] |
const int MityDSP::tcDspFtdiVNC1::cnBaud115200 = 0x00001A [static] |
const int MityDSP::tcDspFtdiVNC1::cnBaud921600 = 0x008003 [static] |
const int MityDSP::tcDspFtdiVNC1::cnBaud1000000 = 0x000003 [static] |
const int MityDSP::tcDspFtdiVNC1::cnBaud1500000 = 0x000002 [static] |
const int MityDSP::tcDspFtdiVNC1::cnBaud2000000 = 0x000001 [static] |
const int MityDSP::tcDspFtdiVNC1::cnBaud3000000 = 0x000000 [static] |
const int tcDspFtdiVNC1::DeviceInsertedP1 = 0x3144 [static] |
const int tcDspFtdiVNC1::DeviceRemovedP1 = 0x3152 [static] |
const int tcDspFtdiVNC1::DeviceInsertedP2 = 0x3244 [static] |
const int tcDspFtdiVNC1::DeviceRemovedP2 = 0x3252 [static] |
const int tcDspFtdiVNC1::ErrorNoDisk = 0x444E [static] |
const int tcDspFtdiVNC1::ErrorBadCommand = 0x4342 [static] |
const int tcDspFtdiVNC1::ErrorCommandFailed = 0x4643 [static] |
const int MityDSP::tcDspFtdiVNC1::MONITOR_EVENT_BYTE = 0x44 [static] |
const int MityDSP::tcDspFtdiVNC1::TYPE_BOMS = 0x20 [static] |
teOperatingMode MityDSP::tcDspFtdiVNC1::meMode [protected] |
int MityDSP::tcDspFtdiVNC1::mnDataReqBit [protected] |
int MityDSP::tcDspFtdiVNC1::mnDataAckBit [protected] |
tcDspSerial* MityDSP::tcDspFtdiVNC1::mpSerial [protected] |
TSK_Handle MityDSP::tcDspFtdiVNC1::mhReceiveThrd [protected] |
int MityDSP::tcDspFtdiVNC1::mnCurrentDevice [protected] |
tcFtdiParser* MityDSP::tcDspFtdiVNC1::mpParser [protected] |
LCK_Handle MityDSP::tcDspFtdiVNC1::mhCommandLck [protected] |
MBX_Handle MityDSP::tcDspFtdiVNC1::mhCommandMbx [protected] |
SEM_Handle MityDSP::tcDspFtdiVNC1::mhCommandComplete [protected] |
bool MityDSP::tcDspFtdiVNC1::mbPort1Present [protected] |
bool MityDSP::tcDspFtdiVNC1::mbPort2Present [protected] |
void* MityDSP::tcDspFtdiVNC1::mpUserArgs[16] [protected] |