Skip to content

Instantly share code, notes, and snippets.

@branw
Created October 1, 2018 18:24
Show Gist options
  • Save branw/fd171f90679a426fe395e82692cd771a to your computer and use it in GitHub Desktop.
Save branw/fd171f90679a426fe395e82692cd771a to your computer and use it in GitHub Desktop.
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