MotorControlModuleSDFM_TMS3.../Projects/EFC_Communication/UMLibrary/driver/chipset/ADS1259.hh
2024-06-07 11:12:56 +03:00

185 lines
3.9 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*!\file
* \brief Файл содержит описание типов для набора модулей обработки микросхемы AD1259.
*/
/*
* AD1259.h
*
* Created on: 7 авг. 2019 г.
* Author: user
*/
#ifndef SOURCE_DRIVER_CHIPSET_AD1259_H_
#define SOURCE_DRIVER_CHIPSET_AD1259_H_
#include "../SerialPortAdapter.hpp"
namespace driver { namespace chipset { namespace ADS1259 {
//Адреса регистров.
struct ControlRegistersPairedAcronims {
enum Acronims {
CONFIG0 = 0x00,
CONFIG1 = 0x01,
CONFIG2 = 0x02,
OFC0 = 0x03,
OFC1 = 0x04,
OFC2 = 0x05,
FSC0 = 0x06,
FSC1 = 0x07,
FSC2 = 0x08
};
};
struct Commands {
enum {
WAKEUP = 0x02,
RESET = 0x06,
START = 0x08,
STOP = 0x0A,
RDATAC = 0x10,
SDATAC = 0x11
};
};
enum RefBias : unsigned {
ref_bias_disable,
ref_bias_enable //По сбросу.
};
enum SpiTimeout : unsigned {
spi_timeout_disable,
spi_timeout_enable //По сбросу.
};
union Config0Reg {
struct {
SpiTimeout spi_timeout : 1;
uint16_t : 1;
RefBias ref_bias : 1;
uint16_t : 1;
uint16_t id : 2;
uint16_t : 1;
uint16_t bit7 : 1;
} bit;
uint16_t all;
Config0Reg() : all(0x80) {}
};
enum OutOfRange : unsigned {
out_of_range_disable, //По сбросу.
out_of_range_enable
};
enum Checksum : unsigned {
checksum_disable, //По сбросу.
checksum_enable
};
enum DigFilterMode : unsigned {
sinc1_filter_mode, //По сбросу.
sinc2_filter_mode
};
enum RefSelect : unsigned {
internal_ref, //По сбросу.
external_ref
};
enum StartConvDelay : unsigned {
nodelay, //По сбросу.
delay_64_clk,
delay_128_clk,
delay_256_clk,
delay_512_clk,
delay_1024_clk,
delay_2048_clk,
delay_4096_clk
};
union Config1Reg {
struct {
StartConvDelay start_conv_delay : 3;
RefSelect ref_select : 1;
DigFilterMode filter_mode : 1;
uint16_t : 1;
Checksum checksum : 1;
OutOfRange out_of_range_flag : 1;
} bit;
uint16_t all;
Config1Reg() : all(0) {}
};
enum DataReadyFlag : unsigned {
data_ready,
data_not_ready
};
enum ClockSource : unsigned {
internal_oscillator,
external_clock
};
enum SyncOut : unsigned {
syncout_disable, //По сбросу.
syncout_enable
};
enum ConvControlMode : unsigned {
gate_control_mode, //По сбросу.
pulse_control_mode
};
enum DataRate {
dr_10sps, //По сбросу.
dr_16sps,
dr_50sps,
dr_60sps,
dr_400sps,
dr_1200sps,
dr_3600sps,
dr_14400sps
};
union Config2Reg {
struct {
DataRate datarate : 3;
uint16_t : 1;
ConvControlMode conv_control_mode : 1;
SyncOut syncout : 1;
ClockSource clock_source : 1;
DataReadyFlag data_ready_flag : 1;
} bit;
uint16_t all;
Config2Reg() : all(0) {}
};
//! Структура настраеваемых параметров микросхемы ADS1259
struct Parameters {
typedef uint16_t OptionRegister;
static const unsigned int allowed_options = 9;
enum AllowedRegisters {
CONFIG0_REGISTER,
CONFIG1_REGISTER,
CONFIG2_REGISTER,
OFC0_REGISTER,
OFC1_REGISTER,
OFC2_REGISTER,
FSC0_REGISTER,
FSC1_REGISTER,
FSC2_REGISTER,
};
OptionRegister option[allowed_options];
};
} }}
#endif /* SOURCE_DRIVER_CHIPSET_AD1259_H_ */