有问题版本,暂存

This commit is contained in:
yelvlab 2025-01-01 02:10:03 +08:00
parent 6dd053e217
commit c9c1e00d6a
4 changed files with 15 additions and 17 deletions

View File

@ -40,6 +40,7 @@ set(TARGET_C_SRC
${CMAKE_SOURCE_DIR}/src/i2c.c ${CMAKE_SOURCE_DIR}/src/i2c.c
${CMAKE_SOURCE_DIR}/src/fwdgt.c ${CMAKE_SOURCE_DIR}/src/fwdgt.c
${CMAKE_SOURCE_DIR}/src/rs485_protocol.c ${CMAKE_SOURCE_DIR}/src/rs485_protocol.c
${CMAKE_SOURCE_DIR}/src/ultrasonic_analog.c
${CMAKE_SOURCE_DIR}/src/gd60914.c ${CMAKE_SOURCE_DIR}/src/gd60914.c
${CMAKE_SOURCE_DIR}/src/ultrasonic_analog.c ${CMAKE_SOURCE_DIR}/src/ultrasonic_analog.c
) )

View File

@ -43,6 +43,7 @@ OF SUCH DAMAGE.
#include "usart.h" #include "usart.h"
#include "fwdgt.h" #include "fwdgt.h"
#include "board_config.h" #include "board_config.h"
#include "ultrasonic_analog.h"
#include "gd60914.h" #include "gd60914.h"
#include "ultrasonic_analog.h" #include "ultrasonic_analog.h"

View File

@ -41,13 +41,11 @@ int main(void)
// gpio_bit_write(RS485_EN_PORT, RS485_EN_PIN, RESET); // gpio_bit_write(RS485_EN_PORT, RS485_EN_PIN, RESET);
while(1){ while(1){
// printf("hello world!\r\n");
// delay_ms(500);
gd60914_get_object_tempture(); gd60914_get_object_tempture();
delay_ms(50); delay_ms(50);
ultrasonic_pwm_out_cycles(ULTRASONIC_TX_CYCLES); ultrasonic_pwm_out_cycles(ULTRASONIC_TX_CYCLES);
// delay_ms(2);
watchdog_reload(); watchdog_reload();
} }

View File

@ -21,8 +21,7 @@ void process_command(uint8_t *cmd, size_t length) {
sprintf(combined_str, "%c%c", cmd[3], cmd[4]); sprintf(combined_str, "%c%c", cmd[3], cmd[4]);
if (strcmp(combined_str, "M1") == 0) { if (strcmp(combined_str, "M1") == 0) {
ultrasonic_distance_report(); ultrasonic_distance_report();
} else if (strcmp(combined_str, "M2") == 0) } else if (strcmp(combined_str, "M2") == 0) {
{
gd60914_tempture_report(); gd60914_tempture_report();
} else if (strcmp(combined_str, "M3") == 0) } else if (strcmp(combined_str, "M3") == 0)
{ {
@ -92,6 +91,17 @@ validation_result_t validate_data_length(uint8_t *data) {
} }
} }
void gd60914_tempture_report(void) {
static uint8_t package_header[3] = {0xB5, 0xF0, 0x02};
uint8_t combined_data[5];
memcpy(combined_data, package_header, 3);
memcpy(combined_data + 3, g_temperature_uint8, 2);
printf("%c%c%c", package_header[0], package_header[1], package_header[2]);
printf("%c%c", g_temperature_uint8[1], g_temperature_uint8[0]);
printf("%c", calculate_crc(combined_data, 6));
}
// void eddy_current_value_report(void) { // void eddy_current_value_report(void) {
// static uint32_t eddy_current_value_uint32 = 0; // static uint32_t eddy_current_value_uint32 = 0;
// //
@ -131,15 +141,3 @@ void ultrasonic_distance_report(void) {
printf("%c%c%c%c", package_data[0], package_data[1], package_data[2], package_data[3]); printf("%c%c%c%c", package_data[0], package_data[1], package_data[2], package_data[3]);
printf("%c", calculate_crc(combined_data, 8)); printf("%c", calculate_crc(combined_data, 8));
} }
void gd60914_tempture_report(void) {
static uint8_t package_header[3] = {0xB5, 0xF0, 0x02};
uint8_t combined_data[5];
memcpy(combined_data, package_header, 3);
memcpy(combined_data + 3, g_temperature_uint8, 2);
printf("%c%c%c", package_header[0], package_header[1], package_header[2]);
printf("%c%c", g_temperature_uint8[1], g_temperature_uint8[0]);
printf("%c", calculate_crc(combined_data, 6));
}