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?
Solved! Go to Solution.
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
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
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