![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Fork to see if I can get working
Dependencies: BufferedSerial OneWire WinbondSPIFlash libxDot-dev-mbed5-deprecated
Fork of xDotBridge_update_test20180823 by
Diff: xDotBridge/src/DS2408.cpp
- Revision:
- 50:e89647e77fd5
- Parent:
- 40:2ec4be320961
- Child:
- 56:40b454c952cc
--- a/xDotBridge/src/DS2408.cpp Fri Feb 17 08:06:37 2017 -0700 +++ b/xDotBridge/src/DS2408.cpp Fri Feb 17 11:58:40 2017 -0700 @@ -37,6 +37,29 @@ return registerRead(pioLogicStateReg, val); } +CmdResult DS2408::pioLogicReliableRead(uint8_t &val) +{ + uint8_t result = 0; + uint8_t result1 = 0xFF; + uint8_t cmdResult; + cmdResult = pioLogicRead(result); + for (int i=0; i < DS2408_NRETRIES; i++) { + cmdResult = pioLogicRead(result1); + if (cmdResult != cmdSuccess) { + continue; + } + // Check they match + if (result == result1) { + val = result; + return cmdSuccess; + } + else { + result = result1; + } + } + return cmdTimeout; +} + CmdResult DS2408::pioLogicWrite(uint8_t val) { mMaster->reset(); @@ -52,3 +75,14 @@ return cmdError; } } + +CmdResult DS2408::pioLogicReliableWrite(uint8_t val) { + uint8_t result; + for (int i=0; i < DS2408_NRETRIES; i++) { + result = pioLogicWrite(val); + if (result == cmdSuccess) { + return cmdSuccess; + } + } + return cmdTimeout; +}