Skip to content

Commit 3956dff

Browse files
ydamigoskartben
authored andcommitted
drivers: hwinfo_smartbond: Implement hwinfo_get_device_id() function
Implement hwinfo_get_device_id() function Signed-off-by: Ioannis Damigos <[email protected]>
1 parent d33da4d commit 3956dff

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

drivers/hwinfo/hwinfo_smartbond.c

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,42 @@
66

77
#include <zephyr/device.h>
88
#include <zephyr/drivers/hwinfo.h>
9+
#include <zephyr/sys/byteorder.h>
910
#include <soc.h>
11+
#include <da1469x_trimv.h>
12+
13+
#define PRODUCT_INFO_GPOUP (12U)
14+
#define CHIP_ID_GPOUP (13U)
15+
16+
#define PRODUCT_INFO_LENGTH (3U)
17+
#define CHIP_ID_LENGTH (1U)
18+
19+
ssize_t z_impl_hwinfo_get_device_id(uint8_t *buffer, size_t length)
20+
{
21+
size_t len;
22+
uint32_t unique_id[4];
23+
uint8_t product_info_len;
24+
uint8_t chip_id_len;
25+
26+
product_info_len = da1469x_trimv_group_read(PRODUCT_INFO_GPOUP, &unique_id[0],
27+
PRODUCT_INFO_LENGTH);
28+
chip_id_len = da1469x_trimv_group_read(CHIP_ID_GPOUP, &unique_id[3],
29+
CHIP_ID_LENGTH);
30+
31+
if ((product_info_len != PRODUCT_INFO_LENGTH) || (chip_id_len != CHIP_ID_LENGTH)) {
32+
return -ENODATA;
33+
}
34+
35+
for (uint8_t i = 0; i < (product_info_len + chip_id_len); i++) {
36+
unique_id[i] = BSWAP_32(unique_id[i]);
37+
}
38+
39+
len = MIN(length, sizeof(unique_id));
40+
41+
memcpy(buffer, unique_id, len);
42+
43+
return len;
44+
}
1045

1146
int z_impl_hwinfo_get_reset_cause(uint32_t *cause)
1247
{

0 commit comments

Comments
 (0)