first version OK!!!!!

This commit is contained in:
2024-09-25 15:42:11 +08:00
parent 392ccaba81
commit 6581d6ff88
4 changed files with 34 additions and 60 deletions

View File

@@ -33,6 +33,7 @@ OF SUCH DAMAGE.
*/
#include "gd32e23x_it.h"
#include <stdio.h>
#include "main.h"
#include "systick.h"
#include "ultrasonic_driver.h"
@@ -118,31 +119,15 @@ void TIMER5_IRQHandler(void) {
}
}
void TIMER14_IRQHandler(void)
{
if (timer_flag_get(TIMER14, TIMER_FLAG_CH0))
{
timer_flag_clear(TIMER14, TIMER_FLAG_CH0);
uint32_t capture_value = timer_channel_capture_value_register_read(TIMER14, TIMER_CH_0);
timer_disable(TIMER14);
}
}
void TIMER15_IRQHandler(void) {
if (timer_interrupt_flag_get(TIMER15, TIMER_INT_FLAG_UP) == SET)
{
timer_interrupt_flag_clear(TIMER15, TIMER_INT_FLAG_UP);
exti_interrupt_enable(EXTI_0);
timer_enable(TIMER14);
exti_interrupt_enable(EXTI_0); // turn on hardware external input interrupt
/*
* GPIO Toggle will be delete when the project is ready
*/
gpio_bit_toggle(GPIOA, GPIO_PIN_7);
/*******************************************************/
timer_counter_value_config(TIMER16, 0);
timer_enable(TIMER16); // turn on timer to calculate the first ultrasonic echo time
timer_disable(TIMER15);
}
@@ -153,13 +138,11 @@ void EXTI0_1_IRQHandler(void) {
{
exti_interrupt_flag_clear(EXTI_0);
/*
* GPIO Toggle will be delete when the project is ready
*/
gpio_bit_toggle(GPIOA, GPIO_PIN_5);
/*******************************************************/
capture_value = timer_channel_capture_value_register_read(TIMER16, TIMER_CH_0);
// timer_event_software_generate(TIMER14, TIMER_EVENT_SRC_CH0G);
// printf("aaa\n");
timer_disable(TIMER16);
exti_interrupt_disable(EXTI_0);
}