完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
在阅读EK-TM4C123GXL关于FreeRTOS的例程时,有个地方没搞懂。下面这个函数用来检测按键状态,其中ui8SwitchClockA和ui8SwitchClockB的作用是什么?
该函数是否能实现软件去抖动,如何实现的?谢谢指导。 uint8_t ButtonsPoll(uint8_t *pui8Delta, uint8_t *pui8RawState) [ uint32_t ui32Delta; uint32_t ui32Data; static uint8_t ui8SwitchClockA = 0; static uint8_t ui8SwitchClockB = 0; // // Read the raw state of the push buttons. Save the raw state // (inverting the bit sense) if the caller supplied storage for the // raw value. // ui32Data = (ROM_GPIOPinRead(BUTTONS_GPIO_BASE, ALL_BUTTONS)); if(pui8RawState) [ *pui8RawState = (uint8_t)~ui32Data; ] // // Determine the switches that are at a different state than the debounced // state. // ui32Delta = ui32Data ^ g_ui8ButtonStates; // // Increment the clocks by one. // ui8SwitchClockA ^= ui8SwitchClockB; ui8SwitchClockB = ~ui8SwitchClockB; // // Reset the clocks corresponding to switches that have not changed state. // ui8SwitchClockA &= ui32Delta; ui8SwitchClockB &= ui32Delta; // // Get the new debounced switch state. // g_ui8ButtonStates &= ui8SwitchClockA | ui8SwitchClockB; g_ui8ButtonStates |= (~(ui8SwitchClockA | ui8SwitchClockB)) & ui32Data; // // Determine the switches that just changed debounced state. // ui32Delta ^= (ui8SwitchClockA | ui8SwitchClockB); // // Store the bit mask for the buttons that have changed for return to // caller. // if(pui8Delta) [ *pui8Delta = (uint8_t)ui32Delta; ] // // Return the debounced buttons states to the caller. Invert the bit // sense so that a '1' indicates the button is pressed, which is a // sensible way to interpret the return value. // return(~g_ui8ButtonStates); ] |
|
相关推荐
3 个讨论
|
|
只有小组成员才能发言,加入小组>>
TMS320F28377D:新做了以377d为芯片的板子,上电后芯片复位引脚出现方波请问如何解决?
1888 浏览 0 评论
TPS55340通电后输入端保险丝烧断,芯片输入和GND之间短路
3641 浏览 4 评论
5027 浏览 0 评论
请问如何用DM368对RGB格式的图片数据进行编码生成JPEG格式图片?
1732 浏览 1 评论
9353 浏览 8 评论
CC3100BOOST使用CC3200lunchXL进行烧录
664浏览 2评论
707浏览 1评论
TMS320F28034: 利用C2prog通过SCI给TMS320F28034烧录程序,出现错误提示:Bootloading... failed (invalid echo)!
668浏览 1评论
1186浏览 1评论
求DLPC350 Programmer’s Guide User's Guide 中文版说明书
1189浏览 1评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-4-20 06:57 , Processed in 0.801764 second(s), Total 67, Slave 56 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号