drivers: hwinfo: add driver support for NXP i.mx RT device ID

Add driver support for NXP i.mx RT ID device.
This device has an ID of 8 bytes.

Signed-off-by: Alexander Wachter <alexander.wachter@student.tugraz.at>
This commit is contained in:
Alexander Wachter 2019-02-04 19:53:59 +01:00 committed by Maureen Helm
commit ad92d5bfe9
7 changed files with 42 additions and 0 deletions

View file

@ -16,3 +16,4 @@ ram: 32768
flash: 8192
supported:
- i2c
- hwinfo

View file

@ -19,3 +19,4 @@ supported:
- i2c
- spi
- netif:eth
- hwinfo

View file

@ -17,3 +17,4 @@ flash: 8192
supported:
- spi
- netif:eth
- hwinfo

View file

@ -14,3 +14,5 @@ toolchain:
- xtools
ram: 128
flash: 128
supported:
- hwinfo

View file

@ -4,5 +4,6 @@ zephyr_sources_ifdef(CONFIG_HWINFO hwinfo_weak_impl.c)
zephyr_sources_ifdef(CONFIG_HWINFO_STM32 hwinfo_stm32.c)
zephyr_sources_ifdef(CONFIG_HWINFO_NRF hwinfo_nrf.c)
zephyr_sources_ifdef(CONFIG_HWINFO_MCUX_SIM hwinfo_mcux_sim.c)
zephyr_sources_ifdef(CONFIG_HWINFO_IMXRT hwinfo_imxrt.c)
zephyr_sources_ifdef(CONFIG_HWINFO_SHELL hwinfo_shell.c)

View file

@ -40,4 +40,11 @@ config HWINFO_MCUX_SIM
help
Enable NXP kinetis mcux hwinfo driver.
config HWINFO_IMXRT
bool "NXP i.mx RT device ID"
default y
depends on SOC_SERIES_IMX_RT
help
Enable NXP i.mx RT hwinfo driver.
endif

View file

@ -0,0 +1,29 @@
/*
* Copyright (c) 2019 Alexander Wachter
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <soc.h>
#include <hwinfo.h>
#include <string.h>
struct imxrt_uid {
u32_t id[2];
};
ssize_t _impl_hwinfo_get_device_id(u8_t *buffer, size_t length)
{
struct imxrt_uid dev_id;
dev_id.id[0] = OCOTP->CFG1;
dev_id.id[1] = OCOTP->CFG2;
if (length > sizeof(dev_id.id)) {
length = sizeof(dev_id.id);
}
memcpy(buffer, dev_id.id, length);
return length;
}