Commits

Trammell Hudson committed 1fd8aaa

character decoding appears to work!

Comments (0)

Files changed (1)

 {
 	uint16_t byte = 0;
 
-#if 0
-	for (int bit = 0 ; bit < 16 ; bit++)
+#undef CONFIG_WAVEFORM
+#ifndef CONFIG_WAVEFORM
+	// 1 start bit, 7 data, 1 parity, 2 stop bits
+#define NUM_BITS (1 + 7 + 1 + 2)
+
+	for (int bit = 0 ; bit < NUM_BITS ; bit++)
 	{
+		if (bit == 0)
+			_delay_us(BIT_CLOCK/4*3);
+		else
+			_delay_us(BIT_CLOCK);
+
 		if (in(TTY_RX))
-			byte = (byte << 1) | 1;
+			byte = (byte >> 1) | (((uint16_t) 1) << NUM_BITS);
 		else
-			byte <<= 1;
-
-		_delay_us(BIT_CLOCK/4);
+			byte >>= 1;
 	}
 #else
 #define TTY_BITS 64
 		//buf[bit] = x ? '0' : '1';
 		int x = adc_read_block();
 		buf[bit] = hexdigit(x >> 6);
-		_delay_us(BIT_CLOCK/6);
+		_delay_us(BIT_CLOCK/4);
+// 220000BB9045608B7000078B79AB9000099DA8BBADCC998A9A9AAAAABBCBBBBB
+// 22 0000 BB90 4560 8B70 0007 8B79 AB90 0009 9DA8 BBAD CC99 8A9A 9AAAAABBCBBBBB
 	}
 	usb_serial_write(buf, sizeof(buf));
 #endif
 			continue;
 
 		uint16_t byte = tty_in();
-/*
+#ifndef CONFIG_WAVEFORM
 		usb_serial_putchar(hexdigit(byte >> 12));
 		usb_serial_putchar(hexdigit(byte >> 8));
 		usb_serial_putchar(hexdigit(byte >> 4));
 		usb_serial_putchar(hexdigit(byte >> 0));
-*/
+		usb_serial_putchar(' ');
+		usb_serial_putchar((byte >> 2) & 0x7F);
+#endif
 		usb_serial_putchar('\r');
 		usb_serial_putchar('\n');
 		continue;