![](/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:
- 48:bab9f747d9ed
- Parent:
- 47:a68747642a7a
- Child:
- 49:18f1354f9e51
diff -r a68747642a7a -r bab9f747d9ed xDotBridge/src/BaseboardIO.cpp --- a/xDotBridge/src/BaseboardIO.cpp Fri Feb 10 07:41:16 2017 -0700 +++ b/xDotBridge/src/BaseboardIO.cpp Mon Feb 13 17:10:59 2017 -0700 @@ -40,7 +40,8 @@ mCCIn(WAKE), // Interrupt pin PA_0 mTamper(GPIO1), // Interrupt pin PA_5 mPairBtn(UART_CTS), // Interrupt pin PA_11 - mLed(SWDIO), +// mLed(SWDIO), + mLed(GPIO0), mSwitchedIOCtrl(I2C_SCL) { // mCCInIntCallback = NULL; @@ -91,8 +92,14 @@ // Registering for interrupts void BaseboardIO::regCCInInt(Callback<void()> func) { - // Pulled high, switched low - mCCIn.fall(func); + sampleUserSwitches(); + if (isCCNO()) { + // Pulled high, switched low + mCCIn.fall(func); + } + else { + mCCIn.rise(func); + } } void BaseboardIO::regTamperInt(Callback<void()> func) { @@ -108,6 +115,8 @@ // Input CmdResult BaseboardIO::sampleUserSwitches() { + if ((mPortEx0 == NULL) || (mPortEx1 == NULL)) + return cmdError; // Sample port expanders if (mPortEx0->pioLogicRead(mPortExpanderVal0) != cmdSuccess) { logError("Error reading port expander 0."); @@ -124,7 +133,7 @@ // Depressed button is high return mPairBtn.read() == 1; } -bool BaseboardIO::isCCOutNO() +bool BaseboardIO::isCCNO() { // When DIP switch is not closed (i.e. value reads high) assume NO return (mPortExpanderVal1 & pEx1NoNcSel) != 0; @@ -181,7 +190,7 @@ } CmdResult BaseboardIO::relayAlert() { - if (isCCOutNO()) { // Normally Open + if (isCCNO()) { // Normally Open return closeRelay(); } else { // Normally Close @@ -190,7 +199,7 @@ } CmdResult BaseboardIO::relayNormal() { - if (isCCOutNO()) { // Normally Open + if (isCCNO()) { // Normally Open return openRelay(); } else { // Normally Close @@ -277,7 +286,7 @@ logInfo("Finished OneWire Search"); if (i != 2) { - logError("Incorrect Number (Got %d. Expected 2) OneWire port expanders found.", i); + logError("Incorrect Number of OneWire devices (Got %d. Expected 2) OneWire port expanders found.", i); return cmdError; }