]>
Commit | Line | Data |
---|---|---|
d684c216 L |
1 | #ifndef COMMON_H |
2 | #define COMMON_H | |
3 | ||
4 | #ifdef __AVR__ | |
5 | #include <avr/io.h> | |
889202c4 | 6 | #include <avr/pgmspace.h> |
8a7decea L |
7 | #include <util/delay.h> |
8 | ||
9 | #define udelay(n) _delay_us(n) | |
d684c216 L |
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 | |
72f58822 | 18 | #endif /* __AVR__ */ |
d684c216 L |
19 | |
20 | #include <stdio.h> | |
21 | ||
22 | #ifdef __FLASH | |
23 | #define FLASH __flash | |
fc30b18e | 24 | #define MEMX __memx |
d684c216 L |
25 | #else |
26 | #define FLASH | |
fc30b18e | 27 | #define MEMX |
d684c216 L |
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; | |
72f58822 | 41 | #endif /* __AVR__ */ |
d684c216 L |
42 | |
43 | #define S_10MS_TO (1<<0) | |
8a7decea L |
44 | #define S_MSG_PENDING (1<<1) |
45 | #define S_CON_PENDING (1<<2) | |
d684c216 L |
46 | |
47 | static inline | |
48 | void my_puts(const char *s) | |
49 | { | |
50 | fputs(s, stdout); | |
d684c216 L |
51 | } |
52 | ||
53 | static inline | |
54 | void my_puts_P(const char *s) | |
55 | { | |
61b0cfe9 | 56 | #ifdef __AVR__ |
d684c216 | 57 | fputs_P(s, stdout); |
72f58822 | 58 | #else |
72f58822 | 59 | fputs(s, stdout); |
72f58822 | 60 | #endif /* __AVR__ */ |
61b0cfe9 L |
61 | } |
62 | ||
d684c216 L |
63 | #endif /* COMMON_H */ |
64 |