Created
October 1, 2018 18:24
-
-
Save branw/fd171f90679a426fe395e82692cd771a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bool flash_read_unique_id(uint32_t *pul_data) { | |
// Initialize the first EEFC bank in 128-bit mode with 4 wait states | |
if (efc_init(EFC0, 0, 4)) { | |
return false; | |
} | |
// Enter the unique identifier mode, copy it, and exit | |
return !efc_perform_read_sequence(EFC0, EFC_FCMD_STUI, EFC_FCMD_SPUI, pul_data, 4); | |
} | |
void setup() { | |
SerialUSB.begin(115200); | |
} | |
void loop() { | |
uint32_t unique_id[4]; | |
if (flash_read_unique_id(unique_id)) { | |
uint32_t hash = unique_id[0] ^ unique_id[1] ^ unique_id[2] ^ unique_id[3]; | |
SerialUSB.println(hash, HEX); | |
} | |
delay(1000); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment