Skip to content

Commit 0a907cd

Browse files
committed
CpuUid: renamed all references in code to device uid
1 parent 3432e6f commit 0a907cd

File tree

8 files changed

+91
-91
lines changed

8 files changed

+91
-91
lines changed

drivers/DeviceUid.cpp

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,48 +14,48 @@
1414
* limitations under the License.
1515
*/
1616

17-
#include "hal/cpu_uid_api.h"
17+
#include "hal/device_uid_api.h"
1818
#include "platform/mbed_assert.h"
1919
#include "platform/CriticalSectionLock.h"
20-
#include "drivers/CpuUid.h"
20+
#include "drivers/DeviceUid.h"
2121

22-
#if DEVICE_CPUUID
22+
#if DEVICE_DEVICEUID
2323

2424
namespace mbed {
2525

26-
uint8_t CpuUid::_uidbuf[MBED_CPU_UID_SIZE] = {0};
27-
uint8_t* CpuUid::_uidptr = NULL;
28-
char CpuUid::_strbuf[CPU_UID_STRING_BUFFER_SIZE] = {'\0'};
29-
char* CpuUid::_strptr = NULL;
30-
#ifndef MBED_CPU_UID_STR_SIZE_MAX
31-
const char CpuUid::_hexChars[16] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
26+
uint8_t DeviceUid::_uidbuf[MBED_DEVICEUID_SIZE] = {0};
27+
uint8_t* DeviceUid::_uidptr = NULL;
28+
char DeviceUid::_strbuf[DEVICEUID_STRING_BUFFER_SIZE] = {'\0'};
29+
char* DeviceUid::_strptr = NULL;
30+
#ifndef MBED_DEVICEUID_STR_SIZE_MAX
31+
const char DeviceUid::_hexChars[16] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
3232
#endif
3333

34-
CpuUid::CpuUid()
34+
DeviceUid::DeviceUid()
3535
{
3636
populate_uid_buf();
3737
}
3838

39-
void CpuUid::populate_uid_buf()
39+
void DeviceUid::populate_uid_buf()
4040
{
4141
if (_uidptr == NULL) {
4242
CriticalSectionLock lock;
43-
cpu_uid_get_uid(_uidbuf);
43+
device_uid_get_uid(_uidbuf);
4444
_uidptr = _uidbuf;
4545
}
4646
}
4747

48-
void CpuUid::populate_str_buf()
48+
void DeviceUid::populate_str_buf()
4949
{
5050
if (_strptr == NULL) {
5151
CriticalSectionLock lock;
52-
#ifdef MBED_CPU_UID_STR_SIZE_MAX
53-
cpu_uid_get_str(_strbuf);
52+
#ifdef MBED_DEVICEUID_STR_SIZE_MAX
53+
device_uid_get_str(_strbuf);
5454
_strptr = _strbuf;
5555
#else
5656
int pos = 0;
5757
populate_uid_buf();
58-
for (int i = 0; i < MBED_CPU_UID_SIZE; ++i) {
58+
for (int i = 0; i < MBED_DEVICEUID_SIZE; ++i) {
5959
_strbuf[pos++] = _hexChars[_uidptr[i] >> 4];
6060
_strbuf[pos++] = _hexChars[_uidptr[i] & 0x0F];
6161
}

drivers/DeviceUid.h

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -13,43 +13,43 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
#ifndef MBED_CPUUID_H
17-
#define MBED_CPUUID_H
16+
#ifndef MBED_DEVICEUID_H
17+
#define MBED_DEVICEUID_H
1818

1919
#include "platform/platform.h"
2020

21-
#if defined(DEVICE_CPUUID) || defined(DOXYGEN_ONLY)
21+
#if defined(DEVICE_DEVICEUID) || defined(DOXYGEN_ONLY)
2222

23-
#ifdef MBED_CPU_UID_STR_SIZE_MAX
24-
#define CPU_UID_STRING_BUFFER_SIZE MBED_CPU_UID_STR_SIZE_MAX
23+
#ifdef MBED_DEVICEUID_STR_SIZE_MAX
24+
#define DEVICEUID_STRING_BUFFER_SIZE MBED_DEVICEUID_STR_SIZE_MAX
2525
#else
26-
#define CPU_UID_STRING_BUFFER_SIZE (MBED_CPU_UID_SIZE * 2 + 1)
26+
#define DEVICEUID_STRING_BUFFER_SIZE (MBED_DEVICEUID_SIZE * 2 + 1)
2727
#endif
2828

2929
namespace mbed {
3030
/** \addtogroup drivers */
3131

32-
/** CPU UID reader class
32+
/** DEVICE UID reader class
3333
*
3434
* @note Synchronization level: Interrupt safe
3535
* @ingroup drivers
3636
*/
37-
class CpuUid {
37+
class DeviceUid {
3838
public:
39-
/** CpuUid constructor
39+
/** DeviceUid constructor
4040
*/
41-
CpuUid();
41+
DeviceUid();
4242

43-
/** Get size of CPU UID in bytes
43+
/** Get size of DEVICE UID in bytes
4444
*
45-
* @return Size of device's CPU UID in bytes
45+
* @return Size of device's DEVICE UID in bytes
4646
*/
4747
int size()
4848
{
49-
return MBED_CPU_UID_SIZE;
49+
return MBED_DEVICEUID_SIZE;
5050
}
5151

52-
/** Get CPU UID data pointer
52+
/** Get DEVICE UID data pointer
5353
*
5454
* @return Pointer to uid data buffer
5555
*/
@@ -59,13 +59,13 @@ class CpuUid {
5959
return _uidptr;
6060
}
6161

62-
/** Get CPU UID vendor string
62+
/** Get DEVICE UID vendor string
6363
*
6464
* @return Pointer to zero terminated uid vendor string
6565
*
6666
* @note
67-
* If vendor did not define MBED_CPU_UID_STR_SIZE_MAX, CpuUid driver will
68-
* assume the HAL interface function cpu_uid_get_str() is not implemented
67+
* If vendor did not define MBED_DEVICEUID_STR_SIZE_MAX, DeviceUid driver will
68+
* assume the HAL interface function device_uid_get_str() is not implemented
6969
* on the target, and instead the driver will construct just an ASCII
7070
* string out of the uid byte buffer contents.
7171
*
@@ -94,13 +94,13 @@ class CpuUid {
9494

9595
/** Overload operator for array subscript
9696
*
97-
* @param x CPU UID Byte index
97+
* @param x DEVICE UID Byte index
9898
*
9999
* @return Byte located at index x
100100
*/
101101
uint8_t operator[](int x)
102102
{
103-
if (x >= 0 && x < MBED_CPU_UID_SIZE) {
103+
if (x >= 0 && x < MBED_DEVICEUID_SIZE) {
104104
populate_uid_buf();
105105
return _uidptr[x];
106106
}
@@ -112,11 +112,11 @@ class CpuUid {
112112
void populate_uid_buf();
113113
void populate_str_buf();
114114

115-
static uint8_t _uidbuf[MBED_CPU_UID_SIZE];
115+
static uint8_t _uidbuf[MBED_DEVICEUID_SIZE];
116116
static uint8_t* _uidptr;
117-
static char _strbuf[CPU_UID_STRING_BUFFER_SIZE];
117+
static char _strbuf[DEVICEUID_STRING_BUFFER_SIZE];
118118
static char* _strptr;
119-
#ifndef MBED_CPU_UID_STR_SIZE_MAX
119+
#ifndef MBED_DEVICEUID_STR_SIZE_MAX
120120
static const char _hexChars[16];
121121
#endif
122122
};

hal/device_uid_api.h

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,50 +15,50 @@
1515
* See the License for the specific language governing permissions and
1616
* limitations under the License.
1717
*/
18-
#ifndef MBED_CPU_UID_API_H
19-
#define MBED_CPU_UID_API_H
18+
#ifndef MBED_DEVICE_UID_API_H
19+
#define MBED_DEVICE_UID_API_H
2020

2121
#include <stddef.h>
2222
#include "device.h"
2323

24-
#if DEVICE_CPUUID
24+
#if DEVICE_DEVICEUID
2525

26-
#ifndef MBED_CPU_UID_SIZE
27-
#error "CPU UID Vendor implementation must define macro MBED_CPU_UID_SIZE with the uid size in bytes!"
26+
#ifndef MBED_DEVICEUID_SIZE
27+
#error "DEVICE UID Vendor implementation must define macro MBED_DEVICEUID_SIZE with the uid size in bytes!"
2828
#endif
2929

30-
#ifndef MBED_CPU_UID_STR_SIZE_MAX
31-
#warning "CPU UID max vendor string length not defined! cpu_uid_get_str() HAL interface is disabled!"
30+
#ifndef MBED_DEVICEUID_STR_SIZE_MAX
31+
#warning "DEVICE UID max vendor string length not defined! device_uid_get_str() HAL interface is disabled!"
3232
#endif
3333

3434
#ifdef __cplusplus
3535
extern "C" {
3636
#endif
3737

3838
/**
39-
* \defgroup hal_cpu_uid CPUUID hal functions
39+
* \defgroup hal_device_uid DEVICEUID hal functions
4040
* @{
4141
*/
4242

43-
/** Get CPU UID data bytes
43+
/** Get DEVICE UID data bytes
4444
*
45-
* @param uid Byte buffer for uid. Must be of size MBED_CPU_UID_SIZE
45+
* @param uid Byte buffer for uid. Must be of size MBED_DEVICEUID_SIZE
4646
*
4747
*/
48-
void cpu_uid_get_uid(uint8_t *uid);
48+
void device_uid_get_uid(uint8_t *uid);
4949

50-
#ifdef MBED_CPU_UID_STR_SIZE_MAX
51-
/** Get UID vendor string
50+
#ifdef MBED_DEVICEUID_STR_SIZE_MAX
51+
/** Get DEVICE UID vendor string
5252
*
53-
* @param str Character buffer for vendor specific UID string. Must be of size MBED_CPU_UID_STR_SIZE_MAX
53+
* @param str Character buffer for vendor specific UID string. Must be of size MBED_DEVICEUID_STR_SIZE_MAX
5454
*
5555
* @note
5656
* Implementing this function on target side can be used to provide a vendor specific
5757
* string describing the contents of the UID.
58-
* The string length including terminating zero character must not exceed MBED_CPU_UID_STR_SIZE_MAX bytes!
58+
* The string length including terminating zero character must not exceed MBED_DEVICEUID_STR_SIZE_MAX bytes!
5959
*
6060
*/
61-
void cpu_uid_get_str(char *str);
61+
void device_uid_get_str(char *str);
6262
#endif
6363

6464
/**@}*/

mbed.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070
#include "drivers/RawSerial.h"
7171
#include "drivers/UARTSerial.h"
7272
#include "drivers/FlashIAP.h"
73-
#include "drivers/CpuUid.h"
73+
#include "drivers/DeviceUid.h"
7474

7575
// mbed Internal components
7676
#include "drivers/Timer.h"

targets/TARGET_NORDIC/TARGET_NRF5/device_uid_api.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,14 @@
3838

3939
#include "device.h"
4040

41-
#if DEVICE_CPUUID
41+
#if DEVICE_DEVICEUID
4242

4343
#include "nrf.h"
44-
#include "cpu_uid_api.h"
44+
#include "device_uid_api.h"
4545

4646
#define UID_WORDS 2
4747

48-
void cpu_uid_get_uid(uint8_t *uid)
48+
void device_uid_get_uid(uint8_t *uid)
4949
{
5050
int pos = 0;
5151

targets/TARGET_STM/device_uid_api.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
*/
3030
#include "device.h"
3131

32-
#if DEVICE_CPUUID
32+
#if DEVICE_DEVICEUID
3333

3434
#include <string.h>
3535
#if defined(TARGET_STM32F0)
@@ -53,15 +53,15 @@
5353
#else
5454
#error "Unsupported STM32 device!"
5555
#endif
56-
#include "cpu_uid_api.h"
56+
#include "device_uid_api.h"
5757

5858
#define UID_WORDS 3
5959

60-
#ifdef MBED_CPU_UID_STR_SIZE_MAX
60+
#ifdef MBED_DEVICEUID_STR_SIZE_MAX
6161
static int cpu_uid_itoa(int value, char *sp, int radix);
6262
#endif
6363

64-
void cpu_uid_get_uid(uint8_t *uid)
64+
void device_uid_get_uid(uint8_t *uid)
6565
{
6666
uint32_t uid_buf[UID_WORDS];
6767
int pos = 0;
@@ -77,8 +77,8 @@ void cpu_uid_get_uid(uint8_t *uid)
7777
}
7878
}
7979

80-
#ifdef MBED_CPU_UID_STR_SIZE_MAX
81-
void cpu_uid_get_str(char *str)
80+
#ifdef MBED_DEVICEUID_STR_SIZE_MAX
81+
void device_uid_get_str(char *str)
8282
{
8383
char buffer[16];
8484
char lot_number[8];

targets/TARGET_Silicon_Labs/TARGET_EFM32/device_uid_api.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/***************************************************************************//**
2-
* @file cpu_uid_api.c
2+
* @file device_uid_api.c
33
*******************************************************************************
44
* @section License
55
* <b>(C) Copyright 2017 Silicon Labs, http://www.silabs.com</b>
@@ -23,18 +23,18 @@
2323

2424
#include "device.h"
2525

26-
#if DEVICE_CPUUID
26+
#if DEVICE_DEVICEUID
2727

2828
#include "em_system.h"
29-
#include "cpu_uid_api.h"
29+
#include "device_uid_api.h"
3030

3131

32-
void cpu_uid_get_uid(uint8_t *uid)
32+
void device_uid_get_uid(uint8_t *uid)
3333
{
3434
int pos = 0;
3535
uint64_t tempuid = SYSTEM_GetUnique();
3636

37-
for (int i = (MBED_CPU_UID_SIZE - 1); i >= 0; --i) {
37+
for (int i = (MBED_DEVICEUID_SIZE - 1); i >= 0; --i) {
3838
uid[pos++] = (uint8_t)((tempuid >> (i*8)) & 0xFF);
3939
}
4040
}

0 commit comments

Comments
 (0)