mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2026-01-04 22:11:41 +00:00
In order to wake the chips from STOP/SLEEP mode with a touch, we need to put the two chips in correct state before going into STOP/SLEEP mode. Also, when one of the chips wakes up, it needs to wake the other chip with GPIO interrupt. This CL implements the necessary methods and also adds a sample routine that put the chips in STOP mode and wait for a touch using the implemented methods. BUG=None TEST=Build and boot. Touch the panel and see the response in console. BRANCH=None Change-Id: Ia5f7df8b550ee2459bcae1840f8a2717c8d947ce Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/204482 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
78 lines
1.7 KiB
C
78 lines
1.7 KiB
C
/* Copyright (c) 2014 The Chromium OS Authors. All rights reserved.
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
* found in the LICENSE file.
|
|
*/
|
|
|
|
/* Touch scanning module */
|
|
|
|
#ifndef __BOARD_KEYBORG_TOUCH_SCAN_H
|
|
#define __BOARD_KEYBORG_TOUCH_SCAN_H
|
|
|
|
enum pin_type {
|
|
PIN_ROW,
|
|
PIN_COL,
|
|
PIN_PD,
|
|
PIN_Z,
|
|
};
|
|
|
|
/* 8-bit window */
|
|
#define ADC_WINDOW_POS 2
|
|
|
|
/* Threshold for each cell */
|
|
#define THRESHOLD 35
|
|
|
|
/* Threshold for entire column */
|
|
#define COL_THRESHOLD 16
|
|
|
|
/* The span width of active columns */
|
|
#define COL_SPAN 5 /* Must not exceed 15 */
|
|
|
|
/* ADC speed */
|
|
#define ADC_SMPR_VAL 0x2 /* 13.5 cycles */
|
|
#define ADC_SMPL_CYCLE_2 27
|
|
#define ADC_QUNTZ_CYCLE_2 25 /* Quantization always takes 12.5 cycles */
|
|
|
|
/* CPU clock is 4 times faster than ADC clock */
|
|
#define ADC_SMPL_CPU_CYCLE (ADC_SMPL_CYCLE_2 * 2)
|
|
|
|
struct ts_pin {
|
|
uint8_t port_id; /* GPIO_A = 0, GPIO_B = 1, ... */
|
|
uint8_t pin;
|
|
};
|
|
|
|
#define TS_GPIO_A 0
|
|
#define TS_GPIO_B 1
|
|
#define TS_GPIO_C 2
|
|
#define TS_GPIO_D 3
|
|
#define TS_GPIO_E 4
|
|
#define TS_GPIO_F 5
|
|
#define TS_GPIO_G 6
|
|
#define TS_GPIO_H 7
|
|
#define TS_GPIO_I 8
|
|
|
|
extern const struct ts_pin row_pins[];
|
|
extern const struct ts_pin col_pins[];
|
|
|
|
#define ROW_COUNT 41
|
|
#define COL_COUNT 60
|
|
|
|
/* Initialize touch scan module */
|
|
void touch_scan_init(void);
|
|
|
|
/* Start scanning on the slave. This is called by SPI command handler. */
|
|
void touch_scan_slave_start(void);
|
|
|
|
/**
|
|
* Initiate full matrix scan on the master. This also sends SPI command
|
|
* to the slave.
|
|
*/
|
|
int touch_scan_full_matrix(void);
|
|
|
|
/* Configure touch scan module to interrupt on touch. */
|
|
void touch_scan_enable_interrupt(void);
|
|
|
|
/* Disable touch scan interrupt. */
|
|
void touch_scan_disable_interrupt(void);
|
|
|
|
#endif /* __BOARD_KEYBORG_TOUCH_SCAN_H */
|