1
0
mirror of git://projects.qi-hardware.com/ben-wpan.git synced 2024-11-23 05:57:31 +02:00

The Great ATSPI Renaming, part 2: rename ATSPI_* identifiers to ATUSB_*

- atusb/fw/include/atusb/ep0.h, atusb/fw/atusb/ep0.c: rename all ATSPI_*
  identifiers (EP0 commands, protocol revision, etc.) to ATUSB_*
- tools/lib/atusb.c, tools/atspi-id/atspi-id.c: track identifier change
This commit is contained in:
Werner Almesberger 2010-11-11 08:41:25 -03:00
parent 7e71f98007
commit 96b6a50b3a
4 changed files with 78 additions and 78 deletions

View File

@ -58,7 +58,7 @@ extern void test_mode(void);
} while (0) } while (0)
static const uint8_t id[] = { EP0ATSPI_MAJOR, EP0ATSPI_MINOR, HW_TYPE }; static const uint8_t id[] = { EP0ATUSB_MAJOR, EP0ATUSB_MINOR, HW_TYPE };
static __xdata uint8_t buf[MAX_PSDU+3]; /* command, PHDR, and LQI */ static __xdata uint8_t buf[MAX_PSDU+3]; /* command, PHDR, and LQI */
static uint8_t size; static uint8_t size;
@ -110,14 +110,14 @@ static __bit my_setup(struct setup_request *setup) __reentrant
uint8_t i; uint8_t i;
switch (setup->bmRequestType | setup->bRequest << 8) { switch (setup->bmRequestType | setup->bRequest << 8) {
case ATSPI_FROM_DEV(ATSPI_ID): case ATUSB_FROM_DEV(ATUSB_ID):
debug("ATSPI_ID\n"); debug("ATUSB_ID\n");
if (setup->wLength > 3) if (setup->wLength > 3)
return 0; return 0;
usb_send(&ep0, id, setup->wLength, NULL, NULL); usb_send(&ep0, id, setup->wLength, NULL, NULL);
return 1; return 1;
case ATSPI_FROM_DEV(ATSPI_BUILD): case ATUSB_FROM_DEV(ATUSB_BUILD):
debug("ATSPI_BUILD\n"); debug("ATUSB_BUILD\n");
tmp = build_number; tmp = build_number;
for (i = BUILD_OFFSET-2; tmp; i--) { for (i = BUILD_OFFSET-2; tmp; i--) {
buf[i] = (tmp % 10)+'0'; buf[i] = (tmp % 10)+'0';
@ -134,38 +134,38 @@ static __bit my_setup(struct setup_request *setup) __reentrant
usb_send(&ep0, buf+i, size, NULL, NULL); usb_send(&ep0, buf+i, size, NULL, NULL);
return 1; return 1;
case ATSPI_TO_DEV(ATSPI_RESET): case ATUSB_TO_DEV(ATUSB_RESET):
debug("ATSPI_RESET\n"); debug("ATUSB_RESET\n");
RSTSRC = SWRSF; RSTSRC = SWRSF;
while (1); while (1);
case ATSPI_TO_DEV(ATSPI_RF_RESET): case ATUSB_TO_DEV(ATUSB_RF_RESET):
debug("ATSPI_RF_RESET\n"); debug("ATUSB_RF_RESET\n");
reset_rf(); reset_rf();
return 1; return 1;
case ATSPI_FROM_DEV(ATSPI_POLL_INT): case ATUSB_FROM_DEV(ATUSB_POLL_INT):
debug("ATSPI_POLL_INT\n"); debug("ATUSB_POLL_INT\n");
if (setup->wLength < 1) if (setup->wLength < 1)
return 0; return 0;
*buf = IRQ_RF; *buf = IRQ_RF;
usb_send(&ep0, buf, 1, NULL, NULL); usb_send(&ep0, buf, 1, NULL, NULL);
return 1; return 1;
case ATSPI_TO_DEV(ATSPI_TEST): case ATUSB_TO_DEV(ATUSB_TEST):
debug("ATSPI_TEST\n"); debug("ATUSB_TEST\n");
test_mode(); test_mode();
return 1; return 1;
case ATSPI_TO_DEV(ATSPI_REG_WRITE): case ATUSB_TO_DEV(ATUSB_REG_WRITE):
debug("ATSPI_REG_WRITE\n"); debug("ATUSB_REG_WRITE\n");
nSS = 0; nSS = 0;
spi_send(AT86RF230_REG_WRITE | setup->wIndex); spi_send(AT86RF230_REG_WRITE | setup->wIndex);
spi_send(setup->wValue); spi_send(setup->wValue);
nSS = 1; nSS = 1;
return 1; return 1;
case ATSPI_FROM_DEV(ATSPI_REG_READ): case ATUSB_FROM_DEV(ATUSB_REG_READ):
debug("ATSPI_REG_READ\n"); debug("ATUSB_REG_READ\n");
nSS = 0; nSS = 0;
spi_send(AT86RF230_REG_READ | setup->wIndex); spi_send(AT86RF230_REG_READ | setup->wIndex);
*buf = spi_recv(); *buf = spi_recv();
@ -173,8 +173,8 @@ static __bit my_setup(struct setup_request *setup) __reentrant
usb_send(&ep0, buf, 1, NULL, NULL); usb_send(&ep0, buf, 1, NULL, NULL);
return 1; return 1;
case ATSPI_TO_DEV(ATSPI_BUF_WRITE): case ATUSB_TO_DEV(ATUSB_BUF_WRITE):
debug("ATSPI_BUF_WRITE\n"); debug("ATUSB_BUF_WRITE\n");
if (setup->wLength < 1) if (setup->wLength < 1)
return 0; return 0;
if (setup->wLength > MAX_PSDU) if (setup->wLength > MAX_PSDU)
@ -184,8 +184,8 @@ static __bit my_setup(struct setup_request *setup) __reentrant
size = setup->wLength+2; size = setup->wLength+2;
usb_recv(&ep0, buf+2, setup->wLength, do_buf_write, NULL); usb_recv(&ep0, buf+2, setup->wLength, do_buf_write, NULL);
return 1; return 1;
case ATSPI_FROM_DEV(ATSPI_BUF_READ): case ATUSB_FROM_DEV(ATUSB_BUF_READ):
debug("ATSPI_BUF_READ\n"); debug("ATUSB_BUF_READ\n");
if (setup->wLength < 2) /* PHR+LQI */ if (setup->wLength < 2) /* PHR+LQI */
return 0; return 0;
if (setup->wLength > MAX_PSDU+2) /* PHR+PSDU+LQI */ if (setup->wLength > MAX_PSDU+2) /* PHR+PSDU+LQI */
@ -201,8 +201,8 @@ static __bit my_setup(struct setup_request *setup) __reentrant
usb_send(&ep0, buf, size+1, NULL, NULL); usb_send(&ep0, buf, size+1, NULL, NULL);
return 1; return 1;
case ATSPI_TO_DEV(ATSPI_SRAM_WRITE): case ATUSB_TO_DEV(ATUSB_SRAM_WRITE):
debug("ATSPI_SRAM_WRITE\n"); debug("ATUSB_SRAM_WRITE\n");
if (setup->wIndex > SRAM_SIZE) if (setup->wIndex > SRAM_SIZE)
return 0; return 0;
if (setup->wIndex+setup->wLength > SRAM_SIZE) if (setup->wIndex+setup->wLength > SRAM_SIZE)
@ -212,8 +212,8 @@ static __bit my_setup(struct setup_request *setup) __reentrant
size = setup->wLength+2; size = setup->wLength+2;
usb_recv(&ep0, buf+2, setup->wLength, do_buf_write, NULL); usb_recv(&ep0, buf+2, setup->wLength, do_buf_write, NULL);
return 1; return 1;
case ATSPI_TO_DEV(ATSPI_SRAM_READ): case ATUSB_TO_DEV(ATUSB_SRAM_READ):
debug("ATSPI_SRAM_READ\n"); debug("ATUSB_SRAM_READ\n");
if (setup->wIndex > SRAM_SIZE) if (setup->wIndex > SRAM_SIZE)
return 0; return 0;
if (setup->wIndex+setup->wLength > SRAM_SIZE) if (setup->wIndex+setup->wLength > SRAM_SIZE)

View File

@ -17,31 +17,31 @@
/* /*
* Direction bRequest wValue wIndex wLength * Direction bRequest wValue wIndex wLength
* *
* ->host ATSPI_ID - - 3 * ->host ATUSB_ID - - 3
* ->host ATSPI_BUILD - - #bytes * ->host ATUSB_BUILD - - #bytes
* host-> ATSPI_RESET - - 0 * host-> ATUSB_RESET - - 0
* *
* host-> ATSPI_RF_RESET - - 0 * host-> ATUSB_RF_RESET - - 0
* ->host ATSPI_POLL_INT - - 1 * ->host ATUSB_POLL_INT - - 1
* host-> ATSPI_TEST - - 0 * host-> ATUSB_TEST - - 0
* *
* host-> ATSPI_REG_WRITE value addr 0 * host-> ATUSB_REG_WRITE value addr 0
* ->host ATSPI_REG_READ - addr 1 * ->host ATUSB_REG_READ - addr 1
* host-> ATSPI_BUF_WRITE - - #bytes * host-> ATUSB_BUF_WRITE - - #bytes
* ->host ATSPI_BUF_READ - - #bytes * ->host ATUSB_BUF_READ - - #bytes
* host-> ATSPI_SRAM_WRITE - addr #bytes * host-> ATUSB_SRAM_WRITE - addr #bytes
* ->host ATSPI_SRAM_READ - addr #bytes * ->host ATUSB_SRAM_READ - addr #bytes
*/ */
/* /*
* EP0 protocol: * EP0 protocol:
* *
* 0.0 initial release * 0.0 initial release
* 0.1 addition of ATSPI_TEST * 0.1 addition of ATUSB_TEST
*/ */
#define EP0ATSPI_MAJOR 0 /* EP0 protocol, major revision */ #define EP0ATUSB_MAJOR 0 /* EP0 protocol, major revision */
#define EP0ATSPI_MINOR 1 /* EP0 protocol, minor revision */ #define EP0ATUSB_MINOR 1 /* EP0 protocol, minor revision */
#define HW_TYPE_100813 0 /* 100813 */ #define HW_TYPE_100813 0 /* 100813 */
@ -57,23 +57,23 @@
*/ */
#define ATSPI_TO_DEV(req) (0x40 | (req) << 8) #define ATUSB_TO_DEV(req) (0x40 | (req) << 8)
#define ATSPI_FROM_DEV(req) (0xc0 | (req) << 8) #define ATUSB_FROM_DEV(req) (0xc0 | (req) << 8)
enum atspi_requests { enum atspi_requests {
ATSPI_ID = 0x00, ATUSB_ID = 0x00,
ATSPI_BUILD, ATUSB_BUILD,
ATSPI_RESET, ATUSB_RESET,
ATSPI_RF_RESET = 0x10, ATUSB_RF_RESET = 0x10,
ATSPI_POLL_INT, ATUSB_POLL_INT,
ATSPI_TEST, ATUSB_TEST,
ATSPI_REG_WRITE = 0x20, ATUSB_REG_WRITE = 0x20,
ATSPI_REG_READ, ATUSB_REG_READ,
ATSPI_BUF_WRITE, ATUSB_BUF_WRITE,
ATSPI_BUF_READ, ATUSB_BUF_READ,
ATSPI_SRAM_WRITE, ATUSB_SRAM_WRITE,
ATSPI_SRAM_READ, ATUSB_SRAM_READ,
}; };

View File

@ -25,7 +25,7 @@
#ifdef HAVE_USB #ifdef HAVE_USB
#define FROM_DEV ATSPI_FROM_DEV(0) #define FROM_DEV ATUSB_FROM_DEV(0)
#define BUF_SIZE 256 #define BUF_SIZE 256
@ -34,9 +34,9 @@ static int get_id(usb_dev_handle *dev, void *data, int size)
{ {
int res; int res;
res = usb_control_msg(dev, FROM_DEV, ATSPI_ID, 0, 0, data, size, 1000); res = usb_control_msg(dev, FROM_DEV, ATUSB_ID, 0, 0, data, size, 1000);
if (res < 0) if (res < 0)
fprintf(stderr, "ATSPI_ID: %s\n", usb_strerror()); fprintf(stderr, "ATUSB_ID: %s\n", usb_strerror());
return res; return res;
} }
@ -63,10 +63,10 @@ static int get_build(usb_dev_handle *dev, char *buf, size_t size)
{ {
int res; int res;
res = usb_control_msg(dev, FROM_DEV, ATSPI_BUILD, 0, 0, buf, size, res = usb_control_msg(dev, FROM_DEV, ATUSB_BUILD, 0, 0, buf, size,
1000); 1000);
if (res < 0) if (res < 0)
fprintf(stderr, "ATSPI_BUILD: %s\n", usb_strerror()); fprintf(stderr, "ATUSB_BUILD: %s\n", usb_strerror());
return res; return res;
} }

View File

@ -1,5 +1,5 @@
/* /*
* lib/atusb.c - ATSPI access functions library (USB version) * lib/atusb.c - ATUSB access functions library (USB version)
* *
* Written 2010 by Werner Almesberger * Written 2010 by Werner Almesberger
* Copyright 2010 Werner Almesberger * Copyright 2010 Werner Almesberger
@ -21,8 +21,8 @@
#include "driver.h" #include "driver.h"
#define FROM_DEV ATSPI_FROM_DEV(0) #define FROM_DEV ATUSB_FROM_DEV(0)
#define TO_DEV ATSPI_TO_DEV(0) #define TO_DEV ATUSB_TO_DEV(0)
/* ----- error handling ---------------------------------------------------- */ /* ----- error handling ---------------------------------------------------- */
@ -83,9 +83,9 @@ static void atusb_reset(void *dsc)
return; return;
res = res =
usb_control_msg(dev, TO_DEV, ATSPI_RESET, 0, 0, NULL, 0, 1000); usb_control_msg(dev, TO_DEV, ATUSB_RESET, 0, 0, NULL, 0, 1000);
if (res < 0) { if (res < 0) {
fprintf(stderr, "ATSPI_RESET: %d\n", res); fprintf(stderr, "ATUSB_RESET: %d\n", res);
error = 1; error = 1;
} }
} }
@ -100,9 +100,9 @@ static void atusb_reset_rf(void *dsc)
return; return;
res = res =
usb_control_msg(dev, TO_DEV, ATSPI_RF_RESET, 0, 0, NULL, 0, 1000); usb_control_msg(dev, TO_DEV, ATUSB_RF_RESET, 0, 0, NULL, 0, 1000);
if (res < 0) { if (res < 0) {
fprintf(stderr, "ATSPI_RF_RESET: %d\n", res); fprintf(stderr, "ATUSB_RF_RESET: %d\n", res);
error = 1; error = 1;
} }
} }
@ -117,9 +117,9 @@ static void atusb_test_mode(void *dsc)
return; return;
res = res =
usb_control_msg(dev, TO_DEV, ATSPI_TEST, 0, 0, NULL, 0, 1000); usb_control_msg(dev, TO_DEV, ATUSB_TEST, 0, 0, NULL, 0, 1000);
if (res < 0) { if (res < 0) {
fprintf(stderr, "ATSPI_TEST: %d\n", res); fprintf(stderr, "ATUSB_TEST: %d\n", res);
error = 1; error = 1;
} }
} }
@ -136,10 +136,10 @@ static void atusb_reg_write(void *dsc, uint8_t reg, uint8_t value)
if (error) if (error)
return; return;
res = usb_control_msg(dev, TO_DEV, ATSPI_REG_WRITE, value, reg, res = usb_control_msg(dev, TO_DEV, ATUSB_REG_WRITE, value, reg,
NULL, 0, 1000); NULL, 0, 1000);
if (res < 0) { if (res < 0) {
fprintf(stderr, "ATSPI_REG_WRITE: %d\n", res); fprintf(stderr, "ATUSB_REG_WRITE: %d\n", res);
error = 1; error = 1;
} }
} }
@ -154,10 +154,10 @@ static uint8_t atusb_reg_read(void *dsc, uint8_t reg)
if (error) if (error)
return 0; return 0;
res = usb_control_msg(dev, FROM_DEV, ATSPI_REG_READ, 0, reg, res = usb_control_msg(dev, FROM_DEV, ATUSB_REG_READ, 0, reg,
(void *) &value, 1, 1000); (void *) &value, 1, 1000);
if (res < 0) { if (res < 0) {
fprintf(stderr, "ATSPI_REG_READ: %d\n", res); fprintf(stderr, "ATUSB_REG_READ: %d\n", res);
error = 1; error = 1;
} }
return value; return value;
@ -175,10 +175,10 @@ static void atusb_buf_write(void *dsc, const void *buf, int size)
if (error) if (error)
return; return;
res = usb_control_msg(dev, TO_DEV, ATSPI_BUF_WRITE, 0, 0, res = usb_control_msg(dev, TO_DEV, ATUSB_BUF_WRITE, 0, 0,
(void *) buf, size, 1000); (void *) buf, size, 1000);
if (res < 0) { if (res < 0) {
fprintf(stderr, "ATSPI_BUF_WRITE: %d\n", res); fprintf(stderr, "ATUSB_BUF_WRITE: %d\n", res);
error = 1; error = 1;
} }
@ -193,10 +193,10 @@ static int atusb_buf_read(void *dsc, void *buf, int size)
if (error) if (error)
return -1; return -1;
res = usb_control_msg(dev, FROM_DEV, ATSPI_BUF_READ, 0, 0, res = usb_control_msg(dev, FROM_DEV, ATUSB_BUF_READ, 0, 0,
buf, size, 1000); buf, size, 1000);
if (res < 0) { if (res < 0) {
fprintf(stderr, "ATSPI_BUF_READ: %d\n", res); fprintf(stderr, "ATUSB_BUF_READ: %d\n", res);
error = 1; error = 1;
} }
@ -216,10 +216,10 @@ static int atusd_interrupt(void *dsc)
if (error) if (error)
return -1; return -1;
res = usb_control_msg(dev, FROM_DEV, ATSPI_POLL_INT, 0, 0, res = usb_control_msg(dev, FROM_DEV, ATUSB_POLL_INT, 0, 0,
(void *) &buf, 1, 1000); (void *) &buf, 1, 1000);
if (res < 0) { if (res < 0) {
fprintf(stderr, "ATSPI_POLL_INT: %d\n", res); fprintf(stderr, "ATUSB_POLL_INT: %d\n", res);
error = 1; error = 1;
} }