amiro-os / components / FileSystemInputOutput / FSIODiWheelDrive.cpp @ ab2f0120
History | View | Annotate | Download (9.34 KB)
1 | 58fe0e0b | Thomas Schöpping | #include <amiro/FileSystemInputOutput/FSIODiWheelDrive.hpp> |
---|---|---|---|
2 | |||
3 | using namespace amiro; |
||
4 | using namespace amiro::fileSystemIo; |
||
5 | |||
6 | msg_t |
||
7 | FSIODiWheelDrive:: |
||
8 | getVcnl4020Offset (uint16_t *buffer, uint8_t idx) { |
||
9 | |||
10 | msg_t bytesWritten = 0;
|
||
11 | const uint8_t bufferSize = sizeof(uint16_t); |
||
12 | |||
13 | // Check if the vcnl index is in a valid range
|
||
14 | if (idx >= sizeof(DiWheelDrive_1_1::vcnl4020offset)) { |
||
15 | return WRONG_INDEX;
|
||
16 | } |
||
17 | |||
18 | // Get the data out of the memory
|
||
19 | switch (this->BSMV) { |
||
20 | case 0x01u: |
||
21 | // Set the pointer to the address
|
||
22 | chFileStreamSeek((BaseFileStream*)&at24c01, offsetof(FSIODiWheelDrive::DiWheelDrive_1_1, vcnl4020offset[idx])); |
||
23 | if (this->bsmv >= 0x01u) { |
||
24 | bytesWritten = chSequentialStreamRead((BaseFileStream*)&at24c01, (uint8_t*) buffer, bufferSize); |
||
25 | } else {
|
||
26 | return NOT_IMPLEMENTED;
|
||
27 | } |
||
28 | break;
|
||
29 | } |
||
30 | |||
31 | if (bytesWritten != bufferSize) {
|
||
32 | return IO_ERROR;
|
||
33 | } else {
|
||
34 | return OK;
|
||
35 | } |
||
36 | } |
||
37 | |||
38 | msg_t |
||
39 | FSIODiWheelDrive:: |
||
40 | setVcnl4020Offset (uint16_t buffer, uint8_t idx) { |
||
41 | |||
42 | msg_t bytesWritten = 0;
|
||
43 | const uint8_t bufferSize = sizeof(uint16_t); |
||
44 | |||
45 | // Check if the vcnl index is in a valid range
|
||
46 | if (idx >= sizeof(DiWheelDrive_1_1::vcnl4020offset)) { |
||
47 | return WRONG_INDEX;
|
||
48 | } |
||
49 | |||
50 | // Get the data out of the memory
|
||
51 | switch (this->BSMV) { |
||
52 | case 0x01u: |
||
53 | // Set the pointer to the address
|
||
54 | chFileStreamSeek((BaseFileStream*)&at24c01, offsetof(FSIODiWheelDrive::DiWheelDrive_1_1, vcnl4020offset[idx])); |
||
55 | if (this->bsmv >= 0x01u) { |
||
56 | bytesWritten = chSequentialStreamWrite((BaseFileStream*)&at24c01, (const uint8_t*) &buffer, bufferSize);
|
||
57 | } else {
|
||
58 | return NOT_IMPLEMENTED;
|
||
59 | } |
||
60 | break;
|
||
61 | } |
||
62 | |||
63 | if (bytesWritten != bufferSize) {
|
||
64 | return IO_ERROR;
|
||
65 | } else {
|
||
66 | return OK;
|
||
67 | } |
||
68 | } |
||
69 | |||
70 | |||
71 | msg_t |
||
72 | FSIODiWheelDrive:: |
||
73 | setwheelfactor (float buffer) {
|
||
74 | |||
75 | msg_t bytesWritten = 0;
|
||
76 | const uint8_t bufferSize = sizeof(float); |
||
77 | |||
78 | // Get the data out of the memory
|
||
79 | switch (this->BSMV) { |
||
80 | case 0x01u: |
||
81 | // Set the pointer to the address
|
||
82 | chFileStreamSeek((BaseFileStream*)&at24c01, offsetof(FSIODiWheelDrive::DiWheelDrive_1_3, wheelfactor)); |
||
83 | if (this->bsmv >= 0x03u) { |
||
84 | bytesWritten = chSequentialStreamWrite((BaseFileStream*)&at24c01, (const uint8_t*) &buffer, bufferSize);
|
||
85 | } else {
|
||
86 | return NOT_IMPLEMENTED;
|
||
87 | } |
||
88 | break;
|
||
89 | } |
||
90 | |||
91 | if (bytesWritten != bufferSize) {
|
||
92 | return IO_ERROR;
|
||
93 | } else {
|
||
94 | return OK;
|
||
95 | } |
||
96 | } |
||
97 | |||
98 | |||
99 | msg_t |
||
100 | FSIODiWheelDrive:: |
||
101 | getWheelFactor (float *buffer) {
|
||
102 | |||
103 | msg_t bytesWritten = 0;
|
||
104 | const uint8_t bufferSize = sizeof(float); |
||
105 | |||
106 | // Get the data out of the memory
|
||
107 | switch (this->BSMV) { |
||
108 | case 0x01u: |
||
109 | // Set the pointer to the address
|
||
110 | chFileStreamSeek((BaseFileStream*)&at24c01, offsetof(FSIODiWheelDrive::DiWheelDrive_1_3, wheelfactor)); |
||
111 | if (this->bsmv >= 0x03u) { |
||
112 | bytesWritten = chSequentialStreamRead((BaseFileStream*)&at24c01, (uint8_t*) buffer, bufferSize); |
||
113 | } else {
|
||
114 | return NOT_IMPLEMENTED;
|
||
115 | } |
||
116 | break;
|
||
117 | } |
||
118 | |||
119 | if (bytesWritten != bufferSize) {
|
||
120 | return IO_ERROR;
|
||
121 | } else {
|
||
122 | return OK;
|
||
123 | } |
||
124 | } |
||
125 | |||
126 | |||
127 | msg_t |
||
128 | FSIODiWheelDrive:: |
||
129 | setiGain (float buffer) {
|
||
130 | |||
131 | msg_t bytesWritten = 0;
|
||
132 | const uint8_t bufferSize = sizeof(float); |
||
133 | |||
134 | // Get the data out of the memory
|
||
135 | switch (this->BSMV) { |
||
136 | case 0x01u: |
||
137 | // Set the pointer to the address
|
||
138 | chFileStreamSeek((BaseFileStream*)&at24c01, offsetof(FSIODiWheelDrive::DiWheelDrive_1_3, igain)); |
||
139 | if (this->bsmv >= 0x03u) { |
||
140 | bytesWritten = chSequentialStreamWrite((BaseFileStream*)&at24c01, (const uint8_t*) &buffer, bufferSize);
|
||
141 | } else {
|
||
142 | return NOT_IMPLEMENTED;
|
||
143 | } |
||
144 | break;
|
||
145 | } |
||
146 | |||
147 | if (bytesWritten != bufferSize) {
|
||
148 | return IO_ERROR;
|
||
149 | } else {
|
||
150 | return OK;
|
||
151 | } |
||
152 | } |
||
153 | |||
154 | |||
155 | msg_t |
||
156 | FSIODiWheelDrive:: |
||
157 | getiGain (float *buffer) {
|
||
158 | |||
159 | msg_t bytesWritten = 0;
|
||
160 | const uint8_t bufferSize = sizeof(float); |
||
161 | |||
162 | // Get the data out of the memory
|
||
163 | switch (this->BSMV) { |
||
164 | case 0x01u: |
||
165 | // Set the pointer to the address
|
||
166 | chFileStreamSeek((BaseFileStream*)&at24c01, offsetof(FSIODiWheelDrive::DiWheelDrive_1_3, igain)); |
||
167 | if (this->bsmv >= 0x03u) { |
||
168 | bytesWritten = chSequentialStreamRead((BaseFileStream*)&at24c01, (uint8_t*) buffer, bufferSize); |
||
169 | } else {
|
||
170 | return NOT_IMPLEMENTED;
|
||
171 | } |
||
172 | break;
|
||
173 | } |
||
174 | |||
175 | if (bytesWritten != bufferSize) {
|
||
176 | return IO_ERROR;
|
||
177 | } else {
|
||
178 | return OK;
|
||
179 | } |
||
180 | } |
||
181 | |||
182 | |||
183 | |||
184 | |||
185 | msg_t |
||
186 | FSIODiWheelDrive:: |
||
187 | setdGain (float buffer) {
|
||
188 | |||
189 | msg_t bytesWritten = 0;
|
||
190 | const uint8_t bufferSize = sizeof(float); |
||
191 | |||
192 | // Get the data out of the memory
|
||
193 | switch (this->BSMV) { |
||
194 | case 0x01u: |
||
195 | // Set the pointer to the address
|
||
196 | chFileStreamSeek((BaseFileStream*)&at24c01, offsetof(FSIODiWheelDrive::DiWheelDrive_1_3, dgain)); |
||
197 | if (this->bsmv >= 0x03u) { |
||
198 | bytesWritten = chSequentialStreamWrite((BaseFileStream*)&at24c01, (const uint8_t*) &buffer, bufferSize);
|
||
199 | } else {
|
||
200 | return NOT_IMPLEMENTED;
|
||
201 | } |
||
202 | break;
|
||
203 | } |
||
204 | |||
205 | if (bytesWritten != bufferSize) {
|
||
206 | return IO_ERROR;
|
||
207 | } else {
|
||
208 | return OK;
|
||
209 | } |
||
210 | } |
||
211 | |||
212 | |||
213 | msg_t |
||
214 | FSIODiWheelDrive:: |
||
215 | getdGain (float *buffer) {
|
||
216 | |||
217 | msg_t bytesWritten = 0;
|
||
218 | const uint8_t bufferSize = sizeof(float); |
||
219 | |||
220 | // Get the data out of the memory
|
||
221 | switch (this->BSMV) { |
||
222 | case 0x01u: |
||
223 | // Set the pointer to the address
|
||
224 | chFileStreamSeek((BaseFileStream*)&at24c01, offsetof(FSIODiWheelDrive::DiWheelDrive_1_3, dgain)); |
||
225 | if (this->bsmv >= 0x03u) { |
||
226 | bytesWritten = chSequentialStreamRead((BaseFileStream*)&at24c01, (uint8_t*) buffer, bufferSize); |
||
227 | } else {
|
||
228 | return NOT_IMPLEMENTED;
|
||
229 | } |
||
230 | break;
|
||
231 | } |
||
232 | |||
233 | if (bytesWritten != bufferSize) {
|
||
234 | return IO_ERROR;
|
||
235 | } else {
|
||
236 | return OK;
|
||
237 | } |
||
238 | } |
||
239 | |||
240 | |||
241 | |||
242 | |||
243 | msg_t |
||
244 | FSIODiWheelDrive:: |
||
245 | setpGain (int buffer) {
|
||
246 | |||
247 | msg_t bytesWritten = 0;
|
||
248 | const uint8_t bufferSize = sizeof(float); |
||
249 | |||
250 | // Get the data out of the memory
|
||
251 | switch (this->BSMV) { |
||
252 | case 0x01u: |
||
253 | // Set the pointer to the address
|
||
254 | chFileStreamSeek((BaseFileStream*)&at24c01, offsetof(FSIODiWheelDrive::DiWheelDrive_1_3, pgain)); |
||
255 | if (this->bsmv >= 0x03u) { |
||
256 | bytesWritten = chSequentialStreamWrite((BaseFileStream*)&at24c01, (const uint8_t*) &buffer, bufferSize);
|
||
257 | } else {
|
||
258 | return NOT_IMPLEMENTED;
|
||
259 | } |
||
260 | break;
|
||
261 | } |
||
262 | |||
263 | if (bytesWritten != bufferSize) {
|
||
264 | return IO_ERROR;
|
||
265 | } else {
|
||
266 | return OK;
|
||
267 | } |
||
268 | } |
||
269 | |||
270 | |||
271 | msg_t |
||
272 | FSIODiWheelDrive:: |
||
273 | getpGain (int *buffer) {
|
||
274 | |||
275 | msg_t bytesWritten = 0;
|
||
276 | const uint8_t bufferSize = sizeof(float); |
||
277 | |||
278 | // Get the data out of the memory
|
||
279 | switch (this->BSMV) { |
||
280 | case 0x01u: |
||
281 | // Set the pointer to the address
|
||
282 | chFileStreamSeek((BaseFileStream*)&at24c01, offsetof(FSIODiWheelDrive::DiWheelDrive_1_3, pgain)); |
||
283 | if (this->bsmv >= 0x03u) { |
||
284 | bytesWritten = chSequentialStreamRead((BaseFileStream*)&at24c01, (uint8_t*) buffer, bufferSize); |
||
285 | } else {
|
||
286 | return NOT_IMPLEMENTED;
|
||
287 | } |
||
288 | break;
|
||
289 | } |
||
290 | |||
291 | if (bytesWritten != bufferSize) {
|
||
292 | return IO_ERROR;
|
||
293 | } else {
|
||
294 | return OK;
|
||
295 | } |
||
296 | } |
||
297 | |||
298 | |||
299 | |||
300 | msg_t |
||
301 | FSIODiWheelDrive:: |
||
302 | getEd (float *buffer) {
|
||
303 | |||
304 | msg_t bytesWritten = 0;
|
||
305 | const uint8_t bufferSize = sizeof(float); |
||
306 | |||
307 | // Get the data out of the memory
|
||
308 | switch (this->BSMV) { |
||
309 | case 0x01u: |
||
310 | // Set the pointer to the address
|
||
311 | chFileStreamSeek((BaseFileStream*)&at24c01, offsetof(FSIODiWheelDrive::DiWheelDrive_1_2, Ed)); |
||
312 | if (this->bsmv >= 0x02u) { |
||
313 | bytesWritten = chSequentialStreamRead((BaseFileStream*)&at24c01, (uint8_t*) buffer, bufferSize); |
||
314 | } else {
|
||
315 | return NOT_IMPLEMENTED;
|
||
316 | } |
||
317 | break;
|
||
318 | } |
||
319 | |||
320 | if (bytesWritten != bufferSize) {
|
||
321 | return IO_ERROR;
|
||
322 | } else {
|
||
323 | return OK;
|
||
324 | } |
||
325 | } |
||
326 | |||
327 | msg_t |
||
328 | FSIODiWheelDrive:: |
||
329 | setEd (float buffer) {
|
||
330 | |||
331 | msg_t bytesWritten = 0;
|
||
332 | const uint8_t bufferSize = sizeof(float); |
||
333 | |||
334 | // Get the data out of the memory
|
||
335 | switch (this->BSMV) { |
||
336 | case 0x01u: |
||
337 | // Set the pointer to the address
|
||
338 | chFileStreamSeek((BaseFileStream*)&at24c01, offsetof(FSIODiWheelDrive::DiWheelDrive_1_2, Ed)); |
||
339 | if (this->bsmv >= 0x02u) { |
||
340 | bytesWritten = chSequentialStreamWrite((BaseFileStream*)&at24c01, (const uint8_t*) &buffer, bufferSize);
|
||
341 | } else {
|
||
342 | return NOT_IMPLEMENTED;
|
||
343 | } |
||
344 | break;
|
||
345 | } |
||
346 | |||
347 | if (bytesWritten != bufferSize) {
|
||
348 | return IO_ERROR;
|
||
349 | } else {
|
||
350 | return OK;
|
||
351 | } |
||
352 | } |
||
353 | |||
354 | msg_t |
||
355 | FSIODiWheelDrive:: |
||
356 | getEb (float *buffer) {
|
||
357 | |||
358 | msg_t bytesWritten = 0;
|
||
359 | const uint8_t bufferSize = sizeof(float); |
||
360 | |||
361 | // Get the data out of the memory
|
||
362 | switch (this->BSMV) { |
||
363 | case 0x01u: |
||
364 | // Set the pointer to the address
|
||
365 | chFileStreamSeek((BaseFileStream*)&at24c01, offsetof(FSIODiWheelDrive::DiWheelDrive_1_2, Eb)); |
||
366 | if (this->bsmv >= 0x02u) { |
||
367 | bytesWritten = chSequentialStreamRead((BaseFileStream*)&at24c01, (uint8_t*) buffer, bufferSize); |
||
368 | } else {
|
||
369 | return NOT_IMPLEMENTED;
|
||
370 | } |
||
371 | break;
|
||
372 | } |
||
373 | |||
374 | if (bytesWritten != bufferSize) {
|
||
375 | return IO_ERROR;
|
||
376 | } else {
|
||
377 | return OK;
|
||
378 | } |
||
379 | } |
||
380 | |||
381 | msg_t |
||
382 | FSIODiWheelDrive:: |
||
383 | setEb (float buffer) {
|
||
384 | |||
385 | msg_t bytesWritten = 0;
|
||
386 | const uint8_t bufferSize = sizeof(float); |
||
387 | |||
388 | // Get the data out of the memory
|
||
389 | switch (this->BSMV) { |
||
390 | case 0x01u: |
||
391 | // Set the pointer to the address
|
||
392 | chFileStreamSeek((BaseFileStream*)&at24c01, offsetof(FSIODiWheelDrive::DiWheelDrive_1_2, Eb)); |
||
393 | if (this->bsmv >= 0x02u) { |
||
394 | bytesWritten = chSequentialStreamWrite((BaseFileStream*)&at24c01, (const uint8_t*) &buffer, bufferSize);
|
||
395 | } else {
|
||
396 | return NOT_IMPLEMENTED;
|
||
397 | } |
||
398 | break;
|
||
399 | } |
||
400 | |||
401 | if (bytesWritten != bufferSize) {
|
||
402 | return IO_ERROR;
|
||
403 | } else {
|
||
404 | return OK;
|
||
405 | } |
||
406 | } |