小Qhhui 发表于 2020-3-19 10:06
例程中有关于中断的相关代码,一般是使用HAL_ISR_FUNCTION
IO中断的话您可以参考下 http://www.deyisupport.com/question_answer/wireless_connectivity/bluetooth/f/103/t/25602.aspx
明白了,中断后按键回调函数OnBoard_KeyCallback会查询按键状态,同时关闭中断直到按键释放。
/* If any key is currently pressed down and interrupt
is still enabled, disable interrupt and switch to polling */
if( keys != 0 )
[
if( OnboardKeyIntEnable == HAL_KEY_INTERRUPT_ENABLE )
[
OnboardKeyIntEnable = HAL_KEY_INTERRUPT_DISABLE;
HalKeyConfig( OnboardKeyIntEnable, OnBoard_KeyCallback);
]
]
/* If no key is currently pressed down and interrupt
is disabled, enable interrupt and turn off polling */
else
[
if( OnboardKeyIntEnable == HAL_KEY_INTERRUPT_DISABLE )
[
OnboardKeyIntEnable = HAL_KEY_INTERRUPT_ENABLE;
HalKeyConfig( OnboardKeyIntEnable, OnBoard_KeyCallback);
]
]