#ifndef MSCP_DEFINE_H
#define MSCP_DEFINE_H

#ifndef WIN32
#ifndef QNX
#define QNX (1)
#endif
#else
#endif


#ifdef __cplusplus
extern "C"
{
#endif

   /* C++ test 用宏 */
#if 0
#define snprintf  (_snprintf)
#define __func__ (__FILE__)
#endif
/*ite项目485串口开关*/
#define _ITE_485_
/* #define CM_ASSERT assert */
/* 将表达式转换为固定类型的值-注意：禁止嵌套使用*/
/*无符号整型 u16 u32 u64*/
#define CM_UNSIGNED_SHORT_EXP(x)    ({unsigned short u16ret = 0u; u16ret = (unsigned short)(x); u16ret;})
#define CM_UNSIGNED_INT_EXP(x)      ({unsigned int u32ret = 0u;   u32ret = (unsigned int)(x);   u32ret;})
#define CM_UNSIGNED_LONG_INT_EXP(x) ({unsigned long int u64ret = 0u; u64ret = (unsigned long int)(x); u64ret;})
/*有符号整型 t16 t32 t64*/
#define CM_SIGNED_SHORT_EXP(x)      ({signed short t16ret = 0; t16ret = (signed short)(x); t16ret;})
#define CM_SIGNED_INT_EXP(x)        ({signed int t32ret = 0;   t32ret = (signed int)(x);   t32ret;})
#define CM_SIGNED_LONG_INT_EXP(x)   ({signed long int t64ret = 0; t64ret = (signed long int)(x); t64ret;})
/* 将表达式或有符号类型转换为无符号BOOL型*/
#define CM_INT_TO_UINT_BOOL(x) ((x)?(unsigned int)1u:(unsigned int)0u)
/* 使用平台的宕机函数 */
#ifdef WIN32
#define CM_ASSERT(x, Mode, faultCode, funNum) (MSCP_ASSERT((unsigned int)(CM_INT_TO_UINT_BOOL(x)),0x55,(unsigned short)Mode, (unsigned char)faultCode, (unsigned char)funNum,__FILE__,0, __LINE__))
#else
/*禁止自重启-允许远程重启*/
#define CM_ASSERT(x, Mode, faultCode, funNum) (MSCP_ASSERT((unsigned int)(CM_INT_TO_UINT_BOOL(x)),0x55,(unsigned short)Mode, (unsigned char)faultCode, (unsigned char)funNum,__FILE__,__func__, __LINE__))
/*禁止自重启-禁止远程重启*/
#define CM_NM_ASSERT(x, Mode, faultCode, funNum) (MSCP_ASSERT((unsigned int)(CM_INT_TO_UINT_BOOL(x)),0xAA,(unsigned short)Mode, (unsigned char)faultCode, (unsigned char)funNum,__FILE__,__func__, __LINE__))
/*允许自重启-允许远程重启*/
#define CM_RE_ASSERT(x, Mode, faultCode, funNum) (MSCP_REBOOT_ASSERT((unsigned int)(CM_INT_TO_UINT_BOOL(x)),0x55,(unsigned short)Mode, (unsigned char)faultCode, (unsigned char)funNum,__FILE__,__func__, __LINE__))
#endif
/* 平台实现的宕机函数 */
extern void MSCP_ASSERT(unsigned int x, unsigned int MaintenanceFlag, unsigned short Mode, unsigned char faultCode, unsigned char funNum, const char *filename, const char *func, int line);
/**
* @brief 自动重启断言
*/
extern void MSCP_REBOOT_ASSERT(unsigned int x, unsigned int MaintenanceFlag,unsigned short Mode, unsigned char faultCode, unsigned char funNum, const char *filename, const char *func, int line);
/* 维护模式下平台的宕机函数 */
#define CM_ASSERT_MAINTAIN(x) (MSCP_ASSERT_MAINTAIN((unsigned int)(CM_INT_TO_UINT_BOOL(x)), __FILE__,__func__, __LINE__))
/* 维护模式下平台实现的宕机函数 */
extern void MSCP_ASSERT_MAINTAIN(unsigned int x, const char *filename, const char *func, int line);

#ifdef __cplusplus
}
#endif
#endif
