Wrapping the receive configuration functions together
This commit is contained in:
@@ -132,8 +132,8 @@ void ultrasonic_transmit_delay(const uint16_t micro_second) {
|
||||
timer_initpara.repetitioncounter =0;
|
||||
timer_init(US_TRAN_DELAY_TIMER, &timer_initpara);
|
||||
|
||||
timer_auto_reload_shadow_enable(US_TRAN_DELAY_TIMER); //使能自动影子重载
|
||||
timer_interrupt_enable(US_TRAN_DELAY_TIMER, TIMER_INT_UP); // 使能自动重载中断
|
||||
timer_auto_reload_shadow_enable(US_TRAN_DELAY_TIMER);
|
||||
timer_interrupt_enable(US_TRAN_DELAY_TIMER, TIMER_INT_UP);
|
||||
nvic_irq_enable(TIMER15_IRQn, 1U);
|
||||
}
|
||||
|
||||
@@ -170,10 +170,16 @@ void ultrasonic_echo_timer_config(void) {
|
||||
timer_icinitpara.icpolarity = TIMER_IC_POLARITY_BOTH_EDGE;
|
||||
timer_icinitpara.icselection = TIMER_IC_SELECTION_INDIRECTTI;
|
||||
timer_icinitpara.icprescaler = TIMER_IC_PSC_DIV1;
|
||||
timer_icinitpara.icfilter = 0x03; // 设置滤波器
|
||||
timer_icinitpara.icfilter = 0x03;
|
||||
timer_input_capture_config(US_ECHO_TIMER, US_ECHO_CH, &timer_icinitpara);
|
||||
}
|
||||
|
||||
void ultrasonic_recevice_config(void) {
|
||||
ultrasonic_transmit_delay(TIME_CORRECTION_US);
|
||||
recevice_exti_config();
|
||||
ultrasonic_echo_timer_config();
|
||||
}
|
||||
|
||||
uint16_t calculate_distance(uint32_t us_value) {
|
||||
uint16_t distace = (TIME_CORRECTION_US + us_value) * 17;
|
||||
/*
|
||||
|
Reference in New Issue
Block a user