/* USB Serial Transmit Bandwidth Test for Teensy USB Development Board * http://www.pjrc.com/teensy/ * Copyright (c) 2009 PJRC.COM, LLC * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ #include #include #include #include #include "usb_serial.h" #define LED_CONFIG (DDRD |= (1<<6)) #define LED_ON (PORTD &= ~(1<<6)) #define LED_OFF (PORTD |= (1<<6)) #define CPU_PRESCALE(n) (CLKPR = 0x80, CLKPR = (n)) void send_str(const char *s); #define CLEAR_TIMER0_OVERFLOW() (TIFR0 |= (1< /tmp/test.txt // The serial_read.exe or serial_list program can read the data // without saving it. // Results can vary depending on the number of other USB devices // connected. For fastest results, disconnect all others. // Results on Ubuntu 9.04, using: ./serial_listen /dev/ttyACM0 // Teensy++: 11565234 in 10 seconds // Teensy: 9610184 in 10 seconds // Results on Mac OS X 10.5.7, using: ./serial_listen /dev/cu.usbmodem12341 // Teensy++: 9013787 in 10 seconds // Teensy: 6386395 in 10 seconds // Results on Windows XP SP3, using: serial_read.exe COM3: // Teensy++: 10220367 in 10 seconds // Teensy: 8196387 in 10 seconds // Results on Windows Vista SP1, using: serial_read.exe COM3: // Teensy++: 10234275 in 10 seconds // Teensy: 8196204 in 10 seconds // Results on Windows 7 (beta 7100), using: serial_read.exe COM3: // Teensy++: 10274718 in 10 seconds // Teensy: 8225423 in 10 seconds // All 5 of these were tested on a Macbook with Intel dual core 2.4 Ghz, // external USB mouse + built-in USB peripherals int main(void) { uint8_t n; uint16_t count; const char test_string[] = { "USB Fast Serial Transmit Bandwidth Test, capture this text.\r\n"}; // set for 16 MHz clock, and turn on the LED CPU_PRESCALE(0); LED_CONFIG; LED_OFF; DDRC |= (1<<2); // Pin C2 to show % cpu usage // configure timer0 to overflow every 4 ms, prescale=256, top=250 // 250 * 256 / 16 MHz = 4 ms TIMSK0 = 0; TCCR0A = (1<