diff --git a/examples/example_callback.c b/examples/example_callback.c index 2c9f267..99ffff2 100644 --- a/examples/example_callback.c +++ b/examples/example_callback.c @@ -15,15 +15,10 @@ uint8_t read_button_GPIO(uint8_t button_id) { case btn1_id: return HAL_GPIO_ReadPin(B1_GPIO_Port, B1_Pin); - break; - case btn2_id: return HAL_GPIO_ReadPin(B2_GPIO_Port, B2_Pin); - break; - default: return 0; - break; } } diff --git a/examples/example_poll.c b/examples/example_poll.c index 162b357..eb06029 100644 --- a/examples/example_poll.c +++ b/examples/example_poll.c @@ -10,11 +10,8 @@ uint8_t read_button_GPIO(uint8_t button_id) { case btn1_id: return HAL_GPIO_ReadPin(B1_GPIO_Port, B1_Pin); - break; - default: return 0; - break; } } @@ -22,19 +19,19 @@ uint8_t read_button_GPIO(uint8_t button_id) int main() { static uint8_t btn1_event_val; - + button_init(&btn1, read_button_GPIO, 0, btn1_id); button_start(&btn1); - + //make the timer invoking the button_ticks() interval 5ms. //This function is implemented by yourself. - __timer_start(button_ticks, 0, 5); - - while(1) + __timer_start(button_ticks, 0, 5); + + while(1) { if(btn1_event_val != get_button_event(&btn1)) { btn1_event_val = get_button_event(&btn1); - + if(btn1_event_val == PRESS_DOWN) { //do something } else if(btn1_event_val == PRESS_UP) { @@ -45,4 +42,3 @@ int main() } } } -