generated from hulk/gd32e23x_template
Compare commits
8 Commits
e940c69d49
...
feature-ul
Author | SHA1 | Date | |
---|---|---|---|
ca332e9ea1 | |||
7ffb8c0612 | |||
7075fd16ea | |||
f7ef4b5af7 | |||
a0ba0c6bd1 | |||
389d480da7 | |||
c12273fd46 | |||
e86f8b0dd3 |
@@ -6,7 +6,7 @@ set(PROJECT_NAME "XLSW_3DP_US-IR")
|
||||
project(${PROJECT_NAME})
|
||||
|
||||
set(VERSION_MAJOR 0)
|
||||
set(VERSION_MINOR 1)
|
||||
set(VERSION_MINOR 2)
|
||||
set(VERSION_PATCH 0)
|
||||
set(VERSION "V${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}")
|
||||
string(TIMESTAMP CURRENT_DATE "%Y-%m-%d")
|
||||
@@ -42,7 +42,6 @@ set(TARGET_C_SRC
|
||||
${CMAKE_SOURCE_DIR}/src/rs485_protocol.c
|
||||
${CMAKE_SOURCE_DIR}/src/ultrasonic_analog.c
|
||||
${CMAKE_SOURCE_DIR}/src/gd60914.c
|
||||
${CMAKE_SOURCE_DIR}/src/ultrasonic_analog.c
|
||||
)
|
||||
|
||||
add_executable(${PROJECT_NAME} ${TARGET_C_SRC})
|
||||
|
@@ -43,7 +43,6 @@ OF SUCH DAMAGE.
|
||||
#include "usart.h"
|
||||
#include "fwdgt.h"
|
||||
#include "board_config.h"
|
||||
#include "ultrasonic_analog.h"
|
||||
#include "gd60914.h"
|
||||
#include "ultrasonic_analog.h"
|
||||
|
||||
|
@@ -15,7 +15,7 @@ void watchdog_init(void) {
|
||||
rcu_osci_stab_wait(RCU_IRC40K);
|
||||
|
||||
/* Configure FWDGT counter clock: 40KHz(IRC40K) / 64 = 0.625 KHz */
|
||||
fwdgt_config(625, FWDGT_PSC_DIV64); // Set timeout to 1 seconds (625 / 0.625 KHz)
|
||||
fwdgt_config(625, FWDGT_PSC_DIV256); // Set timeout to 1 seconds (625 / 0.625 KHz)
|
||||
|
||||
/* Enable FWDGT */
|
||||
fwdgt_enable();
|
||||
|
@@ -34,7 +34,7 @@ OF SUCH DAMAGE.
|
||||
|
||||
#include "gd32e23x_it.h"
|
||||
|
||||
__IO uint16_t g_capture_value;
|
||||
extern uint16_t g_capture_value;
|
||||
|
||||
/*!
|
||||
\brief this function handles NMI exception
|
||||
|
25
src/main.c
25
src/main.c
@@ -7,9 +7,7 @@
|
||||
#include "main.h"
|
||||
|
||||
volatile uint8_t g_temperature_uint8[2] = {0};
|
||||
|
||||
extern uint16_t g_capture_value;
|
||||
uint16_t g_distance_uint16;
|
||||
volatile uint16_t g_capture_value;
|
||||
|
||||
/*!
|
||||
\brief main function
|
||||
@@ -29,24 +27,29 @@ int main(void)
|
||||
/* configure FWDGT */
|
||||
watchdog_init();
|
||||
|
||||
#ifdef SOFTWARE_IIC
|
||||
soft_i2c_config();
|
||||
#else
|
||||
i2c_config();
|
||||
#endif
|
||||
// #ifdef SOFTWARE_IIC
|
||||
// soft_i2c_config();
|
||||
// #else
|
||||
// i2c_config();
|
||||
// #endif
|
||||
|
||||
printf("system start!\r\n");
|
||||
|
||||
ultrasonic_config();
|
||||
|
||||
// gpio_bit_write(RS485_EN_PORT, RS485_EN_PIN, RESET);
|
||||
while(1){
|
||||
gd60914_get_object_tempture();
|
||||
// gd60914_get_object_tempture();
|
||||
|
||||
delay_ms(50);
|
||||
delay_ms(500);
|
||||
|
||||
ultrasonic_pwm_out_cycles(ULTRASONIC_TX_CYCLES);
|
||||
|
||||
delay_ms(10);
|
||||
|
||||
uint16_t distance = ultrasonic_calc_distance();
|
||||
|
||||
printf("%u\r\n", distance);
|
||||
|
||||
watchdog_reload();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user