Skip to content

Commit

Permalink
Merge branch 'fix-ieee802154_kw41z-mac' into 'dev'
Browse files Browse the repository at this point in the history
fix: kw41z: ieee802154: Use MAC address

See merge request blik/embedded/zephyr!28
  • Loading branch information
Tobias Aschenbrenner committed Jun 25, 2018
2 parents 3efe518 + 19784e2 commit 325f3fb
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
6 changes: 6 additions & 0 deletions drivers/ieee802154/Kconfig.kw41z
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ config IEEE802154_KW41Z_INIT_PRIO
Set the initialization priority number. Do not change it unless
you know what you are doing. It has to start before the net stack.

config IEEE802154_KW41Z_MAC_RANDOM
bool "Use random MAC address"
default y
help
Use a random MAC address instead of the built-in unique one

config KW41_DBG_TRACE
bool "Enabled simplified debug tracing of events"
default n
Expand Down
11 changes: 11 additions & 0 deletions drivers/ieee802154/ieee802154_kw41z.c
Original file line number Diff line number Diff line change
Expand Up @@ -844,11 +844,22 @@ static inline u8_t *get_mac(struct device *dev)
* and how to allow for a OUI portion?
*/

#if CONFIG_IEEE802154_KW41Z_MAC_RANDOM
u32_t *ptr = (u32_t *)(kw41z->mac_addr);

UNALIGNED_PUT(sys_rand32_get(), ptr);
ptr = (u32_t *)(kw41z->mac_addr + 4);
UNALIGNED_PUT(sys_rand32_get(), ptr);
#else
const u32_t mac_msb = RSIM->MAC_MSB;
const u32_t mac_lsb = RSIM->MAC_LSB;
u64_t mac = (u64_t) mac_msb << 32 | mac_lsb;

/* Does expect big endianess for the mac */
mac = sys_cpu_to_be64(mac);
memcpy(kw41z->mac_addr, &mac, sizeof(mac));

#endif

/*
* Clear bit 0 to ensure it isn't a multicast address and set
Expand Down

0 comments on commit 325f3fb

Please sign in to comment.