From 94675a7780aa4470004a19b948fc18c4ca46105d Mon Sep 17 00:00:00 2001 From: Eric Holland Date: Sat, 10 Oct 2020 16:48:49 -0400 Subject: [PATCH] [nrf52][i2c] move i2c_init to target Since the i2c driver is optional (not required for platform) the i2c_init should be done during target initialization. The flags used to include the i2c driver should be in either target or project files so it makes sense that the i2c_init should also be called from target files. --- platform/nrf52xxx/init.c | 7 ------- target/nrf-pca10056/init.c | 4 ++++ 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/platform/nrf52xxx/init.c b/platform/nrf52xxx/init.c index d4f55c8c1..1d14260d0 100644 --- a/platform/nrf52xxx/init.c +++ b/platform/nrf52xxx/init.c @@ -8,7 +8,6 @@ #include #include #include -#include #include #include #include @@ -44,10 +43,4 @@ void platform_init(void) { (NRF_FICR->DEVICEADDR[0] >> 16) & 0xFF, \ (NRF_FICR->DEVICEADDR[0] >> 8) & 0xFF, \ (NRF_FICR->DEVICEADDR[0] >> 0) & 0xFF); - - // Note: i2c_init will only instantiate an i2c device if proper defines - // are set. See comments at top of i2c_master.c for more info. -#if (NRFX_TWIM_ENABLED) - i2c_init(); -#endif } diff --git a/target/nrf-pca10056/init.c b/target/nrf-pca10056/init.c index c94e06c03..1c3bb9f3c 100644 --- a/target/nrf-pca10056/init.c +++ b/target/nrf-pca10056/init.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include @@ -26,6 +27,9 @@ void target_early_init(void) { LED4_OFF; nrf52_debug_early_init(); + // Note: i2c_init will only instantiate an i2c device if proper defines + // are set. See comments at top of i2c_master.c(platform driver) for more info. + i2c_init(); }