]> cloudbase.mooo.com Git - z180-stamp.git/blobdiff - include/common.h
Move macro SBIT to common.h
[z180-stamp.git] / include / common.h
index 74339df76dd0ce24d336ea5a50c434705ee41e2e..b0dd038e8775df2be44988733a352c2f07266dab 100644 (file)
@@ -4,6 +4,22 @@
 #ifdef __AVR__
 #include <avr/io.h>
 #include <avr/pgmspace.h>
+#include <util/delay.h>
+
+#define udelay(n)  _delay_us(n)
+
+struct bits {
+  uint8_t b0:1;
+  uint8_t b1:1;
+  uint8_t b2:1;
+  uint8_t b3:1;
+  uint8_t b4:1;
+  uint8_t b5:1;
+  uint8_t b6:1;
+  uint8_t b7:1;
+} __attribute__((__packed__));
+
+#define SBIT(port,pin) ((*(volatile struct bits*)&port).b##pin)
 
 //TODO:
 //  Known to work: 4.8.4, 4.9.1
@@ -22,7 +38,7 @@
 #else
 #define FLASH
 #define MEMX
-#endif 
+#endif
 
 #define stringify(s)   tostring(s)
 #define tostring(s)    #s
@@ -38,16 +54,16 @@ extern volatile uint_least8_t Stat;
 #endif /* __AVR__ */
 
 #define S_10MS_TO      (1<<0)
-#define S_MSG_PENDING  (2<<0)
-#define S_CON_PENDING  (3<<0)
+#define S_MSG_PENDING  (1<<1)
+#define S_CON_PENDING  (1<<2)
 
-static inline 
+static inline
 void my_puts(const char *s)
 {
        fputs(s, stdout);
 }
 
-static inline 
+static inline
 void my_puts_P(const char *s)
 {
 #ifdef __AVR__
@@ -58,4 +74,3 @@ void my_puts_P(const char *s)
 }
 
 #endif /* COMMON_H */
-