1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

drivers: s/CPUID_ID_LEN/CPUID_LEN/

This commit is contained in:
Hauke Petersen 2016-02-07 20:34:33 +01:00
parent f09a631d66
commit f3ac84d43a
6 changed files with 32 additions and 32 deletions

View File

@ -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

View File

@ -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);

View File

@ -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

View File

@ -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 */

View File

@ -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];
}

View File

@ -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;