Technics66! You would have some chip of these 24D0002, 52D4000, 52D4H00, 52D4X00. They are the ones that I have, but I can not authenticate in the registry 0x81; and I think if you try to read with Delcopi any of these in the log you could get an authentication key and it would be very useful ...
I leave you a new sketch, which optimizes a bit the use of memory in global variables.
With "t", perform a test chip (chip information)
with "d", perform a full dump of the chip.
Regards!
#include "twi-all-included.h"
void setup()
{
Serial.begin(9600);
twi_init();
}
bool read_TI046B1_register(uint16_t TenBits_slave_address, uint8_t * registerBuffer, int registerSize, uint8_t * destinationBuffer, uint16_t readSize, bool stopCom)
{
uint16_t slave_address_LSB = TenBits_slave_address & 0x0FF; //0076543210 //8 LSB
uint16_t slave_address_MSB = TenBits_slave_address & 0x300; //9800000000 //2 MSB
//Put the MSB bits to the Left :
slave_address_MSB = slave_address_MSB >> 8; //For example, 0x300 becomes 0x003
//7 bits address equivalent for the begining :
uint8_t SevenBits_compat_address = 0x78 | slave_address_MSB; //TWI library will put send those 7 bits followed by read/write bit.
//Preparation of the write buffer : 8LSB of the slave's address, then 3 bytes writes to call a register read.
uint8_t txBuffer[registerSize + 1];
for(uint8_t i = 0; i < sizeof(txBuffer); i++)
{
if(i==0)
{
txBuffer[i] = slave_address_LSB;
}
else
{
txBuffer[i] = registerBuffer[i-1];
}
}
uint16_t nRet = twi_writeTo(SevenBits_compat_address, txBuffer, sizeof(txBuffer), 1, stopCom);
if (nRet == 1)
{
Serial.println("W1");
return;
}
else if (nRet == 2)
{
Serial.println("W2");
return;
}
else if (nRet == 3)
{
Serial.println("W3");
return;
}
else if (nRet == 4)
{
Serial.println("W4");
return;
}
nRet = twi_readFrom(SevenBits_compat_address, destinationBuffer, readSize, true); //xxx bytes read with a Stop at the end.
if (nRet == 0x00)
{
Serial.println("R1");
return;
}
if (nRet != readSize)
{
Serial.println("R2");
return;
}
if (nRet == readSize)
{
for (uint16_t i=0; i<readSize; i++)
{
//Serial.print("0x");
if (destinationBuffer[i] < 0x10)
{
Serial.print(0, HEX);
Serial.print(destinationBuffer[i], HEX);
}
else
{
Serial.print(destinationBuffer[i], HEX);
}
if(i != readSize) Serial.print(" ");
}
Serial.println("");
return true;
}
}
//DelCopi Secuence
uint16_t a_ = 1, b_ = 1, c_ = 16, d_ = 1, e_ = 1, f_ = 1, g_ = 1, h_ = 1, i_ = 16, k_ = 1024, l_ = 1024;
uint8_t a[1] = {0x03};
uint8_t b[1] = {0x83};
uint8_t c[3] = {0x01,0x50,0x04};
uint8_t d[1] = {0x82};
uint8_t e[2] = {0x81, 0x08};
uint8_t f[1] = {0x82};
uint8_t g[15] = {0x81, 0x4E, 0x86, 0x61, 0xAE, 0x96, 0x54, 0xC2, 0x31, 0xFA, 0xC6, 0x2D, 0x53, 0x74, 0x35};
uint8_t h[1] = {0x82};
uint8_t i[1] = {0x80};
//Full Dump!
uint8_t k[3] = {0x01, 0x00, 0x00};
uint8_t l[3] = {0x01, 0x00, 0x04};
//One Buffer for all!
uint8_t rxBuffer[1024];
void loop()
{
char command = getCommand();
switch (command)
{
case 't': //Test Chip
Serial.print("Send: 03 \t\t\t\t\t\t| Response: ");
read_TI046B1_register(0x000, a, sizeof(a), rxBuffer, a_, 0);
Serial.print("Send: 83 \t\t\t\t\t\t| Response: ");
read_TI046B1_register(0x000, b, sizeof(b), rxBuffer, b_, 0);
Serial.print("Send: 01 50 04 \t\t\t\t\t\t| Response: ");
read_TI046B1_register(0x000, c, sizeof(c), rxBuffer, c_, 0);
Serial.print("Send: 82 \t\t\t\t\t\t| Response: ");
read_TI046B1_register(0x000, d, sizeof(d), rxBuffer, d_, 0);
Serial.print("Send: 81 08 \t\t\t\t\t\t| Response: ");
read_TI046B1_register(0x000, e, sizeof(e), rxBuffer, e_, 1);
Serial.print("Send: 82 \t\t\t\t\t\t| Response: ");
read_TI046B1_register(0x000, f, sizeof(f), rxBuffer, f_, 0);
Serial.print("Send: 81 4E 86 61 AE 96 54 C2 31 FA C6 2D 53 74 35 \t| Response: ");//81 4E 86 61 AE 96 54 C2 31 FA C6 2D 53 74 35
read_TI046B1_register(0x000, g, sizeof(g), rxBuffer, g_, 1);
Serial.print("Send: 82 \t\t\t\t\t\t| Response: ");
read_TI046B1_register(0x000, h, sizeof(h), rxBuffer, h_, 0);
Serial.print("Send: 80 \t\t\t\t\t\t| Response: ");
read_TI046B1_register(0x000, i, sizeof(i), rxBuffer, i_, 0);
Serial.println("");
break;
case 'd': //Dump Chip
Serial.print("Full Dump: ");
read_TI046B1_register(0x000, k, sizeof(k), rxBuffer, k_, 0);
read_TI046B1_register(0x000, l, sizeof(l), rxBuffer, l_, 0);
Serial.println("");
break;
}
}
char getCommand()
{
char c = '\0';
if (Serial.available())
{
c = Serial.read();
}
return c;
}