I am trying to decode the reference code to access the registers in MAX35101 IC.
The code has this syntax at various lines.
What does this mean?
bool MAX35101_Update_TOF_AVG_DIFFData(Flow_ResultsStruct* TOF_DIFF_Results)
{
bool success = false;
success |= MAX35101_Read_2WordValue(TOF_DIFF_AVG_REG, &TOF_DIFF_Results->TOF_DiffData);
return success;
}
Simply what does Z |= X(a, &b->c);
mean?
CodePudding user response:
Z |= X(a, &b->c);
could be rewritten as Z = Z | X(a, &(b->c));
We have a pointer to a struct Flow_ResultsStruct* b
. To access a member of a struct via a pointer we use a ->
. So it is get the address of member c
of struct b
for which we have a pointer.
Pass a
and the address to X.
Now logical or (|
) the return value with Z
which is false (0
) so Z
equals the return of the function.