From f45d2c7b2a7d7867dda1f3e6d827ecac066b238b Mon Sep 17 00:00:00 2001 From: Alexandre Abadie Date: Sun, 21 Jun 2020 18:26:46 +0200 Subject: [PATCH] sys/auto_init: add auto_init for stmpe811 --- sys/auto_init/screen/auto_init_stmpe811.c | 52 +++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 sys/auto_init/screen/auto_init_stmpe811.c diff --git a/sys/auto_init/screen/auto_init_stmpe811.c b/sys/auto_init/screen/auto_init_stmpe811.c new file mode 100644 index 0000000000..fd004b5356 --- /dev/null +++ b/sys/auto_init/screen/auto_init_stmpe811.c @@ -0,0 +1,52 @@ +/* + * Copyright (C) 2020 Inria + * + * This file is subject to the terms and conditions of the GNU Lesser + * General Public License v2.1. See the file LICENSE in the top level + * directory for more details. + */ + +/** + * @ingroup sys_auto_init + * @{ + * @file + * @brief initializes stmpe811 display device + * + * @author Alexandre Abadie + * @} + */ + +#include + +#include "log.h" + +#include "touch_dev.h" + +#include "stmpe811.h" +#include "stmpe811_params.h" +#include "stmpe811_touch_dev.h" + +#define STMPE811_NUMOF ARRAY_SIZE(stmpe811_params) + +stmpe811_t stmpe811_devs[STMPE811_NUMOF]; +static touch_dev_reg_t touch_dev_entries[STMPE811_NUMOF]; + +void auto_init_stmpe811(void) +{ + assert(STMPE811_NUMOF == ARRAY_SIZE(stmpe811_screen_ids)); + + for (size_t i = 0; i < STMPE811_NUMOF; i++) { + LOG_DEBUG("[auto_init_screen] initializing stmpe811 #%u\n", i); + if (stmpe811_init(&stmpe811_devs[i], &stmpe811_params[i], NULL, NULL) < 0) { + LOG_ERROR("[auto_init_screen] error initializing stmpe811 #%u\n", i); + continue; + } + + touch_dev_entries[i].dev = (touch_dev_t *)&stmpe811_devs[i]; + touch_dev_entries[i].screen_id = stmpe811_screen_ids[i]; + touch_dev_entries[i].dev->driver = &stmpe811_touch_dev_driver; + + /* add to touch_dev registry */ + touch_dev_reg_add(&(touch_dev_entries[i])); + } +}