![](/media/cache/group/orange_and_cat.png.50x50_q85.jpg)
pwm period is now 200us instead of the default 20ms veml6040 config is now AF_BIT | TRIG_BIT
Dependencies: mbed MMA8451Q USBDevice WakeUp vt100
Fork of afero_node_suntory_2017_06_15 by
Diff: afLib/afLib.cpp
- Revision:
- 21:d03c7bbb9f37
- Parent:
- 6:88cc04eb613a
--- a/afLib/afLib.cpp Mon Jun 05 07:59:10 2017 +0000 +++ b/afLib/afLib.cpp Fri Jun 09 01:49:53 2017 +0000 @@ -21,8 +21,6 @@ #define IS_MCU_ATTR(x) (x >= 0 && x < 1024) -extern Timer t; - static iafLib *_iaflib = NULL; #define MAX_SYNC_RETRIES 10 @@ -58,6 +56,8 @@ afLib::afLib(PinName mcuInterrupt, isr isrWrapper, onAttributeSet attrSet, onAttributeSetComplete attrSetComplete, afSPI *theSPI) : fco(mcuInterrupt) { + checkLastSync = new Timer(); + checkLastSync->start(); queueInit(); _theSPI= theSPI; _request.p_value = NULL; @@ -138,6 +138,13 @@ _requestQueue[i].p_value = NULL; } } + + if(checkLastSync != NULL) + { + delete (checkLastSync); + checkLastSync = NULL; + } + _iaflib = NULL; } //wsugi 20161128 @@ -152,7 +159,8 @@ void afLib::loop(void) { if (isIdle()) { - deathWish.attach(&afLib::kick_the_bucket,10); + deathWish.attach(callback(WatchDogWrapper::getSelf(), &WatchDogWrapper::kick_the_bucket),10); +// deathWish.attach(&afLib::kick_the_bucket,10); } if (isIdle() && (queueGet(&_request.messageType, &_request.requestId, &_request.attrId, &_request.valueLen, &_request.p_value) == afSUCCESS)) { @@ -458,12 +466,12 @@ updateIntsPending(-1); } else { - if (syncRetries > 0 && syncRetries < MAX_SYNC_RETRIES && t.read_ms() - lastSync > 1000) { + if (syncRetries > 0 && syncRetries < MAX_SYNC_RETRIES && checkLastSync->read_ms() - lastSync > 1000) { updateIntsPending(1); } else if (syncRetries >= MAX_SYNC_RETRIES) { SERIAL_PRINT_DBG_ASR("No response from ASR-1 - does profile have MCU enabled?\n"); #if defined(TARGET_KL25Z) - wtd.kick_the_bucket(); + WatchDogWrapper::getSelf()->kick_the_bucket(); #endif //TARGET_KL25Z syncRetries = 0; _state = STATE_IDLE; @@ -471,11 +479,6 @@ } } -void afLib::kick_the_bucket() -{ - wtd.kick_the_bucket(); -} - /** * onStateIdle * @@ -517,7 +520,7 @@ } else { // Try resending the preamble _state = STATE_STATUS_SYNC; - lastSync = t.read_ms(); + lastSync = checkLastSync->read_ms(); syncRetries++; // _txStatus->dumpBytes(); // _rxStatus->dumpBytes();