Explain content of ph_Reg.h file of PN7462 Firmware Example

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

Explain content of ph_Reg.h file of PN7462 Firmware Example

跳至解决方案
2,060 次查看
kashyap_gada
Contributor II

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

 

标签 (1)
标记 (1)
0 项奖励
回复
1 解答
2,031 次查看
gusarambula
NXP TechSupport
NXP TechSupport

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

在原帖中查看解决方案

2 回复数
2,022 次查看
kashyap_gada
Contributor II

Thank you Gustavo!!!

0 项奖励
回复
2,032 次查看
gusarambula
NXP TechSupport
NXP TechSupport

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