Skip to content
This repository
Browse code

merge from spacewrench

  • Loading branch information...
commit e97de214872b2138655c0839d8237db64863d0bc 2 parents 8b837b3 + b01b8f4
Ward Cunningham authored November 25, 2011

Showing 2 changed files with 11 additions and 10 deletions. Show diff stats Hide diff stats

  1. 17  txtzyme.c
  2. 4  usb_serial.c
17  txtzyme.c
@@ -32,14 +32,15 @@
32 32
 #define LED_OFF		(PORTD &= ~(1<<6))
33 33
 #define LED_ON		(PORTD |= (1<<6))
34 34
 #define CPU_PRESCALE(n) (CLKPR = 0x80, CLKPR = (n))
  35
+#define BIGBUF      1024
35 36
 
36 37
 void send_str(const char *s);
37  
-uint8_t recv_str(char *buf, uint8_t size);
  38
+uint16_t recv_str(char *buf, uint16_t size);
38 39
 void parse(const char *buf);
39 40
 
40 41
 // Basic command interpreter for controlling port pins
41 42
 int main(void) {
42  
-	char buf[64];
  43
+	char buf[BIGBUF];
43 44
 	uint8_t n;
44 45
 
45 46
 	// set for 16 MHz clock, and turn on the LED
@@ -74,7 +75,7 @@ int main(void) {
74 75
 		while (1) {
75 76
 			// send_str(PSTR("> "));
76 77
 			n = recv_str(buf, sizeof(buf));
77  
-			if (n == 255) break;
  78
+			if (n == (uint16_t)(~0)) break;
78 79
 			// send_str(PSTR("\r\n"));
79 80
 			parse(buf);
80 81
 		}
@@ -107,9 +108,9 @@ void send_num(const uint16_t num) {
107 108
 // The return value is the number of characters received, or 255 if
108 109
 // the virtual serial connection was closed while waiting.
109 110
 //
110  
-uint8_t recv_str(char *buf, uint8_t size) {
  111
+uint16_t recv_str(char *buf, uint16_t size) {
111 112
 	int16_t r;
112  
-	uint8_t count=0;
  113
+	uint16_t count=0;
113 114
 
114 115
 	while (count < (size-1)) {
115 116
 		r = usb_serial_getchar();
@@ -125,7 +126,7 @@ uint8_t recv_str(char *buf, uint8_t size) {
125 126
 			  !(usb_serial_get_control() & USB_SERIAL_DTR)) {
126 127
 				// user no longer connected
127 128
 				*buf = 0;
128  
-				return 255;
  129
+				return ~0;
129 130
 			}
130 131
 			// just a normal timeout, keep waiting
131 132
 		}
@@ -145,7 +146,7 @@ uint16_t x = 0;
145 146
 void parse(const char *buf) {
146 147
 	uint16_t count = 0;
147 148
 	last = TCNT1;
148  
-	char *loop;
  149
+	const char *loop = 0;
149 150
 	char ch;
150 151
 	while ((ch = *buf++)) {
151 152
 		switch (ch) {
@@ -232,7 +233,7 @@ void parse(const char *buf) {
232 233
 				send_str(PSTR("\r\n"));
233 234
 				break;
234 235
 			case 'h':
235  
-				send_str(PSTR("0-9<num>\tenter number\r\n<num>p\t\tprint number\r\n<num>a-f<pin>\tselect pin\r\n<pin>i<num>\tinput\r\n<pin><num>o\toutput\r\n<num>m\t\tmsec delay\r\n<num>u\t\tusec delay\r\n<num>U\t\tusec wait\r\n<num>{}\t\trepeat\r\nk<num>\t\tloop count\r\n_<words>_\tprint words\r\n<num>s<num>\tanalog sample\r\nv\t\tprint version\r\nh\t\tprint help\r\n<pin>t<num>\tpulse width\r\n"));
  236
+				send_str(PSTR("Txtzyme [+bigbuf]\r\n0-9<num>\tenter number\r\n<num>p\t\tprint number\r\n<num>a-f<pin>\tselect pin\r\n<pin>i<num>\tinput\r\n<pin><num>o\toutput\r\n<num>m\t\tmsec delay\r\n<num>u\t\tusec delay\r\n<num>{}\t\trepeat\r\nk<num>\t\tloop count\r\n_<words>_\tprint words\r\n<num>s<num>\tanalog sample\r\nv\t\tprint version\r\nh\t\tprint help\r\n<pin>t<num>\tpulse width\r\n"));
236 237
 				break;
237 238
 			case 't':
238 239
 				*(uint8_t *)(0x21 + port * 3) &= ~(1 << pin);		// direction = input
4  usb_serial.c
@@ -40,8 +40,8 @@
40 40
 
41 41
 // You can change these to give your code its own name.  On Windows,
42 42
 // these are only used before an INF file (driver install) is loaded.
43  
-#define STR_MANUFACTURER	L"Your Name"
44  
-#define STR_PRODUCT		L"USB Serial"
  43
+#define STR_MANUFACTURER	L"Ward Cunningham"
  44
+#define STR_PRODUCT		L"Txtzyme Interpreter"
45 45
 
46 46
 // All USB serial devices are supposed to have a serial number
47 47
 // (according to Microsoft).  On windows, a new COM port is created

0 notes on commit e97de21

Please sign in to comment.
Something went wrong with that request. Please try again.