Trammell Hudson avatar Trammell Hudson committed ec8a123 Draft

Cleanup; rename

Comments (0)

Files changed (5)

 
 
 # Target file name (without extension).
-TARGET = example
+TARGET = prom
 
 
 # List C source files here. (C dependencies are automatically generated.)

example.c

-/**
- * \file PROM reader.
- */
-
-#include <avr/io.h>
-#include <avr/pgmspace.h>
-#include <avr/interrupt.h>
-#include <stdint.h>
-#include <string.h>
-#include <util/delay.h>
-#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);
-uint8_t recv_str(char *buf, uint8_t size);
-void parse_and_execute_command(const char *buf, uint8_t num);
-
-static uint8_t
-hexdigit(
-	uint8_t x
-)
-{
-	x &= 0xF;
-	if (x < 0xA)
-		return x + '0' - 0x0;
-	else
-		return x + 'A' - 0xA;
-}
-
-
-static uint8_t
-printable(
-	uint8_t x
-)
-{
-	if ('A' <= x && x <= 'Z')
-		return 1;
-	if ('a' <= x && x <= 'z')
-		return 1;
-	if ('0' <= x && x <= '9')
-		return 1;
-	if (x == ' ')
-		return 1;
-
-	return 0;
-}
-	
-
-
-#define ADDR_PORT_0	PORTB
-#define ADDR_DDR_0	DDRB
-#define ADDR_PIN_0	0
-
-#define ADDR_PORT_1	PORTB
-#define ADDR_DDR_1	DDRB
-#define ADDR_PIN_1	1
-
-#define ADDR_PORT_2	PORTB
-#define ADDR_DDR_2	DDRB
-#define ADDR_PIN_2	2
-
-#define ADDR_PORT_3	PORTB
-#define ADDR_DDR_3	DDRB
-#define ADDR_PIN_3	3
-
-#define ADDR_PORT_4	PORTB
-#define ADDR_DDR_4	DDRB
-#define ADDR_PIN_4	7
-
-#define ADDR_PORT_5	PORTD
-#define ADDR_DDR_5	DDRD
-#define ADDR_PIN_5	0
-
-#define ADDR_PORT_6	PORTD
-#define ADDR_DDR_6	DDRD
-#define ADDR_PIN_6	1
-
-#define ADDR_PORT_7	PORTD
-#define ADDR_DDR_7	DDRD
-#define ADDR_PIN_7	2
-
-#define ADDR_PORT_8	PORTD
-#define ADDR_DDR_8	DDRD
-#define ADDR_PIN_8	3
-
-#define ADDR_PORT_9	PORTC
-#define ADDR_DDR_9	DDRC
-#define ADDR_PIN_9	6
-
-#define ADDR_PORT_10	PORTC
-#define ADDR_DDR_10	DDRC
-#define ADDR_PIN_10	7
-
-#define ADDR_PORT_11	PORTD
-#define ADDR_DDR_11	PORTD
-#define ADDR_PIN_11	6
-
-#define ADDR_PORT_12	PORTD
-#define ADDR_DDR_12	PORTD
-#define ADDR_PIN_12	7
-
-
-#define DATA_PORT_0	PINF
-#define DATA_DDR_0	DDRF
-#define DATA_PIN_0	0
-
-#define DATA_PORT_1	PINF
-#define DATA_DDR_1	DDRF
-#define DATA_PIN_1	1
-
-#define DATA_PORT_2	PINF
-#define DATA_DDR_2	DDRF
-#define DATA_PIN_2	4
-
-#define DATA_PORT_3	PINF
-#define DATA_DDR_3	DDRF
-#define DATA_PIN_3	5
-
-#define DATA_PORT_4	PINF
-#define DATA_DDR_4	DDRF
-#define DATA_PIN_4	6
-
-#define DATA_PORT_5	PINF
-#define DATA_DDR_5	DDRF
-#define DATA_PIN_5	7
-
-#define DATA_PORT_6	PINB
-#define DATA_DDR_6	DDRB
-#define DATA_PIN_6	6
-
-#define DATA_PORT_7	PINB
-#define DATA_DDR_7	DDRB
-#define DATA_PIN_7	5
-
-
-#define sbi(PORT, PIN) (PORT) |= (1 << (PIN))
-#define cbi(PORT, PIN) (PORT) &= ~(1 << (PIN))
-
-static inline void
-set_address(
-	uint16_t addr
-)
-{
-#define PORT(X) PORT##X
-#define DDR(X) DDR##X
-#define PIN(X) PIN##X
-#define CAT(X,Y) X##Y
-
-
-#define ADDR_BIT(ID, bit) do { \
-	if (bit) \
-		sbi(CAT(ADDR_PORT_, ID), CAT(ADDR_PIN_, ID)); \
-	else \
-		cbi(CAT(ADDR_PORT_, ID), CAT(ADDR_PIN_, ID)); \
-} while(0)
-
-	ADDR_BIT(0, addr & 1); addr >>= 1;
-	ADDR_BIT(1, addr & 1); addr >>= 1;
-	ADDR_BIT(2, addr & 1); addr >>= 1;
-	ADDR_BIT(3, addr & 1); addr >>= 1;
-	ADDR_BIT(4, addr & 1); addr >>= 1;
-	ADDR_BIT(5, addr & 1); addr >>= 1;
-	ADDR_BIT(6, addr & 1); addr >>= 1;
-	ADDR_BIT(7, addr & 1); addr >>= 1;
-	ADDR_BIT(8, addr & 1); addr >>= 1;
-	ADDR_BIT(9, addr & 1); addr >>= 1;
-	ADDR_BIT(10, addr & 1); addr >>= 1;
-	ADDR_BIT(11, addr & 1); addr >>= 1;
-	ADDR_BIT(12, addr & 1); addr >>= 1;
-}
-
-
-static uint8_t
-read_byte(
-	uint16_t addr
-)
-{
-	set_address(addr);
-	for(uint8_t i = 0 ; i < 255; i++)
-	{
-		asm("nop");
-		asm("nop");
-		asm("nop");
-		asm("nop");
-		asm("nop");
-		asm("nop");
-		asm("nop");
-	}
-
-#define DATA_BIT(ID) \
-	(CAT(DATA_PORT_, ID) & (1 << CAT(DATA_PIN_, ID)) ? 1 : 0)
-
-	uint8_t b = 0;
-	b |= DATA_BIT(7); b <<= 1;
-	b |= DATA_BIT(6); b <<= 1;
-	b |= DATA_BIT(5); b <<= 1;
-	b |= DATA_BIT(4); b <<= 1;
-	b |= DATA_BIT(3); b <<= 1;
-	b |= DATA_BIT(2); b <<= 1;
-	b |= DATA_BIT(1); b <<= 1;
-	b |= DATA_BIT(0);
-
-	return b;
-}
-
-
-int main(void)
-{
-	// set for 16 MHz clock, and turn on the LED
-	CPU_PRESCALE(0);
-	LED_CONFIG;
-	LED_ON;
-
-	// initialize the USB, and then wait for the host
-	// to set configuration.  If the Teensy is powered
-	// without a PC connected to the USB port, this 
-	// will wait forever.
-	usb_init();
-	while (!usb_configured()) /* wait */ ;
-	_delay_ms(1000);
-
-	// wait for the user to run their terminal emulator program
-	// which sets DTR to indicate it is ready to receive.
-	while (!(usb_serial_get_control() & USB_SERIAL_DTR))
-		continue;
-
-	// Configure all of the address pins as outputs
-
-#define SET_DDR(ID) \
-	sbi(CAT(ADDR_DDR_,ID), CAT(ADDR_PIN_,ID))
-#define CLR_DDR(ID) \
-	cbi(CAT(DATA_DDR_,ID), CAT(DATA_PIN_,ID))
-
-	SET_DDR(0);
-	SET_DDR(1);
-	SET_DDR(2);
-	SET_DDR(3);
-	SET_DDR(4);
-	SET_DDR(5);
-	SET_DDR(6);
-	SET_DDR(7);
-	SET_DDR(8);
-	SET_DDR(9);
-	SET_DDR(10);
-	SET_DDR(11);
-	SET_DDR(12);
-
-	CLR_DDR(0);
-	CLR_DDR(1);
-	CLR_DDR(2);
-	CLR_DDR(3);
-	CLR_DDR(4);
-	CLR_DDR(5);
-	CLR_DDR(6);
-	CLR_DDR(7);
-
-	// discard anything that was received prior.  Sometimes the
-	// operating system or other software will send a modem
-	// "AT command", which can still be buffered.
-	usb_serial_flush_input();
-
-	send_str(PSTR("Press enter to dump\r\n"));
-
-#if 0
-
-	uint16_t addr = 0;
-	char line[64];
-	uint8_t off = 0;
-
-	while (1)
-	{
-		addr++;
-		if (addr == 0)
-			send_str(PSTR("wrap\r\n"));
-
-		uint8_t byte = read_byte(addr);
-		if (byte == 0)
-			continue;
-
-		if (off == 0)
-		{
-			line[off++] = hexdigit(addr >> 12);
-			line[off++] = hexdigit(addr >>  8);
-			line[off++] = hexdigit(addr >>  4);
-			line[off++] = hexdigit(addr >>  0);
-			line[off++] = '=';
-		}
-
-		if (printable(byte))
-		{
-			line[off++] = byte;
-			if (off < sizeof(line) - 2)
-				continue;
-		} else {
-			line[off++] = hexdigit(byte >> 4);
-			line[off++] = hexdigit(byte >> 0);
-		}
-
-		line[off++] = '\r';
-		line[off++] = '\n';
-		usb_serial_write(line, off);
-		off = 0;
-	}
-#else
-	uint16_t addr = 0;
-	while (1)
-	{
-		if (addr == 0)
-		{
-			// wait for input
-			while (!usb_serial_available())
-				continue;
-			while (usb_serial_available())
-				usb_serial_getchar();
-		}
-	
-		uint8_t byte = read_byte(addr++);
-		usb_serial_putchar(byte);
-	}
-#endif
-}
-
-
-// Send a string to the USB serial port.  The string must be in
-// flash memory, using PSTR
-//
-void send_str(const char *s)
-{
-	char c;
-	while (1) {
-		c = pgm_read_byte(s++);
-		if (!c) break;
-		usb_serial_putchar(c);
-	}
-}
+/**
+ * \file PROM reader.
+ */
+
+#include <avr/io.h>
+#include <avr/pgmspace.h>
+#include <avr/interrupt.h>
+#include <stdint.h>
+#include <string.h>
+#include <util/delay.h>
+#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);
+uint8_t recv_str(char *buf, uint8_t size);
+void parse_and_execute_command(const char *buf, uint8_t num);
+
+static uint8_t
+hexdigit(
+	uint8_t x
+)
+{
+	x &= 0xF;
+	if (x < 0xA)
+		return x + '0' - 0x0;
+	else
+		return x + 'A' - 0xA;
+}
+
+
+static uint8_t
+printable(
+	uint8_t x
+)
+{
+	if ('A' <= x && x <= 'Z')
+		return 1;
+	if ('a' <= x && x <= 'z')
+		return 1;
+	if ('0' <= x && x <= '9')
+		return 1;
+	if (x == ' ')
+		return 1;
+
+	return 0;
+}
+	
+
+
+#define ADDR_PORT_0	PORTB
+#define ADDR_DDR_0	DDRB
+#define ADDR_PIN_0	0
+
+#define ADDR_PORT_1	PORTB
+#define ADDR_DDR_1	DDRB
+#define ADDR_PIN_1	1
+
+#define ADDR_PORT_2	PORTB
+#define ADDR_DDR_2	DDRB
+#define ADDR_PIN_2	2
+
+#define ADDR_PORT_3	PORTB
+#define ADDR_DDR_3	DDRB
+#define ADDR_PIN_3	3
+
+#define ADDR_PORT_4	PORTB
+#define ADDR_DDR_4	DDRB
+#define ADDR_PIN_4	7
+
+#define ADDR_PORT_5	PORTD
+#define ADDR_DDR_5	DDRD
+#define ADDR_PIN_5	0
+
+#define ADDR_PORT_6	PORTD
+#define ADDR_DDR_6	DDRD
+#define ADDR_PIN_6	1
+
+#define ADDR_PORT_7	PORTD
+#define ADDR_DDR_7	DDRD
+#define ADDR_PIN_7	2
+
+#define ADDR_PORT_8	PORTD
+#define ADDR_DDR_8	DDRD
+#define ADDR_PIN_8	3
+
+#define ADDR_PORT_9	PORTC
+#define ADDR_DDR_9	DDRC
+#define ADDR_PIN_9	6
+
+#define ADDR_PORT_10	PORTC
+#define ADDR_DDR_10	DDRC
+#define ADDR_PIN_10	7
+
+#define ADDR_PORT_11	PORTD
+#define ADDR_DDR_11	PORTD
+#define ADDR_PIN_11	6
+
+#define ADDR_PORT_12	PORTD
+#define ADDR_DDR_12	PORTD
+#define ADDR_PIN_12	7
+
+
+#define DATA_PORT_0	PINF
+#define DATA_DDR_0	DDRF
+#define DATA_PIN_0	0
+
+#define DATA_PORT_1	PINF
+#define DATA_DDR_1	DDRF
+#define DATA_PIN_1	1
+
+#define DATA_PORT_2	PINF
+#define DATA_DDR_2	DDRF
+#define DATA_PIN_2	4
+
+#define DATA_PORT_3	PINF
+#define DATA_DDR_3	DDRF
+#define DATA_PIN_3	5
+
+#define DATA_PORT_4	PINF
+#define DATA_DDR_4	DDRF
+#define DATA_PIN_4	6
+
+#define DATA_PORT_5	PINF
+#define DATA_DDR_5	DDRF
+#define DATA_PIN_5	7
+
+#define DATA_PORT_6	PINB
+#define DATA_DDR_6	DDRB
+#define DATA_PIN_6	6
+
+#define DATA_PORT_7	PINB
+#define DATA_DDR_7	DDRB
+#define DATA_PIN_7	5
+
+
+#define sbi(PORT, PIN) (PORT) |= (1 << (PIN))
+#define cbi(PORT, PIN) (PORT) &= ~(1 << (PIN))
+
+static inline void
+set_address(
+	uint16_t addr
+)
+{
+#define PORT(X) PORT##X
+#define DDR(X) DDR##X
+#define PIN(X) PIN##X
+#define CAT(X,Y) X##Y
+
+
+#define ADDR_BIT(ID, bit) do { \
+	if (bit) \
+		sbi(CAT(ADDR_PORT_, ID), CAT(ADDR_PIN_, ID)); \
+	else \
+		cbi(CAT(ADDR_PORT_, ID), CAT(ADDR_PIN_, ID)); \
+} while(0)
+
+	ADDR_BIT(0, addr & 1); addr >>= 1;
+	ADDR_BIT(1, addr & 1); addr >>= 1;
+	ADDR_BIT(2, addr & 1); addr >>= 1;
+	ADDR_BIT(3, addr & 1); addr >>= 1;
+	ADDR_BIT(4, addr & 1); addr >>= 1;
+	ADDR_BIT(5, addr & 1); addr >>= 1;
+	ADDR_BIT(6, addr & 1); addr >>= 1;
+	ADDR_BIT(7, addr & 1); addr >>= 1;
+	ADDR_BIT(8, addr & 1); addr >>= 1;
+	ADDR_BIT(9, addr & 1); addr >>= 1;
+	ADDR_BIT(10, addr & 1); addr >>= 1;
+	ADDR_BIT(11, addr & 1); addr >>= 1;
+	ADDR_BIT(12, addr & 1); addr >>= 1;
+}
+
+
+static uint8_t
+read_byte(
+	uint16_t addr
+)
+{
+	set_address(addr);
+	for(uint8_t i = 0 ; i < 255; i++)
+	{
+		asm("nop");
+		asm("nop");
+		asm("nop");
+		asm("nop");
+		asm("nop");
+		asm("nop");
+		asm("nop");
+	}
+
+#define DATA_BIT(ID) \
+	(CAT(DATA_PORT_, ID) & (1 << CAT(DATA_PIN_, ID)) ? 1 : 0)
+
+	uint8_t b = 0;
+	b |= DATA_BIT(7); b <<= 1;
+	b |= DATA_BIT(6); b <<= 1;
+	b |= DATA_BIT(5); b <<= 1;
+	b |= DATA_BIT(4); b <<= 1;
+	b |= DATA_BIT(3); b <<= 1;
+	b |= DATA_BIT(2); b <<= 1;
+	b |= DATA_BIT(1); b <<= 1;
+	b |= DATA_BIT(0);
+
+	return b;
+}
+
+
+int main(void)
+{
+	// set for 16 MHz clock, and turn on the LED
+	CPU_PRESCALE(0);
+	LED_CONFIG;
+	LED_ON;
+
+	// initialize the USB, and then wait for the host
+	// to set configuration.  If the Teensy is powered
+	// without a PC connected to the USB port, this 
+	// will wait forever.
+	usb_init();
+	while (!usb_configured()) /* wait */ ;
+	_delay_ms(1000);
+
+	// wait for the user to run their terminal emulator program
+	// which sets DTR to indicate it is ready to receive.
+	while (!(usb_serial_get_control() & USB_SERIAL_DTR))
+		continue;
+
+	// Configure all of the address pins as outputs
+
+#define SET_DDR(ID) \
+	sbi(CAT(ADDR_DDR_,ID), CAT(ADDR_PIN_,ID))
+#define CLR_DDR(ID) \
+	cbi(CAT(DATA_DDR_,ID), CAT(DATA_PIN_,ID))
+
+	SET_DDR(0);
+	SET_DDR(1);
+	SET_DDR(2);
+	SET_DDR(3);
+	SET_DDR(4);
+	SET_DDR(5);
+	SET_DDR(6);
+	SET_DDR(7);
+	SET_DDR(8);
+	SET_DDR(9);
+	SET_DDR(10);
+	SET_DDR(11);
+	SET_DDR(12);
+
+	CLR_DDR(0);
+	CLR_DDR(1);
+	CLR_DDR(2);
+	CLR_DDR(3);
+	CLR_DDR(4);
+	CLR_DDR(5);
+	CLR_DDR(6);
+	CLR_DDR(7);
+
+	// discard anything that was received prior.  Sometimes the
+	// operating system or other software will send a modem
+	// "AT command", which can still be buffered.
+	usb_serial_flush_input();
+
+	send_str(PSTR("Press enter to dump\r\n"));
+
+#if 0
+
+	uint16_t addr = 0;
+	char line[64];
+	uint8_t off = 0;
+
+	while (1)
+	{
+		addr++;
+		if (addr == 0)
+			send_str(PSTR("wrap\r\n"));
+
+		uint8_t byte = read_byte(addr);
+		if (byte == 0)
+			continue;
+
+		if (off == 0)
+		{
+			line[off++] = hexdigit(addr >> 12);
+			line[off++] = hexdigit(addr >>  8);
+			line[off++] = hexdigit(addr >>  4);
+			line[off++] = hexdigit(addr >>  0);
+			line[off++] = '=';
+		}
+
+		if (printable(byte))
+		{
+			line[off++] = byte;
+			if (off < sizeof(line) - 2)
+				continue;
+		} else {
+			line[off++] = hexdigit(byte >> 4);
+			line[off++] = hexdigit(byte >> 0);
+		}
+
+		line[off++] = '\r';
+		line[off++] = '\n';
+		usb_serial_write(line, off);
+		off = 0;
+	}
+#else
+	uint16_t addr = 0;
+	while (1)
+	{
+		if (addr == 0)
+		{
+			// wait for input
+			while (!usb_serial_available())
+				continue;
+			while (usb_serial_available())
+				usb_serial_getchar();
+		}
+	
+		uint8_t byte = read_byte(addr++);
+		usb_serial_putchar(byte);
+	}
+#endif
+}
+
+
+// Send a string to the USB serial port.  The string must be in
+// flash memory, using PSTR
+//
+void send_str(const char *s)
+{
+	char c;
+	while (1) {
+		c = pgm_read_byte(s++);
+		if (!c) break;
+		usb_serial_putchar(c);
+	}
+}

test-strip

-#!/usr/bin/perl
-use warnings;
-use strict;
-use Data::Dumper;
-use Device::SerialPort;
-
-my $devfile = "/dev/tty.usbmodem12341";
-my $dev = Device::SerialPort->new($devfile)
-	or die "$devfile: Unable to open $!\n";
-
-my $num_leds = 32 * 5;
-my @pixels = map { [0,0,0] } (1..$num_leds);
-my $sprite = 0;
-
-# Pad the latch command out to 64-bytes
-my $latch = chr(0x00) x 64;
-#my $latch = chr(0x00) x (8 * 3 * int(($num_leds + 63) / 64));
-#$latch .= chr(0x00) x (64 - length($latch) % 64);
-
-
-sub translate_pixel
-{
-	my $c = shift;
-	$c |= 0x80;
-	my $mask = 0x80;
-	my $p = '';
-
-	while ($mask)
-	{
-		if ($c & $mask)
-		{
-			$p .= chr(0xFF);
-		} else {
-			$p .= chr(0x00);
-		}
-
-		$mask >>= 1;
-	}
-
-	return $p;
-}
-
-
-while (1)
-{
-	$pixels[$sprite] = [0,0,0];
-	$sprite = ($sprite - 1 + $num_leds) % $num_leds;
-	$pixels[$sprite] = [0,0x3f,0];
-
-	# Translate the colors array into a merged version per string
-	my $s = '';
-	for my $p (@pixels)
-	{
-		my ($r,$g,$b) = @$p;
-
-		$s .= translate_pixel($g);
-		$s .= translate_pixel($r);
-		$s .= translate_pixel($b);
-	}
-
-	for my $i (0..59)
-	{
-		my $t = substr($s, 64 * $i, 64);
-		$dev->write($t);
-		#sleep(0.001);
-	}
-
-	$dev->write($latch);
-
-	sleep 1.0 / 30;
-}

tx_benchmark.c

-/* 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 <avr/io.h>
-#include <avr/pgmspace.h>
-#include <stdint.h>
-#include <util/delay.h>
-#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<<TOV0))
-#define IS_TIMER0_OVERFLOW() (TIFR0 & (1<<TOV0))
-
-
-// USB Serial Transmit Bandwidth Test
-//
-// Within 5 seconds of opening the port, this program
-// will send a message as rapidly as possible, for 10 seconds.
-// When finished, turn off text capture (some programs will not
-// write the last data until you do this), delete any extra lines
-// at the beginning, and then the file size divided by 10 is the
-// maximum transmit bandwidth.
-//
-// To use this, run a terminal emulator and select the option
-// to capture all text to a file.  On Linux & MacOS, you can use
-// the cat command to read data to a file, such as:
-// cat /dev/cu.usbmodem12341 > /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<<WGM01)|(1<<WGM00);
-	OCR0A = 250;
-	TCCR0B = (1<<WGM02)|(1<<CS02);
-
-	// initialize the USB, and then wait for the host
-	// to set configuration.  If the Teensy is powered
-	// without a PC connected to the USB port, this 
-	// will wait forever.
-	usb_init();
-	while (!usb_configured()) /* wait */ ;
-	_delay_ms(1000);
-
-	while (1) {
-		// wait for the user to run their terminal emulator program
-		// which sets DTR to indicate it is ready to receive.
-		while (!(usb_serial_get_control() & USB_SERIAL_DTR)) /* wait */ ;
-
-		// Turn the LED on while sending data
-		LED_ON;
-
-		// give the user 5 seconds to enable text capture in their
-		// terminal emulator, or do whatever to get ready
-		for (n=5; n; n--) {
-			send_str(PSTR("10 second speed test begins in "));
-			usb_serial_putchar(n + '0');
-			send_str(PSTR(" sec.\r\n"));
-			if (!(usb_serial_get_control() & USB_SERIAL_DTR)) break;
-			_delay_ms(1000);
-		}
-
-		// wait for a 4 ms timer0 period to begin
-		CLEAR_TIMER0_OVERFLOW();
-		while (!IS_TIMER0_OVERFLOW()) /* wait */ ;
-		CLEAR_TIMER0_OVERFLOW();
-		count=0;
-
-		// send a string as fast as possible, for 10 seconds
-		while (1) {
-			usb_serial_write(test_string, (uint16_t)(sizeof(test_string)-1));
-			if (IS_TIMER0_OVERFLOW()) {
-				CLEAR_TIMER0_OVERFLOW();
-				count++;
-				if (count == 2500) break;   // 10 sec
-				if (!(usb_serial_get_control() & USB_SERIAL_DTR)) break;
-			}
-		}
-		PORTC &= ~(1<<2);
-		send_str(PSTR("done!\r\n"));
-		LED_OFF;
-
-		// after the test, wait forever doing nothing,
-		// well, at least until the terminal emulator quits
-		// or drops DTR for some reason.
-		while (usb_serial_get_control() & USB_SERIAL_DTR) /* wait */ ;
-	}
-}
-
-// Send a string to the USB serial port.  The string must be in
-// flash memory, using PSTR
-//
-void send_str(const char *s)
-{
-	char c;
-	while (1) {
-		c = pgm_read_byte(s++);
-		if (!c) break;
-		usb_serial_putchar(c);
-	}
-}
-
-
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.