2017-08-14 09:05:19 +00:00
|
|
|
/*
|
2019-06-17 18:27:55 +00:00
|
|
|
* This file is part of the Trezor project, https://trezor.io/
|
2017-08-14 09:05:19 +00:00
|
|
|
*
|
2018-02-26 13:06:10 +00:00
|
|
|
* Copyright (c) SatoshiLabs
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2017-08-14 09:05:19 +00:00
|
|
|
*/
|
|
|
|
|
2017-03-07 13:50:09 +00:00
|
|
|
#include STM32_HAL_H
|
2017-04-07 00:34:53 +00:00
|
|
|
#include "touch.h"
|
2017-03-07 13:50:09 +00:00
|
|
|
|
2018-10-02 16:08:05 +00:00
|
|
|
#if TREZOR_MODEL == T
|
|
|
|
#include "touch_t.h"
|
|
|
|
#elif TREZOR_MODEL == 1
|
|
|
|
#include "touch_1.h"
|
2018-10-02 17:03:06 +00:00
|
|
|
#else
|
2019-06-17 18:27:55 +00:00
|
|
|
#error Unknown Trezor Model
|
2018-10-02 16:08:05 +00:00
|
|
|
#endif
|
2017-03-07 16:33:39 +00:00
|
|
|
|
2019-03-29 15:26:02 +00:00
|
|
|
uint32_t touch_click(void) {
|
|
|
|
uint32_t r = 0;
|
|
|
|
// flush touch events if any
|
|
|
|
while (touch_read()) {
|
|
|
|
}
|
|
|
|
// wait for TOUCH_START
|
|
|
|
while ((touch_read() & TOUCH_START) == 0) {
|
|
|
|
}
|
|
|
|
// wait for TOUCH_END
|
|
|
|
while (((r = touch_read()) & TOUCH_END) == 0) {
|
|
|
|
}
|
|
|
|
// flush touch events if any
|
|
|
|
while (touch_read()) {
|
|
|
|
}
|
|
|
|
// return last touch coordinate
|
|
|
|
return r;
|
2017-09-29 08:11:12 +00:00
|
|
|
}
|