| 26 | self.close() |
| 27 | |
| 28 | def open(self): |
| 29 | self.ftdi = Ftdi() |
| 30 | self.ftdi.open_from_url(self.device_url) |
| 31 | self.ftdi.set_baudrate(921600) |
| 32 | self.ftdi.set_line_property(8, 1, 'N') |
| 33 | |
| 34 | self.eeprom = FtdiEeprom() |
| 35 | self.eeprom.connect(self.ftdi) |
| 36 | |
| 37 | self.provisioned = (self.eeprom.cbus_func_1 == "GPIO" and self.eeprom.cbus_func_2 == "GPIO") |
| 38 | |
| 39 | if not self.provisioned: |
| 40 | print("Warning: Device not provisioned for usbgpu debugging. Use --provision to provision it.") |
| 41 | return |
| 42 | |
| 43 | # setup gpio for reset control |
| 44 | self.ftdi.set_cbus_direction(self.CBUS_RESET | self.CBUS_BOOTLOADER, self.CBUS_RESET | self.CBUS_BOOTLOADER) |
| 45 | self.ftdi.set_cbus_gpio(0x00) |
| 46 | |
| 47 | def close(self): |
| 48 | self.ftdi.close() |