Pin Data Direction

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

Pin Data Direction

1,390 Views
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) ;

Labels (1)
0 Kudos
Reply
5 Replies

1,091 Views
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 Kudos
Reply

1,063 Views
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 Kudos
Reply

1,275 Views
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 Kudos
Reply

1,240 Views
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 Kudos
Reply

1,359 Views
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 Kudos
Reply