Wandering through the source of the i2C Master (Single bit port), a number of questions have popped up, mostly regarding I guess coding conventions.
Q1. Use of "int _"
Is there any practical difference between:
i2c.sda :> int _;
and
i2c.sda :> void;
Surely the former would use additional memory (subject to the works of the optimiser) for no benefit as well as suffering the stylistic shortcoming of a variable with no meaningful name?
Q2. Uninitialised local variable as return value
The function "highPulse" is effectively using an uninitialised variable "temp" in the case of the parameter doSample==0.
Does xC initialise locals automatically (unlike C)?
I understand that the return value of highPulse would be meaningless in the case of doSample==0 and that, in such a case, the caller wouldn't act on the return value.
In which case, why bother with the whole doSample parameter at all? Just always return the sample (gets rid of a parameter, simplifies the code). Is this mixed up in the mysterious "I2C_TI_COMPATIBILITY"?
I2C Module assorted questions
-
- Active Member
- Posts: 44
- Joined: Mon Jul 29, 2013 4:33 am