#ifndef CONST_H
#define CONST_H

// Preprocessor utilities
#define _MKSTR(x) 					        #x
#define MKSTR(x) 				            _MKSTR(x)

// Options
#define BUILD_NO                            0
#define BUILD_YES                           1

// Supported Platforms
#define BUILD_PLATFORM_UNKNOWN              0
#define BUILD_PLATFORM_MINIPIX_V330         1

// Support power detection level
#define BUILD_LOWBAT_LEVEL_1V9              PWR_PVDLEVEL_0    // 1.9 V
#define BUILD_LOWBAT_LEVEL_2V1              PWR_PVDLEVEL_1    // 2.1 V
#define BUILD_LOWBAT_LEVEL_2V3              PWR_PVDLEVEL_2    // 2.3 V
#define BUILD_LOWBAT_LEVEL_2V5              PWR_PVDLEVEL_3    // 2.5 V
#define BUILD_LOWBAT_LEVEL_2V7              PWR_PVDLEVEL_4    // 2.7 V
#define BUILD_LOWBAT_LEVEL_2V9              PWR_PVDLEVEL_5    // 2.9 V
#define BUILD_LOWBAT_LEVEL_3V1              PWR_PVDLEVEL_6    // 3.1 V
#define BUILD_LOWBAT_LEVEL_OFF              0xFFFFFFFF

// Supported compiler
#define BUILD_COMPILER_UNKNOWN              0
#define BUILD_COMPILER_GCC                  1

// Compiler detection
#if defined(__GNUC__)
	#define	BUILD_COMPILER				    BUILD_COMPILER_GCC
	#define	BUILD_COMPILER_NAME		        "GCC"
	#define	BUILD_COMPILER_VERSION          MKSTR(__GNUC__) "." MKSTR(__GNUC_MINOR__) "." MKSTR(__GNUC_PATCHLEVEL__)
	#define	BUILD_COMPILER_LVERSION		    __VERSION__
    // Check GCC version
    #if __GNUC__ < 7
        #error "GCC compiler too old need GCC >= 7 !"
	#endif
#else
    #warning "Unknown compiler !"
#endif

// Boolean
#define false                               0
#define true                                1

// Align (_align need to be a power of 2)
#define ALIGN(_x, _align)  (((_x) + ((_align) - 1)) & ~((_align) - 1))

#define ARRAY_SIZE(_array)       (sizeof(_array) / sizeof(_array[0]))

// Include version
#include "version.h"

#endif
