Guest User

Untitled

a guest
Jul 20th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.45 KB | None | 0 0
  1. #ifndef LOGICINTERFACE
  2. #define LOGICINTERFACE
  3.  
  4. class UsbInterfaceManager; //forward declaration
  5.  
  6. //The typedefs of the supported callback functions.
  7. typedef void (*OnConnectType)( unsigned int logic_id, void* user_data ); //Logic connected -- it's ready to use.
  8. typedef void (*OnDisconnectType)( unsigned int logic_id, void* user_data ); //Logic disconnected.
  9. typedef void (*OnDataType)( unsigned int logic_id, unsigned char* data, unsigned int data_length, void* user_data ); //OnReadData or OnWriteData.
  10. 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.
  11.  
  12. #if defined(WIN32) && defined(DLL_BUILD)
  13. #define DLL_IMPORT_EXPORT __declspec(dllexport)
  14. #else
  15. #define DLL_IMPORT_EXPORT
  16. #endif
  17.  
  18. //LogicInterface class
  19. class DLL_IMPORT_EXPORT LogicInterface
  20. {
  21. public:
  22. LogicInterface();
  23. ~LogicInterface();
  24.  
  25. //Call this function to start connecting to Logic. Wait for a OnConnect callback before talking with Logic.
  26. void BeginConnect();
  27.  
  28. //General
  29. 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.
  30. bool IsSampling( unsigned int logic_id ); //Tells you if logic is currently reading/writing. In case you arn't keeping track.
  31. 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
  32. unsigned int GetSampleRateHz( unsigned int logic_id ); //Returns the sample rate in use. In case you wern't keeping track.
  33.  
  34. //Streaming Data
  35. void ReadStart( unsigned int logic_id ); //Start data collection. You can get the resulting data in your OnReadData callback.
  36. void WriteStart( unsigned int logic_id ); //Start writing out data. Your OnWriteData callback will be called to provide the data to Logic.
  37. void Stop( unsigned int logic_id ); //Stop data collection. Only use if data collection is actually in progress.
  38.  
  39. //Single Byte Data
  40. 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.
  41. 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.
  42.  
  43. //Callback Registration
  44. //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)
  45. //if you don't want to use user_data, just pass 0.
  46. void RegisterOnConnect( OnConnectType callback_function, void* user_data = 0 );
  47. void RegisterOnDisconnect( OnDisconnectType callback_function, void* user_data = 0 );
  48. void RegisterOnReadData( OnDataType callback_function, void* user_data = 0 );
  49. void RegisterOnWriteData( OnDataType callback_function, void* user_data = 0 );
  50. void RegisterOnError( OnErrorType callback_function, void* user_data = 0 );
  51.  
  52. void DeleteU8ArrayPtr( unsigned char* array_ptr ); //generally speaking, don't use this. It's there for DLL support.
  53.  
  54.  
  55.  
  56. private:
  57. UsbInterfaceManager* mUsbInterfaceManager;
  58. };
  59.  
  60. #endif //LOGICINTERFACE
Add Comment
Please, Sign In to add comment