Parent directory

hardware_id.c

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