diff --git a/inc/main.h b/inc/main.h index b0ea637..18c1b69 100644 --- a/inc/main.h +++ b/inc/main.h @@ -36,6 +36,7 @@ OF SUCH DAMAGE. #define MAIN_H #include +#include #include "gd32e23x.h" #include "systick.h" #include "gd32e23x_libopt.h" diff --git a/inc/rs485.h b/inc/rs485.h index f5e1320..3200d5e 100644 --- a/inc/rs485.h +++ b/inc/rs485.h @@ -9,6 +9,7 @@ #include "gd32e23x.h" #include "systick.h" #include +#include #include "ldc1612.h" #include "tmp112.h" #include "fwdgt.h" diff --git a/src/main.c b/src/main.c index 01b811b..267c1a6 100644 --- a/src/main.c +++ b/src/main.c @@ -6,6 +6,8 @@ */ #include "main.h" +bool g_statusSwitch = false; + /*! \brief main function \param[in] none @@ -40,9 +42,10 @@ int main(void) { while (1) { - delay_ms(50); + delay_ms(1000); fwdgt_counter_reload(); - eddy_current_value_report(); + if (g_statusSwitch) + {eddy_current_value_report();} } } diff --git a/src/rs485.c b/src/rs485.c index 05bb0f0..98c0708 100644 --- a/src/rs485.c +++ b/src/rs485.c @@ -7,6 +7,8 @@ uint8_t package_header[3] = {0xB5, 0xF0, 0x04}; uint8_t package_data[4] = {0}; +extern bool g_statusSwitch; + void rs485_config(void) { #ifndef RS485_MAX13487 rcu_periph_clock_enable(RS485_GPIO_RCU); @@ -87,14 +89,15 @@ void process_command(uint8_t *cmd, size_t length) { // printf("%d", length); sprintf(combined_str, "%c%c", cmd[3], cmd[4]); if (strcmp(combined_str, "M1") == 0) { - eddy_current_value_report(); - } else if (strcmp(combined_str, "M2") == 0) - { - tempture_value_report(); - } else if (strcmp(combined_str, "M3") == 0) - { + printf("ok"); + g_statusSwitch = true; + // eddy_current_value_report(); + } else if (strcmp(combined_str, "M2") == 0) { + g_statusSwitch = false; + // tempture_value_report(); + } else if (strcmp(combined_str, "M3") == 0) { printf("%c%c%c%c%c%c", 0xB5, 0xF1, 0x02, 0x6F, 0x6B, 0xCC); - fwdgt_reset_mcu(); + // fwdgt_reset_mcu(); } else { printf("%c%c%c%c%c%c%c", 0xB5, 0xF0, 0x03, 0x65, 0x72, 0x72, 0x3C); return;