hardware_id.c 558 B

12345678910111213141516171819
  1. // Copyright 2022 QMK
  2. // SPDX-License-Identifier: GPL-2.0-or-later
  3. // For some reason this bit is undocumented for some AVR parts and not defined in their avr-libc IO headers
  4. // See https://stackoverflow.com/questions/12350914/how-to-read-atmega-32-signature-row
  5. #ifndef SIGRD
  6. # define SIGRD 5
  7. #endif // SIGRD
  8. #include <avr/boot.h>
  9. #include "hardware_id.h"
  10. hardware_id_t get_hardware_id(void) {
  11. hardware_id_t id = {0};
  12. for (uint8_t i = 0; i < 10; i += 1) {
  13. ((uint8_t*)&id)[i] = boot_signature_byte_get(i + 0x0E);
  14. }
  15. return id;
  16. }