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

68 lines
1.7 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.

/*
* ADS1259ExtendedAdcReader.h
*
* Created on: 9 июл. 2020 г.
* Author: krugliy
*/
#ifndef UMLIBRARY_DRIVER_CHIPSET_ADS1259EXTENDEDADCREADER_H_
#define UMLIBRARY_DRIVER_CHIPSET_ADS1259EXTENDEDADCREADER_H_
#include "../SpiPortRoutineOperation.hpp"
#include "../../systemic/Timer.hh"
#include "../../common/Counter.hpp"
#include "../../math/math_inc.hh"
#include "PackagerADS1259.hh"
#include "PackagerADS1259Extended.hh"
namespace driver {
namespace chipset {
class ADS1259ExtendedAdcReader {
public:
typedef SpiOperationPack< PackagerADS1259::Packager::Frame, Counter<uint16_t> > CommandOperation;
typedef SpiOperationPack< PackagerADS1259Extended::Packager::Frame, Counter<uint16_t> > ReadAdcOperation;
public:
void process();
template<typename ResulType = uint32_t>
const ResulType & get_adc_code() const { return adc_code; }
const bool & is_data_valid() const { return data_valid; }
const bool & is_adc_readed() const { return adc_readed; }
ADS1259ExtendedAdcReader(CommandOperation start_operation, ReadAdcOperation read_operation, float update_period_ms)
: start_adc_operation(start_operation), read_adc_operation(read_operation), update_period(update_period_ms),
start_conv(false), adc_code(0), data_valid(false), adc_readed(false) {
periodizator.start(update_period_ms);
}
private:
ReadAdcOperation read_adc_operation;
CommandOperation start_adc_operation;
bool start_conv;
bool read();
uint32_t adc_code;
bool data_valid;
bool adc_readed;
systemic::Timer periodizator;
const float update_period;
};
} /* namespace chipset */
} /* namespace driver */
#endif /* UMLIBRARY_DRIVER_CHIPSET_ADS1259EXTENDEDADCREADER_H_ */