Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
S
Software for White Rabbit PTP Core
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
32
Issues
32
List
Board
Labels
Milestones
Merge Requests
7
Merge Requests
7
CI / CD
CI / CD
Pipelines
Schedules
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
Software for White Rabbit PTP Core
Commits
0a43d3cb
Commit
0a43d3cb
authored
Nov 04, 2013
by
Wesley W. Terpstra
Committed by
Alessandro Rubini
Nov 14, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
w1: remove need for an ifdef
parent
1f4953c2
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
92 additions
and
103 deletions
+92
-103
dev.mk
dev/dev.mk
+1
-1
w1-eeprom.c
dev/w1-eeprom.c
+1
-63
w1-shell.c
dev/w1-shell.c
+87
-0
w1.c
dev/w1.c
+0
-38
unistd.h
include/std/unistd.h
+2
-0
Makefile
tools/Makefile
+1
-1
No files found.
dev/dev.mk
View file @
0a43d3cb
...
...
@@ -12,7 +12,7 @@ obj-y += \
obj-$(CONFIG_LEGACY_EEPROM) += dev/eeprom.o
obj-$(CONFIG_SDB_EEPROM) += dev/sdb-eeprom.o
obj-$(CONFIG_W1) += dev/w1.o dev/w1-hw.o
obj-$(CONFIG_W1) += dev/w1.o dev/w1-hw.o
dev/w1-shell.o
obj-$(CONFIG_W1) += dev/w1-temp.o dev/w1-eeprom.o
obj-$(CONFIG_UART) += dev/uart.o
obj-$(CONFIG_UART_SW) += dev/uart-sw.o
dev/w1-eeprom.c
View file @
0a43d3cb
...
...
@@ -4,14 +4,8 @@
*/
#include <stdlib.h>
#include <string.h>
#include <w1.h>
#ifndef EXTERNAL_W1
#include <wrc.h>
#include <shell.h>
#else
#include <unistd.h>
#
endif
#
include <w1.h>
#define LSB_ADDR(X) ((X) & 0xFF)
#define MSB_ADDR(X) (((X) & 0xFF00)>>8)
...
...
@@ -142,59 +136,3 @@ int w1_write_eeprom_bus(struct w1_bus *bus,
/* not found */
return
-
1
;
}
#ifndef EXTERNAL_W1
#define BLEN 32
/* A shell command, for testing write: "w1w <offset> <byte> [<byte> ...]" */
static
int
cmd_w1_w
(
const
char
*
args
[])
{
int
offset
,
i
,
blen
;
unsigned
char
buf
[
BLEN
];
if
(
!
args
[
0
]
||
!
args
[
1
])
return
-
1
;
offset
=
atoi
(
args
[
0
]);
for
(
i
=
1
,
blen
=
0
;
args
[
i
]
&&
blen
<
BLEN
;
i
++
,
blen
++
)
{
buf
[
blen
]
=
atoi
(
args
[
i
]);
pp_printf
(
"offset %4i (0x%03x): %3i (0x%02x)
\n
"
,
offset
+
blen
,
offset
+
blen
,
buf
[
blen
],
buf
[
blen
]);
}
i
=
w1_write_eeprom_bus
(
&
wrpc_w1_bus
,
offset
,
buf
,
blen
);
pp_printf
(
"write(0x%x, %i): result = %i
\n
"
,
offset
,
blen
,
i
);
return
i
==
blen
?
0
:
-
1
;
}
DEFINE_WRC_COMMAND
(
w1w
)
=
{
.
name
=
"w1w"
,
.
exec
=
cmd_w1_w
,
};
/* A shell command, for testing read: "w1r <offset> <len> */
static
int
cmd_w1_r
(
const
char
*
args
[])
{
int
offset
,
i
,
blen
;
unsigned
char
buf
[
BLEN
];
if
(
!
args
[
0
]
||
!
args
[
1
])
return
-
1
;
offset
=
atoi
(
args
[
0
]);
blen
=
atoi
(
args
[
1
]);
if
(
blen
>
BLEN
)
blen
=
BLEN
;
i
=
w1_read_eeprom_bus
(
&
wrpc_w1_bus
,
offset
,
buf
,
blen
);
pp_printf
(
"read(0x%x, %i): result = %i
\n
"
,
offset
,
blen
,
i
);
if
(
i
<=
0
||
i
>
blen
)
return
-
1
;
for
(
blen
=
0
;
blen
<
i
;
blen
++
)
{
pp_printf
(
"offset %4i (0x%03x): %3i (0x%02x)
\n
"
,
offset
+
blen
,
offset
+
blen
,
buf
[
blen
],
buf
[
blen
]);
}
return
i
==
blen
?
0
:
-
1
;
}
DEFINE_WRC_COMMAND
(
w1r
)
=
{
.
name
=
"w1r"
,
.
exec
=
cmd_w1_r
,
};
#endif
dev/w1-shell.c
0 → 100644
View file @
0a43d3cb
/*
* Onewire generic interface
* Alessandro Rubini, 2013 GNU GPL2 or later
*/
#include <wrc.h>
#include <shell.h>
#include <w1.h>
#define BLEN 32
/* A shell command, for testing write: "w1w <offset> <byte> [<byte> ...]" */
static
int
cmd_w1_w
(
const
char
*
args
[])
{
int
offset
,
i
,
blen
;
unsigned
char
buf
[
BLEN
];
if
(
!
args
[
0
]
||
!
args
[
1
])
return
-
1
;
offset
=
atoi
(
args
[
0
]);
for
(
i
=
1
,
blen
=
0
;
args
[
i
]
&&
blen
<
BLEN
;
i
++
,
blen
++
)
{
buf
[
blen
]
=
atoi
(
args
[
i
]);
pp_printf
(
"offset %4i (0x%03x): %3i (0x%02x)
\n
"
,
offset
+
blen
,
offset
+
blen
,
buf
[
blen
],
buf
[
blen
]);
}
i
=
w1_write_eeprom_bus
(
&
wrpc_w1_bus
,
offset
,
buf
,
blen
);
pp_printf
(
"write(0x%x, %i): result = %i
\n
"
,
offset
,
blen
,
i
);
return
i
==
blen
?
0
:
-
1
;
}
DEFINE_WRC_COMMAND
(
w1w
)
=
{
.
name
=
"w1w"
,
.
exec
=
cmd_w1_w
,
};
/* A shell command, for testing read: "w1r <offset> <len> */
static
int
cmd_w1_r
(
const
char
*
args
[])
{
int
offset
,
i
,
blen
;
unsigned
char
buf
[
BLEN
];
if
(
!
args
[
0
]
||
!
args
[
1
])
return
-
1
;
offset
=
atoi
(
args
[
0
]);
blen
=
atoi
(
args
[
1
]);
if
(
blen
>
BLEN
)
blen
=
BLEN
;
i
=
w1_read_eeprom_bus
(
&
wrpc_w1_bus
,
offset
,
buf
,
blen
);
pp_printf
(
"read(0x%x, %i): result = %i
\n
"
,
offset
,
blen
,
i
);
if
(
i
<=
0
||
i
>
blen
)
return
-
1
;
for
(
blen
=
0
;
blen
<
i
;
blen
++
)
{
pp_printf
(
"offset %4i (0x%03x): %3i (0x%02x)
\n
"
,
offset
+
blen
,
offset
+
blen
,
buf
[
blen
],
buf
[
blen
]);
}
return
i
==
blen
?
0
:
-
1
;
}
DEFINE_WRC_COMMAND
(
w1r
)
=
{
.
name
=
"w1r"
,
.
exec
=
cmd_w1_r
,
};
/* A shell command, for checking */
static
int
cmd_w1
(
const
char
*
args
[])
{
int
i
;
struct
w1_dev
*
d
;
int32_t
temp
;
w1_scan_bus
(
&
wrpc_w1_bus
);
for
(
i
=
0
;
i
<
W1_MAX_DEVICES
;
i
++
)
{
d
=
wrpc_w1_bus
.
devs
+
i
;
if
(
d
->
rom
)
{
pp_printf
(
"device %i: %08x%08x
\n
"
,
i
,
(
int
)(
d
->
rom
>>
32
),
(
int
)
d
->
rom
);
temp
=
w1_read_temp
(
d
,
0
);
pp_printf
(
"temp: %d.%04d
\n
"
,
temp
>>
16
,
(
int
)((
temp
&
0xffff
)
*
10
*
1000
>>
16
));
}
}
return
0
;
}
DEFINE_WRC_COMMAND
(
w1
)
=
{
.
name
=
"w1"
,
.
exec
=
cmd_w1
,
};
dev/w1.c
View file @
0a43d3cb
...
...
@@ -4,14 +4,7 @@
*/
#include <string.h>
#include <w1.h>
#ifndef EXTERNAL_W1
#include <wrc.h>
#include <shell.h>
#else
#include <unistd.h>
#define pp_printf(...) do {} while (0)
#endif
static
const
struct
w1_ops
*
ops
=
&
wrpc_w1_ops
;
/* local shorter name */
...
...
@@ -136,7 +129,6 @@ int w1_scan_bus(struct w1_bus *bus)
/* error on this one */
return
i
;
}
pp_printf
(
"W1: %08x%08x
\n
"
,
(
int
)(
d
->
rom
>>
32
),
(
int
)
d
->
rom
);
}
return
i
;
}
...
...
@@ -151,33 +143,3 @@ void w1_match_rom(struct w1_dev *dev)
w1_write_byte
(
dev
->
bus
,
(
int
)(
dev
->
rom
>>
i
)
);
}
}
#ifndef EXTERNAL_W1
/* A shell command, for checking */
static
int
cmd_w1
(
const
char
*
args
[])
{
int
i
;
struct
w1_dev
*
d
;
int32_t
temp
;
w1_scan_bus
(
&
wrpc_w1_bus
);
for
(
i
=
0
;
i
<
W1_MAX_DEVICES
;
i
++
)
{
d
=
wrpc_w1_bus
.
devs
+
i
;
if
(
d
->
rom
)
{
pp_printf
(
"device %i: %08x%08x
\n
"
,
i
,
(
int
)(
d
->
rom
>>
32
),
(
int
)
d
->
rom
);
temp
=
w1_read_temp
(
d
,
0
);
pp_printf
(
"temp: %d.%04d
\n
"
,
temp
>>
16
,
(
int
)((
temp
&
0xffff
)
*
10
*
1000
>>
16
));
}
}
return
0
;
}
DEFINE_WRC_COMMAND
(
w1
)
=
{
.
name
=
"w1"
,
.
exec
=
cmd_w1
,
};
#endif
include/std/unistd.h
0 → 100644
View file @
0a43d3cb
/* usleep */
#include <syscon.h>
tools/Makefile
View file @
0a43d3cb
EB
?=
no
SDBFS
?=
no
CFLAGS
=
-Wall
-ggdb
-
DEXTERNAL_W1
-
I
../include
CFLAGS
=
-Wall
-ggdb
-I
../include
LDFLAGS
=
-lutil
ALL
=
genraminit genramvhd genrammif wrpc-uart-sw
ALL
+=
wrpc-w1-read wrpc-w1-write
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment