68 lines
1.7 KiB
C++
68 lines
1.7 KiB
C++
/*
|
||
* 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_ */
|