1 # Copyright (C) 2009 Ubixum, Inc.
3 # This library is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU Lesser General Public
6 # License as published by the Free Software Foundation; either
7 # version 2.1 of the License, or (at your option) any later version.
9 # This library is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # Lesser General Public License for more details.
14 # You should have received a copy of the GNU Lesser General Public
15 # License along with this library; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 from time import sleep
23 # use this functions 1st
25 def openfx2(vid=0x04b4,pid=0x0082,idx=0):
28 def reset_device(reset):
29 print reset and "Put device in reset" or "Set device to run"
30 write_ram (0xe600,reset and '\x01' or '\x00', 1)
32 def write_ram(addr,data,length):
34 while(transferred<length):
35 this_transfer_size=length-transferred>1024 and 1024 or length-transferred
36 buf=data[transferred:]
37 ret=f.do_usb_command( buf,
43 print "wrote %d bytes" % ret
46 print "Error: %d" % ret
49 def reset_bix(filename):
51 Use this function to reset your firmware. You'll need to reopen the device afterward.
54 bix=open(filename).read()
55 print "loading bix file of length: %d" % len(bix)
56 write_ram( 0, bix,len(bix) );