You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

20 lines
583 B

  1. // Copyright 2022 QMK
  2. // SPDX-License-Identifier: GPL-2.0-or-later
  3. #include <ch.h>
  4. #include "hardware_id.h"
  5. hardware_id_t get_hardware_id(void) {
  6. hardware_id_t id = {0};
  7. #if defined(RP2040)
  8. // Forward declare as including "hardware/flash.h" here causes more issues...
  9. void flash_get_unique_id(uint8_t *);
  10. flash_get_unique_id((uint8_t *)&id);
  11. #elif defined(UID_BASE)
  12. id.data[0] = (uint32_t)(*((uint32_t *)UID_BASE));
  13. id.data[1] = (uint32_t)(*((uint32_t *)(UID_BASE + 4)));
  14. id.data[2] = (uint32_t)(*((uint32_t *)(UID_BASE + 8)));
  15. #endif
  16. return id;
  17. }