distortos  v0.4.0
object-oriented C++ RTOS for microcontrollers
SpiMasterOperation.hpp
Go to the documentation of this file.
1 
12 #ifndef INCLUDE_DISTORTOS_DEVICES_COMMUNICATION_SPIMASTEROPERATION_HPP_
13 #define INCLUDE_DISTORTOS_DEVICES_COMMUNICATION_SPIMASTEROPERATION_HPP_
14 
16 
17 namespace distortos
18 {
19 
20 namespace devices
21 {
22 
30 {
31 public:
32 
34  class Transfer
35  {
36  public:
37 
48  constexpr Transfer(const void* const writeBuffer, void* const readBuffer, const size_t size) :
49  readBuffer_{readBuffer},
50  writeBuffer_{writeBuffer},
51  size_{size},
53  errorSet_{}
54  {
55 
56  }
57 
67  void finalize(const SpiMasterErrorSet errorSet, const size_t bytesTransfered)
68  {
69  errorSet_ = errorSet;
70  bytesTransfered_ = bytesTransfered;
71  }
72 
78  size_t getBytesTransfered() const
79  {
80  return bytesTransfered_;
81  }
82 
88  {
89  return errorSet_;
90  }
91 
96  void* getReadBuffer() const
97  {
98  return readBuffer_;
99  }
100 
105  size_t getSize() const
106  {
107  return size_;
108  }
109 
114  const void* getWriteBuffer() const
115  {
116  return writeBuffer_;
117  }
118 
119  private:
120 
122  void* readBuffer_;
123 
125  const void* writeBuffer_;
126 
128  size_t size_;
129 
133 
136  };
137 
146  constexpr SpiMasterOperation(const Transfer transfer) :
147  transfer_{transfer}
148  {
149 
150  }
151 
157  {
158  return &transfer_;
159  }
160 
161 private:
162 
165 };
166 
167 } // namespace devices
168 
169 } // namespace distortos
170 
171 #endif // INCLUDE_DISTORTOS_DEVICES_COMMUNICATION_SPIMASTEROPERATION_HPP_
void * getReadBuffer() const
Definition: SpiMasterOperation.hpp:96
Transfer transfer_
single transfer operation
Definition: SpiMasterOperation.hpp:164
size_t bytesTransfered_
Definition: SpiMasterOperation.hpp:132
SpiMasterErrorSet class header.
const void * getWriteBuffer() const
Definition: SpiMasterOperation.hpp:114
void finalize(const SpiMasterErrorSet errorSet, const size_t bytesTransfered)
Finalizes transfer operation.
Definition: SpiMasterOperation.hpp:67
Transfer class is a single transfer operation.
Definition: SpiMasterOperation.hpp:34
SpiMasterErrorSet getErrorSet() const
Definition: SpiMasterOperation.hpp:87
constexpr SpiMasterOperation(const Transfer transfer)
SpiMasterOperation's constructor with transfer operation.
Definition: SpiMasterOperation.hpp:146
constexpr Transfer(const void *const writeBuffer, void *const readBuffer, const size_t size)
Transfer's constructor.
Definition: SpiMasterOperation.hpp:48
Definition: SpiMasterErrorSet.hpp:29
const void * writeBuffer_
buffer with data that will be written, nullptr to send dummy data
Definition: SpiMasterOperation.hpp:125
size_t getBytesTransfered() const
Definition: SpiMasterOperation.hpp:78
SpiMasterErrorSet errorSet_
set of error bits detected during the transfer
Definition: SpiMasterOperation.hpp:135
Top-level namespace of distortos project.
void * readBuffer_
buffer with data that will be read, nullptr to ignore received data
Definition: SpiMasterOperation.hpp:122
Transfer * getTransfer()
Definition: SpiMasterOperation.hpp:156
size_t getSize() const
Definition: SpiMasterOperation.hpp:105
size_t size_
size of transfer (size of readBuffer_ and/or writeBuffer_), bytes
Definition: SpiMasterOperation.hpp:128
Definition: SpiMasterOperation.hpp:29