#使用雷达模组R24AVD1,波特率9600
详情请阅读代码
/* UART Echo Example
This example code is in the Public Domain (or CC0 licensed, at your option.)
Unless required by applicable law or agreed to in writing, this
software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
CONDITIONS OF ANY KIND, either express or implied.
*/
#include <stdio.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "driver/uart.h"
#include "driver/gpio.h"
#include "sdkconfig.h"
#include "esp_log.h"
/**
* This is an example which echos any data it receives on configured UART back to the sender,
* with hardware flow control turned off. It does not use UART driver event queue.
*
* - Port: configured UART
* - Receive (Rx) buffer: on
* - Transmit (Tx) buffer: off
* - Flow control: off
* - Event queue: off
* - Pin assignment: see defines below (See Kconfig)
*/
#define ECHO_TEST_TXD (35)
#define ECHO_TEST_RXD (36)
#define ECHO_TEST_RTS (UART_PIN_NO_CHANGE)
#define ECHO_TEST_CTS (UART_PIN_NO_CHANGE)
#define ECHO_UART_PORT_NUM (UART_NUM_1)
#define ECHO_UART_BAUD_RATE (9600)
#define ECHO_TASK_STACK_SIZE (CONFIG_EXAMPLE_TASK_STACK_SIZE)
static const char *TAG = "UART TEST";
#define BUF_SIZE (1024)
// typedef struct
// {
// uint8_t *u_rdata;
// uint16_t u_rdata_len;
// } msg_uart_rdata_t; // 串口队列消息缓存
typedef enum{
Deviceid=0x01, //设备ID
Softversion=0x02, //软件版本
Hardversion=0x03, //硬件版本
Protocolversion=0x04 //协议版本
}ID_QUERY_ADDRESS;
typedef enum{
Environmental_state=0x05, //环境状态
Sign_parameter=0x06 //体征参数
}Radar_INFO_ADDRESS;
typedef enum{
Threshold_gear=0x0c, //阈值档位
Scene_setting=0x10, //场景设置
Forced_entry_unmannd=0x12 //强制进入无人档位
}System_PARAMS_ADDRESS;
typedef enum{
ID_QUERY=0x01,//Identification query
Radar_Info=0x03,//Radar information
System_Parms=0x04,//System parameters
}read_cmd_func;
typedef enum
{
Read_Cmd=0x01,
Write_Cmd=0x02,
Passive_Report=0x03,
Actively_Report=0x04
}Command_Function_Code;
//write_cmd_func
typedef enum{
Threshold_gear_low=0x01,
Threshold_gear_middle=0x02,
Threshold_gear_high=0x03,
}Threshold_gear_value;
typedef enum{
Scene_default=0x00,
Scene_area_dection=0x01,
Scene_Restroom,
Scene_Bedroom,
Scene_livingroom,
Scene_Office,
Scene_hotel
}Scene_setting_value;
typedef enum{
Unused_forced=0x00,//不使用强制进入无人功能
unmannd_time_10=0x01,//10s
unmannd_time_30,//30s
unmannd_time_60,//1min
unmannd_time_120,//2min
unmannd_time_300,//5min
unmannd_time_600,//10min
unmannd_time_1800,//30min
unmannd_time_3600//60min
}Forced_unmannd_value;
typedef union
{
unsigned char Byte[4];
float Float;
}Float_Byte;
extern void parsing_recv_data(unsigned char *data,unsigned char len);
exter

本文提供了一个使用R24AVD1雷达模组的示例代码,通过9600波特率的UART进行数据传输,包括发送和接收操作,并展示了如何解析接收到的数据,如环境状态和主动上报功能。
最低0.47元/天 解锁文章
309





