From 2addfe8c42c6bcdc0a15c751e2436447b73d03fe Mon Sep 17 00:00:00 2001 From: "ajmeyer@mit.edu" Date: Thu, 7 Jan 2010 03:31:35 +0000 Subject: Added a print class for USB, works identically to the Serial object. Bugs out if you try and pump more than 64 bytes through it in a single packet (which is really the OS's decision). This can be fixed git-svn-id: https://leaflabs.googlecode.com/svn/trunk/library@93 749a229e-a60e-11de-b98f-4500b42dc123 --- src/example_main.cpp | 34 +++++++++++++--------------------- 1 file changed, 13 insertions(+), 21 deletions(-) (limited to 'src/example_main.cpp') diff --git a/src/example_main.cpp b/src/example_main.cpp index 8c90b7d..7202c66 100644 --- a/src/example_main.cpp +++ b/src/example_main.cpp @@ -1,19 +1,13 @@ #include "wiring.h" #include "HardwareSerial.h" +#include "HardwareUsb.h" #include "math.h" #include "usb.h" int ledPin = 13; uint8_t bytes_in; -BootVectTable* mapleVect; - -void usb_tx_cb(void) { -} - -void usb_rx_cb(void) { - bytes_in = usb_serialGetRecvLen(); -} +HardwareUsb Usb; void setup() { @@ -27,30 +21,28 @@ void setup() Serial2.println("setup end"); - mapleVect = (BootVectTable*)(BOOTLOADER_VECT_TABLE); - mapleVect->serial_tx_cb = usb_tx_cb; - mapleVect->serial_rx_cb = usb_rx_cb; + Usb.begin(); + Usb.flush(); } - int toggle = 0; const char* testMsg = "hello world!\n"; - +const char x = 'a'; static inline void loop() { toggle ^= 1; digitalWrite(ledPin, toggle); - delay(1000); - usb_serialWriteStr("blink...\n"); + delay(50); - if (bytes_in > 0) { - int i; - for (i=0;i 0) { + while (numBytes-->0) { + Usb.print(Usb.read()); } - bytes_in = 0; - usb_serialWriteStr("\n"); } + + Usb.flush(); } -- cgit v1.2.3