diff options
author | Daniel Friesel <derf@finalrewind.org> | 2016-01-08 20:48:26 +0100 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2016-01-08 20:48:26 +0100 |
commit | 3541c176f24f8daee3b0bc35f71e1521daa7137a (patch) | |
tree | eff0d98b265ff831de2ee8bd2ae58a2ca27091c4 | |
parent | 870259ecc121c5574fe119db0b3dad3416deca79 (diff) |
use global defines for usb control commands
-rw-r--r-- | commandline/i2c-util.c | 11 | ||||
-rw-r--r-- | firmware/main.c | 6 | ||||
-rw-r--r-- | global_config.h | 4 |
3 files changed, 10 insertions, 11 deletions
diff --git a/commandline/i2c-util.c b/commandline/i2c-util.c index 426d7d8..03b2fad 100644 --- a/commandline/i2c-util.c +++ b/commandline/i2c-util.c @@ -31,11 +31,6 @@ obtained from http://libusb.sourceforge.net/. * in firmware/usbdrv/USBID-License.txt. */ -#define PSCMD_ECHO 0 -#define PSCMD_GET 1 -#define PSCMD_SET 2 -/* These are the vendor specific SETUP commands implemented by our USB device */ - unsigned char bit_sda = 6; unsigned char bit_scl = 7; @@ -200,7 +195,7 @@ unsigned char get_status() unsigned char buffer[8]; int nBytes = usb_control_msg(handle, USB_TYPE_VENDOR | USB_RECIP_DEVICE | - USB_ENDPOINT_IN, PSCMD_GET, 0, 0, (char *)buffer, + USB_ENDPOINT_IN, USBCMD_GETPORT, 0, 0, (char *)buffer, sizeof(buffer), 5000); if (nBytes < 1) { @@ -268,7 +263,7 @@ void set_sda(char value) usb_control_msg(handle, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_ENDPOINT_IN, - PSCMD_SET, 0, (val_sda << bit_sda) | (val_scl << bit_scl), + USBCMD_SETPORT, 0, (val_sda << bit_sda) | (val_scl << bit_scl), (char *)buffer, sizeof(buffer), 5000); } @@ -281,7 +276,7 @@ void set_scl(char value) usb_control_msg(handle, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_ENDPOINT_IN, - PSCMD_SET, 0, (val_sda << bit_sda) | (val_scl << bit_scl), + USBCMD_SETPORT, 0, (val_sda << bit_sda) | (val_scl << bit_scl), (char *)buffer, sizeof(buffer), 5000); } diff --git a/firmware/main.c b/firmware/main.c index db5bf25..0410134 100644 --- a/firmware/main.c +++ b/firmware/main.c @@ -37,16 +37,16 @@ usbRequest_t *rq = (void *)data; static uchar replyBuf[2]; usbMsgPtr = replyBuf; - if(rq->bRequest == 0) { /* ECHO */ + if(rq->bRequest == USBCMD_ECHO) { /* ECHO */ replyBuf[0] = rq->wValue.bytes[0]; replyBuf[1] = rq->wValue.bytes[1]; return 2; } - if(rq->bRequest == 1) { /* GET_STATUS -> result = 1 bytes */ + if(rq->bRequest == USBCMD_GETPORT) { /* GET_STATUS -> result = 1 bytes */ replyBuf[0] = PINB; return 1; } - if(rq->bRequest == 2) { /* SET_STATUS. Payload byte is output. */ + if(rq->bRequest == USBCMD_SETPORT) { /* SET_STATUS. Payload byte is output. */ DDRB = ~(rq->wIndex.bytes[0]); } return 0; diff --git a/global_config.h b/global_config.h index 16c1918..1a4e8b5 100644 --- a/global_config.h +++ b/global_config.h @@ -1,2 +1,6 @@ #define USBDEV_VERSION_MAJOR 0 #define USBDEV_VERSION_MINOR 1 + +#define USBCMD_ECHO 0 +#define USBCMD_GETPORT 1 +#define USBCMD_SETPORT 2 |