mirror of
git://projects.qi-hardware.com/ben-wpan.git
synced 2024-11-22 14:04:59 +02:00
tools/lib/atusb.c: added SRAM access to atusb driver
- tools/atrf-proxy/PROTOCOL: documented new commands GETRAM and SETRAM for SRAM access - tools/atrf-proxy/atrf-proxy.c (cmd_two, cmd_more): added "setram" command - tools/atrf-proxy/atrf-proxy.c (cmd_more): added "getram" command - tools/lib/atnet.c (atnet_sram_write, atnet_sram_read): SRAM access functions - tools/lub/atnet.c (atnet_driver): added new functions to driver operations
This commit is contained in:
parent
4aff7af370
commit
565fadf258
@ -48,6 +48,14 @@ READ
|
||||
+length raw-data
|
||||
-message
|
||||
|
||||
SETRAM addr value
|
||||
+[comment]
|
||||
-message
|
||||
|
||||
GETRAM addr
|
||||
+value
|
||||
-message
|
||||
|
||||
POLL
|
||||
+0|1
|
||||
-message
|
||||
|
@ -103,6 +103,19 @@ static int cmd_two(struct atrf_dsc *dsc, struct netio *netio, const char *cmd)
|
||||
return netio_printf(netio, "-I/O error\n");
|
||||
return netio_printf(netio, "+\n");
|
||||
}
|
||||
if (!strcasecmp(cmd, "setram")) {
|
||||
int val;
|
||||
|
||||
val = get_num(netio, 1, &ret);
|
||||
if (val < 0)
|
||||
return ret;
|
||||
if (val > 255)
|
||||
return netio_printf(netio, "-bad argument\n");
|
||||
atrf_sram_write(dsc, n, val);
|
||||
if (atrf_error(dsc))
|
||||
return netio_printf(netio, "-I/O error\n");
|
||||
return netio_printf(netio, "+\n");
|
||||
}
|
||||
abort();
|
||||
}
|
||||
|
||||
@ -113,6 +126,8 @@ static int cmd_more(struct atrf_dsc *dsc, struct netio *netio, const char *cmd)
|
||||
|
||||
if (!strcasecmp(cmd, "set"))
|
||||
return cmd_two(dsc, netio, cmd);
|
||||
if (!strcasecmp(cmd, "setram"))
|
||||
return cmd_two(dsc, netio, cmd);
|
||||
if (!strcasecmp(cmd, "write"))
|
||||
return cmd_two(dsc, netio, cmd);
|
||||
|
||||
@ -144,6 +159,16 @@ static int cmd_more(struct atrf_dsc *dsc, struct netio *netio, const char *cmd)
|
||||
return netio_printf(netio, "-I/O error\n");
|
||||
return netio_printf(netio, "+0x%02x\n", res);
|
||||
}
|
||||
if (!strcasecmp(cmd, "getram")) {
|
||||
uint8_t res;
|
||||
|
||||
if (n > 255)
|
||||
return netio_printf(netio, "-bad argument\n");
|
||||
res = atrf_sram_read(dsc, n);
|
||||
if (atrf_error(dsc))
|
||||
return netio_printf(netio, "-I/O error\n");
|
||||
return netio_printf(netio, "+0x%02x\n", res);
|
||||
}
|
||||
return netio_printf(netio, "-unrecognized command\n");
|
||||
}
|
||||
|
||||
|
@ -402,6 +402,42 @@ fail:
|
||||
}
|
||||
|
||||
|
||||
/* ----- SRAM access ------------------------------------------------------- */
|
||||
|
||||
|
||||
static void atnet_sram_write(void *handle, uint8_t addr, uint8_t value)
|
||||
{
|
||||
struct atnet_dsc *dsc = handle;
|
||||
|
||||
if (dsc->error)
|
||||
return;
|
||||
if (dialog(dsc, "SETRAM 0x%02x 0x%02x", addr, value) < 0)
|
||||
dsc->error = 1;
|
||||
}
|
||||
|
||||
|
||||
static uint8_t atnet_sram_read(void *handle, uint8_t addr)
|
||||
{
|
||||
struct atnet_dsc *dsc = handle;
|
||||
unsigned long value;
|
||||
char *end;
|
||||
|
||||
if (dsc->error)
|
||||
return;
|
||||
if (dialog(dsc, "GETRAM 0x%02x", addr) < 0) {
|
||||
dsc->error = 1;
|
||||
return 0;
|
||||
}
|
||||
value = strtoul(dsc->reply+1, &end, 0);
|
||||
if (*end || value > 255) {
|
||||
fprintf(stderr, "invalid response \"%s\"\n", dsc->reply+1);
|
||||
dsc->error = 1;
|
||||
return 0;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
/* ----- RF interrupt ------------------------------------------------------ */
|
||||
|
||||
|
||||
@ -457,5 +493,7 @@ struct atrf_driver atnet_driver = {
|
||||
.reg_read = atnet_reg_read,
|
||||
.buf_write = atnet_buf_write,
|
||||
.buf_read = atnet_buf_read,
|
||||
.sram_write = atnet_sram_write,
|
||||
.sram_read = atnet_sram_read,
|
||||
.interrupt = atnet_interrupt,
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user