diff --git a/arch/arm/src/kinetis/Make.defs b/arch/arm/src/kinetis/Make.defs index bb7f54d87b..b2f1046caa 100644 --- a/arch/arm/src/kinetis/Make.defs +++ b/arch/arm/src/kinetis/Make.defs @@ -90,7 +90,7 @@ CHIP_ASRCS = CHIP_CSRCS = kinetis_allocateheap.c kinetis_clockconfig.c CHIP_CSRCS += kinetis_clrpend.c kinetis_idle.c kinetis_irq.c CHIP_CSRCS += kinetis_lowputc.c kinetis_pin.c kinetis_pingpio.c -CHIP_CSRCS += kinetis_serial.c kinetis_start.c kinetis_wdog.c +CHIP_CSRCS += kinetis_serial.c kinetis_start.c kinetis_uid.c kinetis_wdog.c CHIP_CSRCS += kinetis_cfmconfig.c # Configuration-dependent Kinetis files diff --git a/arch/arm/src/kinetis/kinetis_uid.c b/arch/arm/src/kinetis/kinetis_uid.c new file mode 100644 index 0000000000..54a98d08ce --- /dev/null +++ b/arch/arm/src/kinetis/kinetis_uid.c @@ -0,0 +1,68 @@ +/************************************************************************************ + * arch/arm/src/kinetis/kinetis_uid.c + * + * Copyright (C) 2016 Neil Hancock. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ************************************************************************************/ + +/************************************************************************************ + * Included Files + ************************************************************************************/ + +#include + +#include +#include +#include "kinetis_uid.h" + +#ifdef CONFIG_BOARDCTL_UNIQUEID + +/************************************************************************************ + * Public Functions + ************************************************************************************/ + +void kinetis_get_uniqueid(uint8_t *uniqueid) +{ + int i; + uint32_t *unique_u32; + unique_u32 = (uint32_t *)uniqueid; + + /* + * Copy into buffer LS first, which in the Kinetis is the highest memory + */ + + for (i = 0; i < (KINETIS_UID_SIZE/sizeof(uint32_t)); i++) + { + unique_u32[i] = *((uint32_t*)(KINETIS_SIM_UIDL)-i); + } +} + +#endif /* CONFIG_BOARDCTL_UNIQUEID */ + diff --git a/arch/arm/src/kinetis/kinetis_uid.h b/arch/arm/src/kinetis/kinetis_uid.h new file mode 100644 index 0000000000..84620f53e5 --- /dev/null +++ b/arch/arm/src/kinetis/kinetis_uid.h @@ -0,0 +1,49 @@ +/************************************************************************************ + * arch/arm/src/kinetis/kinetis_uid.h + * + * Copyright (C) 2016 Neil Hancock. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ************************************************************************************/ + +#ifndef __ARCH_ARM_SRC_KINETIS_UID_H +#define __ARCH_ARM_SRC_KINETIS_UID_H + +/************************************************************************************ + * Included Files + ************************************************************************************/ + +#include + +/************************************************************************************ + * Public Function Prototypes + ************************************************************************************/ +#define KINETIS_UID_SIZE 16 +void kinetis_get_uniqueid(uint8_t *uniqueid); +#endif /* __ARCH_ARM_SRC_KINETIS_UID_H */ diff --git a/configs/freedom-k64f/README.txt b/configs/freedom-k64f/README.txt index 0b80b603d1..2c6666a7e6 100644 --- a/configs/freedom-k64f/README.txt +++ b/configs/freedom-k64f/README.txt @@ -56,6 +56,8 @@ OpenSDAv2 HDK-compatible debug interface preloaded with the open-source CMSIS-DAP Interface firmware (mbed interface) for rapid prototyping and product development. + + To use set raw binary output for nuttx.bin Serial Console ============== diff --git a/configs/freedom-k64f/src/Makefile b/configs/freedom-k64f/src/Makefile index 8c533ec849..7da96029aa 100644 --- a/configs/freedom-k64f/src/Makefile +++ b/configs/freedom-k64f/src/Makefile @@ -73,4 +73,7 @@ ifeq ($(CONFIG_PWM),y) CSRCS += k64_pwm.c endif +ifeq ($(CONFIG_BOARDCTL_UNIQUEID),y) +CSRCS += k64_uid.c +endif include $(TOPDIR)/configs/Board.mk diff --git a/configs/freedom-k64f/src/k64_uid.c b/configs/freedom-k64f/src/k64_uid.c new file mode 100644 index 0000000000..545de899c0 --- /dev/null +++ b/configs/freedom-k64f/src/k64_uid.c @@ -0,0 +1,73 @@ +/************************************************************************************ + * configs/freedom-k64/src/kinetis_uid.c + * + * Copyright (C) 2016 Neil Hancock. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ************************************************************************************/ + +/************************************************************************************ + * Included Files + ************************************************************************************/ + +#include + +#include +#include +#include +#include "kinetis_uid.h" + +#include + +/************************************************************************************ + * Pre-processor Definitions + ************************************************************************************/ + +#ifndef OK +# define OK 0 +#endif + +/************************************************************************************ + * Public Functions + ************************************************************************************/ + +#if defined(CONFIG_BOARDCTL_UNIQUEID) + +int board_uniqueid(FAR uint8_t *uniqueid) +{ + if (uniqueid == 0) + { + return -EINVAL; + } + + kinetis_get_uniqueid(uniqueid); + return OK; +} + +#endif diff --git a/configs/freedom-k64f/src/k64_userleds.c b/configs/freedom-k64f/src/k64_userleds.c index 48a396a3ce..e75a2abb8e 100644 --- a/configs/freedom-k64f/src/k64_userleds.c +++ b/configs/freedom-k64f/src/k64_userleds.c @@ -107,3 +107,4 @@ void board_userled_all(uint8_t ledset) kinetis_gpiowrite(GPIO_LED_G, (ledset & BOARD_LED_G_BIT) == 0); kinetis_gpiowrite(GPIO_LED_B, (ledset & BOARD_LED_B_BIT) == 0); } +#endif