summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlec Berg <alecaberg@chromium.org>2014-06-03 16:29:14 -0700
committerchrome-internal-fetch <chrome-internal-fetch@google.com>2014-06-04 21:00:32 +0000
commit8b5277defe449ba1c91066689ad457aad4c24851 (patch)
tree0dcb533180215928cf683b952f52eec17ed26b35
parenteac695e983028156563e4f5aa9df12db752c0583 (diff)
downloadchrome-ec-8b5277defe449ba1c91066689ad457aad4c24851.tar.gz
samus: move als sampling from hooks to its own task
Moved sampling of ALS to its own task. The problem is that it spin waits on the i2c bus mutex, and it's a bad idea to spin wait for very long in the hooks task because the hooks task tickles the watchdog. BUG=chrome-os-partner:29003 BRANCH=none TEST=tested on samus: make sure ALS task is running and no watchdog timeouts when the i2c bus is wedged indefinitely. Change-Id: Ifcebabdfc151ea85cecdfe7a8ed489e8a82ee5ba Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/202545 Reviewed-by: Randall Spangler <rspangler@chromium.org>
-rw-r--r--board/samus/ec.tasklist1
-rw-r--r--common/als.c22
2 files changed, 10 insertions, 13 deletions
diff --git a/board/samus/ec.tasklist b/board/samus/ec.tasklist
index 3b862f9323..2b8da9c77b 100644
--- a/board/samus/ec.tasklist
+++ b/board/samus/ec.tasklist
@@ -18,6 +18,7 @@
*/
#define CONFIG_TASK_LIST \
TASK_ALWAYS(HOOKS, hook_task, NULL, LARGER_TASK_STACK_SIZE) \
+ TASK_NOTEST(ALS, als_task, NULL, TASK_STACK_SIZE) \
TASK_NOTEST(LIGHTBAR, lightbar_task, NULL, LARGER_TASK_STACK_SIZE) \
TASK_ALWAYS(CHARGER, charger_task, NULL, TASK_STACK_SIZE) \
TASK_NOTEST(CHIPSET, chipset_task, NULL, TASK_STACK_SIZE) \
diff --git a/common/als.c b/common/als.c
index e8b99e0d20..8c6ba9c5f1 100644
--- a/common/als.c
+++ b/common/als.c
@@ -10,8 +10,9 @@
#include "als.h"
#include "common.h"
#include "console.h"
-#include "hooks.h"
#include "host_command.h"
+#include "task.h"
+#include "timer.h"
#include "util.h"
int als_read(enum als_id id, int *lux)
@@ -19,23 +20,18 @@ int als_read(enum als_id id, int *lux)
return als[id].read(lux);
}
-/*****************************************************************************/
-/* Hooks */
-
-static void als_update(void)
+void als_task(void)
{
- int i, rv, val;
+ int i, val;
uint16_t *mapped = (uint16_t *)host_get_memmap(EC_MEMMAP_ALS);
- for (i = 0; i < EC_ALS_ENTRIES && i < ALS_COUNT; i++) {
- rv = als_read(i, &val);
- if (rv == EC_SUCCESS)
- mapped[i] = val;
- else
- mapped[i] = 0;
+ while (1) {
+ for (i = 0; i < EC_ALS_ENTRIES && i < ALS_COUNT; i++)
+ mapped[i] = als_read(i, &val) == EC_SUCCESS ? val : 0;
+
+ task_wait_event(SECOND);
}
}
-DECLARE_HOOK(HOOK_SECOND, als_update, HOOK_PRIO_DEFAULT);
/*****************************************************************************/
/* Console commands */