summaryrefslogtreecommitdiff
path: root/avr/common.h
diff options
context:
space:
mode:
authorLeo C2014-08-12 12:35:28 +0200
committerLeo C2014-08-12 12:35:28 +0200
commitd684c21619905153eff68c43927207248925f6c2 (patch)
treec4bfb04a20512679103c6ad39fd9885dea6d9e76 /avr/common.h
parent9b6b4b31e8cb284ad6a68fe16d458e36bbfb46fa (diff)
downloadz180-stamp-d684c21619905153eff68c43927207248925f6c2.zip
New U-Boot like AVR main program.
Uses U-Boot source code taken from: git://git.denx.de/u-boot.git
Diffstat (limited to 'avr/common.h')
-rw-r--r--avr/common.h57
1 files changed, 57 insertions, 0 deletions
diff --git a/avr/common.h b/avr/common.h
new file mode 100644
index 0000000..ace0fcb
--- /dev/null
+++ b/avr/common.h
@@ -0,0 +1,57 @@
+#ifndef COMMON_H
+#define COMMON_H
+
+#ifdef __AVR__
+#include <avr/io.h>
+
+//TODO:
+// Known to work: 4.8.4, 4.9.1
+// Known to fail: 4.8.3, 4.9.0
+#define GCC_BUG_61443 1
+
+#else
+// TODO: stm32
+#endif
+
+#include <stdio.h>
+
+#ifdef __FLASH
+#define FLASH __flash
+#else
+#define FLASH
+#endif
+
+#define stringify(s) tostring(s)
+#define tostring(s) #s
+
+#define FSTR(X) ((const FLASH char[]) { X } )
+#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
+
+
+#ifdef __AVR__
+#define Stat GPIOR0
+#else
+extern volatile uint_least8_t Stat;
+#endif
+
+#define S_10MS_TO (1<<0)
+
+
+#include <util/delay.h>
+
+static inline
+void my_puts(const char *s)
+{
+ fputs(s, stdout);
+// _delay_ms(10);
+}
+
+static inline
+void my_puts_P(const char *s)
+{
+ fputs_P(s, stdout);
+// _delay_ms(10);
+}
+
+#endif /* COMMON_H */
+