MityDSP Documentation Index

MityDSP::tcDspFtdiVNC1 Class Reference

#include <DspFtdiVNC1.h>

List of all members.

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
tcDspSerialmpSerial
TSK_Handle mhReceiveThrd
int mnCurrentDevice
tcFtdiParsermpParser
LCK_Handle mhCommandLck
MBX_Handle mhCommandMbx
SEM_Handle mhCommandComplete
bool mbPort1Present
bool mbPort2Present
tfMediaCallback mfMediaCallback
void * mpUserArgs [16]

Member Enumeration Documentation

Enumerator:
eeInProgress 
eeSuccess 
eeTimedOut 
eeBadCommand 
eeCommandFailed 
eeNoDisk 
Enumerator:
eeSectorRead 
eeResponseData 
eeResponsePrompt 
Enumerator:
ShortCommandSetMsg 
ExtendedCommandSetMsg 
UseAsciiMsg 
UseBinaryMsg 
FirmwareVersionMsg 
SetBaudMsg 
SectorDumpMsg 
SectorWriteMsg 
IdentifyDiskDrive 
SelectSourceDisk 
SelectTargetDisk 
QueryPort1Msg 
QueryPort2Msg 
QueryDeviceMsg 
SetCurrentMsg 
Enumerator:
eeCommand 
eeData 

Constructor & Destructor Documentation

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.

Parameters:
[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.

  • apLatchID[0] is the reset pin
  • apLatchID[1] is the tri state pin
  • apLatchID[2] is the ACBUS5 pin for interface mode selection
  • apLatchID[3] is the ACBUS6 pin for interface mode selection
Returns:
None.
See also:
DspFtdiVNC1.h
MityDSP::tcDspFtdiVNC1::~tcDspFtdiVNC1 (  ) 

Member Function Documentation

void tcDspFtdiVNC1::ReceiveDispatch ( Arg  ftdiVNC1  )  [static]

Static dispatch for receive thread.

Parameters:
[in] ftdiVNC1 pointer to VNC1 object
Returns:
None.
See also:
DspFtdiVNC1.h
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.

Parameters:
[in] apLatch Pointer to an output latch controlling Chip Select.
[in] apLatchID Array of latch IDs to use for this device.

  • apLatchID[0] is the reset pin
  • apLatchID[1] is the tri state pin
  • apLatchID[2] is the ACBUS5 pin for interface mode selection
  • apLatchID[3] is the ACBUS6 pin for interface mode selection

To reset the device, we do the following dance...

  • first set tri-state pin to normal
  • Set the interface mode pins to both low (to tell the chip to use serial mode). (The FTDI VNC1 chip only reads these pins at reset).
  • Toggle reset the line ( a small delay here to make sure the device resets (I couldn't find a spec'd value for reset time).
  • first set tri-state pin back to tri-state

void tcDspFtdiVNC1::Initialize ( int  anBaud,
int  anThreadPri 
)

Initialize the class.

Sets the baud rate for the interface and launches receive thread for the parser.

Parameters:
[in] anBaud Baud rate to use for FTDI interface
[in] anThreadPri Priority for the USB receive thread
Returns:
None.
See also:
DspFtdiVNC1.h
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.

Returns:
None.
See also:
DspFtdiVNC1.h
void tcDspFtdiVNC1::SetBaudRate ( int  anBaud  ) 

Set the FTDI chip baud rate.

Set the baud rate to the FTDI interface.

Parameters:
[in] anBaud Baud rate to use
Returns:
None.
See also:
DspFtdiVNC1.h
void tcDspFtdiVNC1::SetMediaCallback ( unsigned char  anDeviceId,
tfMediaCallback  afCallback,
void *  apUserArg 
)

Sets the callback for USB detected/removed.

Parameters:
[in] anDeviceId USB device index
[in] afCallback Callback
[in] apUserArg Pointer to a user arguement to be provided to the callback
Returns:
None.
See also:
DspFtdiVNC1.h
void tcDspFtdiVNC1::StartReceive (  ) 

Starts the receive parser.

Returns:
None.
See also:
DspFtdiVNC1.h
void tcDspFtdiVNC1::WaitParserStart (  ) 

Sleeps until the parser is alive.

Returns:
None.
See also:
DspFtdiVNC1.h
void tcDspFtdiVNC1::SetMode ( teOperatingMode  apMode  ) 
void tcDspFtdiVNC1::SetCurrentDevice ( int  anDeviceId  ) 

Sets the current device.

Currently disabled for VDFC firmware.

Parameters:
[in] anDeviceId Id of device to select
See also:
DspFtdiVNC1.h

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.

Parameters:
anDeviceId the device id (0[Port1]-1[Port2])
Returns:
true if disk was selected, false if command timeout or no disk
bool tcDspFtdiVNC1::StorageDevicePresent ( unsigned int  offset  ) 
Parameters:
[in] offset device number
Returns:
true if a BOMS device is present
See also:
DspFtdiVNC1.h
int tcDspFtdiVNC1::WriteSector ( char  anDeviceId,
unsigned int  anSector,
void *  apData,
int  anBytes 
)

Writes a sector on a BOMS device.

Parameters:
[in] anDeviceId the device id
[in] anSector sector number
[in] apData data to write
[in] anBytes number of bytes to write (should be 512)
Returns:
number of bytes written, or -1 if error
See also:
DspFtdiVNC1.h
int tcDspFtdiVNC1::ReadSector ( char  anDeviceId,
unsigned int  anSector,
void *  apBuffer,
int  anBytes 
)

Reads a sector on a BOMS device.

Parameters:
[in] anDeviceId the device id
[in] anSector sector number
[out] apBuffer buffer for data read
[in] anBytes size of buffer
Returns:
number of bytes read, or 0 if error
See also:
DspFtdiVNC1.h
int tcDspFtdiVNC1::GetBOMSDevice ( int  anStartDevice  ) 
Parameters:
[in] anStartDevice device number
Returns:
anStartDevice
Note:
non-functional
See also:
DspFtdiVNC1.h
int tcDspFtdiVNC1::GetNumSectors ( int  anDeviceId  ) 

Gets the number of sectors on a BOMS device.

Parameters:
[in] anDeviceId device number (0 or 1)
Returns:
number of sectors present
See also:
DspFtdiVNC1.h
int tcDspFtdiVNC1::SendCommand ( char *  buff,
int  len 
)

Sends a command.

Parameters:
[in] buff data to send
[in] len number of bytes to send
Returns:
number of bytes sent
See also:
DspFtdiVNC1.h
int tcDspFtdiVNC1::GetData ( char *  buff,
int  len,
int  timeout = 0 
)

Gets data from the FTDI interface.

Parameters:
[out] buff buffer to send
[in] len size in bytes of buffer
[in] timeout 
Returns:
number of bytes read
Note:
This will only work if the parser is disabled.
See also:
DspFtdiVNC1.h
int tcDspFtdiVNC1::ReadResponse ( char *  buff,
int  len 
)

Gets data from the FTDI interface, waiting for a prompt afterwords.

Parameters:
[out] buff buffer to send
[in] len size in bytes of buffer
Returns:
number of bytes read
Note:
This will only work if the parser is disabled.
See also:
DspFtdiVNC1.h
void tcDspFtdiVNC1::CallbackMediaState ( unsigned char  anDeviceId,
bool  abPresent 
)

Calls the callback associated with the device.

Parameters:
[in] anDeviceId USB device index
[in] abPresent true if device is present
Returns:
None.
See also:
DspFtdiVNC1.h
bool tcDspFtdiVNC1::DevicePresent ( unsigned int  offset,
int  anTypeMask 
) [protected]

Returns true if a device with the appropriate type mask is present.

Parameters:
[in] offset the device id
[in] anTypeMask type of device
Returns:
true if the device was present
Note:
For VDFC firmware
See also:
DspFtdiVNC1.h
void tcDspFtdiVNC1::SetShortCommandMode (  )  [protected]

Sets VNC1L to use short commands.

Returns:
None.
See also:
DspFtdiVNC1.h
bool tcDspFtdiVNC1::LookForPrompt (  )  [protected]

Read from serial until we get the prompt.

Looks for a prompt on the FTDI interface.

Returns:
true if a prompt was found before 10 bad reads.
Note:
This will only work if the parser is disabled.
See also:
DspFtdiVNC1.h

Member Data Documentation

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]
TSK_Handle MityDSP::tcDspFtdiVNC1::mhReceiveThrd [protected]
LCK_Handle MityDSP::tcDspFtdiVNC1::mhCommandLck [protected]
MBX_Handle MityDSP::tcDspFtdiVNC1::mhCommandMbx [protected]
void* MityDSP::tcDspFtdiVNC1::mpUserArgs[16] [protected]

  
Generated on Fri Sep 23 16:33:50 2011 for MityDSP Core by  Doxygen Version 1.6.1
Copyright © 2009, Critical Link LLC, All rights reserved.