Пример #1
0
    def __init__(self, as_dict: HjsonDict):
        name = as_dict.get('name')
        assert isinstance(name, str)

        bitinfo = as_dict.get('bitinfo')
        assert isinstance(bitinfo, tuple)
        assert len(bitinfo) == 3
        mask, width, lsb = bitinfo

        reset_value = as_dict.get('genresval')
        assert isinstance(reset_value, int)

        swaccess = as_dict.get('swaccess')
        assert isinstance(swaccess, str)

        # We only support some values of swaccess (the ones we need)
        assert swaccess in ['rw1c', 'rw', 'wo', 'r0w1c', 'ro']

        assert width > 0
        assert lsb >= 0

        self.name = name
        self.width = width
        self.lsb = lsb
        self.value = reset_value

        # swaccess
        self.w1c = swaccess in ['rw1c', 'r0w1c']
        self.read_only = swaccess == 'ro'
        self.read_zero = swaccess in ['wo', 'r0w1c']

        self.next_value = reset_value
Пример #2
0
    def __init__(self, as_dict: HjsonDict):
        field_dicts = as_dict.get('fields')
        assert field_dicts is not None
        assert isinstance(field_dicts, list)

        self.fields = [RGField(fd) for fd in field_dicts]