1 /*
2  * Copyright (c) 2012-2014 Travis Geiselbrecht
3  *
4  * Use of this source code is governed by a MIT-style
5  * license that can be found in the LICENSE file or at
6  * https://opensource.org/licenses/MIT
7  */
8 #include <lk/err.h>
9 #include <lk/debug.h>
10 #include <arch/arm/cm.h>
11 #include <dev/uart.h>
12 #include <platform.h>
13 #include <platform/nrf51.h>
14 #include <platform/system_nrf51.h>
15 
16 
17 
platform_early_init(void)18 void platform_early_init(void) {
19     // Crank up the clock before initing timers.
20     SystemInit();
21     arm_cm_systick_init(32768);
22 }
23 
platform_init(void)24 void platform_init(void) {
25     dprintf(SPEW, "Nordic nrf51xxx platform for lk...\n");
26     dprintf(SPEW, "\tFlash: %d pages of %d bytes each (%dk bytes total)\n", \
27             NRF_FICR->CODESIZE, NRF_FICR->CODEPAGESIZE, \
28             (NRF_FICR->CODESIZE * NRF_FICR->CODEPAGESIZE)>>10);
29     dprintf(SPEW, "\tRAM: %d blocks of %d bytes each (%dk bytes total)\n", \
30             NRF_FICR->NUMRAMBLOCK, NRF_FICR->SIZERAMBLOCKS, \
31             (NRF_FICR->NUMRAMBLOCK * NRF_FICR->SIZERAMBLOCKS)>>10);
32     dprintf(SPEW, "\tRadio MAC address  %02x:%02x:%02x:%02x:%02x:%02x\n", \
33             (NRF_FICR->DEVICEADDR[1] >> 8) & 0xFF, \
34             (NRF_FICR->DEVICEADDR[1]) & 0xFF, \
35             (NRF_FICR->DEVICEADDR[0] >> 24) & 0xFF, \
36             (NRF_FICR->DEVICEADDR[0] >> 16) & 0xFF, \
37             (NRF_FICR->DEVICEADDR[0] >>  8) & 0xFF, \
38             (NRF_FICR->DEVICEADDR[0] >>  0) & 0xFF);
39     dprintf(SPEW, "\tHWID: 0x%04x\n",NRF_FICR->CONFIGID & 0x0000ffff);
40 
41 }
42