From 41b8354d7ecc42fd6f6f083700728275430990d2 Mon Sep 17 00:00:00 2001 From: Fabian Pflug Date: Sat, 11 May 2024 16:12:49 +0200 Subject: [PATCH] nrf52: i2c_twim: Fix static 400uA current Hardware error described here: https://docs.nordicsemi.com/bundle/errata_nRF52832_Rev3/page/ERR/nRF52832/Rev3/latest/anomaly_832_89.html When using GPIOTE and TWIM and PM_DEVICE, then the device must be turned off and then on again after suspending, otherwise there is a constant 400uA current draw. Signed-off-by: Fabian Pflug --- modules/hal_nordic/nrfx/nrfx_config.h | 4 ++++ modules/hal_nordic/nrfx/nrfx_config_nrf52832.h | 10 ++++++++++ soc/nordic/nrf52/CMakeLists.txt | 5 +++++ soc/nordic/nrf52/Kconfig | 10 ++++++++++ west.yml | 2 +- 5 files changed, 30 insertions(+), 1 deletion(-) diff --git a/modules/hal_nordic/nrfx/nrfx_config.h b/modules/hal_nordic/nrfx/nrfx_config.h index 4b23f7a2190a97..47c13686033ec2 100644 --- a/modules/hal_nordic/nrfx/nrfx_config.h +++ b/modules/hal_nordic/nrfx/nrfx_config.h @@ -882,6 +882,10 @@ CONFIG_NRF52_ANOMALY_109_WORKAROUND_EGU_INSTANCE #endif +#ifdef CONFIG_NRF52_ANOMALY_89_WORKAROUND +#define NRFX_TWIM_NRF52_ANOMALY_89_WORKAROUND_ENABLED 1 +#endif + #if defined(CONFIG_SOC_SERIES_BSIM_NRFXX) #include "nrfx_config_bsim.h" #endif diff --git a/modules/hal_nordic/nrfx/nrfx_config_nrf52832.h b/modules/hal_nordic/nrfx/nrfx_config_nrf52832.h index b181bf6cdcc6e2..a89ac8110bf5c6 100644 --- a/modules/hal_nordic/nrfx/nrfx_config_nrf52832.h +++ b/modules/hal_nordic/nrfx/nrfx_config_nrf52832.h @@ -1331,6 +1331,16 @@ #define NRFX_TWIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED 0 #endif +/** + * @brief NRFX_TWIM_NRF52_ANOMALY_89_WORKAROUND_ENABLED - Enables nRF52 Anomaly 89 workaround for + * TWIM. + * + * Boolean. Accepted values 0 and 1. + */ +#ifndef NRFX_TWIM_NRF52_ANOMALY_89_WORKAROUND_ENABLED +#define NRFX_TWIM_NRF52_ANOMALY_89_WORKAROUND_ENABLED 0 +#endif + /** * @brief NRFX_TWIM_CONFIG_LOG_LEVEL * diff --git a/soc/nordic/nrf52/CMakeLists.txt b/soc/nordic/nrf52/CMakeLists.txt index 6b01a1ffc778aa..b01fae193bbf71 100644 --- a/soc/nordic/nrf52/CMakeLists.txt +++ b/soc/nordic/nrf52/CMakeLists.txt @@ -13,4 +13,9 @@ if(CONFIG_SOC_NRF52832) message(WARNING "NRF52_ANOMALY_109_WORKAROUND disabled with SPIS, SPIM, TWIM or PWM enabled. This will occasionally cause the first byte transmitted to be incorrect") endif() endif() + if(NOT CONFIG_NRF52_ANOMALY_89_WORKAROUND) + if (CONFIG_NRFX_TWIM AND CONFIG_NRFX_GPIOTE) + message(WARNING "NRF52_ANOMALY_89_WORKAROUND disabled with TWIM and GPIOTE enabled. This can cause a static current draw of 400uA") + endif() + endif() endif() diff --git a/soc/nordic/nrf52/Kconfig b/soc/nordic/nrf52/Kconfig index adb57916627e48..ce3bdc9bc37381 100644 --- a/soc/nordic/nrf52/Kconfig +++ b/soc/nordic/nrf52/Kconfig @@ -119,4 +119,14 @@ config NRF52_ANOMALY_109_WORKAROUND_EGU_INSTANCE help EGU instance used by the nRF52 Anomaly 109 workaround for PWM. +config NRF52_ANOMALY_89_WORKAROUND + bool "Anomaly 89 workaround" + default y + depends on SOC_NRF52832 + depends on NRFX_TWIM || NRFX_SPIM + depends on NRFX_GPIOTE + help + This helps in reducing the 400uA to 450uA static current consumption when + GPIOTE and TWIM is enabled. + endif # SOC_SERIES_NRF52X diff --git a/west.yml b/west.yml index f7c3e04da5e73a..d0e2c2ad6f0301 100644 --- a/west.yml +++ b/west.yml @@ -188,7 +188,7 @@ manifest: groups: - hal - name: hal_nordic - revision: 4a3ba8eaca8f5255f550db7bc54dc3e23212da64 + revision: pull/180/head path: modules/hal/nordic groups: - hal