📄 test_functions.h
字号:
if ((tWORD)( tmp )!=( (tWORD)(ExpData) )) { /* means the test failed */ \ FAIL_3( (tWORD)( CPRINT_E_RE32 ), (tWORD)( Reg ), (tWORD)( tmp ), (tWORD)( ExpData ) ); \ } \ else { \ SUCCESS_3( (tWORD)( CPRINT_S_RE32 ), (tWORD)( Reg ), (tWORD)( tmp ), (tWORD)( ExpData ) ); \ } \}/****************************************************************************** * Macro: REM (read and check Expected with a mask ) * * Parameters: Reg The register ExpData The Expected value mask The mask value * * Returns: * * Notes: The test performed is: if (( (Reg) & mask ) != ( (ExpData) & mask )) *****************************************************************************/#define REM8( Reg, ExpData, Mask ) \{ \ tBYTE tmp; \ tmp = (volatile tBYTE)(*(volatile tBYTE *)(Reg)); \ if (( (tBYTE)(tmp) & (tBYTE)(Mask) ) != ( (tBYTE)(ExpData) & (tBYTE)(Mask) )) { /* test failed */ \ FAIL_4( (tWORD)( CPRINT_E_REM8 ), (tWORD)( Reg ), (tWORD)( tmp ), (tWORD)( ExpData ), (tWORD)( Mask ) ); \ } \ else { \ SUCCESS_4( (tWORD)( CPRINT_S_REM8 ), (tWORD)( Reg ), (tWORD)( tmp ), (tWORD)( ExpData ), (tWORD)( Mask ) ); \ } \}#define REM16( Reg, ExpData, Mask ) \{ \ tHALF tmp; \ tmp = (volatile tHALF)(*(volatile tHALF *)(Reg)); \ if (( (tHALF)(tmp) & (tHALF)(Mask) ) != ( (tHALF)(ExpData) & (tHALF)(Mask) )) { /* test failed */ \ FAIL_4( (tWORD)( CPRINT_E_REM16 ), (tWORD)( Reg ), (tWORD)( tmp ), (tWORD)( ExpData ), (tWORD)( Mask ) ); \ } \ else { \ SUCCESS_4( (tWORD)( CPRINT_S_REM16 ), (tWORD)( Reg ), (tWORD)( tmp ), (tWORD)( ExpData ), (tWORD)( Mask )); \ } \}#define REM32( Reg, ExpData, Mask ) \{ \ tWORD tmp; \ tmp = (volatile tWORD)(*(volatile tWORD *)(Reg)); \ if (( (tWORD)(tmp) & (tWORD)(Mask) ) != ( (tWORD)(ExpData) & (tWORD)(Mask) )) { /* test failed */ \ FAIL_4( (tWORD)( CPRINT_E_REM32 ), (tWORD)( Reg ), (tWORD)( tmp ), (tWORD)( ExpData ), (tWORD)( Mask ) ); \ } \ else { \ SUCCESS_4( (tWORD)( CPRINT_S_REM32 ), (tWORD)( Reg ), (tWORD)( tmp ), (tWORD)( ExpData ), (tWORD)( Mask ) ); \ } \}/****************************************************************************** * Macro: W (Put a value into a register) * * Parameters: Reg The register to written WrData The value to be written * * Returns: * * Notes: *****************************************************************************/#define W8( address, writedata ) \ *(volatile tBYTE *) (address) = (writedata)#define W16( address, writedata ) \ *(volatile tHALF *)(address) = (writedata)#define W32( address , writedata ) \ *(volatile tWORD *)( address ) = ( writedata )/****************************************************************************** * Macro: WR (Write, Read, and Compare) * * Parameters: Reg The register to be written WrData The data to be written * * Returns: * * Notes: The test performed is: if ( (Reg) != (WrData) ) *****************************************************************************/#define WR8( Reg, WrData ) \{ \ tBYTE tmp; \ /* write the reg */ \ *(volatile tBYTE *)(Reg)=(tBYTE)(WrData); \ /* read the reg */ \ tmp = (volatile tBYTE)(*(volatile tBYTE *)(Reg)); \ if ( (tBYTE)(tmp) != (tBYTE)(WrData) ) { /* test failed */ \ FAIL_3( (tWORD)( CPRINT_E_WR8 ), (tWORD)( Reg ), (tWORD)( WrData ), (tWORD)( tmp ) ); \ } \ else { \ SUCCESS_3( (tWORD)( CPRINT_S_WR8 ), (tWORD)( Reg ), (tWORD)( WrData ), (tWORD)( tmp ) ); \ } \}#define WR16( Reg, WrData ) \{ \ tHALF tmp; \ /* write the reg */ \ *(volatile tHALF *)(Reg)=(tHALF)(WrData); \ /* read the reg */ \ tmp = (volatile tHALF)(*(volatile tHALF *)(Reg)); \ if ( (tHALF)(tmp) != (tHALF)(WrData) ) { /* test failed */ \ FAIL_3( (tWORD)( CPRINT_E_WR16 ), (tWORD)( Reg ), (tWORD)( WrData ), (tWORD)( tmp ) ); \ } \ else { \ SUCCESS_3( (tWORD)( CPRINT_S_WR16 ), (tWORD)( Reg ), (tWORD)( WrData ), (tWORD)( tmp ) ); \ } \} #define WR32( Reg, WrData ) \{ \ tWORD tmp; \ /* write the reg */ \ *(volatile tWORD *)(Reg)=(tWORD)(WrData); \ /* read the reg */ \ tmp = (volatile tWORD)(*(volatile tWORD *)(Reg)); \ if ( (tWORD)(tmp) != (tWORD)(WrData) ) { /* test failed */ \ FAIL_3( (tWORD)( CPRINT_E_WR32 ), (tWORD)( Reg ), (tWORD)( WrData ), (tWORD)( tmp ) ); \ } \ else { \ SUCCESS_3( (tWORD)( CPRINT_S_WR32 ), (tWORD)( Reg ), (tWORD)( WrData ), (tWORD)( tmp ) ); \ } \} /****************************************************************************** * Macro: WRE (Write, Read, and Compare Expected) * * Parameters: Reg The register to be written WrData The data to be written ExpData The expected data to read back * * Returns: * * Notes: The test performed is: if ( (Reg) != (Exp) ) *****************************************************************************/#define WRE8( Reg, WrData, ExpData ) \{ \ tBYTE tmp; \ /* write the reg */ \ *(volatile tBYTE *)(Reg)=(tBYTE)(WrData); \ /* read the reg */ \ tmp = (volatile)(*(volatile tBYTE *)(Reg)); \ /* test the reg */ \ if ( (volatile)(tmp) != (tBYTE)(ExpData) ) { /* means the test failed */ \ FAIL_4( (tWORD)( CPRINT_E_WRE8 ), (tWORD)( Reg ), (tWORD)( WrData ), (tWORD)( tmp ), (tWORD)( ExpData ) ); \ } \ else { \ SUCCESS_4( (tWORD)( CPRINT_S_WRE8 ), (tWORD)( Reg ), (tWORD)( WrData ), (tWORD)( tmp ), (tWORD)( ExpData ) ); \ } \}#define WRE16( Reg, WrData, ExpData ) \{ \ tHALF tmp; \ /* write the reg */ \ *(volatile tHALF *)(Reg)=(tHALF)(WrData); \ /* read the reg */ \ tmp = (volatile)(*(volatile tHALF *)(Reg)); \ /* test the reg */ \ if ( (volatile)(tmp) != (tHALF)(ExpData) ) { /* means the test failed */ \ FAIL_4( (tWORD)( CPRINT_E_WRE16 ), (tWORD)( Reg ), (tWORD)( WrData ), (tWORD)( tmp ), (tWORD)( ExpData ) ); \ } \ else { \ SUCCESS_4( (tWORD)( CPRINT_S_WRE16 ), (tWORD)( Reg ), (tWORD)( WrData ), (tWORD)( tmp ), (tWORD)( ExpData ) ); \ } \}#define WRE32( Reg, WrData, ExpData ) \{ \ tWORD tmp; \ /* write the reg */ \ *(volatile tWORD *)(Reg)=(tWORD)(WrData); \ /* read the reg */ \ tmp = (volatile)(*(volatile tWORD *)(Reg)); \ /* test the reg */ \ if ( (volatile)(tmp) != (tWORD)(ExpData) ) { /* means the test failed */ \ FAIL_4( (tWORD)( CPRINT_E_WRE32 ), (tWORD)( Reg ), (tWORD)( WrData ), (tWORD)( tmp ), (tWORD)( ExpData ) ); \ } \ else { \ SUCCESS_4( (tWORD)( CPRINT_S_WRE32 ), (tWORD)( Reg ), (tWORD)( WrData ), (tWORD)( tmp ), (tWORD)( ExpData ) ); \ } \} /****************************************************************************** * Macro: WRM (Write, Read, and Compare Masked) * * Parameters: Reg The register to be written WrData The data to be written Mask The mask to be used * * Returns: * * Notes: The test performed is: if (( (Reg) & (Mask) ) != ( (WrData) & (Mask) )) *****************************************************************************/#define WRM8( Reg, WrData, Mask ) \{ \ tBYTE tmp; \ /* write the reg */ \ *(volatile tBYTE *)(Reg)=(tBYTE)(WrData); \ /* read the reg */ \ tmp = (volatile tBYTE)(*(volatile tBYTE *)(Reg)); \ /* test the reg */ \ if (( (tBYTE)(tmp) & (tBYTE)(Mask) ) != ( (tBYTE)(WrData) & (tBYTE)(Mask) )) { /* failed */ \ FAIL_4( (tWORD)( CPRINT_E_WRM8 ), (tWORD)( Reg ), (tWORD)( WrData ), (tWORD)( tmp ), (tWORD) ( Mask ) ); \ } \ else { \ SUCCESS_4( (tWORD)( CPRINT_S_WRM8 ), (tWORD)( Reg ), (tWORD)( WrData ), (tWORD)( tmp ), (tWORD) ( Mask ) ); \ } \} #define WRM16( Reg, WrData, Mask ) \{ \ tHALF tmp; \ /* write the reg */ \ *(volatile tHALF *)(Reg)=(tHALF)(WrData); \ /* read the reg */ \ tmp = (volatile tHALF)(*(volatile tHALF *)(Reg)); \ /* test the reg */ \ if (( (tHALF)(tmp) & (tHALF)(Mask) ) != ( (tHALF)(WrData) & (tHALF)(Mask) )) { /* failed */ \ FAIL_4( (tWORD)( CPRINT_E_WRM16 ), (tWORD)( Reg ), (tWORD)( WrData ), (tWORD)( tmp ), (tWORD) ( Mask ) ); \ } \ else { \ SUCCESS_4( (tWORD)( CPRINT_S_WRM16 ), (tWORD)( Reg ), (tWORD)( WrData ), (tWORD)( tmp ), (tWORD) ( Mask ) ); \ } \} #define WRM32( Reg, WrData, Mask ) \{ \ tWORD tmp; \ /* write the reg */ \ *(volatile tWORD *)(Reg)=(tWORD)(WrData); \ /* read the reg */ \ tmp = (volatile tWORD)(*(volatile tWORD *)(Reg)); \ /* test the reg */ \ if (( (tWORD)(tmp) & (tWORD)(Mask) ) != ( (tWORD)(WrData) & (tWORD)(Mask) )) { /* failed */ \ FAIL_4( (tWORD)( CPRINT_E_WRM32 ), (tWORD)( Reg ), (tWORD)( WrData ), (tWORD)( tmp ), (tWORD) ( Mask ) ); \ } \ else { \ SUCCESS_4( (tWORD)( CPRINT_S_WRM32 ), (tWORD)( Reg ), (tWORD)( WrData ), (tWORD)( tmp ), (tWORD) ( Mask ) ); \ } \} /****************************************************************************** * Macro: WREM (Write, Read, Compare with Expected and Mask) * * Parameters: Reg The register to be written WrData The data to be written ExpData The expected data to be read Mask The mask to be used
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -