generated from Template/H563ZI-HAL-CMake-Template
新增 DebugSerialPort 支持,CommonCenter、CanMv 和 DfPlayer 改用智能指针
Some checks failed
Build and Upload Artifact / build and upload-artifact (push) Has been cancelled
Some checks failed
Build and Upload Artifact / build and upload-artifact (push) Has been cancelled
This commit is contained in:
@@ -2,35 +2,45 @@
|
||||
#include "stm32h563xx.h"
|
||||
|
||||
#include "Center/common_center.hpp"
|
||||
#include "Common/serial_port.hpp"
|
||||
#include "Helper/gpio_helper.hpp"
|
||||
#include "Helper/delay_helper.h"
|
||||
#include "config.hpp"
|
||||
|
||||
|
||||
void TerminateHandler() {
|
||||
auto led = GpioHelper::GpioInit(GPIOB, GPIO_PIN_0, GPIO_MODE_OUTPUT_PP, GPIO_NOPULL, GPIO_PIN_SET);
|
||||
auto led = Config::kLed;
|
||||
while (true) {
|
||||
led.Toggle();
|
||||
DelayS(1);
|
||||
}
|
||||
}
|
||||
|
||||
void Setup() {
|
||||
void GpioSetup() {
|
||||
GpioHelper::EnableAllGpioPeripheral();
|
||||
GpioHelper::GpioInit(GPIOB, GPIO_PIN_0, GPIO_MODE_OUTPUT_PP, GPIO_NOPULL, GPIO_PIN_RESET);
|
||||
}
|
||||
|
||||
void CommonSetup() {
|
||||
CommonCenter::GetUltrasonic();
|
||||
CommonCenter::GetDfPlayer();
|
||||
CommonCenter::GetCanMv();
|
||||
CommonCenter::GetDebugSerialPort();
|
||||
}
|
||||
|
||||
void Setup() {
|
||||
GpioSetup();
|
||||
DelaySetup();
|
||||
auto ultrasonic = CommonCenter::GetUltrasonic();
|
||||
auto dfPlayer = CommonCenter::GetDfPlayer();
|
||||
auto canMv = CommonCenter::GetCanMv();
|
||||
CommonSetup();
|
||||
}
|
||||
|
||||
extern "C" void AppStart() {
|
||||
Setup();
|
||||
auto ultrasonic = CommonCenter::GetUltrasonic();
|
||||
auto dfPlayer = CommonCenter::GetDfPlayer();
|
||||
auto canMv = CommonCenter::GetCanMv();
|
||||
auto& ultrasonic = CommonCenter::GetUltrasonic();
|
||||
auto& debugSerialPort = CommonCenter::GetDebugSerialPort();
|
||||
while (true) {
|
||||
// Example usage of the classes
|
||||
ultrasonic.GetDistance();
|
||||
dfPlayer.PlayTrack(1);
|
||||
|
||||
DelayMs(1000); // Delay for 1 second
|
||||
auto disatnce = ultrasonic.GetDistance();
|
||||
debugSerialPort.WriteLineBlocking("Distance: %.2f cm", disatnce);
|
||||
DelayS(1); // Delay for 1 second
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user