]> cloudbase.mooo.com Git - z180-stamp.git/blob - include/common.h
working host communication, new command: connect
[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 #define MEMX __memx
21 #else
22 #define FLASH
23 #define MEMX
24 #endif
25
26 #define stringify(s) tostring(s)
27 #define tostring(s) #s
28
29 #define FSTR(X) ((const FLASH char[]) { X } )
30 #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
31
32
33 #ifdef __AVR__
34 #define Stat GPIOR0
35 #else
36 extern volatile uint_least8_t Stat;
37 #endif /* __AVR__ */
38
39 #define S_10MS_TO (1<<0)
40 #define S_MSG_PENDING (2<<0)
41 #define S_CON_PENDING (3<<0)
42
43 static inline
44 void my_puts(const char *s)
45 {
46 fputs(s, stdout);
47 }
48
49 static inline
50 void my_puts_P(const char *s)
51 {
52 #ifdef __AVR__
53 fputs_P(s, stdout);
54 #else
55 fputs(s, stdout);
56 #endif /* __AVR__ */
57 }
58
59 #endif /* COMMON_H */
60