Pin Data Direction

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

Pin Data Direction

975件の閲覧回数
AnilKumar409
Contributor III

Ho to use GPIO_PDDR_PDD(x) in my code efficiently.

Earlier I have used to write it as : PTD->PDDR &= ~((1 << 15) ;

ラベル(1)
0 件の賞賛
返信
5 返答(返信)

676件の閲覧回数
AnilKumar409
Contributor III

Hi @VaneB ,

For input:  base->PDDR &= ~GPIO_PDDR_PDD(pins);

For output: base->PDDR |= GPIO_PDDR_PDD(pins);

Are these lines be passed MISRA-C 2012.?

0 件の賞賛
返信

648件の閲覧回数
VaneB
NXP TechSupport
NXP TechSupport

Hi @AnilKumar409 

The SDK driver is MISRA-C: 2012 compliant, but also is documented in the user manual that the driver still contains Violations of MISRA C 2012. Please refer to the below pictures for more information.

VaneB_0-1695400574253.png

 

0 件の賞賛
返信

860件の閲覧回数
AnilKumar409
Contributor III

hi @VaneB ,

We usually write data direction as,

For input:  base->PDDR &= ~GPIO_PDDR_PDD(pins);

For output: base->PDDR |= GPIO_PDDR_PDD(pins);

Help me avoid bitwise operators '|'and '&''.

0 件の賞賛
返信

825件の閲覧回数
VaneB
NXP TechSupport
NXP TechSupport

Hi @AnilKumar409 

The suggestion we provide for setting the pin direction always uses '|' and '&''.

As I mentioned before you can refer to the functions PINS_GPIO_SetPinDirection() or PINS_GPIO_SetPinsDirection(). Also, you can refer to the examples provided in the S32K1xx Series Cookbook.

 

0 件の賞賛
返信

944件の閲覧回数
VaneB
NXP TechSupport
NXP TechSupport

Hi @AnilKumar409 

The macro needs to be used as base->PDDR = GPIO_PDDR_PDD(pins);

You can also refer to the SDK functions PINS_GPIO_SetPinDirection() and PINS_GPIO_SetPinsDirection() which use this macro. 

 

B.R.

VaneB

0 件の賞賛
返信