kdsk - how to access hardware, say GPIO, inside and outside interrupts?

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

kdsk - how to access hardware, say GPIO, inside and outside interrupts?

1,410 次查看
petero
Contributor I

Using ksdk on a Cortex M4. Using kdsk if your accessing hardware from inside and outside interrupts do you need to add disable and enable interrupts around the hardware access in the main thread?  see //### below

 

Like this:
void main(void)
{
  GPIO_PinInit();   //init some kdsk hardware
  enableInterruptXYZ();
  while (1)
  {
    disableInterruptXYZ();  //### need this line?
    GPIO_WritePinOutput(); //access some kdsk hardware
    enableInterruptXYZ();  //### also need this line?
    //do other stuff
  }
}

 

InterruptXYZ-Handler()
{
GPIO_WritePinOutput(); //access the same kdsk hardware
}

标签 (1)
标记 (1)
0 项奖励
回复
3 回复数

1,202 次查看
petero
Contributor I

Ok.  So your saying GPIO_WritePinOutput() is reentrant?  If yes, seen an documentation confirming this?

0 项奖励
回复

1,202 次查看
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi,

i think GPIO_WritePinOutput() is reentrant function.

BR

xiangjun Rong

0 项奖励
回复

1,202 次查看
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi, Peter,

I think it is unnecessary to disable interrupt when  you want to set or clear a GPIO pins no matter whether the setting/clearing GPIO pin is inside main loop or ISR. when you run the code GPIO_WritePinOutput(); the GPIO pin logic changes immediately.

Hope it can help you

BR

XiangJun Rong

0 项奖励
回复