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
39 lines
1.4 KiB
C
39 lines
1.4 KiB
C
#ifndef DATA_PACKET_H
|
|
#define DATA_PACKET_H
|
|
|
|
#include <stdint.h>
|
|
|
|
#define PACKET_START_BYTE 0xFFFFFFFF
|
|
#define PACKET_END_BYTE 0x0000
|
|
|
|
// 数据包结构 - 启用校验和和包尾
|
|
typedef struct __attribute__((packed)) {
|
|
uint32_t start_byte; // 包头 (4字节)
|
|
uint32_t timestamp; // 时间戳 (4字节)
|
|
int32_t adc_data1; // ADC1 数据 (4字节)
|
|
int32_t adc_data2; // ADC2 数据 (4字节)
|
|
int32_t adc_data3; // ADC3 数据 (4字节)
|
|
uint16_t checksum; // CRC16校验和 (2字节)
|
|
uint16_t end_byte; // 包尾 (2字节)
|
|
} DataPacket_t;
|
|
|
|
// 校正后数据包结构
|
|
typedef struct __attribute__((packed)) {
|
|
uint32_t start_byte; // 包头
|
|
uint32_t timestamp; // 时间戳
|
|
float corrected_x; // 校正后X轴数据
|
|
float corrected_y; // 校正后Y轴数据
|
|
float corrected_z; // 校正后Z轴数据
|
|
uint16_t checksum; // CRC16校验和
|
|
uint16_t end_byte; // 包尾
|
|
} CorrectedDataPacket_t;
|
|
|
|
// 函数声明
|
|
uint16_t Calculate_CRC16(const uint8_t *data, uint16_t len);
|
|
void PackData(DataPacket_t *packet, int32_t adc1, int32_t adc2, int32_t adc3);
|
|
void PackCorrectedData(CorrectedDataPacket_t *packet, float x, float y, float z);
|
|
uint8_t ValidatePacket(const DataPacket_t *packet);
|
|
uint8_t ValidateCorrectedPacket(const CorrectedDataPacket_t *packet);
|
|
|
|
#endif // DATA_PACKET_H
|