Commit 398c3ddc authored by Alessandro Rubini's avatar Alessandro Rubini

tools/w1-host: adapt lm32 sources for host build

Mainly, this removes the shell commands and the inclusion of <wrc.h>
Signed-off-by: Alessandro Rubini's avatarAlessandro Rubini <rubini@gnudd.com>
parent d898611f
......@@ -4,9 +4,7 @@
*/
#include <stdlib.h>
#include <string.h>
#include <wrc.h>
#include <shell.h>
#include <w1.h>
#include "w1.h"
#define LSB_ADDR(X) ((X) & 0xFF)
#define MSB_ADDR(X) (((X) & 0xFF00)>>8)
......@@ -137,56 +135,3 @@ int w1_write_eeprom_bus(struct w1_bus *bus,
/* not found */
return -1;
}
#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: "w1w <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,
};
......@@ -6,10 +6,11 @@
*
* Released according to the GNU GPL, version 2 or any later version.
*/
#include <wrc.h>
#include <string.h>
#include <w1.h>
#include <hw/sockit_owm_regs.h>
#include "w1.h"
#include "../../include/hw/sockit_owm_regs.h"
extern void *BASE_ONEWIRE;
static inline uint32_t __wait_cycle(void *base)
{
......
......@@ -2,8 +2,7 @@
* Temperature input for DS18S20 (family 0x10)
* Alessandro Rubini, 2013 GNU GPL2 or later
*/
#include <wrc.h>
#include <w1.h>
#include "w1.h"
int32_t w1_read_temp(struct w1_dev *dev, unsigned long flags)
{
......
......@@ -2,10 +2,8 @@
* Onewire generic interface
* Alessandro Rubini, 2013 GNU GPL2 or later
*/
#include <wrc.h>
#include <string.h>
#include <shell.h>
#include <w1.h>
#include "w1.h"
static const struct w1_ops *ops = &wrpc_w1_ops; /* local shorter name */
......@@ -130,7 +128,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;
}
......@@ -145,29 +142,3 @@ void w1_match_rom(struct w1_dev *dev)
w1_write_byte(dev->bus, (int)(dev->rom >> i) );
}
}
/* 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,
};
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