⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 macro.h

📁 LPC2366低功耗测试代码
💻 H
📖 第 1 页 / 共 2 页
字号:
*
*               mask        Mask of bits to check if set.
*
* Return(s)   : DEF_YES, if ALL specified bit(s) are     set in value.
*     
*               DEF_NO,	 if ALL specified bit(s) are NOT set in value.
*
* Caller(s)   : various.
*
* Note(s)     : none.
*********************************************************************************************************
*/

#define  DEF_BIT_IS_SET(val, mask)                   ((((val) & (mask)) == (mask)) ? (DEF_YES) : (DEF_NO ))


/*
*********************************************************************************************************
*                                          DEF_BIT_IS_CLR()
*
* Description : Determine if specified bit(s) in a value are clear.
*
* Argument(s) : val         Value to check for specified bit(s) clear.
*
*               mask        Mask of bits to check if clear.
*
* Return(s)   : DEF_YES, if ALL specified bit(s) are     clear in value.
*     
*               DEF_NO,	 if ALL specified bit(s) are NOT clear in value.
*
* Caller(s)   : various.
*
* Note(s)     : none.
*********************************************************************************************************
*/

#define  DEF_BIT_IS_CLR(val, mask)                    (((val) & (mask))            ? (DEF_NO ) : (DEF_YES))


/*$PAGE*/
/*
*********************************************************************************************************
*                                        DEF_BIT_IS_SET_ANY()
*
* Description : Determine if any specified bit(s) in a value are set.
*
* Argument(s) : val         Value to check for specified bit(s) set.
*
*               mask        Mask of bits to check if set.
*
* Return(s)   : DEF_YES, if ANY specified bit(s) are     set in value.
*     
*               DEF_NO,	 if ALL specified bit(s) are NOT set in value.
*
* Caller(s)   : various.
*
* Note(s)     : none.
*********************************************************************************************************
*/

#define  DEF_BIT_IS_SET_ANY(val, mask)                (((val) & (mask))            ? (DEF_YES) : (DEF_NO ))


/*
*********************************************************************************************************
*                                        DEF_BIT_IS_CLR_ANY()
*
* Description : Determine if any specified bit(s) in a value are clear.
*
* Argument(s) : val         Value to check for specified bit(s) clear.
*
*               mask        Mask of bits to check if clear.
*
* Return(s)   : DEF_YES, if ANY specified bit(s) are     clear in value.
*     
*               DEF_NO,	 if ALL specified bit(s) are NOT clear in value.
*
* Note(s)     : none.
*********************************************************************************************************
*/

#define  DEF_BIT_IS_CLR_ANY(val, mask)               ((((val) & (mask)) != (mask)) ? (DEF_YES) : (DEF_NO ))


/*$PAGE*/
/*
*********************************************************************************************************
*                                            MATH MACRO'S
*********************************************************************************************************
*/

/*
*********************************************************************************************************
*                                              DEF_MIN()
*
* Description : Determine the minimum of two values.
*
* Argument(s) : a           First  value.
*
*               b           Second value.
*
* Return(s)   : Minimum of the two values.
*
* Caller(s)   : various.
*
* Note(s)     : none.
*********************************************************************************************************
*/

#define  DEF_MIN(a, b)                                  (((a) < (b)) ? (a) : (b))


/*
*********************************************************************************************************
*                                              DEF_MAX()
*
* Description : Determine the maximum of two values.
*
* Argument(s) : a           First  value.
*
*               b           Second value.
*
* Return(s)   : Maximum of the two values.
*
* Note(s)     : none.
*********************************************************************************************************
*/

#define  DEF_MAX(a, b)                                  (((a) > (b)) ? (a) : (b))


/*$PAGE*/
/*
*********************************************************************************************************
*                                              DEF_ABS()
*
* Description : Determine the absolute value of a value.
*
* Argument(s) : a           Value to calculate absolute value.
*
* Return(s)   : Absolute value of the value.
*
* Caller(s)   : various.
*
* Note(s)     : none.
*********************************************************************************************************
*/

#define  DEF_ABS(a)                                     (((a) < 0) ? (-(a)) : (a))


/*$PAGE*/
/*
*********************************************************************************************************
*                                             MODULE END
*********************************************************************************************************
*/

/*
*********************************************************************************************************
*                                               DEFINES
*********************************************************************************************************
*/

#define  MAIN_OSC_FRQ              10000000L
#define  IRC_OSC_FRQ                4000000L
#define  RTC_OSC_FRQ                  32768L

/*
*********************************************************************************************************
*                                           PCLK PERIPHERAL IDS
*                                       (see 'BSP_CPU_PclkFreq()')
*********************************************************************************************************
*/

#define  PCLK_WDT                         0
#define  PCLK_TIMER0                      1
#define  PCLK_TIMER1                      2
#define  PCLK_UART0                       3
#define  PCLK_UART1                       4
#define  PCLK_PWM0                        5
#define  PCLK_PWM1                        6
#define  PCLK_I2C0                        7
#define  PCLK_SPI                         8
#define  PCLK_RTC                         9
#define  PCLK_SSP1                       10
#define  PCLK_DAC                        11
#define  PCLK_ADC                        12
#define  PCLK_CAN1                       13
#define  PCLK_CAN2                       14
#define  PCLK_ACF                        15
#define  PCLK_BAT_RAM                    16
#define  PCLK_GPIO                       17
#define  PCLK_PCB                        18
#define  PCLK_I2C1                       19
#define  PCLK_SSP0                       21
#define  PCLK_TIMER2                     22
#define  PCLK_TIMER3                     23
#define  PCLK_UART2                      24
#define  PCLK_UART3                      25
#define  PCLK_I2C2                       26
#define  PCLK_MCI                        27
#define  PCLK_SYSCON                     29

/*
*********************************************************************************************************
*                                          GLOBAL VARIABLES
*********************************************************************************************************
*/


 
/*宏定义和全局变量定义*/
/********************************************************/
#ifdef	CORESINGLE		//CORE板单独使用
#ifdef	RAINSENSOR2		//雨量传感器2代
/*****************************************************************
定义雨量传感器宏及全局变量
****************************************************************/
#define	FunCodeRDSensor		0x03    //功能码03:读传感器或显示器的数值
#define RDStartAdd1			0x00  //读传感器的起始地址
#define RDStartAdd2			0x00
#define RDNum1				0X00
#define	RDNum2				0X04   //读取点数:高字节在前

#define	EX160Add			0xFF   //扩展功能160(查询从属设备地址)帧信息起始地址
#define	FUNCodeEX160		0xa0  //扩展功能码160:查询从属设备地址

#define	FUNCodeEX161		0xa1   //扩展功能码161:改变从属设备地址
#define FUNCodeEX163		0xa3   //扩展功能码163:雨量传感器的雨量累加值清零
#define FUNCodeEX164		0xa4   //扩展功能码164:检查雨量传感器状况
#define FUNCodeEX165		0xa5   //扩展功能码165:查询雨量传感器ID码

uint8	AddSlav  ;  //从机地址
uint8	NewAddSlav;  //从机的新地址
 
#endif
#endif

#define		DELAY5MINUTE	(5*60*OS_TICKS_PER_SEC)	//	延迟5分钟
#define		DELAY3MINUTE	(3*60*OS_TICKS_PER_SEC)	//延迟3分钟
#define		DELAY1MINUTE	(3*60*OS_TICKS_PER_SEC)	//延迟1分钟



//指示UART来源
#define		SUART0	1
#define		SUART1	2
#define		SUART2	3
#define		SUART3	4
#define		TOUART	5  //接收超时

//uart相关
#define UART0_SEND_QUEUE_LENGTH   512  /* 给UART0发送数据队列分配的空间大小 	*/
#define UART1_SEND_QUEUE_LENGTH   512  /* 给UART1发送数据队列分配的空间大小 	*/
#define UART2_SEND_QUEUE_LENGTH   512  /* 给UART2发送数据队列分配的空间大小 	*/
#define UART3_SEND_QUEUE_LENGTH   512  /* 给UART0发送数据队列分配的空间大小 	*/


//按键名称及键值定义


#ifdef	USECAN
/*CAN相关宏参数的定义*/
//定义CAN消息
#define		CAN_MSG_READ_IO_AD	0x10
#define		CAN_MSG_READ_IO		0x11
#define		CAN_MSG_READ_AD		0x12
//定义消息来源
#define		CAN_MSG_FROM_IN		0x01	//来自输入板
#define		CAN_MSG_FROM_OUT	0X02	//来自输出板
//定义


#endif


//NandFlash操作命令
#define NandF_READ_DATA    	1
#define NandF_WRITE_DATA	2
#define NandF_RD_ERRO		3
#define NandF_RD_OK			4
#define NandF_WR_ERRO		5
#define NandF_WR_OK			6

//定义USB操作命令
#ifdef	USEUSB
#define	USB_RD				1
#define	USB_WR				2
#define	USB_RD_OK			3
#define	USB_RD_ERROR		4
#define	USB_WR_ERRO			5
#define	USB_WR_OK			6

#endif






#endif                                                          /* End of lib def module include.                       */





⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -