There is one other minor issue on my list.
Sometime I want to define the class with one pin, other times two pins. The second pin is only needed when the device is in the parasite power mode (ie, it steals it's Vcc power from the dataline).
DS1820 probe1(p27,p28); // when it using parasite power or
DS1820 probe1(p27); // when it's externally powered
I have this code, ir compiles ok, but then seems to lock up the program in run mode
DS1820.h
DS1820(PinName dp, PinName pp=NC);
DS1820.cpp
DS1820::DS1820 (PinName dp, PinName pp) : _datapin(dp), _parasitepin(pp) {
if (_parasitepin == NC)
_parasite_power = false;
else
_parasite_power = true;
}
I'm thinking that if (_parasitepin == NC) is attempting to use the DigitalInOut shortcut and it's actually attempting to read the port value and not the default NC assigned in the header. Is there some hidden (not in the documentation) variable that will return the pin number (or NC) of the I/O
the function
void OneWireDevice ( PinName DataPin, PinName PowerPin)
I'd like to call this with only the data_pin or with both pins. But if it's called with just the data_pin I need to know that the power_pin is not being used. I googled around and found _NARGS returns then number of arguments sent to the function.
But, not with this complier.
ParasitePower = false;
if (_NARGS==2) {
ParasitePower = true;
}