Commits

Trammell Hudson committed ead65ec

stop bits and try to send an idle

Comments (0)

Files changed (1)

 
 
 #define BAUDOT(a,b,c,d,e) ( \
-	(1 << 0) | \
-	(a << 1) | \
-	(b << 2) | \
-	(c << 3) | \
-	(d << 4) | \
-	(e << 5) | \
-	(0 << 6) | \
+	(a << 0) | \
+	(b << 1) | \
+	(c << 2) | \
+	(d << 3) | \
+	(e << 4) | \
 	0 )
 
 static uint8_t baudot[] = 
 	uint8_t ch
 )
 {
-	uint8_t c = baudot[ch];
-	if (c == 0)
+	uint8_t c = ch ? baudot[ch] : 0x00;
+	if (c == 0 && ch != 0)
 		return;
 
-	for (int i = 0 ; i < 7 ; i++)
+	// start bit
+	out(0xD7, 0);
+
+#define BIT_CLOCK 22000
+//#define BIT_CLOCK 16666
+
+	_delay_us(BIT_CLOCK); // + BIT_CLOCK/2);
+
+	for (int i = 0 ; i < 5 ; i++)
 	{
 		int x = c & 1;
 		c >>= 1;
 		else
 			out(0xD7, 0);
 
-		_delay_ms(22);
+		_delay_us(BIT_CLOCK);
 	}
 
 	out(0xD7, 1);
+	_delay_us(BIT_CLOCK + BIT_CLOCK/2); // 1.42 stop bits
 }
 
 
 
 		out(0xD6, 1);
 		tty_out(c);
+		tty_out(0x00);
 		out(0xD6, 0);
 	}
 }