From 6aeccd5ee13d5e1328668e1f338abc3272b1d6ef Mon Sep 17 00:00:00 2001 From: mcudev <29890609+mcudev@users.noreply.github.com> Date: Sun, 29 Oct 2017 08:04:40 -0400 Subject: [PATCH] touch: make i2c_handle static and trivial simplification --- embed/trezorhal/touch.c | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/embed/trezorhal/touch.c b/embed/trezorhal/touch.c index c9257953e..ca5ea8396 100644 --- a/embed/trezorhal/touch.c +++ b/embed/trezorhal/touch.c @@ -13,9 +13,7 @@ #include "secbool.h" #include "touch.h" -I2C_HandleTypeDef i2c_handle = { - .Instance = I2C1, -}; +static I2C_HandleTypeDef i2c_handle; void touch_init(void) { @@ -32,15 +30,15 @@ void touch_init(void) }; HAL_GPIO_Init(GPIOB, &GPIO_InitStructure); - I2C_InitTypeDef *init = &(i2c_handle.Init); - init->OwnAddress1 = 0xFE; // master - init->ClockSpeed = 400000; - init->DutyCycle = I2C_DUTYCYCLE_16_9; - init->AddressingMode = I2C_ADDRESSINGMODE_7BIT; - init->DualAddressMode = I2C_DUALADDRESS_DISABLE; - init->GeneralCallMode = I2C_GENERALCALL_DISABLE; - init->NoStretchMode = I2C_NOSTRETCH_DISABLE; - init->OwnAddress2 = 0; + i2c_handle.Instance = I2C1; + i2c_handle.Init.ClockSpeed = 400000; + i2c_handle.Init.DutyCycle = I2C_DUTYCYCLE_16_9; + i2c_handle.Init.OwnAddress1 = 0xFE; // master + i2c_handle.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT; + i2c_handle.Init.DualAddressMode = I2C_DUALADDRESS_DISABLE; + i2c_handle.Init.OwnAddress2 = 0; + i2c_handle.Init.GeneralCallMode = I2C_GENERALCALL_DISABLE; + i2c_handle.Init.NoStretchMode = I2C_NOSTRETCH_DISABLE; ensure(sectrue * (HAL_OK == HAL_I2C_Init(&i2c_handle)), NULL); }