This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionLast revisionBoth sides next revision | ||
en:projects:ucecho_fpga [2010/10/23 00:04] – 84.181.72.152 | en:projects:ucecho_fpga [2013/01/28 02:29] – Add Python 2.6 Example for UCEcho Host coflynn | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== ucecho for ZTEX USB FPGA boards ====== | ====== ucecho for ZTEX USB FPGA boards ====== | ||
- | The following example runs on [[http:// | + | The following example runs on [[http:// |
The firmware (defined in [[en: | The firmware (defined in [[en: | ||
Line 7: | Line 7: | ||
The Bitstream for the FPGA configuration is defined in [[en: | The Bitstream for the FPGA configuration is defined in [[en: | ||
- | The driver | + | The host software |
Uploading the Firmware to EEPROM is also supported by the firmware (e.g. using the FWLoader utility). | Uploading the Firmware to EEPROM is also supported by the firmware (e.g. using the FWLoader utility). | ||
Line 377: | Line 377: | ||
return 0; | return 0; | ||
} | } | ||
+ | </ | ||
+ | |||
+ | |||
+ | ====== Python host software: UCEcho.py ====== | ||
+ | |||
+ | It is also possible to access the device with other programming languages. In this case the firmware must be loaded using the FWLoader utility included in the SDK. For testing you can run UCEcho.jar first and then run this file. For Python be sure to install [[http:// | ||
+ | |||
+ | The Python source code of the host software is: | ||
+ | |||
+ | <code python> | ||
+ | # | ||
+ | # | ||
+ | # Based on work from http:// | ||
+ | # | ||
+ | # This program is free software; you can redistribute it and/or modify | ||
+ | # it under the terms of the GNU General Public License version 3 as | ||
+ | # | ||
+ | # | ||
+ | # This program is distributed in the hope that it will be useful, but | ||
+ | # | ||
+ | # | ||
+ | # | ||
+ | # | ||
+ | # You should have received a copy of the GNU General Public License | ||
+ | # along with this program; if not, see http:// | ||
+ | # | ||
+ | import sys | ||
+ | try: | ||
+ | import usb | ||
+ | except: | ||
+ | print "usb import failed. Install pyusb from http:// | ||
+ | sys.exit() | ||
+ | | ||
+ | |||
+ | if __name__ == ' | ||
+ | |||
+ | #Find Device | ||
+ | dev = usb.core.find(idVendor=0x221A, | ||
+ | |||
+ | if dev is None: | ||
+ | print " | ||
+ | print " You should run UCEcho.jar first, and then without unplugging" | ||
+ | print " USB module run this program to ensure all devices are fully" | ||
+ | print " programmed." | ||
+ | | ||
+ | sys.exit() | ||
+ | |||
+ | # set the active configuration. With no arguments, the first | ||
+ | # configuration will be the active one | ||
+ | dev.set_configuration() | ||
+ | |||
+ | #You can find these from the descriptors - see pyusb doc for an | ||
+ | #example of this. I'm simplifying this because I know exact | ||
+ | #interface & endpoint addresses | ||
+ | writeEP = 0x04 | ||
+ | readEP = 0x82 | ||
+ | interface = 0 | ||
+ | |||
+ | resp = " | ||
+ | |||
+ | while resp != " | ||
+ | resp = raw_input(" | ||
+ | dev.write(writeEP, | ||
+ | print "Send %d bytes: `%s'" | ||
+ | ret = dev.read(readEP, | ||
+ | retstr = '' | ||
+ | print "Read %d bytes: `%s'" | ||
</ | </ | ||