aboutsummaryrefslogtreecommitdiff
path: root/tools/avr_codegen/test.c
diff options
context:
space:
mode:
authorcnlohr <lohr85@gmail.com>2016-12-03 21:16:13 -0500
committercnlohr <lohr85@gmail.com>2016-12-03 21:16:13 -0500
commit368f4dcca9f8fdadfee527345b59f7a7ba6d6367 (patch)
treeeaf7b4f4a281cd892dee7159df9ca7b4ff2c7cf8 /tools/avr_codegen/test.c
parent684b109e8cd3246c93fdec3e63157bbd11bb359a (diff)
downloadlibsurvive-368f4dcca9f8fdadfee527345b59f7a7ba6d6367.tar.gz
libsurvive-368f4dcca9f8fdadfee527345b59f7a7ba6d6367.tar.bz2
Update tools encode a 2.5 MHz signal with the AVR.
Diffstat (limited to 'tools/avr_codegen/test.c')
-rw-r--r--tools/avr_codegen/test.c45
1 files changed, 45 insertions, 0 deletions
diff --git a/tools/avr_codegen/test.c b/tools/avr_codegen/test.c
new file mode 100644
index 0000000..e962e09
--- /dev/null
+++ b/tools/avr_codegen/test.c
@@ -0,0 +1,45 @@
+#include <avr/io.h>
+#include <avr/interrupt.h>
+#include <avr/sleep.h>
+#include <util/delay.h>
+
+void delay_ms(uint32_t time) {
+ uint32_t i;
+ for (i = 0; i < time; i++) {
+ _delay_ms(1);
+ }
+}
+
+#define NOOP asm volatile("nop" ::)
+
+
+static void setup_clock( void )
+{
+ /*Examine Page 33*/
+
+ CLKPR = 0x80; /*Setup CLKPCE to be receptive*/
+ CLKPR = 0x00; /*No scalar*/
+ OSCCAL = 0x80; //B8 is bottom E8 is top.
+}
+
+int main( )
+{
+ cli();
+ setup_clock();
+ DDRB = _BV(4);
+ uint8_t marker;
+
+ while(1)
+ {
+ marker = 0x05;
+ do{
+ PORTB = _BV(4);
+ marker--;
+ PORTB = 0;
+ } while( marker );
+
+ _delay_us(1000000/60);
+ }
+
+ return 0;
+}