Skip to content

Commit 7d62acf

Browse files
committed
Use HAL to read DEVICEID
1 parent 7ce33ca commit 7d62acf

File tree

2 files changed

+7
-14
lines changed

2 files changed

+7
-14
lines changed

arch/cpu/nrf/dev/usb-arch.c

+3-2
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454

5555
#include "nrfx.h"
5656
#include "nrfx_power.h"
57+
#include "nrf_ficr.h"
5758
/*---------------------------------------------------------------------------*/
5859
extern void tusb_hal_nrf_power_event(uint32_t event);
5960
/*---------------------------------------------------------------------------*/
@@ -76,8 +77,8 @@ power_event_handler(nrfx_power_usb_evt_t event)
7677
void
7778
usb_arch_init(void)
7879
{
79-
const uint16_t serial_num_high_bytes = (uint16_t)NRF_FICR->DEVICEADDR[1] | 0xC000; // The masking makes the address match the Random Static BLE address.
80-
const uint32_t serial_num_low_bytes = NRF_FICR->DEVICEADDR[0];
80+
const uint16_t serial_num_high_bytes = nrf_ficr_deviceid_get(NRF_FICR, 1) | 0xC000;
81+
const uint32_t serial_num_low_bytes = nrf_ficr_deviceid_get(NRF_FICR, 0);
8182
const nrfx_power_config_t power_config = { 0 };
8283
const nrfx_power_usbevt_config_t power_usbevt_config = {
8384
.handler = power_event_handler

arch/cpu/nrf/sys/linkaddr-arch.c

+4-12
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
#include "linkaddr.h"
4949

5050
#include "nrf.h"
51+
#include "nrf_ficr.h"
5152

5253
#include "linkaddr-arch.h"
5354

@@ -72,18 +73,9 @@ populate_link_address(void)
7273
device_address[0] = (NORDIC_SEMI_VENDOR_OUI) >> 16 & 0xFF;
7374
device_address[1] = (NORDIC_SEMI_VENDOR_OUI) >> 8 & 0xFF;
7475
device_address[2] = NORDIC_SEMI_VENDOR_OUI & 0xFF;
75-
#if defined(NRF_FICR)
76-
device_address[3] = NRF_FICR->DEVICEADDR[1] & 0xFF;
77-
device_address_low = NRF_FICR->DEVICEADDR[0];
78-
#elif defined(NRF_FICR_NS)
79-
device_address[3] = NRF_FICR_NS->DEVICEADDR[1] & 0xFF;
80-
device_address_low = NRF_FICR_NS->DEVICEADDR[0];
81-
#elif defined(NRF_FICR_S)
82-
device_address[3] = 0;
83-
device_address_low = 0;
84-
#else
85-
#error "NRF_FICR not supported?"
86-
#endif
76+
device_address[3] = nrf_ficr_deviceid_get(NRF_FICR, 1) & 0xFF;
77+
device_address_low = nrf_ficr_deviceid_get(NRF_FICR, 0);
78+
8779
memcpy(&device_address[4], &device_address_low, sizeof(device_address_low));
8880

8981
memcpy(&linkaddr_node_addr, &device_address[8 - LINKADDR_SIZE],

0 commit comments

Comments
 (0)