beautypg.com

Rainbow Electronics DS1957 User Manual

Page 11

background image

DS1957

11 of 25

When reading data from the IPR that has not been processed by the microcomputer inside the DS1957,
the bus master already knows the actual value of the length byte. To read back data for optional
verification, the bus master transmits the Read IPR command byte followed by the length byte and reads
as many data bytes as specified by the length byte. After this, the DS1957 responds with an inverted
CRC16 of the command code, length byte and all data bytes. The data bytes are received in reversed
order, (i.e., the most significant bit of the last byte written to the IPR is received first). After the last byte,
the second last follows, and so on. The last byte written is the first to be received (LIFO, last in, first
out). The calculation of the CRC is based on the bytes as they are received by the bus master. If the CRC
calculated by the bus master does not match the value transmitted by the DS1957, the data transfer was
not successful and the IPR needs to be rewritten. If the CRC value matches, the master should access the
DS1957 again and issue another READ IPR command sequence. If now the length byte is 128 minus the
previously used length value, and the master reads as many bytes as the new length byte specifies plus the
CRC16, the original status of the IPR is restored. If this second access cycle is omitted or a transmission
error occurs before the bus master sends the reset pulse to finish the command, the data previously
written to the IPR is lost and needs to be rewritten. The second access cycle can be avoided if one always
reads all 128 bytes of the IPR.

WRITE I/O BUFFER [2DH]

The I/O buffer is used under firmware control to manage the data that is exchanged between bus master
and microcomputer through the Intermediate Product Register (IPR). The I/O buffer consists of two
separate 8-byte memory sections, one for sending data to (input buffer) and one for receiving data from
the DS1957 (output buffer). Both, the write and read access to the I/O buffer require the specification of
a length byte. The number of free bytes in the input buffer and valid (used) bytes in the output buffer is
available to the bus master by reading the status of the DS1957 using the Read Status command. Details
on the format of the messages exchanged through the I/O buffer are specified in the “Crypto iButton
Firmware Reference Manual.”

After the command code for the Write I/O Buffer command, the bus master transmits the length byte
followed by the data bytes to be written. The length byte must not exceed the number of free bytes in the
input buffer. After as many data bytes as specified by the length byte have been transmitted, the bus
master receives the inverted CRC16 of the command code, length byte and data bytes transmitted. The
bus master now calculates the CRC and compares it with the CRC value received from the DS1957. If
the CRC values do not match, the data transfer was not successful and the Write I/O Buffer command
sequence needs to be repeated. If the CRC values match, the bus master has to transmit the release
sequence 9DB3H to signal the microcomputer inside the DS1957 the arrival of new data. As a
confirmation, the bus master will receive all 0s if the release sequence was accepted by the DS1957. If
the bus master receives 1s instead, the release sequence was not accepted and the command sequence
needs to be repeated.

READ I/O BUFFER [22H]

The Read I/O Buffer command flow follows the same syntax as the Write I/O Buffer command. After
the command code for the Read I/O Buffer command the bus master transmits the length byte and starts
reading. After as many data bytes as specified by the length byte have been received, the bus master
receives the inverted CRC16 of the command code, length byte and the data bytes. The bus master now
calculates the CRC and compares it with the CRC value received from the DS1957. If the CRC values do
not match, the data transfer was not successful and the Read I/O Buffer command sequence needs to be
repeated. If the CRC values match, the bus master has to transmit the release sequence 624CH to signal
to the microcomputer inside the DS1957 that the data has been read successfully. As a confirmation, the
bus master will receive all 0s if the release sequence was accepted by the DS1957. If the bus master
receives 1s instead, the release sequence was not accepted and the command sequence needs to be
repeated.