Skip to content

Commit

Permalink
[RENAME]drivers/kw2xrf: improve default short address V1
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterKietzmann committed May 25, 2016
1 parent ad5ad76 commit a0133c2
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion drivers/kw2xrf/kw2xrf.c
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,7 @@ int kw2xrf_init(kw2xrf_t *dev, spi_t spi, spi_speed_t spi_speed,
# else
uint8_t cpuid[CPUID_LEN];
#endif
uint16_t addr_short = 0;
eui64_t addr_long;
#endif

Expand Down Expand Up @@ -439,15 +440,20 @@ int kw2xrf_init(kw2xrf_t *dev, spi_t spi, spi_speed_t spi_speed,
for (int i = IEEE802154_LONG_ADDRESS_LEN; i < CPUID_LEN; i++) {
cpuid[i & 0x07] ^= cpuid[i];
}
#endif

#if CPUID_LEN > IEEE802154_SHORT_ADDRESS_LEN
for (int i = 0; i < CPUID_LEN; i++) {
addr_short ^= (uint16_t)(cpuid[i] << ((i & 0x01) * 8));
}
#endif
/* make sure we mark the address as non-multicast and not globally unique */
cpuid[0] &= ~(0x01);
cpuid[0] |= 0x02;
/* copy and set long address */
memcpy(&addr_long, cpuid, IEEE802154_LONG_ADDRESS_LEN);
kw2xrf_set_addr_long(dev, NTOHLL(addr_long.uint64.u64));
kw2xrf_set_addr(dev, NTOHS(addr_long.uint16[0].u16));
kw2xrf_set_addr(dev, addr_short);
#else
kw2xrf_set_addr_long(dev, KW2XRF_DEFAULT_SHORT_ADDR);
kw2xrf_set_addr(dev, KW2XRF_DEFAULT_ADDR_LONG);
Expand Down

0 comments on commit a0133c2

Please sign in to comment.