From edb5a658879353f2921a7c1fe28ad9e949587a2e Mon Sep 17 00:00:00 2001 From: 0x1abin <270995079@qq.com> Date: Wed, 20 Jun 2018 14:10:53 +0800 Subject: [PATCH] fixed variable type and memset param --- examples/example_callback.c | 6 +++--- examples/example_poll.c | 2 +- multi_button.c | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/examples/example_callback.c b/examples/example_callback.c index ef05722..a7fbc6e 100644 --- a/examples/example_callback.c +++ b/examples/example_callback.c @@ -3,12 +3,12 @@ struct Button btn1; struct Button btn2; -int read_button1_GPIO() +uint8_t read_button1_GPIO() { return HAL_GPIO_ReadPin(B1_GPIO_Port, B1_Pin); } -int read_button2_GPIO() +uint8_t read_button2_GPIO() { return HAL_GPIO_ReadPin(B2_GPIO_Port, B2_Pin); } @@ -24,7 +24,7 @@ int main() button_attach(&btn1, SINGLE_CLICK, BTN1_SINGLE_Click_Handler); button_attach(&btn1, DOUBLE_CLICK, BTN1_DOUBLE_Click_Handler); button_attach(&btn1, LONG_RRESS_START, BTN1_LONG_RRESS_START_Handler); - button_attach(&btn2, LONG_PRESS_HOLD, BTN1_LONG_PRESS_HOLD_Handler); + button_attach(&btn1, LONG_PRESS_HOLD, BTN1_LONG_PRESS_HOLD_Handler); button_attach(&btn2, PRESS_DOWN, BTN2_PRESS_DOWN_Handler); button_attach(&btn2, PRESS_UP, BTN2_PRESS_UP_Handler); diff --git a/examples/example_poll.c b/examples/example_poll.c index 510f89e..054cd72 100644 --- a/examples/example_poll.c +++ b/examples/example_poll.c @@ -2,7 +2,7 @@ struct Button btn1; -int read_button1_GPIO() +uint8_t read_button1_GPIO() { return HAL_GPIO_ReadPin(B1_GPIO_Port, B1_Pin); } diff --git a/multi_button.c b/multi_button.c index d137ef1..752f2d2 100644 --- a/multi_button.c +++ b/multi_button.c @@ -19,7 +19,7 @@ static struct Button* head_handle = NULL; */ void button_init(struct Button* handle, uint8_t(*pin_level)(), uint8_t active_level) { - memset(handle, sizeof(struct Button), 0); + memset(handle, 0, sizeof(struct Button)); handle->event = (uint8_t)NONE_PRESS; handle->hal_button_Level = pin_level; handle->button_level = handle->hal_button_Level();