Update eeprom_i2c.py

_getaddr(self, addr, nbytes) was assuming a block size of 128 bytes.
Corrected to use the self._nbits, the block size passed in when the eeprom object was initialized.
pull/16/head
Leon Stankowski 2023-05-11 04:42:19 -04:00 zatwierdzone przez GitHub
rodzic 5037f0999a
commit a0daf69db9
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
1 zmienionych plików z 5 dodań i 1 usunięć

Wyświetl plik

@ -67,7 +67,11 @@ class EEPROM(BlockDevice):
self._addrbuf[0] = (la >> 8) & 0xFF
self._addrbuf[1] = la & 0xFF
self._i2c_addr = self._min_chip_address + ca
pe = (addr & ~0x7F) + 0x80 # byte 0 of next page
# pe = (addr & ~0x7F) + 0x80 # byte 0 of next page
# original code was assuming 128 byte block size, corrected to use the block size passed in when initialized
pe = ((addr >> self._nbits) + 1) << self._nbits
return min(nbytes, pe - la)
# Read or write multiple bytes at an arbitrary address