36 lines
756 B
C++
36 lines
756 B
C++
/*
|
||
* SpiPortReader.hpp
|
||
*
|
||
* Created on: 13 нояб. 2019 г.
|
||
* Author: user
|
||
*/
|
||
|
||
#ifndef SOURCE_DRIVER_SPIPORTREADER_HPP_
|
||
#define SOURCE_DRIVER_SPIPORTREADER_HPP_
|
||
|
||
#include "SpiPortRoutineOperation.hpp"
|
||
|
||
#include <cstddef>
|
||
#include <stdint.h>
|
||
|
||
namespace driver {
|
||
|
||
template<typename Frame>
|
||
struct SpiPortReader {
|
||
typedef uint16_t Latency;
|
||
Latency latency;
|
||
|
||
typedef driver::SpiOperationPack<Frame, Latency> Operation;
|
||
Operation get_op;
|
||
|
||
Frame get() { return (get_op() ? get_op() : 0), get_op.output; }
|
||
|
||
SpiPortReader( peripheral::ISerialPort & port, std::size_t frame_size, Frame request_frame )
|
||
: get_op(port, frame_size, request_frame, latency), latency(0) {}
|
||
|
||
};
|
||
|
||
}
|
||
|
||
#endif /* SOURCE_DRIVER_SPIPORTREADER_HPP_ */
|