]> cloudbase.mooo.com Git - z180-stamp.git/blob - include/common.h
e8879a613c1477dceabab305aa5e1c2c3430decb
[z180-stamp.git] / include / common.h
1 #ifndef COMMON_H
2 #define COMMON_H
3
4 #ifdef __AVR__
5 #include <avr/io.h>
6
7 //TODO:
8 // Known to work: 4.8.4, 4.9.1
9 // Known to fail: 4.8.3, 4.9.0
10 #define GCC_BUG_61443 1
11
12 #else
13 // TODO: stm32
14 #endif /* __AVR__ */
15
16 #include <stdio.h>
17
18 #ifdef __FLASH
19 #define FLASH __flash
20 #else
21 #define FLASH
22 #endif
23
24 #define stringify(s) tostring(s)
25 #define tostring(s) #s
26
27 #define FSTR(X) ((const FLASH char[]) { X } )
28 #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
29
30
31 #ifdef __AVR__
32 #define Stat GPIOR0
33 #else
34 extern volatile uint_least8_t Stat;
35 #endif /* __AVR__ */
36
37 #define S_10MS_TO (1<<0)
38 #define S_Z180_RUNNING (2<<0)
39
40 static inline
41 void my_puts(const char *s)
42 {
43 fputs(s, stdout);
44 }
45
46 static inline
47 void my_puts_P(const char *s)
48 {
49 #ifdef __AVR__
50 fputs_P(s, stdout);
51 #else
52 fputs(s, stdout);
53 #endif /* __AVR__ */
54 }
55
56 #endif /* COMMON_H */
57