Browse Source

drivers: s/CPUID_ID_LEN/CPUID_LEN/

pr/gpio
Hauke Petersen 7 years ago
parent
commit
f3ac84d43a
  1. 14
      drivers/at86rf2xx/at86rf2xx.c
  2. 8
      drivers/cc110x/cc110x-netdev2.c
  3. 8
      drivers/cc110x/cc110x.c
  4. 6
      drivers/enc28j60/enc28j60.c
  5. 14
      drivers/kw2xrf/kw2xrf.c
  6. 14
      sys/net/gnrc/application_layer/zep/gnrc_zep.c

14
drivers/at86rf2xx/at86rf2xx.c

@ -89,8 +89,8 @@ int at86rf2xx_init(at86rf2xx_t *dev, spi_t spi, spi_speed_t spi_speed,
void at86rf2xx_reset(at86rf2xx_t *dev)
{
#if CPUID_ID_LEN
uint8_t cpuid[CPUID_ID_LEN];
#if CPUID_LEN
uint8_t cpuid[CPUID_LEN];
eui64_t addr_long;
#endif
@ -103,16 +103,16 @@ void at86rf2xx_reset(at86rf2xx_t *dev)
dev->seq_nr = 0;
dev->options = 0;
/* set short and long address */
#if CPUID_ID_LEN
#if CPUID_LEN
cpuid_get(cpuid);
#if CPUID_ID_LEN < 8
/* in case CPUID_ID_LEN < 8, fill missing bytes with zeros */
for (int i = CPUID_ID_LEN; i < 8; i++) {
#if CPUID_LEN < 8
/* in case CPUID_LEN < 8, fill missing bytes with zeros */
for (int i = CPUID_LEN; i < 8; i++) {
cpuid[i] = 0;
}
#else
for (int i = 8; i < CPUID_ID_LEN; i++) {
for (int i = 8; i < CPUID_LEN; i++) {
cpuid[i & 0x07] ^= cpuid[i];
}
#endif

8
drivers/cc110x/cc110x-netdev2.c

@ -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;
#ifdef CPUID_ID_LEN
int n = (CPUID_ID_LEN < sizeof(eui64_t))
? CPUID_ID_LEN
#ifdef CPUID_LEN
int n = (CPUID_LEN < sizeof(eui64_t))
? CPUID_LEN
: sizeof(eui64_t);
char cpuid[CPUID_ID_LEN];
char cpuid[CPUID_LEN];
cpuid_get(cpuid);
memcpy(eui64 + 8 - n, cpuid, n);

8
drivers/cc110x/cc110x.c

@ -87,11 +87,11 @@ int cc110x_setup(cc110x_t *dev, const cc110x_params_t *params)
cc110x_set_channel(dev, CC110X_DEFAULT_CHANNEL);
/* set default node id */
#ifdef CPUID_ID_LEN
if (CPUID_ID_LEN>0) {
char cpuid[CPUID_ID_LEN];
#ifdef CPUID_LEN
if (CPUID_LEN>0) {
char cpuid[CPUID_LEN];
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

6
drivers/enc28j60/enc28j60.c

@ -29,7 +29,7 @@
#include "enc28j60.h"
#include "enc28j60_regs.h"
#if CPUID_ID_LEN
#if CPUID_LEN
#include "periph/cpuid.h"
#endif
@ -344,8 +344,8 @@ static int nd_init(netdev2_t *netdev)
/* set non-back-to-back inter packet gap -> 0x12 is default */
cmd_wcr(dev, REG_B2_MAIPGL, 2, MAIPGL_FD);
/* set default MAC address */
#if CPUID_ID_LEN
uint8_t macbuf[CPUID_ID_LEN];
#if CPUID_LEN
uint8_t macbuf[CPUID_LEN];
cpuid_get(&macbuf); /* we get the full ID but use only parts of it */
macbuf[0] |= 0x02; /* locally administered address */
macbuf[0] &= ~0x01; /* unicast address */

14
drivers/kw2xrf/kw2xrf.c

@ -392,8 +392,8 @@ int kw2xrf_init(kw2xrf_t *dev, spi_t spi, spi_speed_t spi_speed,
uint8_t reg = 0;
uint8_t tmp[2];
kw2xrf_gpio_int = int_pin;
#if CPUID_ID_LEN
uint8_t cpuid[CPUID_ID_LEN];
#if CPUID_LEN
uint8_t cpuid[CPUID_LEN];
eui64_t addr_long;
#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->option = 0;
#if CPUID_ID_LEN
#if CPUID_LEN
cpuid_get(cpuid);
#if CPUID_ID_LEN < 8
#if CPUID_LEN < 8
/* in case CPUID_ID_LEN < 8, fill missing bytes with zeros */
for (int i = CPUID_ID_LEN; i < 8; i++) {
/* in case CPUID_LEN < 8, fill missing bytes with zeros */
for (int i = CPUID_LEN; i < 8; i++) {
cpuid[i] = 0;
}
#else
for (int i = 8; i < CPUID_ID_LEN; i++) {
for (int i = 8; i < CPUID_LEN; i++) {
cpuid[i & 0x07] ^= cpuid[i];
}

14
sys/net/gnrc/application_layer/zep/gnrc_zep.c

@ -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,
uint16_t dst_port)
{
#if CPUID_ID_LEN
uint8_t cpuid[CPUID_ID_LEN];
#if CPUID_LEN
uint8_t cpuid[CPUID_LEN];
uint32_t hash1, hash2;
#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->pan = byteorder_btols(byteorder_htons(GNRC_ZEP_DEFAULT_PANID));
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 */
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));
if (CPUID_ID_LEN % 2) {
hash2 = djb2_hash(cpuid + (CPUID_ID_LEN / 2), (CPUID_ID_LEN / 2) - 1);
if (CPUID_LEN % 2) {
hash2 = djb2_hash(cpuid + (CPUID_LEN / 2), (CPUID_LEN / 2) - 1);
}
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;

Loading…
Cancel
Save