新增 Hc05 类,支持 HC-05 蓝牙模块的串口通信,增加串口设置波特率函数
All checks were successful
Build and Upload Artifact / build and upload-artifact (push) Successful in 19m59s

This commit is contained in:
chauyin
2025-05-12 21:57:21 +08:00
parent c3e0edd72d
commit 17d298c782
9 changed files with 119 additions and 18 deletions

View File

@@ -7,7 +7,8 @@
class DfPlayer {
public:
explicit DfPlayer(UART_HandleTypeDef* uart) : serialPort(std::make_unique<SerialPort>(uart, kLength, kTimeout)) {}
explicit DfPlayer(UART_HandleTypeDef* uart)
: serialPort(std::make_unique<SerialPort>(uart, kBaudRate, kLength, kTimeout)) {}
~DfPlayer() = default;
@@ -49,8 +50,9 @@ private:
kQueryFlashCurrentTrack = 0x4D,
};
static constexpr uint32_t kLength = 128;
static constexpr uint32_t kTimeout = 10;
static constexpr uint32_t kBaudRate = 9600;
static constexpr uint32_t kLength = 128;
static constexpr uint32_t kTimeout = 10;
std::unique_ptr<SerialPort> serialPort;
void SendCommand(Command cmd, uint16_t param = 0);