1 /* 2 * Copyright (c) 2017 Oticon A/S 3 * Copyright (c) 2023 Nordic Semiconductor ASA 4 * 5 * SPDX-License-Identifier: Apache-2.0 6 */ 7 8 /* 9 * Factory information configuration registers 10 * https://infocenter.nordicsemi.com/topic/ps_nrf52833/ficr.html?cp=5_1_0_3_3 11 */ 12 13 /* 14 * TOLOW: we start with most registers cleared, and a few evident ones set to some values. 15 * It could be interesting to let people load them from command line 16 * for example by specifying a file with their values. and/or by specifying particular ones 17 * with command line options; something like -deviceaddr=<bt_address> 18 */ 19 20 #include "NHW_common_types.h" 21 #include "NHW_config.h" 22 #include "NHW_peri_types.h" 23 #include <string.h> 24 #include "bs_rand_main.h" 25 #include "nsi_tasks.h" 26 #include "weak_stubs.h" 27 28 NRF_FICR_Type NRF_FICR_regs; 29 nhw_52_ficr_init(void)30static void nhw_52_ficr_init(void) { 31 memset(&NRF_FICR_regs, 0xFF, sizeof(NRF_FICR_regs)); 32 33 #define FLASH_PAGE_SIZE (4*1024) 34 #define FLASH_N_PAGES 128 35 #define FLASH_SIZE (FLASH_N_PAGES*FLASH_PAGE_SIZE) 36 37 NRF_FICR_regs.CODEPAGESIZE = FLASH_PAGE_SIZE; 38 NRF_FICR_regs.CODESIZE = FLASH_N_PAGES; 39 40 NRF_FICR_regs.DEVICEID[0] = (bs_random_uint32() & 0xFFFFFF00) + bsim_args_get_global_device_nbr(); 41 NRF_FICR_regs.DEVICEID[1] = bs_random_uint32(); 42 NRF_FICR_regs.DEVICEADDRTYPE = 0; 43 NRF_FICR_regs.DEVICEADDR[0] = bs_random_uint32(); 44 NRF_FICR_regs.DEVICEADDR[1] = bs_random_uint32(); 45 46 for (int i = 0 ; i < 4; i++) { 47 NRF_FICR_regs.ER[i] = bs_random_uint32(); 48 NRF_FICR_regs.IR[i] = bs_random_uint32(); 49 } 50 51 NRF_FICR_regs.INFO.PART = 0x52833; 52 NRF_FICR_regs.INFO.VARIANT = 0x41414230; 53 NRF_FICR_regs.PRODTEST[0] = 0xBB42319F; 54 NRF_FICR_regs.PRODTEST[1] = 0xBB42319F; 55 NRF_FICR_regs.PRODTEST[2] = 0xBB42319F; 56 } 57 58 NSI_TASK(nhw_52_ficr_init, HW_INIT, 100); 59