diff options
| author | sommersoft <sommersoft@users.noreply.github.com> | 2018-01-18 13:39:11 -0600 |
|---|---|---|
| committer | Scott Shawcroft <scott@tannewt.org> | 2018-01-18 11:39:11 -0800 |
| commit | 44bc1711aa2eb093329bdbd4ee8c137bd2f7a9f4 (patch) | |
| tree | 4a19220e4aec23fcab2e0170d3c8e6a021f3a628 /ports/nrf/common-hal | |
| parent | dfa6b6e9c5ec8d7b2a085eb9ddcf565c3433d1c1 (diff) | |
Added Unique ID Functions/Updated Support Matrix (#527)
shared_bindings/index.rst: updated Support Matrix format as discussed in PR #503 & Issue #448.
shared-bindings/microcontroller/Processor.c & .h: added UID lookup functionality for use with all ports. Fixes #462.
Diffstat (limited to 'ports/nrf/common-hal')
| -rw-r--r-- | ports/nrf/common-hal/microcontroller/Processor.c | 10 | ||||
| -rw-r--r-- | ports/nrf/common-hal/microcontroller/Processor.h | 2 |
2 files changed, 12 insertions, 0 deletions
diff --git a/ports/nrf/common-hal/microcontroller/Processor.c b/ports/nrf/common-hal/microcontroller/Processor.c index 4e74a4909..ba5aa0932 100644 --- a/ports/nrf/common-hal/microcontroller/Processor.c +++ b/ports/nrf/common-hal/microcontroller/Processor.c @@ -35,3 +35,13 @@ uint32_t common_hal_mcu_processor_get_frequency(void) { return 64000000ul; } +void common_hal_mcu_processor_get_uid(uint8_t raw_id[]) { + + uint32_t* id_addresses[2] = {(uint32_t *) 0x060, (uint32_t *) 0x064}; + + for (int i=0; i<2; i++) { + for (int k=0; k<4; k++) { + raw_id[4 * i + k] = (*(id_addresses[i]) >> k * 8) & 0xf; + } + } +} diff --git a/ports/nrf/common-hal/microcontroller/Processor.h b/ports/nrf/common-hal/microcontroller/Processor.h index 00d95ad4f..4049c165f 100644 --- a/ports/nrf/common-hal/microcontroller/Processor.h +++ b/ports/nrf/common-hal/microcontroller/Processor.h @@ -27,6 +27,8 @@ #ifndef MICROPY_INCLUDED_NRF_COMMON_HAL_MICROCONTROLLER_PROCESSOR_H #define MICROPY_INCLUDED_NRF_COMMON_HAL_MICROCONTROLLER_PROCESSOR_H +#define COMMON_HAL_MCU_PROCESSOR_UID_LENGTH 8 + #include "py/obj.h" typedef struct { |
