Trammell Hudson avatar Trammell Hudson committed 704ddc2

boost works!

Comments (0)

Files changed (1)

 /**
  * \file 45 baud sync teletype interface
  *
+ * Uses a boost converter to make the 50-100V for driving the ciol.
  */
 
 #include <avr/io.h>
 }
 
 
+static void
+boost_setup(void)
+{
+
+        // Configure OC1x in fast-PWM mode, 10-bit
+        sbi(TCCR1B, WGM12);
+        sbi(TCCR1A, WGM11);
+        sbi(TCCR1A, WGM10);
+
+        // OC1C is used to generate the boost converter pump
+        // Configure output mode to clear on match, set at top
+        sbi(TCCR1A, COM1C1);
+        cbi(TCCR1A, COM1C0);
+
+        // Configure clock 1 at clk/1
+        cbi(TCCR1B, CS12);
+        cbi(TCCR1B, CS11);
+        sbi(TCCR1B, CS10);
+
+	OCR1C = 0x2B0; // very little off time makes the mosfet unhappy
+	ddr(0xB7, 1);
+	out(0xB7, 1);
+}
+
+
+static void
+boost_adjust(
+	int delta
+)
+{
+	OCR1C += delta;
+
+	char buf[] = {
+		hexdigit(OCR1C >> 12),
+		hexdigit(OCR1C >>  8),
+		hexdigit(OCR1C >>  4),
+		hexdigit(OCR1C >>  0),
+		'\r',
+		'\n'
+	};
+
+	usb_serial_write(buf, sizeof(buf));
+}
+
+
+
+
 int main(void)
 {
 	// set for 16 MHz clock
 	ddr(0xD7, 1);
 	out(0xD7, 1);
 
+	boost_setup();
+
 	// 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 
 		if (c == -1)
 			continue;
 
+		if (c == '+')
+		{
+			boost_adjust(10);
+			continue;
+		} else
+		if (c == '-')
+		{
+			boost_adjust(-10);
+			continue;
+		}
+
 		out(0xD6, 1);
 		tty_out(c);
 		out(0xD6, 0);
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.