|
就是Ti送的板演示游戏程序的按键读取部分
//
// Read the state of the push buttons.
//
ulData = (GPIOPinRead(GPIO_PORTE_BASE, (GPIO_PIN_0 | GPIO_PIN_1 |
GPIO_PIN_2 | GPIO_PIN_3)) |
(GPIOPinRead(GPIO_PORTF_BASE, GPIO_PIN_1) << 3));
//
// Determine the switches that are at a different state than the debounced
// state.
//
ulDelta = ulData ^ g_ucSwitches;
以下不明白
//
// Increment the clocks by one.
//
g_ucSwitchClockA ^= g_ucSwitchClockB;
g_ucSwitchClockB = ~g_ucSwitchClockB;
//
// Reset the clocks corresponding to switches that have not changed state.
//
g_ucSwitchClockA &= ulDelta;
g_ucSwitchClockB &= ulDelta;
//
// Get the new debounced switch state.
//
g_ucSwitches &= g_ucSwitchClockA | g_ucSwitchClockB;
g_ucSwitches |= (~(g_ucSwitchClockA | g_ucSwitchClockB)) & ulData;
//
// Determine the switches that just changed debounced state.
//
ulDelta ^= (g_ucSwitchClockA | g_ucSwitchClockB); |
阿莫论坛20周年了!感谢大家的支持与爱护!!
一只鸟敢站在脆弱的枝条上歇脚,它依仗的不是枝条不会断,而是自己有翅膀,会飞。
|