generated from hulk/gd32e23x_template
有问题版本,暂存
This commit is contained in:
@@ -18,8 +18,8 @@ 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) {
|
||||
printf("%c%c%c%c%c%c", 0xB5, 0xF1, 0x02, 0x6F, 0x6B, 0xCC);
|
||||
// eddy_current_value_report();
|
||||
|
||||
ultrasonic_distance_report();
|
||||
} else if (strcmp(combined_str, "M2") == 0) {
|
||||
printf("%c%c%c%c%c%c%c", 0xB5, 0xF1, 0x02, 0x6F, 0x6B, 0x6B, 0xCC);
|
||||
// tempture_value_report();
|
||||
@@ -90,3 +90,43 @@ validation_result_t validate_data_length(uint8_t *data) {
|
||||
return VALIDATION_LENGTH_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
// void eddy_current_value_report(void) {
|
||||
// static uint32_t eddy_current_value_uint32 = 0;
|
||||
//
|
||||
// eddy_current_value_uint32 = ldc1612_get_raw_channel_result(CHANNEL_0);
|
||||
//
|
||||
// package_data[0] = (eddy_current_value_uint32 >> 24) & 0xFF;
|
||||
// package_data[1] = (eddy_current_value_uint32 >> 16) & 0xFF;
|
||||
// package_data[2] = (eddy_current_value_uint32 >> 8) & 0xFF;
|
||||
// package_data[3] = eddy_current_value_uint32 & 0xFF;
|
||||
//
|
||||
// uint8_t combined_data[7];
|
||||
// memcpy(combined_data, package_header, 3);
|
||||
// memcpy(combined_data + 3, package_data, 4);
|
||||
//
|
||||
// printf("%c%c%c", package_header[0], package_header[1], package_header[2]);
|
||||
// printf("%c%c%c%c", package_data[0], package_data[1], package_data[2], package_data[3]);
|
||||
// printf("%c", calculate_crc(combined_data, 8));
|
||||
// }
|
||||
|
||||
void ultrasonic_distance_report(void) {
|
||||
static uint32_t distance_uint32 = 0;
|
||||
static uint8_t package_header[3] = {0xB5, 0xF0, 0x04};
|
||||
static uint8_t package_data[4] = {0};
|
||||
|
||||
distance_uint32 = ultrasonic_calc_distance();
|
||||
|
||||
package_data[0] = (distance_uint32 >> 24) & 0xFF;
|
||||
package_data[1] = (distance_uint32 >> 16) & 0xFF;
|
||||
package_data[2] = (distance_uint32 >> 8) & 0xFF;
|
||||
package_data[3] = distance_uint32 & 0xFF;
|
||||
|
||||
uint8_t combined_data[7];
|
||||
memcpy(combined_data, package_header, 3);
|
||||
memcpy(combined_data + 3, package_data, 4);
|
||||
|
||||
printf("%c%c%c", package_header[0], package_header[1], package_header[2]);
|
||||
printf("%c%c%c%c", package_data[0], package_data[1], package_data[2], package_data[3]);
|
||||
printf("%c", calculate_crc(combined_data, 8));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user