summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Van Doorn <vandoorn.nick@gmail.com>2017-12-18 09:16:40 -0800
committerNick Van Doorn <vandoorn.nick@gmail.com>2017-12-18 09:16:40 -0800
commit49d6a7a827baa6ff7250371021693c5b6e7b987b (patch)
tree058bd07a66d9ea7bcdad250ae09561b79d4cac10
parent18b311979ae71499074ab9da204fb9275047339a (diff)
Implement helper to flatten res array
-rw-r--r--util.c9
-rw-r--r--util.h2
2 files changed, 11 insertions, 0 deletions
diff --git a/util.c b/util.c
index 8d1830f..66e717c 100644
--- a/util.c
+++ b/util.c
@@ -111,6 +111,15 @@ le_result_t gpio_setHigh (int pin) {
return gpio_setValue(pin, HIGH);
}
+le_result_t util_flattenRes (le_result_t *res, int nRes) {
+ for (int i = 0; i < nRes; i++) {
+ le_result_t *resPtr = res + i;
+ if (*resPtr != LE_OK) return *resPtr;
+ }
+ return LE_OK;
+}
+
+// Functions below are deprecated
void delayMicro (unsigned long microsecs) {
unsigned long retTime = getTimeMicrosecs() + microsecs;
while (getTimeMicrosecs() < retTime);
diff --git a/util.h b/util.h
index 668e37d..93d0e12 100644
--- a/util.h
+++ b/util.h
@@ -34,4 +34,6 @@ void delayMicro (unsigned long microsecs);
void delayMilli (unsigned long millisecs);
long getTimeMicrosecs ();
+le_result_t util_flattenRes (le_result_t *res, int nRes);
+
#endif