mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-06 20:13:40 +00:00
nrf,sam,rp2040: add machine.HardwareID function
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"encoding/hex"
|
||||
"machine"
|
||||
"time"
|
||||
)
|
||||
|
||||
func main() {
|
||||
time.Sleep(2 * time.Second)
|
||||
|
||||
// For efficiency, it's best to get the device ID once and cache it
|
||||
// (e.g. on RP2040 XIP flash and interrupts disabled for period of
|
||||
// retrieving the hardware ID from ROM chip)
|
||||
id := machine.DeviceID()
|
||||
|
||||
for {
|
||||
println("Device ID:", hex.EncodeToString(id))
|
||||
time.Sleep(1 * time.Second)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user