diff --git a/EEPROM.py b/EEPROM.py index 067a665..bb0f6a8 100644 --- a/EEPROM.py +++ b/EEPROM.py @@ -1,14 +1,13 @@ -import pyb import time -from pyb import I2C +from machine import I2C +import machine t24C512= 512 * 1024 / 8 #512 Kbits t24C256= 256 * 1024 / 8 #256 Kbits t24C128= 128 * 1024 / 8 #128 Kbits t24C64= 64 * 1024 / 8 #64 Kbits -i2c = I2C(1, I2C.MASTER) -i2c.init(I2C.MASTER, baudrate=200000) +i2c = I2C(0, I2C.MASTER, baudrate=100000) class SingleEEPROM(): capacity=0 @@ -21,20 +20,20 @@ def writeEEPROM(self, eeaddress, value): data[0]=eeaddress >> 8 #MSB data[1]=eeaddress & 0xFF #LSB data[2]=value - i2c.send(data, addr=self.address) + i2c.writeto(self.address, data) time.sleep(.05) def readEEPROM(self, eeaddress): data = bytearray(2) data[0]=eeaddress >> 8 #MSB data[1]=eeaddress & 0xFF #LSB - i2c.send(data, addr=self.address) - value=i2c.recv(1, self.address) + i2c.writeto(self.address, data) + value=i2c.readfrom(self.address, 1) return value[0] def selfTest(self): i=0 while i