Skip to content

Commit

Permalink
[nrf52][i2c] move i2c_init to target
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
hollanderic committed Oct 10, 2020
1 parent 38dd509 commit 94675a7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
7 changes: 0 additions & 7 deletions platform/nrf52xxx/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -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
}
4 changes: 4 additions & 0 deletions target/nrf-pca10056/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -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>

Expand All @@ -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();
}


Expand Down

0 comments on commit 94675a7

Please sign in to comment.