finished cleaning up the gyro board usb stuff
diff --git a/gyro_board/src/usb/LPCUSB/USB_SENSOR_STREAM.c b/gyro_board/src/usb/LPCUSB/USB_SENSOR_STREAM.c
index 99218cf..8d4bff3 100644
--- a/gyro_board/src/usb/LPCUSB/USB_SENSOR_STREAM.c
+++ b/gyro_board/src/usb/LPCUSB/USB_SENSOR_STREAM.c
@@ -45,13 +45,13 @@
#define usbTXBUFFER_LEN ( 600 )
// Read the processor manual for picking these.
-#define INT_IN_EP 0x81
#define BULK_IN_EP 0x82
#define BULK_OUT_EP 0x05
#define ISOC_IN_EP 0x83
-#define NUM_ENDPOINTS 4
+#define NUM_ENDPOINTS 3
#define MAX_PACKET_SIZE 64
+#define DATA_PACKET_SIZE DATA_STRUCT_SEND_SIZE
#define LE_WORD(x) ((x)&0xFF),((x)>>8)
@@ -115,19 +115,12 @@
0x02, // bmAttributes = bulk
LE_WORD(MAX_PACKET_SIZE), // wMaxPacketSize
0x00, // bInterval
-// Data EP in
- 0x07,
- DESC_ENDPOINT,
- INT_IN_EP, // bEndpointAddress
- 0x03, // bmAttributes = intr
- LE_WORD(MAX_PACKET_SIZE), // wMaxPacketSize
- 0x01, // bInterval
// isoc data EP IN
0x07,
DESC_ENDPOINT,
ISOC_IN_EP, // bEndpointAddress
0x0D, // bmAttributes = isoc, synchronous, data endpoint
- LE_WORD(1023), // wMaxPacketSize
+ LE_WORD(DATA_PACKET_SIZE), // wMaxPacketSize
0x01, // bInterval
// string descriptors
@@ -207,13 +200,6 @@
}
-static void DataIn(unsigned char bEP, unsigned char bEPStatus) {
- fillSensorPacket(&usbPacket);
- static uint8_t sequence = 0;
- usbPacket.sequence = sequence++;
- USBHwEPWrite(bEP, (unsigned char *)&usbPacket, sizeof(usbPacket));
-}
-
/**
* Writes one character to VCOM port
*
@@ -283,7 +269,7 @@
fillSensorPacket(&usbPacket);
static uint8_t sequence = 0;
usbPacket.sequence = sequence++;
- USBHwEPWrite(ISOC_IN_EP, (unsigned char *)&usbPacket, sizeof(usbPacket));
+ USBHwEPWrite(ISOC_IN_EP, (unsigned char *)&usbPacket, DATA_PACKET_SIZE);
}
void usb_init(void) {
@@ -309,7 +295,6 @@
// HandleClassRequest, abClassReqData);
// register endpoint handlers
- USBHwRegisterEPIntHandler(INT_IN_EP, DataIn);
USBHwRegisterEPIntHandler(BULK_IN_EP, DebugIn);
USBHwRegisterEPIntHandler(BULK_OUT_EP, DebugOut);
diff --git a/gyro_board/src/usb/data_struct.h b/gyro_board/src/usb/data_struct.h
index 9e97950..4470476 100644
--- a/gyro_board/src/usb/data_struct.h
+++ b/gyro_board/src/usb/data_struct.h
@@ -97,9 +97,16 @@
};
#pragma pack(pop)
+// This is how big the isochronous packets that we're going to send are.
+// This number is more painful to change than the actual size of the struct
+// because the code on both ends has to agree on this (or at least that's what
+// Brian found empirically 2013-10-24).
+#define DATA_STRUCT_SEND_SIZE 128
+
#ifdef __cplusplus
// TODO(brians): Consider using C1X's _Static_assert once we have a compiler
// (GCC 4.6) + flags that support it.
-static_assert(sizeof(DATA_STRUCT_NAME) <= 64,
- "We only have room for 64 bytes in the USB packet.");
+static_assert(sizeof(DATA_STRUCT_NAME) <= DATA_STRUCT_SEND_SIZE,
+ "We only have room for " STRINGIFY(DATA_STRUCT_SEND_SIZE)
+ " bytes in the USB packet.");
#endif // defined(__cplusplus)