From 724cfbc6c4fcec3608db9ec2ef9ad946b7d7e201 Mon Sep 17 00:00:00 2001 From: Vic Yang Date: Tue, 20 May 2014 11:17:08 -0700 Subject: [PATCH] Keyborg: fix bug in slave data processing This fixes two bugs: - The row order on the slave is reversed - The last value is missed when transferring data to the master BUG=None TEST=Build and check the heatmap BRANCH=None Change-Id: Ic51ad1132d948ec6ec68dc673288ec6f29c6ebe7 Signed-off-by: Vic Yang Reviewed-on: https://chromium-review.googlesource.com/200621 Reviewed-by: Vincent Palatin --- board/keyborg/touch_scan.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/board/keyborg/touch_scan.c b/board/keyborg/touch_scan.c index 9ea947eb43..3b3a7a84f1 100644 --- a/board/keyborg/touch_scan.c +++ b/board/keyborg/touch_scan.c @@ -140,7 +140,7 @@ void scan_column(uint8_t *data) void touch_scan_slave_start(void) { - int col, i; + int col, i, v; struct spi_comm_packet *resp = (struct spi_comm_packet *)buf; for (col = 0; col < COL_COUNT * 2; ++col) { @@ -155,10 +155,17 @@ void touch_scan_slave_start(void) scan_column(resp->data); resp->cmd_sts = EC_SUCCESS; + /* Reverse the scanned data */ + for (i = 0; ROW_COUNT - 1 - i > i; ++i) { + v = resp->data[i]; + resp->data[i] = resp->data[ROW_COUNT - 1 - i]; + resp->data[ROW_COUNT - 1 - i] = v; + } + /* Trim trailing zeros. */ for (i = 0; i < ROW_COUNT; ++i) if (resp->data[i] >= THRESHOLD) - resp->size = i; + resp->size = i + 1; /* Flush the last response */ if (col != 0)