mirror of
https://github.com/oliverschmidt/contiki.git
synced 2024-08-14 09:28:59 +00:00
Code style fix
This commit is contained in:
parent
9ec2b64008
commit
6815e2a53f
@ -28,7 +28,7 @@
|
|||||||
*
|
*
|
||||||
* This file is part of the Contiki operating system.
|
* This file is part of the Contiki operating system.
|
||||||
*
|
*
|
||||||
* @(#)$Id: ds2411.c,v 1.3 2009/06/23 13:12:37 joxe Exp $
|
* @(#)$Id: ds2411.c,v 1.4 2009/12/05 11:26:20 adamdunkels Exp $
|
||||||
*/
|
*/
|
||||||
/*
|
/*
|
||||||
* Device driver for the Dallas Semiconductor DS2411 chip. Heavily
|
* Device driver for the Dallas Semiconductor DS2411 chip. Heavily
|
||||||
@ -115,7 +115,7 @@ unsigned char ds2411_id[8];
|
|||||||
#define tH 480
|
#define tH 480
|
||||||
#define tI 70
|
#define tI 70
|
||||||
#define tJ 410
|
#define tJ 410
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
static int
|
static int
|
||||||
owreset(void)
|
owreset(void)
|
||||||
{
|
{
|
||||||
@ -128,7 +128,7 @@ owreset(void)
|
|||||||
udelay(tJ);
|
udelay(tJ);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
static void
|
static void
|
||||||
owwriteb(unsigned byte)
|
owwriteb(unsigned byte)
|
||||||
{
|
{
|
||||||
@ -145,13 +145,14 @@ owwriteb(unsigned byte)
|
|||||||
OUTP_1(); /* Releases the bus */
|
OUTP_1(); /* Releases the bus */
|
||||||
udelay(tD);
|
udelay(tD);
|
||||||
}
|
}
|
||||||
if (i == 0)
|
if(i == 0) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
i--;
|
i--;
|
||||||
byte >>= 1;
|
byte >>= 1;
|
||||||
} while(1);
|
} while(1);
|
||||||
}
|
}
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
static unsigned
|
static unsigned
|
||||||
owreadb(void)
|
owreadb(void)
|
||||||
{
|
{
|
||||||
@ -162,31 +163,34 @@ owreadb(void)
|
|||||||
udelay_tA();
|
udelay_tA();
|
||||||
OUTP_1(); /* Releases the bus */
|
OUTP_1(); /* Releases the bus */
|
||||||
udelay(tE);
|
udelay(tE);
|
||||||
if (INP())
|
if(INP()) {
|
||||||
result |= 0x80; /* LSbit first */
|
result |= 0x80; /* LSbit first */
|
||||||
|
}
|
||||||
udelay(tF);
|
udelay(tF);
|
||||||
if (i == 0)
|
if(i == 0) {
|
||||||
return result;
|
return result;
|
||||||
|
}
|
||||||
i--;
|
i--;
|
||||||
result >>= 1;
|
result >>= 1;
|
||||||
} while(1);
|
} while(1);
|
||||||
}
|
}
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
/* Polynomial ^8 + ^5 + ^4 + 1 */
|
/* Polynomial ^8 + ^5 + ^4 + 1 */
|
||||||
static unsigned
|
static unsigned
|
||||||
crc8_add(unsigned acc, unsigned byte)
|
crc8_add(unsigned acc, unsigned byte)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
acc ^= byte;
|
acc ^= byte;
|
||||||
for (i = 0; i < 8; i++)
|
for(i = 0; i < 8; i++) {
|
||||||
if (acc & 1)
|
if(acc & 1) {
|
||||||
acc = (acc >> 1) ^ 0x8c;
|
acc = (acc >> 1) ^ 0x8c;
|
||||||
else
|
} else {
|
||||||
acc >>= 1;
|
acc >>= 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
return acc;
|
return acc;
|
||||||
}
|
}
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
int
|
int
|
||||||
ds2411_init()
|
ds2411_init()
|
||||||
{
|
{
|
||||||
@ -203,17 +207,20 @@ ds2411_init()
|
|||||||
owwriteb(0x33); /* Read ROM command. */
|
owwriteb(0x33); /* Read ROM command. */
|
||||||
family = owreadb();
|
family = owreadb();
|
||||||
/* We receive 6 bytes in the reverse order, LSbyte first. */
|
/* We receive 6 bytes in the reverse order, LSbyte first. */
|
||||||
for (i = 7; i >= 2; i--)
|
for(i = 7; i >= 2; i--) {
|
||||||
ds2411_id[i] = owreadb();
|
ds2411_id[i] = owreadb();
|
||||||
|
}
|
||||||
crc = owreadb();
|
crc = owreadb();
|
||||||
splx(s);
|
splx(s);
|
||||||
|
|
||||||
/* Verify family and that CRC match. */
|
/* Verify family and that CRC match. */
|
||||||
if (family != 0x01)
|
if(family != 0x01) {
|
||||||
goto fail;
|
goto fail;
|
||||||
|
}
|
||||||
acc = crc8_add(0x0, family);
|
acc = crc8_add(0x0, family);
|
||||||
for (i = 7; i >= 2; i--)
|
for(i = 7; i >= 2; i--) {
|
||||||
acc = crc8_add(acc, ds2411_id[i]);
|
acc = crc8_add(acc, ds2411_id[i]);
|
||||||
|
}
|
||||||
if(acc == crc) {
|
if(acc == crc) {
|
||||||
#ifdef CONTIKI_TARGET_SKY
|
#ifdef CONTIKI_TARGET_SKY
|
||||||
/* 00:12:75 Moteiv # Moteiv Corporation */
|
/* 00:12:75 Moteiv # Moteiv Corporation */
|
||||||
@ -229,3 +236,4 @@ ds2411_init()
|
|||||||
memset(ds2411_id, 0x0, sizeof(ds2411_id));
|
memset(ds2411_id, 0x0, sizeof(ds2411_id));
|
||||||
return 0; /* Fail! */
|
return 0; /* Fail! */
|
||||||
}
|
}
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
Loading…
Reference in New Issue
Block a user