Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #ifndef LOGICINTERFACE
- #define LOGICINTERFACE
- class UsbInterfaceManager; //forward declaration
- //The typedefs of the supported callback functions.
- typedef void (*OnConnectType)( unsigned int logic_id, void* user_data ); //Logic connected -- it's ready to use.
- typedef void (*OnDisconnectType)( unsigned int logic_id, void* user_data ); //Logic disconnected.
- typedef void (*OnDataType)( unsigned int logic_id, unsigned char* data, unsigned int data_length, void* user_data ); //OnReadData or OnWriteData.
- typedef void (*OnErrorType)( unsigned int logic_id, void* user_data ); //Logic generated a non fatal error -- ususally this just means the sample rate couldn't be maintained or some other problem caused the read or write to fail.
- #if defined(WIN32) && defined(DLL_BUILD)
- #define DLL_IMPORT_EXPORT __declspec(dllexport)
- #else
- #define DLL_IMPORT_EXPORT
- #endif
- //LogicInterface class
- class DLL_IMPORT_EXPORT LogicInterface
- {
- public:
- LogicInterface();
- ~LogicInterface();
- //Call this function to start connecting to Logic. Wait for a OnConnect callback before talking with Logic.
- void BeginConnect();
- //General
- bool IsUsb2pt0( unsigned int logic_id ); //Returns whether or not Logic is connected as a high speed USB 2.0 device (480mbps) or a Full speed (12mbps) device.
- bool IsSampling( unsigned int logic_id ); //Tells you if logic is currently reading/writing. In case you arn't keeping track.
- void SetSampleRateHz( unsigned int logic_id, unsigned int sample_rate_hz ); //Set the sample rate. Must be a supported value, i.e.: 24000000, 16000000, 12000000, 8000000, 4000000, 2000000, 1000000, 500000, 250000, 200000, 100000, 50000, 25000
- unsigned int GetSampleRateHz( unsigned int logic_id ); //Returns the sample rate in use. In case you wern't keeping track.
- //Streaming Data
- void ReadStart( unsigned int logic_id ); //Start data collection. You can get the resulting data in your OnReadData callback.
- void WriteStart( unsigned int logic_id ); //Start writing out data. Your OnWriteData callback will be called to provide the data to Logic.
- void Stop( unsigned int logic_id ); //Stop data collection. Only use if data collection is actually in progress.
- //Single Byte Data
- unsigned char GetInput( unsigned int logic_id ); //Get the current byte Logic is reading. Don't do this while you're doing the Read or Write streaming above.
- void SetOutput( unsigned int logic_id, unsigned char val ); //Make logic output a particular byte value. Don't do this while you're doing the Read or Write streaming above.
- //Callback Registration
- //user_data is provided to pass your object's 'this' pointer, allowing static member functions to access the object. (or for whatever else you might want)
- //if you don't want to use user_data, just pass 0.
- void RegisterOnConnect( OnConnectType callback_function, void* user_data = 0 );
- void RegisterOnDisconnect( OnDisconnectType callback_function, void* user_data = 0 );
- void RegisterOnReadData( OnDataType callback_function, void* user_data = 0 );
- void RegisterOnWriteData( OnDataType callback_function, void* user_data = 0 );
- void RegisterOnError( OnErrorType callback_function, void* user_data = 0 );
- void DeleteU8ArrayPtr( unsigned char* array_ptr ); //generally speaking, don't use this. It's there for DLL support.
- private:
- UsbInterfaceManager* mUsbInterfaceManager;
- };
- #endif //LOGICINTERFACE
Add Comment
Please, Sign In to add comment