generated from hulk/gd32e23x_template
Merge branch 'feature-ultrasonic' into dev
# Conflicts: # CMakeLists.txt # inc/main.h # inc/rs485_protocol.h # src/main.c # src/rs485_protocol.c
This commit is contained in:
@@ -9,6 +9,24 @@
|
||||
|
||||
// #define DEBUG_VERBOES
|
||||
|
||||
#define POWER_SUPPLY_12V
|
||||
// #define POWER_SUPPLY_24V
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
#ifdef POWER_SUPPLY_12V
|
||||
#define POWER_VOLTAGE "12V"
|
||||
#define TIME_CORRECTION_US 250
|
||||
#define CAPTURE_VALUE_MAX 515
|
||||
#elif defined(POWER_SUPPLY_24V)
|
||||
#define POWER_VOLTAGE "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 I2C_GPIO_RCU RCU_GPIOF
|
||||
@@ -38,9 +56,41 @@
|
||||
#define LED_PORT GPIOA
|
||||
#define LED_PIN GPIO_PIN_9
|
||||
#define LED_RCU RCU_GPIOA
|
||||
#define LED_BLINK_TIMER_RCU RCU_TIMER16
|
||||
#define LED_BLINK_TIMER TIMER16
|
||||
#define LED_BLINK_IRQ TIMER16_IRQn
|
||||
#define LED_BLINK_TIMER_RCU RCU_TIMER5
|
||||
#define LED_BLINK_TIMER TIMER5
|
||||
#define LED_BLINK_IRQ TIMER5_IRQn
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
|
||||
#define US_TX_GPIO_RCU RCU_GPIOB
|
||||
#define US_TX_GPIO_PORT GPIOB
|
||||
#define US_TX_PIN GPIO_PIN_1
|
||||
#define US_TX_GPIO_AF GPIO_AF_0
|
||||
#define US_TX_RCU RCU_TIMER13
|
||||
#define US_TX_TIMER TIMER13
|
||||
#define US_TX_CH TIMER_CH_0
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
#define US_TX_DELAY_RCU RCU_TIMER15
|
||||
#define US_TX_DELAY_TIMER TIMER15
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
#define US_RX_GPIO_RCU RCU_GPIOA
|
||||
#define US_RX_EXTI_RCU RCU_CFGCMP
|
||||
#define US_RX_GPIO_PORT GPIOA
|
||||
#define US_RX_GPIO_PIN GPIO_PIN_0
|
||||
#define US_RX_EXTI_IRQ EXTI0_1_IRQn
|
||||
#define US_RX_GPIO_EXTI EXTI_0
|
||||
#define US_RX_EXTI_LINE EXTI_SOURCE_PIN0
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
#define US_ECHO_RCU RCU_TIMER16
|
||||
#define US_ECHO_TIMER TIMER16
|
||||
#define US_ECHO_CH TIMER_CH_0
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
|
@@ -55,6 +55,6 @@ void PendSV_Handler(void);
|
||||
/* this function handles SysTick exception */
|
||||
void SysTick_Handler(void);
|
||||
|
||||
void TIMER16_IRQHandler(void);
|
||||
void TIMER5_IRQHandler(void);
|
||||
|
||||
#endif /* GD32E23X_IT_H */
|
||||
|
@@ -14,6 +14,7 @@
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "ultrasonic_analog.h"
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
@@ -50,4 +51,6 @@ validation_result_t validate_data_length(uint8_t* data);
|
||||
|
||||
void gd60914_tempture_report(void);
|
||||
|
||||
void ultrasonic_distance_report(void);
|
||||
|
||||
#endif //RS485_PROTOCOL_H
|
||||
|
43
inc/ultrasonic_analog.h
Normal file
43
inc/ultrasonic_analog.h
Normal file
@@ -0,0 +1,43 @@
|
||||
//
|
||||
// Created by yelv1 on 24-12-31.
|
||||
//
|
||||
|
||||
#ifndef ULTRASONIC_ANALOG_H
|
||||
#define ULTRASONIC_ANALOG_H
|
||||
|
||||
#include "gd32e23x.h"
|
||||
#include "systick.h"
|
||||
#include "gd32e23x_libopt.h"
|
||||
#include "board_config.h"
|
||||
#include "usart.h"
|
||||
#include "fwdgt.h"
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
extern volatile bool ultrasonicMeasurementDone;
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
#define ULTRASONIC_TX_CYCLES 0x05U
|
||||
#define ULTRASONIC_TX_TIME 498 // (ms)
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
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_config(void);
|
||||
|
||||
uint16_t ultrasonic_calc_distance(void);
|
||||
|
||||
|
||||
#endif //ULTRASONIC_ANALOG_H
|
Reference in New Issue
Block a user