Add UID Unique ID
This commit is contained in:
parent
e1b1748b7a
commit
64b020f1a8
@ -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
|
||||
|
68
arch/arm/src/kinetis/kinetis_uid.c
Normal file
68
arch/arm/src/kinetis/kinetis_uid.c
Normal file
@ -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 <nuttx/config.h>
|
||||
|
||||
#include <chip/kinetis_k64memorymap.h>
|
||||
#include <chip/kinetis_sim.h>
|
||||
#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 */
|
||||
|
49
arch/arm/src/kinetis/kinetis_uid.h
Normal file
49
arch/arm/src/kinetis/kinetis_uid.h
Normal file
@ -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 <stdint.h>
|
||||
|
||||
/************************************************************************************
|
||||
* Public Function Prototypes
|
||||
************************************************************************************/
|
||||
#define KINETIS_UID_SIZE 16
|
||||
void kinetis_get_uniqueid(uint8_t *uniqueid);
|
||||
#endif /* __ARCH_ARM_SRC_KINETIS_UID_H */
|
@ -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
|
||||
==============
|
||||
|
@ -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
|
||||
|
73
configs/freedom-k64f/src/k64_uid.c
Normal file
73
configs/freedom-k64f/src/k64_uid.c
Normal file
@ -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 <nuttx/config.h>
|
||||
|
||||
#include <chip/kinetis_k64memorymap.h>
|
||||
#include <chip/kinetis_sim.h>
|
||||
#include <errno.h>
|
||||
#include "kinetis_uid.h"
|
||||
|
||||
#include <nuttx/board.h>
|
||||
|
||||
/************************************************************************************
|
||||
* 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
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user