clean shit

This commit is contained in:
yelvlab 2024-09-24 09:36:22 +08:00
parent 0dbf154070
commit f077443081
3 changed files with 4 additions and 48 deletions

View File

@ -98,6 +98,6 @@ void SysTick_Handler(void)
{
}
void TIMER13_IRQHandler(void) {
void TIMER2_IRQHandler(void) {
}

View File

@ -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);

View File

@ -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);
}
}