1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-28 00:58:09 +00:00

touch: address simplification

This commit is contained in:
mcudev 2017-10-29 08:09:59 -04:00 committed by Pavol Rusnak
parent 6aeccd5ee1
commit 2ae1c99b06

View File

@ -43,13 +43,13 @@ void touch_init(void)
ensure(sectrue * (HAL_OK == HAL_I2C_Init(&i2c_handle)), NULL);
}
#define TOUCH_ADDRESS 56
#define TOUCH_ADDRESS (0x38 << 1) // the HAL requires the 7-bit address to be shifted by one bit
#define TOUCH_PACKET_SIZE 16
uint32_t touch_read(void)
{
static uint8_t data[TOUCH_PACKET_SIZE], old_data[TOUCH_PACKET_SIZE];
if (HAL_OK != HAL_I2C_Master_Receive(&i2c_handle, TOUCH_ADDRESS << 1, data, TOUCH_PACKET_SIZE, 1)) {
if (HAL_OK != HAL_I2C_Master_Receive(&i2c_handle, TOUCH_ADDRESS, data, TOUCH_PACKET_SIZE, 1)) {
return 0; // read failure
}
if (0 == memcmp(data, old_data, TOUCH_PACKET_SIZE)) {