Skip to content

Commit

Permalink
drivers/input: Add alive checking timer
Browse files Browse the repository at this point in the history
Add timer which it periodically check the status of the ist415 chipset
and reset it in case there is any issue.

Signed-off-by: eunwoo.nam <[email protected]>
  • Loading branch information
ewoodev committed Dec 23, 2024
1 parent 9a0e6f9 commit 9480d82
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
37 changes: 37 additions & 0 deletions os/drivers/input/ist415.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
#include <tinyara/i2c.h>
#include <tinyara/irq.h>
#include <tinyara/wqueue.h>
#include <tinyara/wdog.h>

#include <tinyara/input/touchscreen.h>
#include <tinyara/input/ist415.h>
Expand Down Expand Up @@ -99,6 +100,33 @@ static const struct touchscreen_ops_s g_ist415_ops = {
* Private Functions
****************************************************************************/

/****************************************************************************
* Name: ist415_irq_handler_work
****************************************************************************/

static void ist415_lockup_work(struct ist415_dev_s *dev)
{
touchdbg("checking\n");
}

/****************************************************************************
* Name: ist415_irq_handler_work
****************************************************************************/

static void ist415_timer_handler(int argc, uint32_t arg1)
{
struct ist415_dev_s *dev = (struct ist415_dev_s *)arg1;

/* TODO: alive check*/
work_queue(HPWORK, &dev->work, (worker_t)ist415_lockup_work, (void *)dev, 0);

wd_start(dev->wdog, MSEC2TICK(EVENT_TIMER_INTERVAL), (wdentry_t)ist415_timer_handler, 1, (uint32_t)dev);
}

/****************************************************************************
* Name: ist415_irq_handler_work
****************************************************************************/

static void ist415_irq_handler_work(struct ist415_dev_s *dev)
{
struct touch_sample_s data;
Expand Down Expand Up @@ -940,6 +968,15 @@ int ist415_initialize(const char *path, struct i2c_dev_s *i2c, struct ist415_con
ist415_start(dev);
// ist415_enable(dev);

dev->wdog = wd_create();
if (dev->wdog) {
if (wd_start(dev->wdog, MSEC2TICK(EVENT_TIMER_INTERVAL), (wdentry_t)ist415_timer_handler, 1, (uint32_t)dev) != OK) {
touchdbg("Fail to start ist415 wdog\n");
}
} else {
touchdbg("Fail to alloc ist415 wdog\n");
}

upper = (struct touchscreen_s *)kmm_zalloc(sizeof(struct touchscreen_s));
if (!upper) {
touchdbg("Fail to alloc touchscreen_s\n");
Expand Down
5 changes: 5 additions & 0 deletions os/drivers/input/ist415.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@

#include <tinyara/i2c.h>
#include <tinyara/wqueue.h>
#include <tinyara/wdog.h>

#define IST415_I2C_FREQ 100000
#define IST415_I2C_ADDRLEN 7
Expand Down Expand Up @@ -236,6 +237,9 @@

#define TSP_INFO_SWAP_XY (1 << 0)

/* timer & err cnt */
#define EVENT_TIMER_INTERVAL 5000 // 5s

struct ts_event_coordinate {
uint8_t eid: 2;
uint8_t tid: 4;
Expand Down Expand Up @@ -434,6 +438,7 @@ struct ist415_dev_s {
int intr_debug_size;

struct work_s work;
WDOG_ID wdog;
};

void put_unaligned_be32(uint32_t value, void *addr);
Expand Down

0 comments on commit 9480d82

Please sign in to comment.