示例#1
0
    def parse_chip_profile(chip_profile, board_name):
        chip_id = chip_profile['id']
        eeprofile = Profile.get_eeprom()
        eeprofile[chip_id] = dict()

        for key, value in chip_profile.iteritems():
            eeprofile[chip_id][key] = copy.deepcopy(value)

        eeprofile[chip_id]['bus'] = Profile.get_bus_path(chip_profile['bus'])
        eeprofile[chip_id]['addr'] = int(chip_profile['addr'], 16)
示例#2
0
    def parse_chip_profile(chip_profile, board_name):
        chipname = chip_profile['id']

        extendios = Profile.get_extendio()
        extendios[board_name] = extendios.setdefault(board_name, OrderedDict())
        extendio = extendios[board_name]

        extendio[chipname] = dict()
        extendio[chipname]['bus'] = Profile.get_bus_path(chip_profile['bus'])
        extendio[chipname]['addr'] = int(chip_profile['addr'], 16)
        extendio[chipname]['partno'] = chip_profile['partno']
        extendio[chipname]['switch_channel'] = chip_profile['switch_channel']

        chips = Profile.get_chips()
        chips[chipname] = extendio[chipname]

        bit_values = 0
        bit_dir = 0
        dir_value = {'input': 1, 'output': 0}
        for pin in chip_profile['property']:
            pinname = pin['id']

            extendio[pinname] = dict()
            extendio[pinname]['pin'] = pin['pin']
            extendio[pinname]['chip'] = chipname

            if 'default' in pin.keys():
                bit_values |= (int(pin['default']) << (int(pin['pin']) - 1))
            if 'dir' in pin.keys():
                bit_dir |= (dir_value[pin['dir']] << (int(pin['pin']) - 1))

        value_list = []
        dir_list = []
        for x in xrange(len(chip_profile['property']) / 8):
            value_list.append((bit_values >> (x * 8)) & 0xff)
            dir_list.append((bit_dir >> (x * 8)) & 0xff)

        initconfig = Profile.get_initconfig()
        initconfig['extendio'] = initconfig.setdefault('extendio',
                                                       OrderedDict())
        initconfig['extendio'][board_name] = initconfig['extendio'].setdefault(
            board_name, OrderedDict())
        initconfig['extendio'][board_name][chipname] = dict(dir=dir_list,
                                                            value=value_list)