STM_ATEM/User/ltc2508_driver.h
zhoujie 6297f3044d feat(adc): implement comprehensive ADC data acquisition and processing system
Add complete data acquisition pipeline with LTC2508 ADC drivers, correction algorithms,
data storage, and system monitoring. Includes ARM DSP optimized matrix operations for
sensor calibration, SD card data logging with USB mass storage, and robust error handling
with validation throughout the processing chain.

- Add LTC2508 multi-channel SPI driver with DMA support and error recovery
- Implement correction module with ARM DSP matrix operations for sensor calibration
- Add data storage system with SD card logging and configurable file management
- Integrate system monitor for health tracking and error reporting
- Enhance data packet structure with CRC validation and timestamps
- Add USB mass storage interface for SD card access
- Implement comprehensive error handling and statistics collection
2026-01-25 18:15:13 +08:00

47 lines
1.4 KiB
C

#ifndef LTC2508_DRIVER_H
#define LTC2508_DRIVER_H
#include "main.h" // 包含 main.h 以获取 SPI 和 GPIO 等的句柄
// 定义每个 ADC 采样的数据长度 (32-bit)
#define LTC2508_DATA_LEN 2 // 2个 16bit 数据
// 假设我们有3个 LTC2508
#define NUM_LTC2508 3
// LTC2508错误状态定义
typedef enum {
LTC2508_OK = 0,
LTC2508_ERROR_INIT,
LTC2508_ERROR_SPI,
LTC2508_ERROR_DMA,
LTC2508_ERROR_TIMEOUT,
LTC2508_ERROR_DATA_INVALID
} LTC2508_StatusTypeDef;
// LTC2508统计信息
typedef struct {
uint32_t total_samples;
uint32_t error_count;
uint32_t timeout_count;
uint32_t dma_error_count;
uint8_t last_error;
} LTC2508_StatsTypeDef;
// 用于存储三路 ADC 数据的全局变量 (每个 ADC 2个 16-bit 数据)
extern volatile uint16_t g_adc_data[NUM_LTC2508][LTC2508_DATA_LEN];
// ADC 数据准备就绪标志
extern volatile uint8_t g_adc_data_ready_flag;
// 错误统计信息
extern LTC2508_StatsTypeDef g_ltc2508_stats;
// 函数原型
LTC2508_StatusTypeDef LTC2508_Init(SPI_HandleTypeDef *hspi1, SPI_HandleTypeDef *hspi2, SPI_HandleTypeDef *hspi3);
LTC2508_StatusTypeDef LTC2508_TriggerDmaRead(void);
void LTC2508_DmaComplete_Callback(SPI_HandleTypeDef *hspi);
void LTC2508_ErrorCallback(SPI_HandleTypeDef *hspi);
LTC2508_StatusTypeDef LTC2508_ValidateData(uint8_t channel);
void LTC2508_GetStats(LTC2508_StatsTypeDef *stats);
void LTC2508_ResetStats(void);
#endif // LTC2508_DRIVER_H