]> rtime.felk.cvut.cz Git - pes-rpp/rpp-lib.git/commitdiff
mout: Remove stupid waiting in rpp_mout_set()
authorMichal Sojka <sojkam1@fel.cvut.cz>
Thu, 14 Apr 2016 14:56:08 +0000 (16:56 +0200)
committerMichal Sojka <sojkam1@fel.cvut.cz>
Thu, 14 Apr 2016 14:56:08 +0000 (16:56 +0200)
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
rpp/src/rpp/mout.c

index 8c1910b61842f346c9526e6f0293151d5cdd64fc..297a0348b2da9b1e0b5803b1de433affa7503b6a 100644 (file)
@@ -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);
 
index 6f9ce2ede9a3ab2abee7ee50a0c483efecf2c735..ae2d4a9501ac476272fd4babe3653b2950b70fa4 100644 (file)
@@ -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;