Code:
chip->vcell = (msb << 4) + (lsb >> 4);
This is already basic on the right side of the equal sign,
on the other side it’s addressing an element of a structure (a list)
which can be done with any PBP array with a variable index like:
Code:
var word vcell
var byte/word chip[size]
...
chip[vcell] = value or sum
I don’t know why they are doing it, the four bytes that roll off each end would be discarded in both languages (not carried).
For both of these, this is a call to a function (subroutine in basic):
Code:
msb = max17040_read_reg(client, MAX17040_VCELL_MSB);
You have not posted the function, but I assume it’s the lower level I2C function (I2CREAD/WRITE...).
The parameters in brackets are arguments passed to the function as input which would be the address.
The return value is when is written into the value to the left of the equal sign for calling the function.
The basic subroutine would read a variable for the EEPROM address that was set by the main loop,
and set another variable with the result data, later read by the main loop that called the subroutine.
In PBP the I2C commands would probably be just the same written inline with the main program loop.
In the C code the functions might be an eyesore to throw at the bottom of your page.
Bookmarks