Reading a Port as a set of parallel bits

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

Reading a Port as a set of parallel bits

Jump to solution
838 Views
davepfaltzgraff
Senior Contributor I

In KSDK1, I was able to read a port as a set or parallel bits using the GPIO_HAL_ReadPortInput(FP_BASE) function.

 

It appears that in KSDK2, this has been removed and I can only find routines to read individual bits on the port using the GPIO_ReadPinInput(FP_BASE, PIN_NO) routine.

 

How can I read the set if bits in KSDK2?

Labels (1)
0 Kudos
Reply
1 Solution
611 Views
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi, David,

This is the api function GPIO_ReadPinInput() body:

static inline uint32_t GPIO_ReadPinInput(GPIO_Type *base, uint32_t pin)

{

    return (((base->PDIR) >> pin) & 0x01U);

}

You see that the function only read the specified bit instead of all the bits in PDIR register.

If you want to read all the PDIR register, you can define a function yourself.

for example

static inline uint32_t GPIO_ReadInput(GPIO_Type *base)

{

    return (base->PDIR);

}

Hope it can help you.

BR

XiangJun Rong

View solution in original post

0 Kudos
Reply
2 Replies
611 Views
davepfaltzgraff
Senior Contributor I

Hi XiangJun Rong,

That's what I had thought, but when I tried it, I didn't get the results I expected. My problem was some code brought in from an old project that was driving the pins low when I expected them to be inputs. Now that I have eliminated that code, the system is now operating as expected.

Thanks,

Dave

0 Kudos
Reply
612 Views
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi, David,

This is the api function GPIO_ReadPinInput() body:

static inline uint32_t GPIO_ReadPinInput(GPIO_Type *base, uint32_t pin)

{

    return (((base->PDIR) >> pin) & 0x01U);

}

You see that the function only read the specified bit instead of all the bits in PDIR register.

If you want to read all the PDIR register, you can define a function yourself.

for example

static inline uint32_t GPIO_ReadInput(GPIO_Type *base)

{

    return (base->PDIR);

}

Hope it can help you.

BR

XiangJun Rong

0 Kudos
Reply