Explain content of ph_Reg.h file of PN7462 Firmware Example

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Explain content of ph_Reg.h file of PN7462 Firmware Example

Jump to solution
2,064 Views
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

 

Labels (1)
Tags (1)
0 Kudos
Reply
1 Solution
2,035 Views
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

View solution in original post

2 Replies
2,026 Views
kashyap_gada
Contributor II

Thank you Gustavo!!!

0 Kudos
Reply
2,036 Views
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