Skip to content
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions userial/ad26.c
Original file line number Diff line number Diff line change
Expand Up @@ -251,10 +251,17 @@ float Volt_Reading(int portnum, int vdd, int *cad)
if(cad) {

/* Get Current reading as well */
/* convert from 12-bit 2's complement, see
Comment thread
bcl marked this conversation as resolved.
* https://en.wikipedia.org/wiki/Two%27s_complement
*/
c = send_block[8] & 0x3;

*cad = (c << 8) | send_block[7];
if(send_block[8] & 0x4) *cad = - *cad;
if(send_block[8] & 0x4) {
/* Negative value represented by set sign bit
* with weight of -2^12
*/
*cad = *cad - 4096;
Comment thread
bcl marked this conversation as resolved.
Outdated
}

// printf("CAD=%d\n", *cad);
}
Expand Down