From e1cc9144ee0158fb98e51ec510faf25631bfc3ae Mon Sep 17 00:00:00 2001 From: Pavol Rusnak Date: Mon, 4 Apr 2011 23:19:30 +0200 Subject: [PATCH] firmware wip3 --- firmware/src/usbhidrom_main.c | 24 +++++++++++++----------- firmware/test.c | 21 +++++++++++---------- 2 files changed, 24 insertions(+), 21 deletions(-) diff --git a/firmware/src/usbhidrom_main.c b/firmware/src/usbhidrom_main.c index 3ce9dbc..0b947d8 100644 --- a/firmware/src/usbhidrom_main.c +++ b/firmware/src/usbhidrom_main.c @@ -32,25 +32,27 @@ USB_DEV_INFO DeviceInfo; HID_DEVICE_INFO HidDevInfo; ROM ** rom = (ROM **)0x1fff1ff8; -/* - * Get HID Input Report -> InReport - */ -static uint8_t buffer[64]; +/* --------------------------------------------------- */ + +#define INSIZE 8 +#define OUTSIZE 2 void GetInReport (uint8_t src[], uint32_t length) { - memcpy(src, buffer, length); + int i; + for (i = 0; i < INSIZE; ++i) { + src[i] = 'A' + i; + } } -/* - * Set HID Output Report <- OutReport - */ void SetOutReport (uint8_t dst[], uint32_t length) { - memcpy(buffer, dst, length); + // TODO: parse dst } +/* --------------------------------------------------- */ + int main (void) { /* for delay loop */ @@ -66,8 +68,8 @@ int main (void) HidDevInfo.idProduct = USB_PROD_ID; HidDevInfo.bcdDevice = USB_DEVICE; HidDevInfo.StrDescPtr = (uint32_t)&USB_StringDescriptor[0]; - HidDevInfo.InReportCount = 1; - HidDevInfo.OutReportCount = 1; + HidDevInfo.InReportCount = INSIZE; + HidDevInfo.OutReportCount = OUTSIZE; HidDevInfo.SampleInterval = 0x20; HidDevInfo.InReport = GetInReport; HidDevInfo.OutReport = SetOutReport; diff --git a/firmware/test.c b/firmware/test.c index 7c94f38..691f13e 100644 --- a/firmware/test.c +++ b/firmware/test.c @@ -30,7 +30,8 @@ static const int PRODUCT_ID = 0x0003; // Values for bmRequestType in the Setup transaction's Data packet. -static const int INTERRUPT_ENDPOINT_PACKET_SIZE = 16; +static const int INSIZE = 8; +static const int OUTSIZE = 2; static const int INTERFACE_NUMBER = 0; // Uses interrupt endpoint 1 IN and OUT: @@ -108,16 +109,16 @@ int main(void) int exchange_input_and_output_reports_via_interrupt_transfers(libusb_device_handle *devh) { int bytes_transferred; - unsigned char data_in[INTERRUPT_ENDPOINT_PACKET_SIZE-1]; - unsigned char data_out[INTERRUPT_ENDPOINT_PACKET_SIZE-1]; + unsigned char data_in[INSIZE-1]; + unsigned char data_out[OUTSIZE-1]; int i = 0;; int result = 0;; // Store data in the output buffer for sending. - for (i=0;i= 0) { printf("Output report data sent via interrupt transfer:\n"); - for(i = 0; i < INTERRUPT_ENDPOINT_PACKET_SIZE; i++) + for(i = 0; i < OUTSIZE; i++) { printf("%02x ",data_out[i]); } @@ -144,16 +145,16 @@ int exchange_input_and_output_reports_via_interrupt_transfers(libusb_device_hand devh, INTERRUPT_IN_ENDPOINT, data_in, - INTERRUPT_ENDPOINT_PACKET_SIZE, + INSIZE, &bytes_transferred, TIMEOUT_MS); if (result >= 0) { - if (bytes_transferred == INTERRUPT_ENDPOINT_PACKET_SIZE) + if (bytes_transferred == INSIZE) { printf("Input report received via interrupt transfer:\n"); - for(i = 0; i < INTERRUPT_ENDPOINT_PACKET_SIZE; i++) + for(i = 0; i < INSIZE; i++) { printf("%02x ",data_in[i]); }