IWDG заведен

This commit is contained in:
2025-03-31 18:39:34 +03:00
parent b9d5ff7f46
commit 6b5edc1c41
5 changed files with 100 additions and 5 deletions

View File

@@ -0,0 +1,39 @@
#ifndef RECORDER_BUFFER_H
#define RECORDER_BUFFER_H
#ifdef __cplusplus
#include <cstdint>
extern "C" {
#else
#include <stdint.h>
#endif
// размер буфера, должен быть 2^x
#define CHANNEL_BUFFER_SIZE 1024
#define CHANNEL_BUFFER_SIZE_MASK (CHANNEL_BUFFER_SIZE - 1)
typedef struct {
uint64_t timepoint;
uint32_t duration;
} BufferItem;
// Структура кольцевого буфера
typedef struct {
volatile uint32_t head;
volatile uint32_t tail;
volatile uint32_t overruns;
BufferItem buffer[CHANNEL_BUFFER_SIZE];
} ChannelBuffer_t;
void ChannelBuffer_reset(ChannelBuffer_t *buffer);
void ChannelBuffer_push(ChannelBuffer_t *buffer, BufferItem item);
int ChannelBuffer_pop(ChannelBuffer_t *buffer, BufferItem* dest);
extern ChannelBuffer_t buffer_ch1;
extern ChannelBuffer_t buffer_ch2;
#ifdef __cplusplus
}
#endif
#endif //RECORDER_BUFFER_H