Use twim(i2c) driver from nrfx library. See comments and patterns in target/nrf-pca10056 for info on how to properly utilize driver as it requires some GLOBAL_DEFINES and gpio defines.
39 lines
1.3 KiB
C
39 lines
1.3 KiB
C
/*
|
|
* Copyright (c) 2016 Eric Holland
|
|
*
|
|
* Use of this source code is governed by a MIT-style
|
|
* license that can be found in the LICENSE file or at
|
|
* https://opensource.org/licenses/MIT
|
|
*/
|
|
#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 <nrfx.h>
|
|
#include <mdk/system_nrf52.h>
|
|
|
|
void platform_early_init(void) {
|
|
// Crank up the clock before initing timers.
|
|
SystemInit();
|
|
arm_cm_systick_init(32768);
|
|
}
|
|
|
|
void platform_init(void) {
|
|
dprintf(SPEW, "Nordic nrf52xxx platform for lk...\n");
|
|
dprintf(SPEW, "\tFlash: %d pages of %d bytes each (%dk bytes total)\n", \
|
|
NRF_FICR->CODESIZE, NRF_FICR->CODEPAGESIZE, \
|
|
(NRF_FICR->CODESIZE * NRF_FICR->CODEPAGESIZE)>>10);
|
|
dprintf(SPEW, "\tRadio MAC address %02x:%02x:%02x:%02x:%02x:%02x\n", \
|
|
(NRF_FICR->DEVICEADDR[1] >> 8) & 0xFF, \
|
|
(NRF_FICR->DEVICEADDR[1]) & 0xFF, \
|
|
(NRF_FICR->DEVICEADDR[0] >> 24) & 0xFF, \
|
|
(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.
|
|
i2c_init();
|
|
}
|