ZHCSF47E June 2016 – December 2017 TAS2560
PRODUCTION DATA.
The TAS2560 contain logic to verify that all write operations to the device were correctly received. This can be used to detect a configuration error of the device in the event of a problem or collision on the I2C bus. On every register write other than to the book switch register(B0_P0_R127) or page switch register(B0_Px_R0) will update the 8-bit CRC checksum using the contents of the 8-bit register write data. Only register write operations will update the CRC, register read operations will not change the CRC value. The CRC checksum register CRC_CHECKSUM will return the current checksum from all previous write operations. The CRC checksum register can be write to initialize the starting value and is initially defaulted to 0x00 on a reset. The polynomial used for the CRC is 0x7 (CRC-8-CCITT I.432.1; ATM HEC, ISDN HEC and cell delineation, (1+x^1+x^2+x^8)) Since we are using CRC, order of writes will also affect CRC.
global gChecksum # To keep track of the checksum in firmware
# Function to init the local checksum as well as that inside device
function initChecksum():
gChecksum = 0
i2c_write(regChecksum, 0) # regChecksum is the register number of the checksum R/W reg in device
# Function to update the local checksum
function addToChecksum(addr, data):
if addr != regChecksum: # Checksum reg is ignored
# Update gChecksum with data. Ignore book/page registers
tempdata = gChecksum ^ inData
for ( i = 0; i < 8; i++ ):
if (( tempdata & 0x80 ) != 0 ):
tempdata <<= 1
tempdata ^= 0x07
else:
tempdata <<= 1;
gChecksum = tempdata
# Function to compare checksums
function checkChecksum():
return (i2c_read(regChecksum) == gChecksum)
# Existing I2C write that does multibyte write to device
function i2c_write(addr, {data}):
# Write the stuff to the device
function i2c_read(addr):
# Read the data at device addr
return result
# New function for verified writes
function i2c_write_checksum(addr, {data}):
initChecksum()
i2c_write(addr, {data})
for word in data:
addToChecksum(addr, word)
addr++
return checkChecksum()