示例#1
0
文件: eeprom.py 项目: xroumegue/pmt
 def read_eeprom_seq(self, ep_num):
     ret_data = []
     i = 0
     address = 0
     add_write = (common.board_eeprom[ep_num]['at24cxx']['addr'] << 1) + 0
     add_read = (common.board_eeprom[ep_num]['at24cxx']['addr'] << 1) + 1
     pins = common.board_eeprom[ep_num]
     common_func.ftdi_i2c_init(self.device, pins)
     common_func.ftdi_i2c_start(self.device, pins)
     common_func.ftdi_i2c_write(self.device, pins, add_write)
     if common.board_eeprom[ep_num]['at24cxx']['type']:
         common_func.ftdi_i2c_write(self.device, pins, address >> 8)
         common_func.ftdi_i2c_write(self.device, pins, address & 0xFF)
     else:
         common_func.ftdi_i2c_write(self.device, pins, address)
     common_func.ftdi_i2c_start(self.device, pins)
     common_func.ftdi_i2c_write(self.device, pins, add_read)
     while i < 10:
         ret_data.append(common_func.ftdi_i2c_read(self.device, pins, 0))
         i += 1
     common_func.ftdi_i2c_stop(self.device, pins)
     if ret_data[0][0] == 0:
         ret_data.pop(0)
     self.eeprom_info['CONFIG_FLAG'] = hex(
         0x01) if hex(ret_data[0][0] & 0x0F) != hex(0xF) else hex(0x0)
     self.eeprom_info['BOARD_ID'] = hex(((ret_data[0][0] & 0xFC) >> 2)
                                        | ((ret_data[1][0] - 1) << 6))
     self.eeprom_info['BOARD_REV'] = hex(ret_data[2][0])
     self.eeprom_info['SOC_ID'] = hex(ret_data[3][0])
     self.eeprom_info['SOC_REV'] = hex(ret_data[4][0])
     self.eeprom_info['PMIC_ID'] = hex(ret_data[5][0])
     self.eeprom_info['PMIC_REV'] = hex(ret_data[6][0])
     self.eeprom_info['NBR_PWR_RAILS'] = hex(ret_data[7][0])
     self.eeprom_info['BOARD_SN'] = hex(ret_data[8][0])
     self.display_eeprom_info()
示例#2
0
文件: eeprom.py 项目: xroumegue/pmt
 def write_eeprom_page_i2c(self, ep_num):
     infos = []
     address = 0
     for info in self.file_info:
         if info[0] == 'BOARD_ID':
             info[4] = int(info[4], 16)
             data1 = info[4] << 2 if info[4] <= 40 else (
                 info[4] << 2) & 0xFF
             data1 |= 0x01
             data2 = 1 if info[4] <= 40 else ((
                 (info[4] << 2) & 0xFF00) >> 8) + 1
             infos.append(data1)
             infos.append(data2)
         else:
             data = int(info[4], 16)
             infos.append(data)
     add_write = (common.board_eeprom[ep_num]['at24cxx']['addr'] << 1) + 0
     pins = common.board_eeprom[ep_num]
     common_func.ftdi_i2c_init(self.device, pins)
     common_func.ftdi_i2c_start(self.device, pins)
     common_func.ftdi_i2c_write(self.device, pins, add_write)
     if common.board_eeprom[ep_num]['at24cxx']['type']:
         common_func.ftdi_i2c_write(self.device, pins, address >> 8)
         common_func.ftdi_i2c_write(self.device, pins, address & 0xFF)
     else:
         common_func.ftdi_i2c_write(self.device, pins, address)
     for ind in range(0, len(infos) - 1):
         common_func.ftdi_i2c_write(self.device, pins, infos[ind])
     common_func.ftdi_i2c_stop(self.device, pins)
     common_func.time.sleep(0.3)
     self.write_eeprom_i2c(8, infos[-1], ep_num)
示例#3
0
 def get_temperature(self, pins):
     out = []
     add_read = (pins['sensor'][0] << 1) + 1
     common_func.ftdi_i2c_init(self.ftdic, pins)
     common_func.ftdi_i2c_start(self.ftdic, pins)
     common_func.ftdi_i2c_write(self.ftdic, pins, add_read)
     out = common_func.ftdi_i2c_read_buffer(self.ftdic, pins, 2)
     common_func.ftdi_i2c_stop(self.ftdic, pins)
     return out
示例#4
0
 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
示例#5
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.')
示例#6
0
文件: eeprom.py 项目: xroumegue/pmt
 def read_eeprom_i2c(self, pins):
     out = []
     add_write = (pins['at24cxx']['addr'] << 1) + 0
     add_read = (pins['at24cxx']['addr'] << 1) + 1
     common_func.ftdi_i2c_init(self.device, pins)
     common_func.ftdi_i2c_start(self.device, pins)
     common_func.ftdi_i2c_write(self.device, pins, add_write)
     if pins['at24cxx']['type']:
         common_func.ftdi_i2c_write(self.device, pins, 0 >> 8)
         common_func.ftdi_i2c_write(self.device, pins, 0 & 0xFF)
     else:
         common_func.ftdi_i2c_write(self.device, pins, 0)
     common_func.ftdi_i2c_start(self.device, pins)
     common_func.ftdi_i2c_write(self.device, pins, add_read)
     for i in range(2):
         out.append(common_func.ftdi_i2c_read(self.device, pins, 0))
     out.append(common_func.ftdi_i2c_read(self.device, pins, 1))
     common_func.ftdi_i2c_stop(self.device, pins)
     return out