Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

在C51平台使用中需要注意下,上电后就会触发一次按下或者抬起事件 #9

Open
lemonKakaKaKa opened this issue Mar 3, 2020 · 1 comment

Comments

@lemonKakaKaKa
Copy link

开发环境如下:uvision V4.10
image

按键初始化函数需要修改下:
image

猜测是编译器有问题。

@lemonKakaKaKa
Copy link
Author

/**

  • @brief Initializes the button struct handle.
  • @param handle: the button handle strcut.
  • @param pin_level: read the HAL GPIO of the connet button level.
  • @param active_level: pressed GPIO level.
  • @RetVal None
    /
    void button_init(struct Button
    handle, uint8_t(*pin_level)(), uint8_t active_level)
    {
    memset(handle, 0, sizeof(struct Button));
    handle->event = (uint8_t)NONE_PRESS;
    handle->hal_button_Level = pin_level;
    handle->active_level = active_level;
    handle->btn_level = !active_level;
    // handle->btn_level = handle->hal_button_Level(); // Keil C51在这里不能调用这个函数,否则会出现令人费解的错误,如果读取到的点平为
    // 高电平,这个函数里handle->btn_level会被设置为1,但是实际上handle所指向的
    // 结构体中的btn_level还是0。!!!
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant