70 lines
1.8 KiB
C++
70 lines
1.8 KiB
C++
/*
|
||
* ADS1259ContModeAdcReader.h
|
||
*
|
||
* Created on: 16 авг. 2020 г.
|
||
* Author: user
|
||
*/
|
||
|
||
#ifndef UMLIBRARY_DRIVER_CHIPSET_ADS1259CONTMODEADCREADER_HH_
|
||
#define UMLIBRARY_DRIVER_CHIPSET_ADS1259CONTMODEADCREADER_H_
|
||
|
||
#include "ADS1259.hh"
|
||
#include "PackagerADS1259.hh"
|
||
|
||
#include "../../systemic/Timer.hh"
|
||
|
||
#include "../../common/Counter.hpp"
|
||
#include "../../math/math_inc.hh"
|
||
|
||
#include <memory_resource>
|
||
|
||
namespace driver {
|
||
namespace chipset {
|
||
|
||
class ADS1259ContModeAdcReader {
|
||
|
||
public:
|
||
typedef PackagerADS1259::PackagerADS1259::AdcContModePackager AdcReaderPackager;
|
||
|
||
typedef SpiOperationPack< AdcReaderPackager::Frame, Counter<uint16_t> > ReadAdcOperation;
|
||
typedef SpiOperationPack< AdcReaderPackager::Frame, Counter<uint16_t> > CommandOperation;
|
||
|
||
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; }
|
||
|
||
//todo: нужно хранить состояние до тех пор пока оно не имело попытку измениться.
|
||
bool is_adc_readed() const;
|
||
|
||
ADS1259ContModeAdcReader(CommandOperation, ReadAdcOperation read_operation, systemic::time_t update_period_ms)
|
||
: adc_packager(), read_adc_operation(read_operation), adc_code(0), update_period(update_period_ms),
|
||
data_valid(false), adc_readed(false) {
|
||
|
||
periodizator.start(update_period_ms);
|
||
|
||
}
|
||
|
||
private:
|
||
|
||
AdcReaderPackager adc_packager;
|
||
ReadAdcOperation read_adc_operation;
|
||
|
||
uint32_t adc_code;
|
||
|
||
systemic::Timer periodizator;
|
||
const systemic::time_t update_period;
|
||
|
||
bool data_valid;
|
||
mutable bool adc_readed;
|
||
|
||
};
|
||
|
||
} /* namespace chipset */
|
||
} /* namespace driver */
|
||
|
||
#endif /* UMLIBRARY_DRIVER_CHIPSET_ADS1259CONTMODEADCREADER_HH_ */
|