![](/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/BaseboardIO.cpp
- Revision:
- 56:40b454c952cc
- Parent:
- 55:79ab0bbc5008
- Child:
- 57:bdac7dd17af2
--- a/xDotBridge/src/BaseboardIO.cpp Mon Feb 27 08:06:36 2017 -0700 +++ b/xDotBridge/src/BaseboardIO.cpp Mon Feb 27 14:06:54 2017 -0700 @@ -53,10 +53,12 @@ mPortEx0 = NULL; mPortEx1 = NULL; } -CmdResult BaseboardIO::init() +CmdResult BaseboardIO::init(bool overwriteNvm) { + bool storedROMsGood = false; + uint8_t val; // Setup port expanders - if (readInfoFromNVM() == cmdSuccess) { + if (readInfoFromNVM() == cmdSuccess && !overwriteNvm) { logInfo("Stored ROM0 Addr: %02x:%02x:%02x:%02x:%02x:%02x:%02x%02x found.", mNvmObj.mPortExpanderROM0[7], mNvmObj.mPortExpanderROM0[6], @@ -76,8 +78,25 @@ mNvmObj.mPortExpanderROM1[1], mNvmObj.mPortExpanderROM1[0]); logInfo("BaseboardIO parameters successfully loaded from NVM"); + // Check that the ROM Addresses are correct and valid + uint8_t portEx0Ctrl, portEx1Ctrl; + mPortEx0 = new DS2408(&mOWMaster, mNvmObj.mPortExpanderROM0); + mPortEx0->registerReadReliable(0x8D, portEx0Ctrl); + // Gets 0xFF if it is not the correct address + logInfo("PortEx0 Control register reads %02X", portEx0Ctrl); + + mPortEx1 = new DS2408(&mOWMaster, mNvmObj.mPortExpanderROM1); + mPortEx1->registerReadReliable(0x8D, portEx1Ctrl); + logInfo("PortEx1 Control register reads %02X", portEx1Ctrl); + if ((portEx0Ctrl == 0xFF) || (portEx1Ctrl == 0xFF)) { + logError("Stored port expander ROM check failed. Set EEPROM to defaults."); + } + else { + storedROMsGood = true; + } } - else { // EEPROM values not there or corrupt. Should only happen in factory. + if (!storedROMsGood) + { // EEPROM values not there or corrupt. Should only happen in factory. mNvmObj.setDefaults(); // Find ROM address and test which one is which. Requires user // switches to be in known state. @@ -91,9 +110,14 @@ else { logError("Baseboard config failed to save to NVM"); } + mPortEx0 = new DS2408(&mOWMaster, mNvmObj.mPortExpanderROM0); + mPortEx0->registerReadReliable(0x8D, val); + // Gets 0xFF if it is not the correct address + logInfo("PortEx0 Control register reads %02X", val); + mPortEx1 = new DS2408(&mOWMaster, mNvmObj.mPortExpanderROM1); + mPortEx1->registerReadReliable(0x8D, val); + logInfo("PortEx1 Control register reads %02X", val); } - mPortEx0 = new DS2408(&mOWMaster, mNvmObj.mPortExpanderROM0); - mPortEx1 = new DS2408(&mOWMaster, mNvmObj.mPortExpanderROM1); // Put relay in known state if (relayNormal() != cmdSuccess) {