def init_system(self, desc, ind): if self.type == 1: # i2c mode self.device = common_func.ftdi_open(ind, 1) common_func.ftdic_setbitmode(self.device, 0x0, 0x00) common_func.ftdic_setbitmode(self.device, 0x0, 0x02) else: # serial mode if common_func.OS == 'Windows': self.device = common_func.ftdi_open(ind, 0) elif common_func.OS == 'Linux': self.device = ftdi.Ftdi() self.device.open(vendor=desc[0], product=desc[1], address=desc[3])
def get_eeprom_board(self, pins, board_id): """checks if the eeprom is present on the current board""" self.ftdic = common_func.ftdi_open(board_id, 1) common_func.ftdic_setbitmode(self.ftdic, 0x0, 0x00) common_func.ftdic_setbitmode(self.ftdic, 0x0, 0x02) common_func.ftdi_i2c_init(self.ftdic, pins) add_write = (pins['at24cxx'][0] << 1) + 0 common_func.ftdi_i2c_start(self.ftdic, pins) if common_func.ftdi_i2c_write(self.ftdic, pins, add_write): common_func.ftdi_i2c_stop(self.ftdic, pins) self.ftdic.close() return 1 else: common_func.ftdi_i2c_stop(self.ftdic, pins) self.ftdic.close() return 0
def init_system(self, pins): """initialization of the FTDI chip""" mode = 1 if pins in self.board_mapping_gpio_i2c or pins in self.board_mapping_power else 0 channel = pins['ftdi'][0] out_pins = 0 logging.info('FTDI Initialization...') self.ftdic = common_func.ftdi_open(self.id, channel) if mode == 0: # if GPIO mode for gpio in self.board_mapping_gpio: # if channel 0, parse gpio default value of channel 0 if gpio['ftdi'][0] == channel: out_pins += gpio['ftdi'][1] common_func.ftdic_setbitmode(0xFF, 0x1) if mode == 1: # if I2C mode common_func.ftdic_setbitmode(self.ftdic, 0x0, 0x00) # reset the controller common_func.ftdic_setbitmode(self.ftdic, 0x0, 0x02) # set as MPSSE common_func.ftdi_i2c_init(self.ftdic, pins) # Init FT4232H MPSSE with correct parameters logging.info('Done.')