Could some body explain what is happening in the following code snippet from ph_Reg.h of PN7462 firmware example ----
Specifically plain get field, get field ns and get field ns sc.
/** \def PH_REG_GET_FIELD
* Get the value of REG_NAME Register's FIELD_NAME field. Shifting _is_ done */
/** \def PH_REG_GET_FIELD_NS
* Same as #PH_REG_GET_FIELD but do not shift */
#define PH_REG_GET_FIELD(REG_NAME,FIELD_NAME) \
( \
((REG_NAME ## _ ## FIELD_NAME ## _MASK) \
& (REG_NAME ## _R | PH_REG_GET_SC(REG_NAME))) \
>> (REG_NAME ## _ ## FIELD_NAME ## _POS))
#define PH_REG_GET_FIELD_NS(REG_NAME,FIELD_NAME) \
( \
((REG_NAME ## _ ## FIELD_NAME ## _MASK) \
& (REG_NAME ## _R | PH_REG_GET_SC(REG_NAME))))
/** \def PH_REG_GET_FIELD_NS_SC
* Get the value of REG_NAME Register's FIELD_NAME field. Shifting _is_not_ done */
#define PH_REG_GET_FIELD_NS_SC(REG_NAME,REG_MASK) \
( \
((PH_REG_GET_SC(REG_NAME))) \
& (REG_MASK))
Regards
已解决! 转到解答。
Hello kashyap_gada,
You may find brief descriptions of these macros on the PN7462 FW API Guide.
These functions get the value of the REG_NAME register’s FIELD NAME field.
The differences would be:
PH_REG_GET_FIELD: Shifting is done (default, which is why is not specified on the function name)
PH_REG_GET_FIELD_NS: Shifting is NOT done, which is why it ads the NS (No Shifting) to the function name.
PH_REG_GET_FIELD_NS_SC: Shifting is NOT done, and the field is selected through a register mask.
Other functions defined with _SC simply do not check if the register is read only or not so that may be the reason why it uses the mask instead. Perhaps SC stands for scilicet (which would be equivalent to “one is permitted to know”).
I hope that this information helps!
Regards,
Gustavo
Hello kashyap_gada,
You may find brief descriptions of these macros on the PN7462 FW API Guide.
These functions get the value of the REG_NAME register’s FIELD NAME field.
The differences would be:
PH_REG_GET_FIELD: Shifting is done (default, which is why is not specified on the function name)
PH_REG_GET_FIELD_NS: Shifting is NOT done, which is why it ads the NS (No Shifting) to the function name.
PH_REG_GET_FIELD_NS_SC: Shifting is NOT done, and the field is selected through a register mask.
Other functions defined with _SC simply do not check if the register is read only or not so that may be the reason why it uses the mask instead. Perhaps SC stands for scilicet (which would be equivalent to “one is permitted to know”).
I hope that this information helps!
Regards,
Gustavo