Reading a Port as a set of parallel bits

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

Reading a Port as a set of parallel bits

ソリューションへジャンプ
591件の閲覧回数
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?

ラベル(1)
0 件の賞賛
1 解決策
364件の閲覧回数
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 件の賞賛
2 返答(返信)
364件の閲覧回数
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 件の賞賛
365件の閲覧回数
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 件の賞賛