generated from Template/H563ZI-HAL-CMake-Template
删除多个类和结构体的拷贝构造函数和赋值运算符,确保不可复制性
All checks were successful
Build and Upload Artifact / build and upload-artifact (push) Successful in 20m4s
All checks were successful
Build and Upload Artifact / build and upload-artifact (push) Successful in 20m4s
This commit is contained in:
@@ -9,6 +9,10 @@
|
||||
|
||||
class CommonCenter {
|
||||
public:
|
||||
CommonCenter() = delete;
|
||||
CommonCenter(const CommonCenter&) = delete;
|
||||
CommonCenter& operator=(const CommonCenter&) = delete;
|
||||
|
||||
static Ultrasonic& GetUltrasonic() {
|
||||
static Ultrasonic* instance = nullptr;
|
||||
if (instance == nullptr) {
|
||||
|
||||
@@ -10,7 +10,11 @@ public:
|
||||
explicit CanMv(UART_HandleTypeDef* uart)
|
||||
: serialPort(std::make_unique<SerialPort>(uart, kBaudRate, kLength, kTimeout)) {}
|
||||
|
||||
~CanMv() = default;
|
||||
~CanMv() = default;
|
||||
CanMv(const CanMv&) = delete;
|
||||
CanMv& operator=(const CanMv&) = delete;
|
||||
CanMv(CanMv&&) = delete;
|
||||
CanMv& operator=(CanMv&&) = delete;
|
||||
|
||||
private:
|
||||
static constexpr uint32_t kBaudRate = 115200;
|
||||
|
||||
@@ -10,7 +10,11 @@ public:
|
||||
explicit DfPlayer(UART_HandleTypeDef* uart)
|
||||
: serialPort(std::make_unique<SerialPort>(uart, kBaudRate, kLength, kTimeout)) {}
|
||||
|
||||
~DfPlayer() = default;
|
||||
~DfPlayer() = default;
|
||||
DfPlayer(const DfPlayer&) = delete;
|
||||
DfPlayer& operator=(const DfPlayer&) = delete;
|
||||
DfPlayer(DfPlayer&&) = delete;
|
||||
DfPlayer& operator=(DfPlayer&&) = delete;
|
||||
|
||||
void Play();
|
||||
void Stop();
|
||||
|
||||
@@ -32,7 +32,11 @@ public:
|
||||
explicit Hc05(UART_HandleTypeDef* uart)
|
||||
: serialPort(std::make_unique<SerialPort>(uart, kBaudRate, kLength, kTimeout)) {}
|
||||
|
||||
~Hc05() = default;
|
||||
~Hc05() = default;
|
||||
Hc05(const Hc05&) = delete;
|
||||
Hc05& operator=(const Hc05&) = delete;
|
||||
Hc05(Hc05&&) = delete;
|
||||
Hc05& operator=(Hc05&&) = delete;
|
||||
|
||||
Response SendCommand() {
|
||||
Response data;
|
||||
|
||||
@@ -16,6 +16,11 @@ public:
|
||||
explicit Key(GpioHelper::Gpio gpio, GPIO_PinState normalStatus) : gpio(gpio), normalStatus(normalStatus) {
|
||||
GpioHelper::GpioInit(gpio, GPIO_MODE_INPUT, normalStatus ? GPIO_PULLUP : GPIO_PULLDOWN);
|
||||
}
|
||||
~Key() = default;
|
||||
Key(const Key&) = delete;
|
||||
Key& operator=(const Key&) = delete;
|
||||
Key(Key&&) = delete;
|
||||
Key& operator=(Key&&) = delete;
|
||||
|
||||
bool IsPressed() {
|
||||
auto reading = gpio.Read();
|
||||
|
||||
@@ -25,6 +25,10 @@ public:
|
||||
}
|
||||
|
||||
~SerialPort() = default;
|
||||
SerialPort(const SerialPort&) = delete;
|
||||
SerialPort& operator=(const SerialPort&) = delete;
|
||||
SerialPort(SerialPort&&) = delete;
|
||||
SerialPort& operator=(SerialPort&&) = delete;
|
||||
|
||||
void SetBaudRate(uint32_t baudRate) {
|
||||
HAL_UART_DeInit(handle);
|
||||
|
||||
@@ -19,6 +19,12 @@ public:
|
||||
captureFlag = GetCaptureFlag(channel);
|
||||
}
|
||||
|
||||
~Ultrasonic() = default;
|
||||
Ultrasonic(const Ultrasonic&) = delete;
|
||||
Ultrasonic& operator=(const Ultrasonic&) = delete;
|
||||
Ultrasonic(Ultrasonic&&) = delete;
|
||||
Ultrasonic& operator=(Ultrasonic&&) = delete;
|
||||
|
||||
double GetDistance(uint32_t time = 1) {
|
||||
double distance = 0;
|
||||
for (uint32_t cnt = 0; cnt < time; ++cnt) {
|
||||
@@ -46,6 +52,7 @@ private:
|
||||
double MeasureEchoTime() {
|
||||
timer->Instance->CNT = 0;
|
||||
uint32_t data[2];
|
||||
__HAL_TIM_CLEAR_FLAG(timer, captureFlag);
|
||||
HAL_TIM_IC_Start(timer, channel);
|
||||
try {
|
||||
for (auto& value : data) {
|
||||
|
||||
@@ -6,6 +6,12 @@
|
||||
|
||||
class GpioHelper {
|
||||
public:
|
||||
GpioHelper() = delete;
|
||||
GpioHelper(const GpioHelper&) = delete;
|
||||
GpioHelper& operator=(const GpioHelper&) = delete;
|
||||
GpioHelper(GpioHelper&&) = delete;
|
||||
GpioHelper& operator=(GpioHelper&&) = delete;
|
||||
|
||||
struct Gpio {
|
||||
GPIO_TypeDef* port;
|
||||
uint16_t pin;
|
||||
|
||||
@@ -4,8 +4,7 @@
|
||||
#include <cstdint>
|
||||
#include <stdexcept>
|
||||
|
||||
class TaskHelper {
|
||||
public:
|
||||
namespace TaskHelper {
|
||||
template <typename Func>
|
||||
static void WaitFor(Func func, uint32_t timeoutMilliseconds) {
|
||||
auto start = HAL_GetTick();
|
||||
@@ -16,4 +15,4 @@ public:
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}; // namespace TaskHelper
|
||||
|
||||
@@ -6,6 +6,10 @@
|
||||
#include "./Helper/gpio_helper.hpp"
|
||||
|
||||
struct Config {
|
||||
Config() = delete;
|
||||
Config(const Config&) = delete;
|
||||
Config& operator=(const Config&) = delete;
|
||||
|
||||
static inline struct {
|
||||
GpioHelper::Gpio trigger;
|
||||
TIM_HandleTypeDef* timer;
|
||||
|
||||
Reference in New Issue
Block a user