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 {
|
class CommonCenter {
|
||||||
public:
|
public:
|
||||||
|
CommonCenter() = delete;
|
||||||
|
CommonCenter(const CommonCenter&) = delete;
|
||||||
|
CommonCenter& operator=(const CommonCenter&) = delete;
|
||||||
|
|
||||||
static Ultrasonic& GetUltrasonic() {
|
static Ultrasonic& GetUltrasonic() {
|
||||||
static Ultrasonic* instance = nullptr;
|
static Ultrasonic* instance = nullptr;
|
||||||
if (instance == nullptr) {
|
if (instance == nullptr) {
|
||||||
|
|||||||
@@ -11,6 +11,10 @@ public:
|
|||||||
: serialPort(std::make_unique<SerialPort>(uart, kBaudRate, kLength, kTimeout)) {}
|
: 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:
|
private:
|
||||||
static constexpr uint32_t kBaudRate = 115200;
|
static constexpr uint32_t kBaudRate = 115200;
|
||||||
|
|||||||
@@ -11,6 +11,10 @@ public:
|
|||||||
: serialPort(std::make_unique<SerialPort>(uart, kBaudRate, kLength, kTimeout)) {}
|
: 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 Play();
|
||||||
void Stop();
|
void Stop();
|
||||||
|
|||||||
@@ -33,6 +33,10 @@ public:
|
|||||||
: serialPort(std::make_unique<SerialPort>(uart, kBaudRate, kLength, kTimeout)) {}
|
: 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 SendCommand() {
|
||||||
Response data;
|
Response data;
|
||||||
|
|||||||
@@ -16,6 +16,11 @@ public:
|
|||||||
explicit Key(GpioHelper::Gpio gpio, GPIO_PinState normalStatus) : gpio(gpio), normalStatus(normalStatus) {
|
explicit Key(GpioHelper::Gpio gpio, GPIO_PinState normalStatus) : gpio(gpio), normalStatus(normalStatus) {
|
||||||
GpioHelper::GpioInit(gpio, GPIO_MODE_INPUT, normalStatus ? GPIO_PULLUP : GPIO_PULLDOWN);
|
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() {
|
bool IsPressed() {
|
||||||
auto reading = gpio.Read();
|
auto reading = gpio.Read();
|
||||||
|
|||||||
@@ -25,6 +25,10 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
~SerialPort() = default;
|
~SerialPort() = default;
|
||||||
|
SerialPort(const SerialPort&) = delete;
|
||||||
|
SerialPort& operator=(const SerialPort&) = delete;
|
||||||
|
SerialPort(SerialPort&&) = delete;
|
||||||
|
SerialPort& operator=(SerialPort&&) = delete;
|
||||||
|
|
||||||
void SetBaudRate(uint32_t baudRate) {
|
void SetBaudRate(uint32_t baudRate) {
|
||||||
HAL_UART_DeInit(handle);
|
HAL_UART_DeInit(handle);
|
||||||
|
|||||||
@@ -19,6 +19,12 @@ public:
|
|||||||
captureFlag = GetCaptureFlag(channel);
|
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 GetDistance(uint32_t time = 1) {
|
||||||
double distance = 0;
|
double distance = 0;
|
||||||
for (uint32_t cnt = 0; cnt < time; ++cnt) {
|
for (uint32_t cnt = 0; cnt < time; ++cnt) {
|
||||||
@@ -46,6 +52,7 @@ private:
|
|||||||
double MeasureEchoTime() {
|
double MeasureEchoTime() {
|
||||||
timer->Instance->CNT = 0;
|
timer->Instance->CNT = 0;
|
||||||
uint32_t data[2];
|
uint32_t data[2];
|
||||||
|
__HAL_TIM_CLEAR_FLAG(timer, captureFlag);
|
||||||
HAL_TIM_IC_Start(timer, channel);
|
HAL_TIM_IC_Start(timer, channel);
|
||||||
try {
|
try {
|
||||||
for (auto& value : data) {
|
for (auto& value : data) {
|
||||||
|
|||||||
@@ -6,6 +6,12 @@
|
|||||||
|
|
||||||
class GpioHelper {
|
class GpioHelper {
|
||||||
public:
|
public:
|
||||||
|
GpioHelper() = delete;
|
||||||
|
GpioHelper(const GpioHelper&) = delete;
|
||||||
|
GpioHelper& operator=(const GpioHelper&) = delete;
|
||||||
|
GpioHelper(GpioHelper&&) = delete;
|
||||||
|
GpioHelper& operator=(GpioHelper&&) = delete;
|
||||||
|
|
||||||
struct Gpio {
|
struct Gpio {
|
||||||
GPIO_TypeDef* port;
|
GPIO_TypeDef* port;
|
||||||
uint16_t pin;
|
uint16_t pin;
|
||||||
|
|||||||
@@ -4,8 +4,7 @@
|
|||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
|
||||||
class TaskHelper {
|
namespace TaskHelper {
|
||||||
public:
|
|
||||||
template <typename Func>
|
template <typename Func>
|
||||||
static void WaitFor(Func func, uint32_t timeoutMilliseconds) {
|
static void WaitFor(Func func, uint32_t timeoutMilliseconds) {
|
||||||
auto start = HAL_GetTick();
|
auto start = HAL_GetTick();
|
||||||
@@ -16,4 +15,4 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
}; // namespace TaskHelper
|
||||||
|
|||||||
@@ -6,6 +6,10 @@
|
|||||||
#include "./Helper/gpio_helper.hpp"
|
#include "./Helper/gpio_helper.hpp"
|
||||||
|
|
||||||
struct Config {
|
struct Config {
|
||||||
|
Config() = delete;
|
||||||
|
Config(const Config&) = delete;
|
||||||
|
Config& operator=(const Config&) = delete;
|
||||||
|
|
||||||
static inline struct {
|
static inline struct {
|
||||||
GpioHelper::Gpio trigger;
|
GpioHelper::Gpio trigger;
|
||||||
TIM_HandleTypeDef* timer;
|
TIM_HandleTypeDef* timer;
|
||||||
|
|||||||
Reference in New Issue
Block a user