usb_options.c 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. #include "main.h"
  2. #include "options.h"
  3. #include "utils.h"
  4. #include "drivers\flash\flashChip.h"
  5. #ifdef USBTMC
  6. #define _USB_OPTIONS_C
  7. #include "usb_options.h"
  8. #include "drivers\flash\flashchip.h"
  9. #define DEV_OPTIONS_SIZE 8
  10. unsigned char DeviceOptions[DEV_OPTIONS_SIZE];
  11. //-------------------------------
  12. int LoadOptions( USB_DEVICE_INFO * udi )
  13. {
  14. BREAKPOINT;
  15. return flash_API_ReadOptions( FLASH_OPT_MAIN, DeviceOptions, DEV_OPTIONS_SIZE );
  16. }
  17. //-------------------------------
  18. int StoreOptions( USB_DEVICE_INFO * udi )
  19. {
  20. BREAKPOINT;
  21. return flash_API_WriteOptions( FLASH_OPT_MAIN, DeviceOptions, DEV_OPTIONS_SIZE );
  22. }
  23. //-------------------------------
  24. int InterfaceSwitch( USB_DEVICE_INFO * udi, USB_INTERFACE interface )
  25. {
  26. if(interface == USB_INTERFACE_CONT )
  27. {
  28. s_memset( DeviceOptions, 0xFF, DEV_OPTIONS_SIZE );
  29. }
  30. else
  31. {
  32. #ifdef USBTMC_LOCKED
  33. s_memset( DeviceOptions, 0xFF, DEV_OPTIONS_SIZE );
  34. #else
  35. s_memcpy( DeviceOptions, "USBTMC!", DEV_OPTIONS_SIZE );
  36. #endif
  37. }
  38. return StoreOptions ( udi );
  39. }
  40. //-------------------------------
  41. USB_INTERFACE GetInterface( USB_DEVICE_INFO * udi )
  42. {
  43. //#ifndef DEBUG_FIRST_RELEASE // îòëàäî÷íûé îáðàçåö - òîëüêî ïåðåêëþ÷åíèå êëþ÷åé äëÿ Ñàçîíîâà.
  44. //BREAKPOINT;
  45. //#endif
  46. //#ifndef DEBUG_FIRST_RELEASE
  47. //flash_Debug();
  48. //#endif
  49. ///*debug!*/tn_arm_enable_interrupts();
  50. ///*debug!*/return USB_INTERFACE_CONT; // NO USBTMC!
  51. ///*debug!*/while(1);
  52. LoadOptions( udi );
  53. #ifndef USBTMC_LOCKED
  54. if( DeviceOptions[0] == 'U' )
  55. if( DeviceOptions[1] == 'S' )
  56. if( DeviceOptions[2] == 'B' )
  57. if( DeviceOptions[3] == 'T' )
  58. if( DeviceOptions[4] == 'M' )
  59. if( DeviceOptions[5] == 'C' )
  60. if( DeviceOptions[6] == '!' )
  61. if( DeviceOptions[7] == 0 )
  62. return USB_INTERFACE_SCPI;
  63. #endif
  64. return USB_INTERFACE_CONT;
  65. }
  66. //-------------------------------
  67. #endif