📄 reset.h
字号:
\
SetGroupBits16(REG16(RegisterName), \
(GroupBitName ## _POS), \
(GroupBitName ## _NUMB), \
(~(GroupBitName ## _RES_VAL))); \
if(GetGroupBits16(REG16(RegisterName),GroupBitName ## _POS,GroupBitName ## _NUMB)!=\
GetGroupBits16(~(GroupBitName ## _RES_VAL),0,GroupBitName ## _NUMB)) \
{ \
RES_Set( START_ARRAY_DATA); \
RES_Set(GroupBitName ## _BAD_RESET_VALUE); \
RES_Set(DATA_STORE); \
RES_Set(0x0001); \
RES_Set(DATAEXPECTED_DATAREAD); \
RES_Set(GetGroupBits16(~(GroupBitName ## _RES_VAL),0,GroupBitName ## _NUMB)); \
RES_Set(GetGroupBits16(REG16(RegisterName),GroupBitName ## _POS,GroupBitName ## _NUMB)); \
RES_Set( END_ARRAY_DATA); \
RES_Set( TEST_BAD); \
} \
else \
{ \
RES_Set( TEST_OK); \
} \
SetGroupBits16(REG16(RegisterName), \
(GroupBitName ## _POS), \
(GroupBitName ## _NUMB), \
(GroupBitName ## _RES_VAL))
// ==========================================================================================
// Macro Name : MODIFY_REGISTER_RESET_VALUE16
// Description : Some registers are R/W. To test them we must write and
// reread a value. First this macro writes the complemented RESET VALUE.
// Then it rereads it. It ends reseting the register to its initial reset value.
// Return value : None but writes errors in the spy. The first code written
// is the error associated to the field. Then writes a DATA_STORE code followed by
// 0x0001 to tell the user it is not a reset value problem but a write/read problem.
#define MODIFY_REGISTER_RESET_VALUE16(RegisterName) \
\
REG16(RegisterName)=(~(RegisterName ## _RES_VAL))&0xFFFF; \
if((REG16(RegisterName)&0xFFFF)!=((~(RegisterName ## _RES_VAL))&0xFFFF))\
{ \
RES_Set(RegisterName ## _BAD_RESET_VALUE); \
RES_Set(DATA_STORE); \
RES_Set(0x0001); \
RES_Set(DATAEXPECTED_DATAREAD); \
RES_Set(RegisterName ## _RES_VAL); \
RES_Set(REG16(RegisterName)); \
} \
REG16(RegisterName)=(RegisterName ## _RES_VAL);
// ==========================================================================================
// Macro Name : MODIFY_FIELD_UNDEFINED16
// Description : Some registers are R/W. To test them we must write and
// reread a value. First this macro writes the complemented RESET VALUE.
// Then it rereads it. It ends reseting the field to its reset value.
// Return value : None but writes errors in the spy. The first code written
// is the error associated to the field. Then writes a DATA_STORE code followed by
// 0x0001 to tell the user it is not a reset value problem but a write/read problem.
#define MODIFY_FIELD_UNDEFINED16(RegisterName,GroupBitName) \
\
SetGroupBits16(REG16(RegisterName), \
(GroupBitName ## _POS), \
(GroupBitName ## _NUMB), \
(~(GroupBitName ## _SET_VAL))); \
if(GetGroupBits16(REG16(RegisterName),GroupBitName ## _POS,GroupBitName ## _NUMB)!=\
GetGroupBits16(~(GroupBitName ## _SET_VAL),0,GroupBitName ## _NUMB)) \
{ \
RES_Set(GroupBitName ## _BAD_RESET_VALUE); \
RES_Set(DATA_STORE); \
RES_Set(0x0002); \
RES_Set(DATAEXPECTED_DATAREAD); \
RES_Set(GetGroupBits16(~(GroupBitName ## _SET_VAL),0,GroupBitName ## _NUMB));\
RES_Set(GetGroupBits16(REG16(RegisterName),GroupBitName ## _POS,GroupBitName ## _NUMB));\
} \
else \
{ \
SetGroupBits16(REG16(RegisterName), \
(GroupBitName ## _POS), \
(GroupBitName ## _NUMB), \
(GroupBitName ## _SET_VAL)); \
if(GetGroupBits16(REG16(RegisterName), \
(GroupBitName ## _POS), \
(GroupBitName ## _NUMB))!= \
((GroupBitName ## _SET_VAL))) \
{ \
RES_Set(GroupBitName ## _BAD_RESET_VALUE); \
RES_Set(DATA_STORE); \
RES_Set(0x0003); \
RES_Set(DATAEXPECTED_DATAREAD); \
RES_Set(GroupBitName ## _SET_VAL); \
RES_Set(GetGroupBits16(REG16(RegisterName), \
(GroupBitName ## _POS), \
(GroupBitName ## _NUMB))); \
} \
}
// ==========================================================================================
// Macro Name : MODIFY_REGISTER_UNDEFINED16
// Description : Some registers are R/W. To test them we must write and
// reread a value. First this macro writes the complemented RESET VALUE.
// Then it rereads it. It ends reseting the register to its initial reset value.
// Return value : None but writes errors in the spy. The first code written
// is the error associated to the field. Then writes a DATA_STORE code followed by
// 0x0001 to tell the user it is not a reset value problem but a write/read problem.
#define MODIFY_REGISTER_UNDEFINED16(RegisterName) \
\
REG16(RegisterName)=(~(RegisterName ## _SET_VAL))&0xFFFF; \
if((REG16(RegisterName)&0xFFFF)!=((~(RegisterName ## _SET_VAL))&0xFFFF))\
{ \
RES_Set(RegisterName ## _BAD_RESET_VALUE); \
RES_Set(DATA_STORE); \
RES_Set(0x0002); \
RES_Set(DATAEXPECTED_DATAREAD); \
RES_Set(~RegisterName ## _SET_VAL); \
RES_Set(REG16(RegisterName)); \
} \
else \
{ \
REG16(RegisterName)=(RegisterName ## _SET_VAL)&0xFFFF; \
if((REG16(RegisterName)&0xFFFF)!=(((RegisterName ## _SET_VAL)&0xFFFF)))\
{ \
RES_Set(RegisterName ## _BAD_RESET_VALUE); \
RES_Set(DATA_STORE); \
RES_Set(0x0003); \
RES_Set(DATAEXPECTED_DATAREAD); \
RES_Set(RegisterName ## _SET_VAL); \
RES_Set(REG16(RegisterName)); \
} \
}
// ============================================
// McBSP access macros
// ============================================
/*
Macros available are :
======================
MCBSP_GET_GROUP_BITS16
MCBSP_SET_GROUP_BITS16
MCBSP_TEST_FIELD_RESET_VALUE !!! 16 is implicit
MCBSP_MODIFY_FIELD_RESET_VALUE16
Register access do not need MCBSP specific macros.
*/
// ==========================================================================================
// Macro Name :MCBSP_GET_GROUP_BITS16
// Description : Idem as GetGroupBits16 but using the position indexing the
// end of the field instead of the begining of the field.
#define MCBSP_GET_GROUP_BITS16(register,position,width) \
(((register) & ((0xFFFF>>(16-(width)))<< \
((position)-(width)+1)))>> \
((position)-(width)+1))
#define MCBSP_GET_GROUP_BITS16CONST(value,width) \
((value) & (0xFFFF>>(16-(width))))
// ==========================================================================================
// Macro Name :MCBSP_SET_GROUP_BITS16
// Description : Idem as SetGroupBits16 but using the position indexing the
// end of the field instead of the begining of the field.
#define MCBSP_SET_GROUP_BITS16(register,position,width,value) \
register&=~((0xFFFF>>(16-(width)))<<((position)-(width)+1));\
register|=((value&(0xFFFF >> (16-(width)) ))<<((position)-(width)+1))
// ==========================================================================================
// Macro Name :MCBSP_TEST_FIELD_RESET_VALUE
// Same as TEST_FIELD_RESET_VALUE using the MCBSP config
#define MCBSP_TEST_FIELD_RESET_VALUE(RegisterName,GroupBitName) \
if(MCBSP_GET_GROUP_BITS16(REG16(RegisterName),(GroupBitName), \
(GroupBitName ## _SZ))!=(GroupBitName ## _RES_VAL)) \
RES_Set(GroupBitName ## _BAD_RESET_VALUE);
// ==========================================================================================
// Macro Name : MCBSP_MODIFY_FIELD_RESET_VALUE16
// Description : Some registers are R/W. To test them we must write and
// reread a value. First this macro writes the complemented RESET VALUE.
// Then it rereads it. It ends reseting the field to its reset value.
// Return value : None but writes errors in the spy. The first code written
// is the error associated to the field. Then writes a DATA_STORE code followed by
// 0x0001 to tell the user it is not a reset value problem but a write/read problem.
#define MCBSP_MODIFY_FIELD_RESET_VALUE16(RegisterName,GroupBitName)\
\
MCBSP_SET_GROUP_BITS16(REG16(RegisterName), \
(GroupBitName), \
(GroupBitName ## _SZ), \
(~(GroupBitName ## _RES_VAL))); \
if(MCBSP_GET_GROUP_BITS16(REG16(RegisterName), \
(GroupBitName), \
(GroupBitName ## _SZ))!= \
(MCBSP_GET_GROUP_BITS16CONST(~(GroupBitName ## _RES_VAL),\
(GroupBitName ## _SZ) ))) \
{ \
RES_Set(GroupBitName ## _BAD_RESET_VALUE); \
RES_Set(DATA_STORE); \
RES_Set(0x0001); \
RES_Set(DATAEXPECTED_DATAREAD); \
RES_Set(MCBSP_GET_GROUP_BITS16CONST(~(GroupBitName ## _RES_VAL),GroupBitName ## _SZ));\
RES_Set(MCBSP_GET_GROUP_BITS16(REG16(RegisterName),GroupBitName,GroupBitName ## _SZ)); \
} \
MCBSP_SET_GROUP_BITS16(REG16(RegisterName), \
(GroupBitName), \
(GroupBitName ## _SZ), \
(GroupBitName ## _RES_VAL));
// ============================================
// 8 bits access macros
// ============================================
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -