This commit is contained in:
yelvlab 2025-01-09 15:48:50 +08:00
parent 7ffb8c0612
commit ca332e9ea1
3 changed files with 15 additions and 8 deletions

View File

@ -44,6 +44,7 @@ OF SUCH DAMAGE.
#include "fwdgt.h"
#include "board_config.h"
#include "gd60914.h"
#include "ultrasonic_analog.h"
#ifdef SOFTWARE_IIC
#include "soft_i2c.h"

View File

@ -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();

View File

@ -27,23 +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();
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();
}
}