Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

merge from spacewrench

  • Loading branch information...
commit e97de214872b2138655c0839d8237db64863d0bc 2 parents 8b837b3 + b01b8f4
@WardCunningham authored
Showing with 11 additions and 10 deletions.
  1. +9 −8 txtzyme.c
  2. +2 −2 usb_serial.c
View
17 txtzyme.c
@@ -32,14 +32,15 @@
#define LED_OFF (PORTD &= ~(1<<6))
#define LED_ON (PORTD |= (1<<6))
#define CPU_PRESCALE(n) (CLKPR = 0x80, CLKPR = (n))
+#define BIGBUF 1024
void send_str(const char *s);
-uint8_t recv_str(char *buf, uint8_t size);
+uint16_t recv_str(char *buf, uint16_t size);
void parse(const char *buf);
// Basic command interpreter for controlling port pins
int main(void) {
- char buf[64];
+ char buf[BIGBUF];
uint8_t n;
// set for 16 MHz clock, and turn on the LED
@@ -74,7 +75,7 @@ int main(void) {
while (1) {
// send_str(PSTR("> "));
n = recv_str(buf, sizeof(buf));
- if (n == 255) break;
+ if (n == (uint16_t)(~0)) break;
// send_str(PSTR("\r\n"));
parse(buf);
}
@@ -107,9 +108,9 @@ void send_num(const uint16_t num) {
// The return value is the number of characters received, or 255 if
// the virtual serial connection was closed while waiting.
//
-uint8_t recv_str(char *buf, uint8_t size) {
+uint16_t recv_str(char *buf, uint16_t size) {
int16_t r;
- uint8_t count=0;
+ uint16_t count=0;
while (count < (size-1)) {
r = usb_serial_getchar();
@@ -125,7 +126,7 @@ uint8_t recv_str(char *buf, uint8_t size) {
!(usb_serial_get_control() & USB_SERIAL_DTR)) {
// user no longer connected
*buf = 0;
- return 255;
+ return ~0;
}
// just a normal timeout, keep waiting
}
@@ -145,7 +146,7 @@ uint16_t x = 0;
void parse(const char *buf) {
uint16_t count = 0;
last = TCNT1;
- char *loop;
+ const char *loop = 0;
char ch;
while ((ch = *buf++)) {
switch (ch) {
@@ -232,7 +233,7 @@ void parse(const char *buf) {
send_str(PSTR("\r\n"));
break;
case 'h':
- 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"));
+ 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"));
break;
case 't':
*(uint8_t *)(0x21 + port * 3) &= ~(1 << pin); // direction = input
View
4 usb_serial.c
@@ -40,8 +40,8 @@
// You can change these to give your code its own name. On Windows,
// these are only used before an INF file (driver install) is loaded.
-#define STR_MANUFACTURER L"Your Name"
-#define STR_PRODUCT L"USB Serial"
+#define STR_MANUFACTURER L"Ward Cunningham"
+#define STR_PRODUCT L"Txtzyme Interpreter"
// All USB serial devices are supposed to have a serial number
// (according to Microsoft). On windows, a new COM port is created
Please sign in to comment.
Something went wrong with that request. Please try again.