Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2017
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. #!usr/bin/python3
  2.  
  3. '''
  4. Basic script to send USB Vendor Commands to PSoC5LP
  5.  
  6. Based on Cypress AN56377
  7.  
  8. VID = 0x04B4
  9. PID = 0xE176
  10.  
  11. Direction = OUT
  12. ReqType = Vendor
  13. Target = Device
  14.  
  15. Request Codes:
  16. 0xA1 = Turn onboard LED on
  17. 0xB1 = Turn onboard LED off
  18. 0xA2 = TODO, read data
  19. 0xB2 = TODO, send data
  20.  
  21. '''
  22.  
  23. import usb
  24. import sys
  25. import time
  26.  
  27. VID = 0x04B4
  28. PID = 0xE176
  29.  
  30. dev = usb.core.find(idVendor = VID, idProduct = PID)
  31.  
  32. if not dev:
  33. print("No se encontro el PSoC")
  34. exit(1)
  35.  
  36. print("PSoC encontrado")
  37.  
  38. for i in range(10):
  39. # dev.ctrl_transfer(bmRequestType, bmRequest, wValue, wIndex, data)
  40. # Prendemos el LED
  41. dev.ctrl_transfer(0x40 , 0xA1, 0, 0, [])
  42. # Esperamos
  43. time.sleep(0.5)
  44. # Apagamos el LED
  45. dev.ctrl_transfer(0x40 , 0xB1, 0, 0, [])
  46. time.sleep(0.5)
  47.  
  48. print("Adios!")
  49. exit(0)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement