From b5a524e5749e48c15f02d1f608a4b8102d90032c Mon Sep 17 00:00:00 2001
From: Vegard Storheil Eriksen <zyp@jvnv.net>
Date: Wed, 6 Mar 2013 16:58:23 +0100
Subject: Use an isochronous pipe for streaming sensor data.

---
 main.cpp | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/main.cpp b/main.cpp
index 9e48875..aa1df03 100644
--- a/main.cpp
+++ b/main.cpp
@@ -40,9 +40,10 @@ static Pin pwm_outputs[] = {PC6, PC7, PC8, PC9};
 
 auto dev_desc = device_desc(0x200, 0, 0, 0, 64, 0x1234, 0x5678, 0, 0, 0, 0, 1);
 auto conf_desc = configuration_desc(3, 1, 0, 0xc0, 0,
-	interface_desc(0, 0, 2, 0xff, 0x00, 0x00, 0,
+	interface_desc(0, 0, 3, 0xff, 0x00, 0x00, 0,
 		endpoint_desc(0x01, 0x02, 64, 0), // OUT
-		endpoint_desc(0x81, 0x02, 64, 0)  // IN
+		endpoint_desc(0x81, 0x02, 64, 0), // IN
+		endpoint_desc(0x82, 0x01, 64, 1)  // IN ISO
 	)
 );
 
@@ -148,8 +149,9 @@ class USB_TM : public USB_class_driver {
 	protected:
 		virtual void handle_set_configuration(uint8_t configuration) {
 			if(configuration) {
-				usb.hw_conf_ep(0x81, EPType::Bulk, 64);
 				usb.hw_conf_ep(0x01, EPType::Bulk, 64);
+				usb.hw_conf_ep(0x81, EPType::Bulk, 64);
+				usb.hw_conf_ep(0x82, EPType::Isochronous, 64);
 				usb.register_out_handler(this, 1);
 			}
 		}
@@ -297,8 +299,10 @@ int main() {
 			magn.z,
 		};
 		
-		if(usb.ep_ready(1)) {
-			usb.write(1, (uint32_t*)buf, sizeof(buf));
+		if(usb.ep_ready(2)) {
+			usb.write(2, (uint32_t*)buf, sizeof(buf));
+		} else {
+			usb_rblog.log("Busy.");
 		}
 	}
 }
-- 
cgit v1.2.3