1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

cpu/lpc1768: added cpuid periph driver implementation

This commit is contained in:
nqdinh 2016-03-10 11:01:34 +07:00
parent a2f8a3fdd4
commit 5ad659a54a
2 changed files with 55 additions and 0 deletions

View File

@ -38,6 +38,13 @@ extern "C" {
#define CPU_FLASH_BASE LPC_FLASH_BASE
/** @} */
/**
* @brief CPU ID configuration
* @{
*/
#define CPUID_LEN (16U)
/* @} */
#ifdef __cplusplus
}
#endif

View File

@ -0,0 +1,48 @@
/*
* Copyright (C) 2015 Freie Universität Berlin
*
* This file is subject to the terms and conditions of the GNU Lesser General
* Public License v2.1. See the file LICENSE in the top level directory for more
* details.
*/
/**
* @ingroup driver_periph
* @{
*
* @file
* @brief Low-level CPUID driver implementation
*
* @author Paul RATHGEB <paul.rathgeb@skynet.be>
* @author Dinh Nguyen <nqdinhddt@gmail.com>
* @}
*/
#include <string.h>
#include <stdint.h>
#include "periph/cpuid.h"
#include "cpu_conf.h"
/**
* @name IAP base address
*/
#define IAP_ADDRESS 0x1FFF1FF1
void cpuid_get(void *id)
{
uint32_t result[5];
/* IAP command for UUID : 58 (UM10360 page 645) */
uint32_t command = 58;
/* Define pointer to function type */
void (*iap)(uint32_t[], uint32_t[]);
/* Set the function pointer */
iap = (void (*)(uint32_t[], uint32_t[])) IAP_ADDRESS;
/* Read UUID */
iap(&command, result);
if (result[0] == 0) {
memcpy(id, &result[1], CPUID_LEN);
}
else {
memset(id, 0xFF, CPUID_LEN);
}
}