Commit 50f9a2ea authored by Wesley W. Terpstra's avatar Wesley W. Terpstra

w1-tools: remove dependency on duplicated code

parent 4fd8e991
......@@ -4,9 +4,14 @@
*/
#include <stdlib.h>
#include <string.h>
#include <w1.h>
#ifndef EXTERNAL_W1
#include <wrc.h>
#include <shell.h>
#include <w1.h>
#else
#include <unistd.h>
#endif
#define LSB_ADDR(X) ((X) & 0xFF)
#define MSB_ADDR(X) (((X) & 0xFF00)>>8)
......@@ -138,6 +143,7 @@ int w1_write_eeprom_bus(struct w1_bus *bus,
return -1;
}
#ifndef EXTERNAL_W1
#define BLEN 32
/* A shell command, for testing write: "w1w <offset> <byte> [<byte> ...]" */
......@@ -190,3 +196,5 @@ DEFINE_WRC_COMMAND(w1r) = {
.name = "w1r",
.exec = cmd_w1_r,
};
#endif
......@@ -6,9 +6,9 @@
*
* Released according to the GNU GPL, version 2 or any later version.
*/
#include <wrc.h>
#include <string.h>
#include <w1.h>
#include <board.h>
#include <hw/sockit_owm_regs.h>
static inline uint32_t __wait_cycle(void *base)
......
......@@ -2,11 +2,17 @@
* Onewire generic interface
* Alessandro Rubini, 2013 GNU GPL2 or later
*/
#include <wrc.h>
#include <string.h>
#include <shell.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 */
void w1_write_byte(struct w1_bus *bus, int byte)
......@@ -146,6 +152,8 @@ void w1_match_rom(struct w1_dev *dev)
}
}
#ifndef EXTERNAL_W1
/* A shell command, for checking */
static int cmd_w1(const char *args[])
{
......@@ -171,3 +179,5 @@ DEFINE_WRC_COMMAND(w1) = {
.name = "w1",
.exec = cmd_w1,
};
#endif
CFLAGS = -Wall -ggdb
CFLAGS = -Wall -ggdb -DEXTERNAL_W1 -I../include
LDFLAGS = -lutil
ALL = genraminit genramvhd genrammif wrpc-uart-sw
ALL += wrpc-w1-read wrpc-w1-write
......@@ -18,14 +18,11 @@ all: $(ALL)
%: %.c
$(CC) $(CFLAGS) $< $(LDFLAGS) -o $@
wrpc-w1-read: wrpc-w1-read.c w1-host/libw1.a
wrpc-w1-read: wrpc-w1-read.c ../dev/w1.c ../dev/w1-eeprom.c ../dev/w1-hw.c
$(CC) $(CFLAGS) $^ $(LDFLAGS) -o $@
wrpc-w1-write: wrpc-w1-write.c w1-host/libw1.a
wrpc-w1-write: wrpc-w1-write.c ../dev/w1.c ../dev/w1-eeprom.c ../dev/w1-hw.c
$(CC) $(CFLAGS) $^ $(LDFLAGS) -o $@
w1-host/libw1.a:
$(MAKE) -C w1-host
clean:
rm -f $(ALL) *.o *~
$(MAKE) -C w1-host clean
......@@ -20,7 +20,7 @@
#include <sys/stat.h>
#include <sys/mman.h>
#include "w1-host/w1.h"
#include <w1.h>
#define SPEC_W1_OFFSET 0x20600 /* from "sdb" on the shell, current gateware */
......
......@@ -20,7 +20,7 @@
#include <sys/stat.h>
#include <sys/mman.h>
#include "w1-host/w1.h"
#include <w1.h>
#define SPEC_W1_OFFSET 0x20600 /* from "sdb" on the shell, current gateware */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment