Welcome to the Parallax Discussion Forums, sign-up to participate.
SCLPIN = pin number of SCL pin of 24AA02E48 chip
i2c : "basic_i2c_driver.spin"
i2c.ReadPage(SCLPIN, $A0, $FA | i2c#OneAddr, @buff, 6)
wiz.SetMac(buff, buff, buff, buff, buff, buff)
Peter Jakacki wrote: »
Yes, by all means allow for it and swapping the scl/sda lets you use the same I2C pins too. However by just writing the MAC to 6 bytes in upper EPROM, it is effectively "permanent" since the Prop loader doesn't directly erase or access that part of EEPROM.
Is this just a one off? All the more reason to not or ever bother with an extra chip!
If it were a big production item it would make sense though.
ReadBytes (i2c#BootPin, $A4, $FA, @own_mac, 6)
PUB ReadBytes (SCL, devSel, addrReg, dataPtr, num)
'' Read in a block of i2c data. Device select code is devSel. Device starting
'' address is addrReg. Data address is at dataPtr. Number of bytes is count.
'' The device select code is modified using the upper 3 bits of the 19 bit addrReg.
'' Return zero if no errors or the acknowledge bits if an error occurred.
i2c.Start(SCL) ' Select the device & send address
i2c.Write(SCL, devSel | i2c#Xmit)
i2c.Write(SCL, addrReg & $FF) ' Only one address byte for 24AA02E48
i2c.Start(SCL) ' Reselect the device for reading
i2c.Write(SCL, devSel | i2c#Recv)
byte[dataPtr++] := i2c.Read(SCL, i2c#ACK)
byte[dataPtr] := i2c.Read(SCL, i2c#NAK)