drivers: s/CPUID_ID_LEN/CPUID_LEN/
This commit is contained in:
parent
f09a631d66
commit
f3ac84d43a
@ -89,8 +89,8 @@ int at86rf2xx_init(at86rf2xx_t *dev, spi_t spi, spi_speed_t spi_speed,
|
|||||||
|
|
||||||
void at86rf2xx_reset(at86rf2xx_t *dev)
|
void at86rf2xx_reset(at86rf2xx_t *dev)
|
||||||
{
|
{
|
||||||
#if CPUID_ID_LEN
|
#if CPUID_LEN
|
||||||
uint8_t cpuid[CPUID_ID_LEN];
|
uint8_t cpuid[CPUID_LEN];
|
||||||
eui64_t addr_long;
|
eui64_t addr_long;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -103,16 +103,16 @@ void at86rf2xx_reset(at86rf2xx_t *dev)
|
|||||||
dev->seq_nr = 0;
|
dev->seq_nr = 0;
|
||||||
dev->options = 0;
|
dev->options = 0;
|
||||||
/* set short and long address */
|
/* set short and long address */
|
||||||
#if CPUID_ID_LEN
|
#if CPUID_LEN
|
||||||
cpuid_get(cpuid);
|
cpuid_get(cpuid);
|
||||||
|
|
||||||
#if CPUID_ID_LEN < 8
|
#if CPUID_LEN < 8
|
||||||
/* in case CPUID_ID_LEN < 8, fill missing bytes with zeros */
|
/* in case CPUID_LEN < 8, fill missing bytes with zeros */
|
||||||
for (int i = CPUID_ID_LEN; i < 8; i++) {
|
for (int i = CPUID_LEN; i < 8; i++) {
|
||||||
cpuid[i] = 0;
|
cpuid[i] = 0;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
for (int i = 8; i < CPUID_ID_LEN; i++) {
|
for (int i = 8; i < CPUID_LEN; i++) {
|
||||||
cpuid[i & 0x07] ^= cpuid[i];
|
cpuid[i & 0x07] ^= cpuid[i];
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -69,12 +69,12 @@ static inline int _get_iid(netdev2_t *netdev, eui64_t *value, size_t max_len)
|
|||||||
}
|
}
|
||||||
|
|
||||||
uint8_t *eui64 = (uint8_t*) value;
|
uint8_t *eui64 = (uint8_t*) value;
|
||||||
#ifdef CPUID_ID_LEN
|
#ifdef CPUID_LEN
|
||||||
int n = (CPUID_ID_LEN < sizeof(eui64_t))
|
int n = (CPUID_LEN < sizeof(eui64_t))
|
||||||
? CPUID_ID_LEN
|
? CPUID_LEN
|
||||||
: sizeof(eui64_t);
|
: sizeof(eui64_t);
|
||||||
|
|
||||||
char cpuid[CPUID_ID_LEN];
|
char cpuid[CPUID_LEN];
|
||||||
cpuid_get(cpuid);
|
cpuid_get(cpuid);
|
||||||
|
|
||||||
memcpy(eui64 + 8 - n, cpuid, n);
|
memcpy(eui64 + 8 - n, cpuid, n);
|
||||||
|
|||||||
@ -87,11 +87,11 @@ int cc110x_setup(cc110x_t *dev, const cc110x_params_t *params)
|
|||||||
cc110x_set_channel(dev, CC110X_DEFAULT_CHANNEL);
|
cc110x_set_channel(dev, CC110X_DEFAULT_CHANNEL);
|
||||||
|
|
||||||
/* set default node id */
|
/* set default node id */
|
||||||
#ifdef CPUID_ID_LEN
|
#ifdef CPUID_LEN
|
||||||
if (CPUID_ID_LEN>0) {
|
if (CPUID_LEN>0) {
|
||||||
char cpuid[CPUID_ID_LEN];
|
char cpuid[CPUID_LEN];
|
||||||
cpuid_get(cpuid);
|
cpuid_get(cpuid);
|
||||||
cc110x_set_address(dev, (uint8_t) cpuid[CPUID_ID_LEN-1]);
|
cc110x_set_address(dev, (uint8_t) cpuid[CPUID_LEN-1]);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@ -29,7 +29,7 @@
|
|||||||
#include "enc28j60.h"
|
#include "enc28j60.h"
|
||||||
#include "enc28j60_regs.h"
|
#include "enc28j60_regs.h"
|
||||||
|
|
||||||
#if CPUID_ID_LEN
|
#if CPUID_LEN
|
||||||
#include "periph/cpuid.h"
|
#include "periph/cpuid.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -344,8 +344,8 @@ static int nd_init(netdev2_t *netdev)
|
|||||||
/* set non-back-to-back inter packet gap -> 0x12 is default */
|
/* set non-back-to-back inter packet gap -> 0x12 is default */
|
||||||
cmd_wcr(dev, REG_B2_MAIPGL, 2, MAIPGL_FD);
|
cmd_wcr(dev, REG_B2_MAIPGL, 2, MAIPGL_FD);
|
||||||
/* set default MAC address */
|
/* set default MAC address */
|
||||||
#if CPUID_ID_LEN
|
#if CPUID_LEN
|
||||||
uint8_t macbuf[CPUID_ID_LEN];
|
uint8_t macbuf[CPUID_LEN];
|
||||||
cpuid_get(&macbuf); /* we get the full ID but use only parts of it */
|
cpuid_get(&macbuf); /* we get the full ID but use only parts of it */
|
||||||
macbuf[0] |= 0x02; /* locally administered address */
|
macbuf[0] |= 0x02; /* locally administered address */
|
||||||
macbuf[0] &= ~0x01; /* unicast address */
|
macbuf[0] &= ~0x01; /* unicast address */
|
||||||
|
|||||||
@ -392,8 +392,8 @@ int kw2xrf_init(kw2xrf_t *dev, spi_t spi, spi_speed_t spi_speed,
|
|||||||
uint8_t reg = 0;
|
uint8_t reg = 0;
|
||||||
uint8_t tmp[2];
|
uint8_t tmp[2];
|
||||||
kw2xrf_gpio_int = int_pin;
|
kw2xrf_gpio_int = int_pin;
|
||||||
#if CPUID_ID_LEN
|
#if CPUID_LEN
|
||||||
uint8_t cpuid[CPUID_ID_LEN];
|
uint8_t cpuid[CPUID_LEN];
|
||||||
eui64_t addr_long;
|
eui64_t addr_long;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -419,19 +419,19 @@ int kw2xrf_init(kw2xrf_t *dev, spi_t spi, spi_speed_t spi_speed,
|
|||||||
dev->proto = KW2XRF_DEFAULT_PROTOCOL;
|
dev->proto = KW2XRF_DEFAULT_PROTOCOL;
|
||||||
dev->option = 0;
|
dev->option = 0;
|
||||||
|
|
||||||
#if CPUID_ID_LEN
|
#if CPUID_LEN
|
||||||
cpuid_get(cpuid);
|
cpuid_get(cpuid);
|
||||||
|
|
||||||
#if CPUID_ID_LEN < 8
|
#if CPUID_LEN < 8
|
||||||
|
|
||||||
/* in case CPUID_ID_LEN < 8, fill missing bytes with zeros */
|
/* in case CPUID_LEN < 8, fill missing bytes with zeros */
|
||||||
for (int i = CPUID_ID_LEN; i < 8; i++) {
|
for (int i = CPUID_LEN; i < 8; i++) {
|
||||||
cpuid[i] = 0;
|
cpuid[i] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
for (int i = 8; i < CPUID_ID_LEN; i++) {
|
for (int i = 8; i < CPUID_LEN; i++) {
|
||||||
cpuid[i & 0x07] ^= cpuid[i];
|
cpuid[i & 0x07] ^= cpuid[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -91,8 +91,8 @@ static uint16_t _calc_fcs(uint16_t fcs, const uint8_t *frame, uint8_t frame_len)
|
|||||||
kernel_pid_t gnrc_zep_init(gnrc_zep_t *dev, uint16_t src_port, ipv6_addr_t *dst,
|
kernel_pid_t gnrc_zep_init(gnrc_zep_t *dev, uint16_t src_port, ipv6_addr_t *dst,
|
||||||
uint16_t dst_port)
|
uint16_t dst_port)
|
||||||
{
|
{
|
||||||
#if CPUID_ID_LEN
|
#if CPUID_LEN
|
||||||
uint8_t cpuid[CPUID_ID_LEN];
|
uint8_t cpuid[CPUID_LEN];
|
||||||
uint32_t hash1, hash2;
|
uint32_t hash1, hash2;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -120,18 +120,18 @@ kernel_pid_t gnrc_zep_init(gnrc_zep_t *dev, uint16_t src_port, ipv6_addr_t *dst,
|
|||||||
dev->chan = GNRC_ZEP_DEFAULT_CHANNEL;
|
dev->chan = GNRC_ZEP_DEFAULT_CHANNEL;
|
||||||
dev->pan = byteorder_btols(byteorder_htons(GNRC_ZEP_DEFAULT_PANID));
|
dev->pan = byteorder_btols(byteorder_htons(GNRC_ZEP_DEFAULT_PANID));
|
||||||
dev->flags = GNRC_ZEP_FLAGS_USE_SRC_PAN;
|
dev->flags = GNRC_ZEP_FLAGS_USE_SRC_PAN;
|
||||||
#if CPUID_ID_LEN
|
#if CPUID_LEN
|
||||||
/* initialize dev->addr and dev->eui64 from cpuid if available */
|
/* initialize dev->addr and dev->eui64 from cpuid if available */
|
||||||
cpuid_get(cpuid);
|
cpuid_get(cpuid);
|
||||||
|
|
||||||
hash1 = djb2_hash(cpuid, CPUID_ID_LEN / 2);
|
hash1 = djb2_hash(cpuid, CPUID_LEN / 2);
|
||||||
dev->addr.u16 = (uint16_t)((hash1 >> 16) ^ (hash1 & 0xffff));
|
dev->addr.u16 = (uint16_t)((hash1 >> 16) ^ (hash1 & 0xffff));
|
||||||
|
|
||||||
if (CPUID_ID_LEN % 2) {
|
if (CPUID_LEN % 2) {
|
||||||
hash2 = djb2_hash(cpuid + (CPUID_ID_LEN / 2), (CPUID_ID_LEN / 2) - 1);
|
hash2 = djb2_hash(cpuid + (CPUID_LEN / 2), (CPUID_LEN / 2) - 1);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
hash2 = djb2_hash(cpuid + (CPUID_ID_LEN / 2), CPUID_ID_LEN / 2);
|
hash2 = djb2_hash(cpuid + (CPUID_LEN / 2), CPUID_LEN / 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
dev->eui64.u32[0] = hash1;
|
dev->eui64.u32[0] = hash1;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user