From f077443081f87d6aaf0bc3c18e88eb866c96a1ec Mon Sep 17 00:00:00 2001 From: yelvlab Date: Tue, 24 Sep 2024 09:36:22 +0800 Subject: [PATCH] clean shit --- src/gd32e23x_it.c | 2 +- src/input_capture_exp.c | 46 ----------------------------------------- src/main.c | 4 +++- 3 files changed, 4 insertions(+), 48 deletions(-) diff --git a/src/gd32e23x_it.c b/src/gd32e23x_it.c index a9e86f4..9131621 100644 --- a/src/gd32e23x_it.c +++ b/src/gd32e23x_it.c @@ -98,6 +98,6 @@ void SysTick_Handler(void) { } -void TIMER13_IRQHandler(void) { +void TIMER2_IRQHandler(void) { } \ No newline at end of file diff --git a/src/input_capture_exp.c b/src/input_capture_exp.c index 45447e5..6971f14 100644 --- a/src/input_capture_exp.c +++ b/src/input_capture_exp.c @@ -64,56 +64,15 @@ void input_capture_config(void) */ void pwm_config(void) { - rcu_periph_clock_enable(RCU_GPIOB); - - gpio_mode_set(GPIOB, GPIO_MODE_AF, GPIO_PUPD_NONE, GPIO_PIN_1); - gpio_output_options_set(GPIOB, GPIO_OTYPE_PP, GPIO_OSPEED_50MHZ, GPIO_PIN_1); - gpio_af_set(GPIOB, GPIO_AF_0, GPIO_PIN_1); - timer_oc_parameter_struct timer_ocinitpara; timer_parameter_struct timer_initpara; - rcu_periph_clock_enable(RCU_TIMER13); - timer_deinit(TIMER13); - - timer_struct_para_init(&timer_initpara); - timer_initpara.prescaler = 71; - timer_initpara.alignedmode = TIMER_COUNTER_EDGE; - timer_initpara.counterdirection = TIMER_COUNTER_UP; - timer_initpara.period = 999; - timer_initpara.clockdivision = TIMER_CKDIV_DIV1; - timer_init(TIMER13, &timer_initpara); - - timer_channel_output_struct_para_init(&timer_ocinitpara); - timer_ocinitpara.outputstate =TIMER_CCX_ENABLE; - timer_ocinitpara.outputnstate =TIMER_CCXN_DISABLE; - timer_ocinitpara.ocpolarity =TIMER_OC_POLARITY_HIGH; - timer_ocinitpara.ocnpolarity =TIMER_OCN_POLARITY_HIGH; - timer_ocinitpara.ocidlestate =TIMER_OC_IDLE_STATE_LOW; - timer_ocinitpara.ocnidlestate =TIMER_OCN_IDLE_STATE_LOW; - timer_channel_output_config(TIMER13, TIMER_CH_0, &timer_ocinitpara); - - timer_channel_output_pulse_value_config(TIMER13, TIMER_CH_0, 500); - timer_channel_output_mode_config(TIMER13, TIMER_CH_0, TIMER_OC_MODE_PWM0); - timer_auto_reload_shadow_enable(TIMER13); - - // timer_interrupt_enable(TIMER13, TIMER_INT_UP); - // nvic_irq_enable(TIMER13_IRQn, 1); - timer_enable(TIMER13); -/*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&*/ rcu_periph_clock_enable(RCU_GPIOA); - gpio_mode_set(GPIOA, GPIO_MODE_AF, GPIO_PUPD_NONE, GPIO_PIN_10); - gpio_output_options_set(GPIOA, GPIO_OTYPE_PP, GPIO_OSPEED_50MHZ, GPIO_PIN_10); - gpio_af_set(GPIOA, GPIO_AF_2, GPIO_PIN_10); - gpio_mode_set(GPIOA, GPIO_MODE_AF, GPIO_PUPD_NONE, GPIO_PIN_9); gpio_output_options_set(GPIOA, GPIO_OTYPE_PP, GPIO_OSPEED_50MHZ, GPIO_PIN_9); gpio_af_set(GPIOA, GPIO_AF_2, GPIO_PIN_9); - // timer_oc_parameter_struct timer_ocinitpara; - // timer_parameter_struct timer_initpara; - rcu_periph_clock_enable(RCU_TIMER0); timer_deinit(TIMER0); @@ -132,13 +91,8 @@ void pwm_config(void) timer_ocinitpara.ocnpolarity = TIMER_OCN_POLARITY_HIGH; timer_ocinitpara.ocidlestate = TIMER_OC_IDLE_STATE_LOW; timer_ocinitpara.ocnidlestate = TIMER_OCN_IDLE_STATE_LOW; - timer_channel_output_config(TIMER0, TIMER_CH_2, &timer_ocinitpara); timer_channel_output_config(TIMER0, TIMER_CH_1, &timer_ocinitpara); - timer_channel_output_pulse_value_config(TIMER0, TIMER_CH_2, 500); - timer_channel_output_mode_config(TIMER0, TIMER_CH_2, TIMER_OC_MODE_PWM0); - timer_channel_output_shadow_config(TIMER0, TIMER_CH_2, TIMER_OC_SHADOW_DISABLE); - timer_channel_output_pulse_value_config(TIMER0, TIMER_CH_1, 500); timer_channel_output_mode_config(TIMER0, TIMER_CH_1, TIMER_OC_MODE_PWM1); timer_channel_output_shadow_config(TIMER0, TIMER_CH_1, TIMER_OC_SHADOW_DISABLE); diff --git a/src/main.c b/src/main.c index c3536a1..7975186 100644 --- a/src/main.c +++ b/src/main.c @@ -42,11 +42,13 @@ int main(void) printf("\r\n"); printf("START!\r\n"); - printf("XLSW-3DP-UltraSonic Analog 300K!\r\n"); + printf("Input Capture Test!\r\n"); printf("\r\n"); while(1) { + printf("Input Capture Test!\r\n"); + delay_ms(500); } }