- # Take config parameters of specified GPIOs, and combine them to produce
- # bytes for sending via WB bus
- def _pack_csr(self, start, end):
- #start, end = self._parse_gpio_arg(gpio_str)
- num_csr = end-start
- csr = [0] * num_csr
- for i in range(0, num_csr):
- gpio = i + start
- print("Pack: gpio{}".format(gpio))
- csr[i] = ((self.shadow_csr[gpio].oe << self.shift_dict['oe'])
- | (self.shadow_csr[gpio].ie << self.shift_dict['ie'])
- | (self.shadow_csr[gpio].puen << self.shift_dict['puen'])
- | (self.shadow_csr[gpio].pden << self.shift_dict['pden'])
- | (self.shadow_csr[gpio].io << self.shift_dict['io'])
- | (self.shadow_csr[gpio].bank << self.shift_dict['bank']))
-
- print("GPIO{0} Packed CSR: {1:x}".format(gpio, csr[i]))
-
- return csr # return the config byte list
+ # Take a combined word and update shadow reg's
+ # TODO: convert hard-coded sizes to use the csrbus_layout (or dict?)
+ def update_single_shadow(self, csr_byte, gpio):
+ oe = (csr_byte >> self.shift_dict['oe']) & 0x1
+ ie = (csr_byte >> self.shift_dict['ie']) & 0x1
+ puen = (csr_byte >> self.shift_dict['puen']) & 0x1
+ pden = (csr_byte >> self.shift_dict['pden']) & 0x1
+ io = (csr_byte >> self.shift_dict['io']) & 0x1
+ bank = (csr_byte >> self.shift_dict['bank']) & 0x3
+
+ print("csr={0:x} | oe={1}, ie={2}, puen={3}, pden={4}, io={5}, bank={6}"
+ .format(csr_byte, oe, ie, puen, pden, io, bank))
+
+ self.shadow_csr[gpio].set(oe, ie, puen, pden, io, bank)
+ return oe, ie, puen, pden, io, bank