Skip to content

Commit 206c02d

Browse files
committed
STM32 fix
Change to the HAL_GetUIDw0(), HAL_GetUIDw1() and HAL_GetUIDw2() for 96-bit UID
1 parent cc4c5ca commit 206c02d

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ The uniqueness of the serial number is guaranteed only when using all 128 bits.
6565

6666
STM32 32-bit Arm Cortex MCUs has a unique 96-bit serial number which is a concatenation of three 32-bit words, the address is different depending on the microcontroller.
6767

68-
The [Arduino Core STM32](https://github.com/stm32duino/Arduino_Core_STM32) has the variable UID_BASE whos contain the first 32-bit word of the serial number.
68+
The [Arduino Core STM32](https://github.com/stm32duino/Arduino_Core_STM32) has the functions HAL_GetUIDw0(), HAL_GetUIDw1() and HAL_GetUIDw2() for 96-bit UID.
6969

7070
## Tested Microcontroller
7171

@@ -109,7 +109,7 @@ To make the variable UniqueID8 to work propably the library uses the default byt
109109
# Installation
110110

111111
* Install the library by [Using the Library Manager](https://www.arduino.cc/en/Guide/Libraries#toc3)
112-
* **OR** by [Importing the .zip library](https://www.arduino.cc/en/Guide/Libraries#toc4) using either the [master](https://github.com/ricaun/ArduinoUniqueID/archive/1.0.7.zip) or one of the [releases](https://github.com/ricaun/ArduinoUniqueID/releases) ZIP files.
112+
* **OR** by [Importing the .zip library](https://www.arduino.cc/en/Guide/Libraries#toc4) using either the [master](https://github.com/ricaun/ArduinoUniqueID/archive/1.0.9.zip) or one of the [releases](https://github.com/ricaun/ArduinoUniqueID/releases) ZIP files.
113113

114114
## Examples
115115

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=ArduinoUniqueID
2-
version=1.0.8
2+
version=1.0.9
33
author=Luiz Henrique Cassettari
44
maintainer=Luiz Henrique Cassettari <ricaun@gmail.com>
55
sentence=Arduino Library to gets the Manufacture Serial Number from the Atmel AVR, SAM, SAMD, STM32, and ESP Microcontroller.

src/ArduinoUniqueID.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -90,15 +90,15 @@ ArduinoUniqueID::ArduinoUniqueID()
9090

9191
#elif defined(ARDUINO_ARCH_STM32)
9292
uint32_t pdwUniqueID[3];
93-
pdwUniqueID[2] = *(uint32_t *)(UID_BASE + 0);
94-
pdwUniqueID[1] = *(uint32_t *)(UID_BASE + 4);
95-
pdwUniqueID[0] = *(uint32_t *)(UID_BASE + 8);
93+
pdwUniqueID[0] = HAL_GetUIDw0();
94+
pdwUniqueID[1] = HAL_GetUIDw1();
95+
pdwUniqueID[2] = HAL_GetUIDw2();
9696
for (int i = 0; i < 3; i++)
9797
{
98-
id[i*4+3] = (uint8_t)(pdwUniqueID[i] >> 24);
99-
id[i*4+2] = (uint8_t)(pdwUniqueID[i] >> 16);
100-
id[i*4+1] = (uint8_t)(pdwUniqueID[i] >> 8);
101-
id[i*4+0] = (uint8_t)(pdwUniqueID[i] >> 0);
98+
id[i*4+0] = (uint8_t)(pdwUniqueID[i] >> 24);
99+
id[i*4+1] = (uint8_t)(pdwUniqueID[i] >> 16);
100+
id[i*4+2] = (uint8_t)(pdwUniqueID[i] >> 8);
101+
id[i*4+3] = (uint8_t)(pdwUniqueID[i] >> 0);
102102
}
103103
#endif
104104
}

0 commit comments

Comments
 (0)