132 lines
3 KiB
C
132 lines
3 KiB
C
#ifndef STRUCTURES_DEFINE_H
|
|
#define STRUCTURES_DEFINE_H
|
|
#include <stdint.h>
|
|
|
|
enum ADC_CHANNELS : uint16_t {
|
|
V1_VSENSE = 0,
|
|
V2_VSENSE,
|
|
|
|
ADC_MAXCHANNELS, // interní konstanta - počet kanálů
|
|
};
|
|
typedef uint16_t SAMPLE;
|
|
union DATA_BLOCK {
|
|
SAMPLE channels [ADC_MAXCHANNELS];
|
|
uint32_t common_data;
|
|
};
|
|
enum TRIGER_MODE : uint16_t {
|
|
TRIGER_MODE_AUTO = 0,
|
|
TRIGER_MODE_NORMAL,
|
|
TRIGER_MODE_SINGLE
|
|
};
|
|
struct TrigerSettings {
|
|
uint16_t value;
|
|
uint16_t offset;
|
|
TRIGER_MODE mode;
|
|
ADC_CHANNELS channel;
|
|
bool rising;
|
|
explicit TrigerSettings () noexcept : value(0x80u), offset(100u), mode(TRIGER_MODE_AUTO), channel(V1_VSENSE), rising(false) {}
|
|
};
|
|
static_assert (sizeof(TrigerSettings) == 10, "TrigerSettings error");
|
|
enum VOLTAGE_SCALE {
|
|
S100mV = 0b0011, // 1:1 x10
|
|
S200mV = 0b0111, // 1:1 x5
|
|
S500mV = 0b1011, // 1:1 x2
|
|
|
|
S1V = 0b0000, // 1:10 x10
|
|
S2V = 0b0100, // 1:10 x5
|
|
S5V = 0b1000, // 1:10 x2
|
|
|
|
S10V = 0b0001, // 1:100x10
|
|
S20V = 0b0101, // 1:100x5
|
|
S50V = 0b1001, // 1:100x2
|
|
};
|
|
union ChannelVoltage {
|
|
struct {
|
|
uint8_t a : 4;
|
|
uint8_t b : 4;
|
|
};
|
|
uint8_t value;
|
|
char common [1];
|
|
explicit ChannelVoltage () noexcept : value (0u) {}
|
|
};
|
|
static_assert (sizeof(ChannelVoltage) == 1, "ChannelVoltage error");
|
|
union AllSettings {
|
|
struct _x {
|
|
TrigerSettings trg;
|
|
uint16_t tim;
|
|
uint8_t asc,bsc;
|
|
} part;
|
|
uint8_t common [sizeof (_x)];
|
|
explicit AllSettings (const TrigerSettings & ts, const unsigned n, const ChannelVoltage chv) noexcept {
|
|
part.trg.value = ts.value;
|
|
part.trg.offset = ts.offset;
|
|
part.trg.mode = ts.mode;
|
|
part.trg.channel = ts.channel;
|
|
part.trg.rising = ts.rising;
|
|
part.tim = n;
|
|
part.asc = chv.a;
|
|
part.bsc = chv.b;
|
|
}
|
|
};
|
|
static_assert (sizeof(AllSettings) == 14, "TrigerSettings error");
|
|
union SendHeader {
|
|
struct s_bits {
|
|
uint16_t pack_len : 15;
|
|
uint16_t trig_flg : 1;
|
|
} bits;
|
|
uint16_t common;
|
|
};
|
|
static_assert (sizeof(SendHeader) == 2, "SendHeader error");
|
|
enum DESTINATION {
|
|
DEST_CHA = 0,
|
|
DEST_CHB,
|
|
DEST_TRIG,
|
|
DEST_BASE,
|
|
};
|
|
|
|
enum TRIGGER_CMD {
|
|
TRIGGER_CMD_MODE = 0,
|
|
TRIGGER_CMD_VALUE,
|
|
TRIGGER_CMD_OFSET,
|
|
};
|
|
union TriggerModeUnion {
|
|
struct s_bits {
|
|
uint16_t mode : 2;
|
|
uint16_t channel : 1;
|
|
uint16_t rissing : 1;
|
|
uint16_t unused : 12;
|
|
} bits;
|
|
uint16_t common;
|
|
};
|
|
static_assert (sizeof(TriggerModeUnion) == 2, "TriggerModeUnion error");
|
|
|
|
union RcvdHeader {
|
|
struct s_bits {
|
|
uint16_t cmd_value : 12;
|
|
uint16_t cmd_type : 2;
|
|
uint16_t destinat : 2;
|
|
} bits;
|
|
uint16_t common;
|
|
};
|
|
static_assert (sizeof(RcvdHeader) == 2, "RcvdHeader error");
|
|
|
|
enum MOVE_ITEMS {
|
|
MOVE_VALUE = 0,
|
|
MOVE_OFSET,
|
|
MOVE_MARKERA,
|
|
MOVE_MARKERB,
|
|
TIME_ZOOM,
|
|
OFSET_A,
|
|
OFSET_B,
|
|
};
|
|
enum TIME_BASE_MODE {
|
|
TIME_BASE_TRIGERED = 0,
|
|
TIME_BASE_CONTINUOUS,
|
|
};
|
|
struct TimeBaseDescriptor {
|
|
uint16_t divider;
|
|
uint16_t presc;
|
|
TIME_BASE_MODE mode;
|
|
};
|
|
|
|
#endif // STRUCTURES_DEFINE_H
|