From 36ca7562096290372a76985a814d25099e8004f2 Mon Sep 17 00:00:00 2001 From: bmy <2583236812@qq.com> Date: Tue, 16 Apr 2024 09:58:51 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=9B=B4=E6=96=B0=E6=97=8B=E8=BD=AC?= =?UTF-8?q?=E7=BC=96=E7=A0=81=E5=99=A8=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/by_rt_button.c | 10 ++--- app/isr.c | 102 ++++++++++++++++++++++----------------------- 2 files changed, 55 insertions(+), 57 deletions(-) diff --git a/app/by_rt_button.c b/app/by_rt_button.c index c3bc0f5..ca306a6 100644 --- a/app/by_rt_button.c +++ b/app/by_rt_button.c @@ -17,10 +17,10 @@ uint8_t by_get_rb_status(void) void by_rb_init(void) { - gpio_init(E9, GPI, GPIO_HIGH, GPI_PULL_UP); - gpio_init(E10, GPI, GPIO_HIGH, GPI_PULL_UP); - gpio_init(E11, GPI, GPIO_HIGH, GPI_PULL_UP); + gpio_init(B9, GPI, GPIO_HIGH, GPI_PULL_UP); + gpio_init(E0, GPI, GPIO_HIGH, GPI_PULL_UP); + gpio_init(E1, GPI, GPIO_HIGH, GPI_PULL_UP); - exti_init(E9, EXTI_TRIGGER_FALLING); - exti_init(E11, EXTI_TRIGGER_BOTH); + exti_init(E0, EXTI_TRIGGER_FALLING); + exti_init(E1, EXTI_TRIGGER_BOTH); } diff --git a/app/isr.c b/app/isr.c index 28aef48..55468c1 100644 --- a/app/isr.c +++ b/app/isr.c @@ -152,6 +152,15 @@ void DVP_IRQHandler(void) void EXTI0_IRQHandler(void) { if (SET == EXTI_GetITStatus(EXTI_Line0)) { + if (rotate_button == rotate_button_none) { + if (SET == gpio_get_level(B9)) { + rotate_button = rotate_button_backward; + queue_add_element(BY_BACKWARD); + } else { + rotate_button = rotate_button_forward; + queue_add_element(BY_FORWARD); + } + } EXTI_ClearITPendingBit(EXTI_Line0); } } @@ -159,6 +168,23 @@ void EXTI0_IRQHandler(void) void EXTI1_IRQHandler(void) { if (SET == EXTI_GetITStatus(EXTI_Line1)) { + + static uint64_t time_via = 0; + system_delay_ms(10); + if (RESET == gpio_get_level(E1)) { + time_via = system_get_tick(); + } else if (SET == gpio_get_level(E1)) { + time_via = system_get_tick() - time_via; + if (time_via > LONG_PRESS_THRESHOLD_TICK) { + rotate_button = rotate_button_press_long; + queue_add_element(BY_PRESS_LONG); + + } else { + rotate_button = rotate_button_press_short; + queue_add_element(BY_PRESS_SHORT); + } + time_via = 0; + } EXTI_ClearITPendingBit(EXTI_Line1); } } @@ -199,17 +225,6 @@ void EXTI9_5_IRQHandler(void) EXTI_ClearITPendingBit(EXTI_Line8); } if (SET == EXTI_GetITStatus(EXTI_Line9)) { - - if (rotate_button == rotate_button_none) { - if (SET == gpio_get_level(E10)) { - rotate_button = rotate_button_backward; - queue_add_element(BY_BACKWARD); - } else { - rotate_button = rotate_button_forward; - queue_add_element(BY_FORWARD); - } - } - EXTI_ClearITPendingBit(EXTI_Line9); } } @@ -225,49 +240,32 @@ void EXTI15_10_IRQHandler(void) EXTI_ClearITPendingBit(EXTI_Line10); } if (SET == EXTI_GetITStatus(EXTI_Line11)) { - static uint64_t time_via = 0; - system_delay_ms(10); - if (RESET == gpio_get_level(E11)) { - time_via = system_get_tick(); - EXTI_ClearITPendingBit(EXTI_Line11); - } else if (SET == gpio_get_level(E11)) { - time_via = system_get_tick() - time_via; - if (time_via > LONG_PRESS_THRESHOLD_TICK) { - rotate_button = rotate_button_press_long; - queue_add_element(BY_PRESS_LONG); + EXTI_ClearITPendingBit(EXTI_Line11); + } + if (SET == EXTI_GetITStatus(EXTI_Line12)) { + EXTI_ClearITPendingBit(EXTI_Line12); + } + if (SET == EXTI_GetITStatus(EXTI_Line13)) { + // -----------------* ToF INT 更新中断 预置中断处理函数 *----------------- + tof_module_exti_handler(); + // -----------------* ToF INT 更新中断 预置中断处理函数 *----------------- + // 此处编写用户代码 (A13/B13..E13) 引脚触发 - } else { - rotate_button = rotate_button_press_short; - queue_add_element(BY_PRESS_SHORT); - } - time_via = 0; - EXTI_ClearITPendingBit(EXTI_Line11); - } - if (SET == EXTI_GetITStatus(EXTI_Line12)) { - EXTI_ClearITPendingBit(EXTI_Line12); - } - if (SET == EXTI_GetITStatus(EXTI_Line13)) { - // -----------------* ToF INT 更新中断 预置中断处理函数 *----------------- - tof_module_exti_handler(); - // -----------------* ToF INT 更新中断 预置中断处理函数 *----------------- - // 此处编写用户代码 (A13/B13..E13) 引脚触发 + // 此处编写用户代码 (A13/B13..E13) 引脚触发 - // 此处编写用户代码 (A13/B13..E13) 引脚触发 - - EXTI_ClearITPendingBit(EXTI_Line13); - } - if (SET == EXTI_GetITStatus(EXTI_Line14)) { - // -----------------* DM1XA 光信号 预置中断处理函数 *----------------- - dm1xa_light_callback(); - // -----------------* DM1XA 光信号 预置中断处理函数 *----------------- - EXTI_ClearITPendingBit(EXTI_Line14); - } - if (SET == EXTI_GetITStatus(EXTI_Line15)) { - // -----------------* DM1XA 声/反馈信号 预置中断处理函数 *----------------- - dm1xa_sound_callback(); - // -----------------* DM1XA 声/反馈信号 预置中断处理函数 *----------------- - EXTI_ClearITPendingBit(EXTI_Line15); - } + EXTI_ClearITPendingBit(EXTI_Line13); + } + if (SET == EXTI_GetITStatus(EXTI_Line14)) { + // -----------------* DM1XA 光信号 预置中断处理函数 *----------------- + dm1xa_light_callback(); + // -----------------* DM1XA 光信号 预置中断处理函数 *----------------- + EXTI_ClearITPendingBit(EXTI_Line14); + } + if (SET == EXTI_GetITStatus(EXTI_Line15)) { + // -----------------* DM1XA 声/反馈信号 预置中断处理函数 *----------------- + dm1xa_sound_callback(); + // -----------------* DM1XA 声/反馈信号 预置中断处理函数 *----------------- + EXTI_ClearITPendingBit(EXTI_Line15); } }