1 /*
2  * Copyright (c) 2020 Gerson Fernando Budke <nandojve@gmail.com>
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 #define DT_DRV_COMPAT atmel_sam4l_uid
8 
9 #include <zephyr/device.h>
10 #include <zephyr/drivers/hwinfo.h>
11 #include <zephyr/init.h>
12 #include <soc.h>
13 #include <string.h>
14 
z_impl_hwinfo_get_device_id(uint8_t * buffer,size_t length)15 ssize_t z_impl_hwinfo_get_device_id(uint8_t *buffer, size_t length)
16 {
17 	uint8_t *uid_addr = (uint8_t *) DT_INST_REG_ADDR(0);
18 
19 	if (buffer == NULL) {
20 		return 0;
21 	}
22 
23 	if (length > DT_INST_REG_SIZE(0)) {
24 		length = DT_INST_REG_SIZE(0);
25 	}
26 
27 	memcpy(buffer, uid_addr, length);
28 
29 	return length;
30 }
31