Skip to content

Commit

Permalink
STM32 fix
Browse files Browse the repository at this point in the history
Change to the HAL_GetUIDw0(), HAL_GetUIDw1() and HAL_GetUIDw2() for 96-bit UID
  • Loading branch information
ricaun committed Jul 23, 2019
1 parent cc4c5ca commit 206c02d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ The uniqueness of the serial number is guaranteed only when using all 128 bits.

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.

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.
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.

## Tested Microcontroller

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

* Install the library by [Using the Library Manager](https://www.arduino.cc/en/Guide/Libraries#toc3)
* **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.
* **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.

## Examples

Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=ArduinoUniqueID
version=1.0.8
version=1.0.9
author=Luiz Henrique Cassettari
maintainer=Luiz Henrique Cassettari <ricaun@gmail.com>
sentence=Arduino Library to gets the Manufacture Serial Number from the Atmel AVR, SAM, SAMD, STM32, and ESP Microcontroller.
Expand Down
14 changes: 7 additions & 7 deletions src/ArduinoUniqueID.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,15 +90,15 @@ ArduinoUniqueID::ArduinoUniqueID()

#elif defined(ARDUINO_ARCH_STM32)
uint32_t pdwUniqueID[3];
pdwUniqueID[2] = *(uint32_t *)(UID_BASE + 0);
pdwUniqueID[1] = *(uint32_t *)(UID_BASE + 4);
pdwUniqueID[0] = *(uint32_t *)(UID_BASE + 8);
pdwUniqueID[0] = HAL_GetUIDw0();
pdwUniqueID[1] = HAL_GetUIDw1();
pdwUniqueID[2] = HAL_GetUIDw2();
for (int i = 0; i < 3; i++)
{
id[i*4+3] = (uint8_t)(pdwUniqueID[i] >> 24);
id[i*4+2] = (uint8_t)(pdwUniqueID[i] >> 16);
id[i*4+1] = (uint8_t)(pdwUniqueID[i] >> 8);
id[i*4+0] = (uint8_t)(pdwUniqueID[i] >> 0);
id[i*4+0] = (uint8_t)(pdwUniqueID[i] >> 24);
id[i*4+1] = (uint8_t)(pdwUniqueID[i] >> 16);
id[i*4+2] = (uint8_t)(pdwUniqueID[i] >> 8);
id[i*4+3] = (uint8_t)(pdwUniqueID[i] >> 0);
}
#endif
}
Expand Down

0 comments on commit 206c02d

Please sign in to comment.