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 "fwdgt.h"
#include "board_config.h" #include "board_config.h"
#include "gd60914.h" #include "gd60914.h"
#include "ultrasonic_analog.h"
#ifdef SOFTWARE_IIC #ifdef SOFTWARE_IIC
#include "soft_i2c.h" #include "soft_i2c.h"

View File

@ -15,7 +15,7 @@ void watchdog_init(void) {
rcu_osci_stab_wait(RCU_IRC40K); rcu_osci_stab_wait(RCU_IRC40K);
/* Configure FWDGT counter clock: 40KHz(IRC40K) / 64 = 0.625 KHz */ /* 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 */ /* Enable FWDGT */
fwdgt_enable(); fwdgt_enable();

View File

@ -27,23 +27,29 @@ int main(void)
/* configure FWDGT */ /* configure FWDGT */
watchdog_init(); watchdog_init();
#ifdef SOFTWARE_IIC // #ifdef SOFTWARE_IIC
soft_i2c_config(); // soft_i2c_config();
#else // #else
i2c_config(); // i2c_config();
#endif // #endif
printf("system start!\r\n"); printf("system start!\r\n");
ultrasonic_config(); ultrasonic_config();
while(1){ while(1){
gd60914_get_object_tempture(); // gd60914_get_object_tempture();
delay_ms(50); delay_ms(500);
ultrasonic_pwm_out_cycles(ULTRASONIC_TX_CYCLES); ultrasonic_pwm_out_cycles(ULTRASONIC_TX_CYCLES);
delay_ms(10);
uint16_t distance = ultrasonic_calc_distance();
printf("%u\r\n", distance);
watchdog_reload(); watchdog_reload();
} }
} }