analogdevicesinc / TMC-API

TRINAMIC's IC API
MIT License
188 stars 83 forks source link

Update TMC5130.c #23

Closed yibiao-h closed 2 years ago

yibiao-h commented 2 years ago

Correction of readInt function duplication readWriteArray

trinamic-LH commented 2 years ago

Hello,

the TMC5130 IC requires two datagrams in a row for a read request. The first datagram transfers the address to be read and the subsequent datagram then will receive the data from that read request. The first call to tmc5130_readWriteArray will replace the 5 bytes in the data array. We re-write the address byte into that array before calling tmc5130_readWriteArray again to prevent an accidental write. After the second write, the reply data is extracted from the data array.

See also on the datasheet: image