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