Refactor and clean up codebase
- Removed unused constants and type aliases in app_spi_command_defs.h and temp_sensor.h. - Simplified ISpiCommandHandler destructor to default. - Eliminated redundant methods and comments in temp_sensor and usart0 files. - Consolidated writeU32Le function to app_spi_command_defs.h for reuse. - Updated comments for clarity and accuracy in task_manager.h and task_runner.cpp. - Removed hardfault.h as it contained no declarations. - Cleaned up CANFD and watchdog implementations by removing dead code and unnecessary comments. - Updated version numbers in config.h to reflect recent changes. - Enhanced error handling and diagnostics in hardfault handling.
This commit is contained in:
@@ -10,6 +10,7 @@
|
||||
#include <math.h>
|
||||
|
||||
namespace {
|
||||
/* ---- 校验常量与辅助函数 ---- */
|
||||
constexpr float kMinValidVdda = 2.7f;
|
||||
constexpr float kMaxValidVdda = 3.6f;
|
||||
constexpr float kMinValidTemperature = -40.0f;
|
||||
@@ -24,16 +25,14 @@ static bool isFiniteFloat(float value)
|
||||
{
|
||||
return isfinite(value) != 0;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
namespace {
|
||||
/* ---- DMA 配置 ---- */
|
||||
constexpr uint32_t kDmaPeriph = DMA0;
|
||||
constexpr dma_channel_enum kDmaChannel = DMA_CH0;
|
||||
constexpr uint32_t kChannelCount = 3U;
|
||||
constexpr uint32_t kVinGpio = GPIOA;
|
||||
constexpr uint32_t kVinPin = GPIO_PIN_6;
|
||||
volatile uint16_t s_dmaBuffer[kChannelCount] = {0U, 0U, 0U};
|
||||
volatile uint8_t s_dmaReady = 0U;
|
||||
} // namespace
|
||||
|
||||
/**
|
||||
@@ -108,30 +107,6 @@ void Adc::init()
|
||||
SysTickTimer::delayMs(CONFIG_ADC_STABILIZE_DELAY_MS);
|
||||
adc_software_trigger_enable(CONFIG_ADC_INSTANCE, ADC_REGULAR_CHANNEL);
|
||||
SysTickTimer::delayMs(1U);
|
||||
s_dmaReady = 1U;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 查询 ADC DMA 采样是否已经就绪。
|
||||
* @param[in] 无。
|
||||
* @param[out] 无。
|
||||
* @retval bool true 表示 DMA 已启动并完成初始稳定等待,false 表示尚未就绪。
|
||||
*/
|
||||
bool Adc::dmaReady()
|
||||
{
|
||||
return s_dmaReady != 0U;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 获取 ADC DMA 原始缓冲区首地址。
|
||||
* @param[in] 无。
|
||||
* @param[out] 无。
|
||||
* @retval const uint16_t* 返回 DMA 原始缓冲区首地址。
|
||||
* @note 缓冲顺序固定为 `VIN_ADC / TEMP / VREFINT`。
|
||||
*/
|
||||
const uint16_t *Adc::dmaBuffer()
|
||||
{
|
||||
return (const uint16_t *)s_dmaBuffer;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user