Skip to content

Commit

Permalink
samr21: cpuid implemented by reading 128 bits from flash
Browse files Browse the repository at this point in the history
  • Loading branch information
Troels51 committed Dec 15, 2014
1 parent 1c03805 commit 9fafc45
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion boards/samr21-xpro/Makefile.features
Original file line number Diff line number Diff line change
@@ -1 +1 @@
FEATURES_PROVIDED += periph_gpio cpp
FEATURES_PROVIDED += periph_gpio periph_cpuid cpp
4 changes: 4 additions & 0 deletions cpu/samd21/include/cpu-conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,9 @@
/** @} */


/**
* @brief CPUID_ID_LEN length of cpuid in bytes
*/
#define CPUID_ID_LEN (16) /* 128 bits long, 16 bytes long */
#endif /* __CPU_CONF_H */
/** @} */
17 changes: 17 additions & 0 deletions cpu/samd21/periph/cpuid.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@

#include <string.h>

#include "cpu-conf.h"
#include "periph/cpuid.h"

#define Word0 (*(volatile uint32_t *)0x0080A00C)
#define Word1 (*(volatile uint32_t *)0x0080A040)
#define Word2 (*(volatile uint32_t *)0x0080A044)
#define Word3 (*(volatile uint32_t *)0x0080A048)


void cpuid_get(void *id)
{
uint32_t source_address[] = {Word0, Word1, Word2, Word3};
memcpy(id, (void*) source_address, CPUID_ID_LEN);
}

0 comments on commit 9fafc45

Please sign in to comment.