?? macro.h
字號:
*
* 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 + -