summaryrefslogtreecommitdiffstats
path: root/sw-avr/rom-loader/main.c
diff options
context:
space:
mode:
authorNao Pross <naopross@thearcway.org>2018-10-30 12:07:58 +0100
committerNao Pross <naopross@thearcway.org>2018-10-30 12:34:37 +0100
commitcda16639cbf19d6eb5c11f05f1045e54b3fdaba9 (patch)
tree25227b76ae6dd50d5eddc30e4806af2003e70f54 /sw-avr/rom-loader/main.c
parentUpdate gitignore (diff)
downloadz80uPC-cda16639cbf19d6eb5c11f05f1045e54b3fdaba9.tar.gz
z80uPC-cda16639cbf19d6eb5c11f05f1045e54b3fdaba9.zip
[avr] Add test program for IO and basic usart
Diffstat (limited to 'sw-avr/rom-loader/main.c')
-rw-r--r--sw-avr/rom-loader/main.c34
1 files changed, 33 insertions, 1 deletions
diff --git a/sw-avr/rom-loader/main.c b/sw-avr/rom-loader/main.c
index b178c06..784afb6 100644
--- a/sw-avr/rom-loader/main.c
+++ b/sw-avr/rom-loader/main.c
@@ -1,6 +1,38 @@
#include <avr/io.h>
+#include "usart.h"
+#include "pinmap.h"
+
+// TODO: remove
+#include <util/delay.h>
+
+
+inline void io_init(void)
+{
+ ADDRL_DDR |= (_BV(ADDRL_bitE) | _BV(ADDRL_bitD));
+ ADDRL_DDR |= (0x7<<ADDRL_bitA0); // 3 bits
+
+ ADDRH_DDR |= (_BV(ADDRH_bitE) | _BV(ADDRH_bitD));
+ ADDRH_DDR |= (0x7<<ADDRH_bitA0);
+
+ // all output
+ DATA_DDR = 0xFF;
+}
+
int main(void)
{
- return;
+ io_init();
+ usart_init();
+
+ // TODO: remove
+ DATA_PORT |= _BV(1);
+
+ while (1) {
+ DATA_PORT ^= _BV(1);
+ _delay_ms(500);
+
+ usart_send('c');
+ }
+
+ return 0;
}