重构代码结构(拆分为多文件),并添加了XLSW通信协议。
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
#define ULTRASONIC_DRIVER_H
|
||||
|
||||
#include "gd32e23x.h"
|
||||
#include "i2c.h"
|
||||
|
||||
#define POWER_SUPPLY_12V
|
||||
// #define POWER_SUPPLY_24V
|
||||
@@ -25,23 +26,6 @@
|
||||
#define ULTRASONIC_CYCLES 0x05U
|
||||
#define ULTRASONIC_TRAN_US 498 // (ms)
|
||||
|
||||
#define LED_PORT GPIOA
|
||||
#define LED_PIN GPIO_PIN_9
|
||||
#define LED_RCU RCU_GPIOA
|
||||
#define LED_TIMER_RCU RCU_TIMER5
|
||||
#define LED_TIMER TIMER5
|
||||
#define LED_IRQ TIMER5_IRQn
|
||||
|
||||
#define USART_RCU RCU_USART0
|
||||
#define USART_GPIO_RCU RCU_GPIOA
|
||||
#define USART_GPIO_PORT GPIOA
|
||||
#define USART_TX_PIN GPIO_PIN_2
|
||||
#define USART_RX_PIN GPIO_PIN_3
|
||||
#define USART0_PHY USART0
|
||||
#define USART_BAUDRATE 115200U
|
||||
|
||||
#define USART_EN_PIN GPIO_PIN_4
|
||||
|
||||
#define US_TRAN_GPIO_RCU RCU_GPIOB
|
||||
#define US_TRAN_GPIO_PORT GPIOB
|
||||
#define US_TRAN_PIN GPIO_PIN_1
|
||||
@@ -65,15 +49,12 @@
|
||||
#define US_ECHO_TIMER TIMER16
|
||||
#define US_ECHO_CH TIMER_CH_0
|
||||
|
||||
void led_config(void);
|
||||
void usart_config(void);
|
||||
void UltraSonic_GPIO_Config(void);
|
||||
void UltraSonic_Transmit_Config(void);
|
||||
void UltraSonic_PwmOut_Cycles(const uint8_t cycles);
|
||||
void UltraSonic_Transmit_Delay(const uint16_t micro_second);
|
||||
void UltraSonic_ReceExti_Config(void);
|
||||
void UltraSonic_EchoTimer_Config(void);
|
||||
void UltraSonic_Receive_Config(void);
|
||||
uint16_t UltraSonic_CalcDistance(uint32_t us_value);
|
||||
void ultrasonic_gpio_config(void);
|
||||
void ultrasonic_pwm_out_cycles(const uint8_t cycles);
|
||||
void ultrasonic_transmit_delay(const uint16_t micro_second);
|
||||
void ultrasonic_rece_exti_Config(void);
|
||||
void ultrasonic_echo_timer_config(void);
|
||||
void ultrasonic_receive_config(void);
|
||||
uint16_t ultrasonic_calc_distance(uint32_t us_value);
|
||||
|
||||
#endif //ULTRASONIC_DRIVER_H
|
||||
|
||||
Reference in New Issue
Block a user