Add over-range judgment printing and compilation conditions under different voltages

This commit is contained in:
2024-09-25 18:41:52 +08:00
parent 9cdd0008a5
commit 2c96ee7848
3 changed files with 27 additions and 22 deletions

View File

@@ -7,8 +7,21 @@
#include "gd32e23x.h"
#define POWER_SUPPLY_12V
// #define POWER_SUPPLY_24V
#ifdef POWER_SUPPLY_12V
#define TIME_CORRECTION_US 250
#define CAPTURE_VALUE_MAX 515
#elif defined(POWER_SUPPLY_24V)
#define TIME_CORRECTION_US 230
#define CAPTURE_VALUE_MAX 550
#else
#error "Please define either POWER_SUPPLY_12V or POWER_SUPPLY_24V"
#endif
#define ULTRASONIC_CYCLES 0x05U
#define ULTRASONIC_TRAN_US 100 // (ms)
#define ULTRASONIC_TRAN_US 500 // (ms)
#define LED_PORT GPIOA
#define LED_PIN GPIO_PIN_9
@@ -48,16 +61,11 @@
#define US_ECHO_TIMER TIMER16
#define US_ECHO_CH TIMER_CH_0
#define SOUND_SPEED 340 // m/s
#define TIME_CORRECTION_US 250
void led_config(void);
void usart_config(void);
void ultrasonic_config(void);
void ultrasonic_transmit_config(void);
void ultrasonic_pwm_out_cycles(const uint8_t cycles);
void ultrasonic_transmit_delay(const uint16_t micro_second);
void recevice_exti_config(void);
void ultrasonic_echo_timer_config(void);