Bit set and bit clear driver functions in chip

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Bit set and bit clear driver functions in chip

1,005件の閲覧回数
hmyoong
Contributor III

I noticed that some of the driver functions like to read the register again during bit set or bit clear of any bit.

STATIC INLINE void Chip_SYSCTL_EnablePeriphWakeup(uint32_t periphmask)
{
LPC_SYSCTL->STARTERP1 = periphmask | (LPC_SYSCTL->STARTERP0 & ~SYSCTL_STARTERP0_RESERVED);
}

=> There is a bug here, should the code be?

STATIC INLINE void Chip_SYSCTL_EnablePeriphWakeup(uint32_t periphmask)
{
LPC_SYSCTL->STARTERP1 = periphmask | (LPC_SYSCTL->STARTERP1 & ~SYSCTL_STARTERP1_RESERVED);
}

Can this be done like this?

STATIC INLINE void Chip_SYSCTL_EnablePeriphWakeup(uint32_t periphmask)
{
 LPC_SYSCTL->STARTERP1 |= periphmask;
}

Another example

#define WKT_CTRL_RESERVED (~7)
#define WKT_CTRL_ALARMFLAG ((uint32_t) (1 << 1)) /*!< Wake-up or alarm timer flag */

STATIC INLINE void Chip_WKT_ClearIntStatus(LPC_WKT_T *pWKT)
{
 pWKT->CTRL = WKT_CTRL_ALARMFLAG | (pWKT->CTRL & ~WKT_CTRL_RESERVED);
}

Be changed to

STATIC INLINE void Chip_WKT_ClearIntStatus(LPC_WKT_T *pWKT)
{
 pWKT->CTRL &= ~WKT_CTRL_ALARMFLAG;
}
ラベル(1)
0 件の賞賛
返信
2 返答(返信)

866件の閲覧回数
jeremyzhou
NXP Employee
NXP Employee

Hi HM Yoong,

Thank you for your interest in NXP Semiconductor products and the opportunity to serve you.

I was wondering if you can tell me the name of  MCU and its correlated LPCopen library you use.
Have a great day,
TIC

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 件の賞賛
返信

866件の閲覧回数
hmyoong
Contributor III

I am using LPCXpresso824-MAX evaluation board.

0 件の賞賛
返信