From 16f135fef9a28d3b8c72bd4cc1bc8a2309b887c1 Mon Sep 17 00:00:00 2001 From: Michal Sojka Date: Thu, 14 Apr 2016 16:56:08 +0200 Subject: [PATCH] mout: Remove stupid waiting in rpp_mout_set() Test the diag pin immediately. This function will probably be called periodically, so the fault (if any) will be detected next period. --- rpp/include/rpp/mout.h | 4 +--- rpp/src/rpp/mout.c | 18 +++--------------- 2 files changed, 4 insertions(+), 18 deletions(-) diff --git a/rpp/include/rpp/mout.h b/rpp/include/rpp/mout.h index 8c1910b..297a034 100644 --- a/rpp/include/rpp/mout.h +++ b/rpp/include/rpp/mout.h @@ -41,9 +41,7 @@ int8_t rpp_mout_init(); * -2 if val is not HIGH or LOW.\n * -3 if pin could not be set. With current implementation this should * never happen.\n - * -4 if pin is confirmed to be in trouble. - * This normally indicates a hardware failure and that the driver - * chip pulled the diagnostic pin. + * -4 if a fault is indicated by DIAG pin */ int8_t rpp_mout_set(uint8_t pin, uint8_t val); diff --git a/rpp/src/rpp/mout.c b/rpp/src/rpp/mout.c index 6f9ce2e..ae2d4a9 100644 --- a/rpp/src/rpp/mout.c +++ b/rpp/src/rpp/mout.c @@ -69,27 +69,15 @@ int8_t rpp_mout_set(uint8_t pin, uint8_t val) ret = drv_mout_set(idx, val); if (ret == SUCCESS) cache[idx] = val; - RPP_MUTEX_UNLOCK(mutex_mout); - if (ret != SUCCESS) + else { + RPP_MUTEX_UNLOCK(mutex_mout); return -3; - - // FIXME Wait some time for synchronization - // Don't use vTaskDelay() here because the minimum time to wait is one tick, - // and depending of the configuration of the user model one tick can overrun - // the program. - int wait; - for (wait = 0; wait < 10; wait++) { - asm (" nop"); } - RPP_MUTEX_LOCK(mutex_mout); - // Get value back and compare ret = drv_mout_diag(idx); RPP_MUTEX_UNLOCK(mutex_mout); - if (ret < 0) { + if (ret == 0) return -4; - } - #else RPP_MUTEX_LOCK(mutex_mout); cache[idx] = val; -- 2.39.2