]> cloudbase.mooo.com Git - z180-stamp.git/blobdiff - include/common.h
New command: cfboot - boot from cf card.
[z180-stamp.git] / include / common.h
index cfbbae5c1fc1cf3185f18e67bb9983667d7f9080..dea638aa7d0261f808890992a4065a4d30317e85 100644 (file)
@@ -1,12 +1,15 @@
 /*
  * (C) Copyright 2014 Leo C. <erbl259-lmu@yahoo.de>
  *
- * SPDX-License-Identifier:    GPL-2.0+
+ * SPDX-License-Identifier:    GPL-2.0
  */
 
 #ifndef COMMON_H
 #define COMMON_H
 
+#include <stdio.h>
+#include <stdint.h>
+
 #ifdef __AVR__
 #include <avr/io.h>
 #include <avr/pgmspace.h>
@@ -36,8 +39,6 @@ struct bits {
 // TODO: stm32
 #endif /* __AVR__ */
 
-#include <stdio.h>
-
 #ifdef __FLASH
 #define FLASH __flash
 #define MEMX __memx
@@ -52,6 +53,12 @@ struct bits {
 #define FSTR(X) ((const FLASH char[]) { X } )
 #define ARRAY_SIZE(x)  (sizeof(x) / sizeof((x)[0]))
 
+#define MIN(a,b)    ({ typeof (a) _a = (a);                                    \
+                                               typeof (b) _b = (b);                                   \
+                                               _a < _b ? _a : _b; })
+#define MAX(a,b)    ({ typeof (a) _a = (a);                                    \
+                                               typeof (b) _b = (b);                                   \
+                                               _a > _b ? _a : _b; })
 
 #ifdef __AVR__
 #define Stat GPIOR0