[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.
This commit is contained in:
Eric Holland
2020-10-10 16:48:49 -04:00
parent 38dd509b27
commit 94675a7780
2 changed files with 4 additions and 7 deletions

View File

@@ -8,7 +8,6 @@
#include <lk/err.h>
#include <lk/debug.h>
#include <arch/arm/cm.h>
#include <dev/i2c.h>
#include <dev/uart.h>
#include <platform.h>
#include <platform/init.h>
@@ -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
}

View File

@@ -11,6 +11,7 @@
#include <lk/compiler.h>
#include <nrfx_usbd.h>
#include <dev/gpio.h>
#include <dev/i2c.h>
#include <platform/init.h>
#include <target/gpioconfig.h>
@@ -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();
}