Pin Data Direction

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

Pin Data Direction

959 次查看
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 回复数

660 次查看
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 项奖励

632 次查看
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 项奖励

844 次查看
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 项奖励

809 次查看
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 项奖励

928 次查看
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 项奖励