X-Git-Url: http://cloudbase.mooo.com/gitweb/z180-stamp.git/blobdiff_plain/26331e248f87b8d640054c91b581f482cd89bede..7af9364ebd7ad6c143f31e9abe745c6d75f8322b:/include/common.h diff --git a/include/common.h b/include/common.h index b0dd038..e22b7a1 100644 --- a/include/common.h +++ b/include/common.h @@ -1,6 +1,17 @@ +/* + * (C) Copyright 2014 Leo C. + * + * SPDX-License-Identifier: GPL-2.0 + */ + #ifndef COMMON_H #define COMMON_H +#include +#include + +#define GCC_VERSION (__GNUC__*10000 + __GNUC_MINOR__*100 + __GNUC_PATCHLEVEL__) + #ifdef __AVR__ #include #include @@ -21,17 +32,18 @@ struct bits { #define SBIT(port,pin) ((*(volatile struct bits*)&port).b##pin) -//TODO: +//GCC bug PR61443 // Known to work: 4.8.4, 4.9.1 // Known to fail: 4.8.3, 4.9.0 + +#if (GCC_VERSION < 40804) || (GCC_VERSION == 40900) #define GCC_BUG_61443 1 +#endif /* PR61443 */ #else // TODO: stm32 #endif /* __AVR__ */ -#include - #ifdef __FLASH #define FLASH __flash #define MEMX __memx @@ -46,6 +58,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 @@ -53,7 +71,7 @@ struct bits { extern volatile uint_least8_t Stat; #endif /* __AVR__ */ -#define S_10MS_TO (1<<0) +#define S_10MS_TO (1<<0) #define S_MSG_PENDING (1<<1) #define S_CON_PENDING (1<<2)